attrs.clear(); attrs.addAttribute("", "name", "name", "CDATA", child);  attrs.addAttribute("", "created", "created", "CDATA", dateFormat.format(new Date(childCollection .getCreationTime()))); printPermissions(attrs, childCollection.getPermissions()); serializer.startElement(NS, "collection", "exist:collection", attrs); serializer.endElement(NS, "collection", "exist:collection");
if(childCollection.getPermissions().validate(broker.getUser(), Permission.READ)) { attrs.clear(); attrs.addAttribute("", "name", "name", "CDATA", child);  attrs.addAttribute("", "created", "created", "CDATA", dateFormat.format(new Date(childCollection .getCreationTime()))); printPermissions(attrs, childCollection.getPermissions()); serializer.startElement(NS, "collection", "exist:collection", attrs); serializer.endElement(NS, "collection", "exist:collection"); }
	protected String printCollection(DBBroker broker, Collection collection) {		SAXSerializer serializer = null;		StringWriter writer = new StringWriter();		try {			serializer = SAXSerializerPool.getInstance().borrowSAXSerializer();			serializer.setWriter(writer);			serializer.setOutputProperties(defaultProperties);			AttributesImpl attrs = new AttributesImpl();			serializer.startDocument();			serializer.startPrefixMapping("exist", NS);			serializer.startElement(NS, "result", "exist:result", attrs);			attrs.addAttribute("", "name", "name", "CDATA", collection					.getName());			printPermissions(attrs, collection.getPermissions());			serializer					.startElement(NS, "collection", "exist:collection", attrs);			for (Iterator i = collection.collectionIterator(); i.hasNext(); ) {				String child = (String) i.next();				Collection childCollection = broker.getCollection(collection						.getName()						+ '/' + child);				attrs.clear();				attrs.addAttribute("", "name", "name", "CDATA", child);				attrs.addAttribute("", "created", "created", "CDATA",						dateFormat.format(new Date(childCollection								.getCreationTime())));				printPermissions(attrs, childCollection.getPermissions());				serializer.startElement(NS, "collection", "exist:collection",						attrs);				serializer.endElement(NS, "collection", "exist:collection");			}			for (Iterator i = collection.iterator(); i.hasNext(); ) {				DocumentImpl doc = (DocumentImpl) i.next();				String resource = doc.getFileName();				int p = resource.lastIndexOf('/');				attrs.clear();				attrs.addAttribute("", "name", "name", "CDATA", p < 0						? resource						: resource.substring(p + 1));				attrs.addAttribute("", "created", "created", "CDATA",						dateFormat.format(new Date(doc.getCreated())));				attrs.addAttribute("", "last-modified", "last-modified",						"CDATA", dateFormat.format(new Date(doc								.getLastModified())));				printPermissions(attrs, doc.getPermissions());				serializer						.startElement(NS, "resource", "exist:resource", attrs);				serializer.endElement(NS, "resource", "exist:resource");			}			serializer.endElement(NS, "collection", "exist:collection");			serializer.endElement(NS, "result", "exist:result");			serializer.endDocument();		} catch (SAXException e) {			// should never happen			LOG.warn("Error while serializing collection contents: "					+ e.getMessage(), e);		} finally {			SAXSerializerPool.getInstance().returnSAXSerializer(serializer);		}		return writer.toString();	}