if(collectionLocked)
if(collectionLocked && collection != null)
	public void process(User user, HttpServletRequest request,			HttpServletResponse response, String path) throws ServletException, IOException {		File tempFile = saveRequestContent(request);		String url = tempFile.toURI().toASCIIString();		String contentType = request.getContentType();		DBBroker broker = null;		Collection collection = null;		boolean collectionLocked = true;        TransactionManager transact = pool.getTransactionManager();        Txn txn = transact.beginTransaction();		try {			broker = pool.get(user);            ///TODO : use dedicated function in XmldbURI			if(path == null)				path = "";			if(path.endsWith("/"))				path = path.substring(0, path.length() - 1);			int p = path.lastIndexOf("/");            //TODO : strange test here -pb			if(p < 1) {                transact.abort(txn);				response.sendError(HttpServletResponse.SC_CONFLICT, "No collection specified for PUT");				return;			}			String collectionName = path.substring(0, p);			path = path.substring(p + 1);						collection = broker.openCollection(collectionName, Lock.WRITE_LOCK);			if(collection == null) {                transact.abort(txn);				response.sendError(HttpServletResponse.SC_CONFLICT, "Parent collection " + collectionName +				" not found");				return;			}			if(collection.hasChildCollection(path)) {                transact.abort(txn);				response.sendError(HttpServletResponse.SC_CONFLICT, "Cannot overwrite an existing collection with a resource");				return;			}            MimeType mime;			if(contentType == null) {				mime = MimeTable.getInstance().getContentTypeFor(path);                if (mime != null)                    contentType = mime.getName();			} else {			    mime = MimeTable.getInstance().getContentType(contentType);            }            if (mime == null)                mime = MimeType.BINARY_TYPE;			LOG.debug("storing document " + path + "; content-type = " + contentType);            			if(mime.isXMLType()) {				InputSource is = new InputSource(url);				IndexInfo info = collection.validate(txn, broker, path, is);                info.getDocument().setMimeType(contentType);				collection.release();				collectionLocked = false;				collection.store(txn, broker, info, is, false);			} else {				byte[] chunk = new byte[4096];				ByteArrayOutputStream os = new ByteArrayOutputStream();				FileInputStream is = new FileInputStream(tempFile);				int l;				while((l = is.read(chunk)) > -1) {					os.write(chunk, 0, l);				}				collection.addBinaryResource(txn, broker, path, os.toByteArray(), contentType);			}            transact.commit(txn);		} catch (EXistException e) {            transact.abort(txn);			throw new ServletException("Failed to store resource: " + e.getMessage(), e);		} catch (PermissionDeniedException e) {            transact.abort(txn);			response.sendError(HttpServletResponse.SC_FORBIDDEN);		} catch (TriggerException e) {            transact.abort(txn);			response.sendError(HttpServletResponse.SC_FORBIDDEN);		} catch (SAXException e) {            transact.abort(txn);			response.sendError(HttpServletResponse.SC_BAD_REQUEST);		} catch (LockException e) {            transact.abort(txn);			response.sendError(HttpServletResponse.SC_CONFLICT);		} finally {			if(collectionLocked)				collection.release();			pool.release(broker);		}		response.setStatus(HttpServletResponse.SC_CREATED);	}