}
} catch (LockException e) { throw new PermissionDeniedException(e.getMessage()); }
	public Response doPost(DBBroker broker, String content, String path) 	throws BadRequestException, PermissionDeniedException {		boolean indent = true;		boolean summary = false;		int howmany = 10;		int start = 1;		Properties outputProperties = new Properties(defaultProperties);		String query = null;		Response response = null;		try {			InputSource src = new InputSource(new StringReader(content));			DocumentBuilderFactory docFactory = DocumentBuilderFactory			.newInstance();			docFactory.setNamespaceAware(true);			DocumentBuilder docBuilder = null;			try {				docBuilder = docFactory.newDocumentBuilder();			} catch (ParserConfigurationException e) {				LOG.warn(e);				throw new BadRequestException(e.getMessage());			}			Document doc = docBuilder.parse(src);			Element root = doc.getDocumentElement();			if(root.getNamespaceURI().equals(NS)) {				if(root.getLocalName().equals("query")) {					// process <query>xpathQuery</query>					String option = root.getAttribute("start");					if(option != null)						try {							start = Integer.parseInt(option);						} catch(NumberFormatException e) {						}						option = root.getAttribute("max");						if(option != null)							try {								howmany = Integer.parseInt(option);							} catch(NumberFormatException e) {							}														NodeList children =root.getChildNodes();							for(int i = 0;i < children.getLength(); i++) {								Node child = children.item(i);								if(child.getNodeType() == Node.ELEMENT_NODE && child.getNamespaceURI().equals(NS)) {									if(child.getLocalName().equals("text")) {										StringBuffer buf =new StringBuffer();										Node next = child.getFirstChild();										while(next != null) {											if(next.getNodeType() == Node.TEXT_NODE || 													next.getNodeType() == Node.CDATA_SECTION_NODE)												buf.append(next.getNodeValue());											next = next.getNextSibling();										}										query =buf.toString();									} else if(child.getLocalName().equals("properties")) {										Node node = child.getFirstChild();										while(node !=null) {											if(node.getNodeType() == Node.ELEMENT_NODE && 													node.getNamespaceURI().equals(NS) &&													node.getLocalName().equals("property")) {												Element property = (Element)node;												String key = property.getAttribute("name");												String value = property.getAttribute("value");												LOG.debug(key + " = " + value);												if(key != null && value != null)													outputProperties.setProperty(key, value);											}											node = node.getNextSibling();										}									}								}							}				}				// execute query				if (query != null)					response = new Response(search(broker, query, path, howmany, start, outputProperties));				else					throw new BadRequestException("No query specified");			} else if(root.getNamespaceURI().equals(XUPDATE_NS)) {				LOG.debug("Got xupdate request: " + content);				DocumentSet docs =new DocumentSet();				Collection collection = broker.getCollection(path);				if(collection != null) {					collection.allDocs(broker, docs, true);				} else {					DocumentImpl xupdateDoc = (DocumentImpl)broker.getDocument(path);					if(doc != null)						docs.add(doc);					else						broker.getAllDocuments(docs);				}				XUpdateProcessor processor = new XUpdateProcessor(broker, docs);				Modification modifications[] =					processor.parse(new InputSource(new StringReader(content)));				long mods = 0;				for (int i = 0; i < modifications.length; i++) {					mods += modifications[i].process();					broker.flush();				}				//	FD : Returns an XML doc				response = new Response("<?xml version='1.0'?>\n" +				"<exist:modifications mlns:exist='" + NS + "' count='" + mods + 				"'>" + mods + "modifications processed.</exist:modifications>");				// END FD			} else				throw new BadRequestException(						"Unknown XML root element: " + root.getNodeName());		} catch (SAXException e) {			Exception cause = e;			if(e.getException() != null)				cause = e.getException();			LOG.debug("SAX exception while parsing request: " + cause.getMessage(), cause);			throw new BadRequestException( 					"SAX exception while parsing request: " + cause.getMessage());		} catch (ParserConfigurationException e) {			throw new BadRequestException("Parser exception while parsing request: " + e.getMessage());		} catch (XPathException e) {			throw new BadRequestException("Query exception while parsing request: " + e.getMessage());		} catch (IOException e) {			throw new BadRequestException("IO exception while parsing request: " + e.getMessage());		} catch (EXistException e) {			throw new BadRequestException(e.getMessage());		}		return response;	}