Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'develop' into feature/lucence-range-index

  • Loading branch information...
commit d336126e41262807a2d80cad199042e8088a8b07 2 parents 9257c27 + 9953d0f
@wolfgangmm wolfgangmm authored
Showing with 364 additions and 197 deletions.
  1. +8 −8 .classpath
  2. +4 −1 .gitignore
  3. +1 −1  build/scripts/build-impl.xml
  4. +1 −1  extensions/expath/extension.xml
  5. BIN  extensions/expath/lib/http-client-java-0.3.0.jar
  6. BIN  extensions/expath/lib/http-client-java-1.0-SNAPSHOT.jar
  7. +47 −29 extensions/expath/src/org/expath/httpclient/model/exist/EXistResult.java
  8. BIN  extensions/exquery/lib/exquery-annotations-common-1.0-SNAPSHOT.jar
  9. BIN  extensions/exquery/lib/exquery-annotations-common-api-1.0-SNAPSHOT.jar
  10. BIN  extensions/exquery/lib/exquery-common-1.0-SNAPSHOT.jar
  11. BIN  extensions/exquery/lib/exquery-serialization-annotations-1.0-SNAPSHOT.jar
  12. BIN  extensions/exquery/lib/exquery-serialization-annotations-api-1.0-SNAPSHOT.jar
  13. BIN  extensions/exquery/lib/exquery-xquery-1.0-SNAPSHOT.jar
  14. BIN  extensions/exquery/lib/exquery-xquery3-1.0-SNAPSHOT.jar
  15. BIN  extensions/exquery/restxq/lib/exquery-restxq-1.0-SNAPSHOT.jar
  16. BIN  extensions/exquery/restxq/lib/exquery-restxq-api-1.0-SNAPSHOT.jar
  17. +37 −0 ...nsions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/adapters/EXQueryErrorCode.java
  18. +8 −2 extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/xquery/UriFunctions.java
  19. +6 −12 extensions/security/ldap/src/org/exist/security/realm/ldap/LDAPRealm.java
  20. +6 −1 extensions/security/ldap/src/org/exist/security/realm/ldap/LdapContextFactory.java
  21. +24 −17 extensions/webdav/src/org/exist/webdav/ExistCollection.java
  22. +43 −39 extensions/webdav/src/org/exist/webdav/ExistDocument.java
  23. +13 −2 extensions/webdav/src/org/exist/webdav/ExistResource.java
  24. +71 −16 extensions/webdav/src/org/exist/webdav/ExistResourceFactory.java
  25. +14 −14 extensions/webdav/src/org/exist/webdav/MiltonCollection.java
  26. +27 −11 extensions/webdav/src/org/exist/webdav/MiltonDocument.java
  27. +9 −11 extensions/webdav/src/org/exist/webdav/MiltonResource.java
  28. +4 −1 extensions/webdav/src/org/exist/webdav/MiltonWebDAVServlet.java
  29. +8 −0 extensions/webdav/webdav.properties
  30. BIN  lib/optional/commons-fileupload-1.2.2.jar
  31. BIN  lib/optional/commons-fileupload-1.3.jar
  32. +1 −1  nbbuild.xml
  33. +10 −10 nbproject/project.properties
  34. +1 −3 src/org/exist/Database.java
  35. +2 −3 src/org/exist/http/servlets/HttpRequestWrapper.java
  36. +19 −14 src/org/exist/storage/BrokerPool.java
  37. BIN  tools/aspectj/lib/{aspectjrt-1.7.1.jar → aspectjrt-1.7.3.jar}
  38. BIN  tools/aspectj/lib/{aspectjtools-1.7.1.jar → aspectjtools-1.7.3.jar}
  39. BIN  tools/aspectj/lib/{aspectjweaver-1.7.1.jar → aspectjweaver-1.7.3.jar}
View
16 .classpath
@@ -48,7 +48,9 @@
<classpathentry kind="lib" path="lib/core/xmlrpc-client-3.1.3.jar"/>
<classpathentry kind="lib" path="lib/core/xmlrpc-common-3.1.3.jar"/>
<classpathentry kind="lib" path="lib/core/xmlrpc-server-3.1.3.jar"/>
- <classpathentry kind="lib" path="extensions/expath/lib/http-client-java-0.3.0.jar"/>
+ <classpathentry kind="lib" path="extensions/modules/lib/cssparser-0.9.5.jar"/>
+ <classpathentry kind="lib" path="extensions/modules/lib/sac-1.3.jar"/>
+ <classpathentry kind="lib" path="extensions/expath/lib/http-client-java-1.0-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="extensions/exquery/lib/exquery-common-1.0-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="extensions/exquery/lib/exquery-annotations-common-api-1.0-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="extensions/exquery/lib/exquery-annotations-common-1.0-SNAPSHOT.jar"/>
@@ -68,7 +70,7 @@
<classpathentry kind="lib" path="lib/optional/axis-ant-1.4.jar"/>
<classpathentry kind="lib" path="lib/optional/axis-schema-1.3.jar"/>
<classpathentry kind="lib" path="lib/optional/axis-1.4.jar"/>
- <classpathentry kind="lib" path="lib/optional/commons-fileupload-1.2.2.jar"/>
+ <classpathentry kind="lib" path="lib/optional/commons-fileupload-1.3.jar"/>
<classpathentry kind="lib" path="lib/optional/commons-httpclient-3.1.jar"/>
<classpathentry kind="lib" path="lib/core/commons-io-2.4.jar"/>
<classpathentry kind="lib" path="lib/optional/jaxrpc-1.1.jar"/>
@@ -105,6 +107,9 @@
<classpathentry kind="lib" path="lib/core/commons-codec-1.7.jar"/>
<classpathentry kind="lib" path="lib/core/gnu-crypto-2.0.1-min.jar"/>
<classpathentry kind="lib" path="lib/optional/commons-net-2.2.jar"/>
+ <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-analyzers-3.6.1.jar"/>
+ <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-core-3.6.1.jar"/>
+ <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-queries-3.6.1.jar"/>
<classpathentry kind="lib" path="tools/jetty/lib/existdb-favicon.jar"/>
<classpathentry kind="lib" path="tools/jetty/lib/jetty-continuation-8.1.9.v20130131.jar"/>
<classpathentry kind="lib" path="tools/jetty/lib/jetty-http-8.1.9.v20130131.jar"/>
@@ -128,17 +133,12 @@
<classpathentry kind="lib" path="extensions/security/openid/lib/openid4java-0.9.6.jar"/>
<classpathentry kind="lib" path="extensions/debuggee/lib/mina-core-2.0.5.jar"/>
<classpathentry kind="lib" path="lib/optional/commons-lang3-3.1.jar"/>
- <classpathentry kind="lib" path="tools/aspectj/lib/aspectjrt-1.7.1.jar"/>
+ <classpathentry kind="lib" path="tools/aspectj/lib/aspectjrt-1.7.3.jar"/>
<classpathentry kind="lib" path="lib/core/quartz-2.1.6.jar"/>
<classpathentry kind="lib" path="lib/optional/fluent-hc-4.2.3.jar"/>
<classpathentry kind="lib" path="lib/optional/httpclient-4.2.3.jar"/>
<classpathentry kind="lib" path="lib/optional/httpclient-cache-4.2.3.jar"/>
<classpathentry kind="lib" path="lib/optional/httpcore-4.2.2.jar"/>
<classpathentry kind="lib" path="lib/optional/httpmime-4.2.3.jar"/>
- <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-analyzers-common-4.3.1.jar"/>
- <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-core-4.3.1.jar"/>
- <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-facet-4.3.1.jar"/>
- <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-queries-4.3.1.jar"/>
- <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-queryparser-4.3.1.jar"/>
<classpathentry kind="output" path="test/classes"/>
</classpath>
View
5 .gitignore
@@ -9,7 +9,8 @@ dist/
exist.jar
exist-optional.jar
extensions/**/build/
-extensions/**/lib/
+extensions/lib/
+extensions/modules/lib/
lib/extensions/
local.*
mime-types.xml
@@ -38,3 +39,5 @@ tools/wrapper/logs/
backup/
test/junit/
test/temp/
+nbproject/build/
+nbproject/private/
View
2  build/scripts/build-impl.xml
@@ -104,7 +104,7 @@
<classpath refid="classpath.core"/>
</taskdef>
- <taskdef classpath="${tools.aspectj}/lib/aspectjtools-1.7.1.jar" resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties"/>
+ <taskdef classpath="${tools.aspectj}/lib/aspectjtools-1.7.3.jar" resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties"/>
<path id="classpath.aspectj">
<fileset dir="${tools.aspectj}/lib">
<include name="*.jar"/>
View
2  extensions/expath/extension.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project basedir="." default="all" name="expath-20100109">
+<project basedir="." default="all" name="expath-20130805">
<property file="../local.build.properties"/>
<property file="../build.properties"/>
View
BIN  extensions/expath/lib/http-client-java-0.3.0.jar
Binary file not shown
View
BIN  extensions/expath/lib/http-client-java-1.0-SNAPSHOT.jar
Binary file not shown
View
76 extensions/expath/src/org/expath/httpclient/model/exist/EXistResult.java
@@ -1,6 +1,6 @@
/*
* eXist EXPath
- * Copyright (C) 2011 Adam Retter <adam@existsolutions.com>
+ * Copyright (C) 2013 Adam Retter <adam@existsolutions.com>
* www.existsolutions.com
*
* This program is free software; you can redistribute it and/or
@@ -21,9 +21,11 @@
*/
package org.expath.httpclient.model.exist;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
import javax.xml.transform.Source;
+import org.apache.log4j.Logger;
import org.exist.memtree.DocumentImpl;
import org.exist.xquery.NodeTest;
import org.exist.xquery.TypeTest;
@@ -47,67 +49,83 @@
*/
public class EXistResult implements Result {
- private Sequence result = new ValueSequence();
+ private static final Logger logger = Logger.getLogger(EXistResult.class);
+
+ ValueSequence result = new ValueSequence();
+
private final XQueryContext context;
- public EXistResult(XQueryContext context) {
+ public EXistResult(final XQueryContext context) {
this.context = context;
}
@Override
- public void add(String string) throws HttpClientException {
+ public void add(final Reader reader) throws HttpClientException {
+
+ // START TEMP - replace with a defferred StingReader when eXist has this soon.
+ final StringBuilder builder = new StringBuilder();
try {
- result.add(new StringValue(string));
- } catch (XPathException xpe) {
- throw new HttpClientException("Unable to add string value to result:" + xpe.getMessage(), xpe);
+ final char cbuf[] = new char[4096];
+ int read = -1;
+ while((read = reader.read(cbuf)) > -1) {
+ builder.append(cbuf, 0, read);
+ }
+ } catch(final IOException ioe) {
+ throw new HttpClientException("Unable to add string value to result: " + ioe.getMessage(), ioe);
+ } finally {
+ try {
+ reader.close();
+ } catch(final IOException ioe) {
+ logger.warn(ioe.getMessage(), ioe);
+ }
}
+ // END TEMP
+
+ result.add(new StringValue(builder.toString()));
+
}
- //TODO would be better if the EXPath API provided a stream!
@Override
- public void add(byte[] bytes) throws HttpClientException {
+ public void add(final InputStream is) throws HttpClientException {
try {
- result.add(BinaryValueFromInputStream.getInstance(context, new Base64BinaryValueType(), new ByteArrayInputStream(bytes)));
- } catch(XPathException xpe) {
+ result.add(BinaryValueFromInputStream.getInstance(context, new Base64BinaryValueType(), is));
+ } catch(final XPathException xpe) {
throw new HttpClientException("Unable to add binary value to result:" + xpe.getMessage(), xpe);
}
}
@Override
- public void add(Source src) throws HttpClientException {
+ public void add(final Source src) throws HttpClientException {
try {
- NodeValue nodeValue = ModuleUtils.sourceToXML(context, src);
+ final NodeValue nodeValue = ModuleUtils.sourceToXML(context, src);
result.add(nodeValue);
- } catch(SAXException saxe) {
+ } catch(final SAXException saxe) {
throw new HttpClientException("Unable to add Source to result:" + saxe.getMessage(), saxe);
- } catch(IOException ioe) {
+ } catch(final IOException ioe) {
throw new HttpClientException("Unable to add Source to result:" + ioe.getMessage(), ioe);
- } catch(XPathException xpe) {
- throw new HttpClientException("Unable to add Source to result:" + xpe.getMessage(), xpe);
}
}
@Override
- public void add(HttpResponse response) throws HttpClientException {
- EXistTreeBuilder builder = new EXistTreeBuilder(context);
+ public void add(final HttpResponse response) throws HttpClientException {
+ final EXistTreeBuilder builder = new EXistTreeBuilder(context);
response.outputResponseElement(builder);
- DocumentImpl doc = builder.close();
+ final DocumentImpl doc = builder.close();
try {
// we add the root *element* to the result sequence
NodeTest kind = new TypeTest(Type.ELEMENT);
// the elem must always be added at the front, so if there are
// already other items, we create a new one, add the elem, then
// add the original items after
- if ( result.isEmpty() ) {
- doc.selectChildren(kind, result);
- }
- else {
- Sequence buf = result;
- result = new ValueSequence();
+ if(result.isEmpty()) {
doc.selectChildren(kind, result);
- result.addAll(buf);
+ } else {
+ final ValueSequence newResult = new ValueSequence();
+ doc.selectChildren(kind, newResult);
+ newResult.addAll(result);
+ result = newResult;
}
- } catch (XPathException xpe) {
+ } catch (final XPathException xpe) {
throw new HttpClientException("Unable to add HttpResponse to result:" + xpe.getMessage(), xpe);
}
}
View
BIN  extensions/exquery/lib/exquery-annotations-common-1.0-SNAPSHOT.jar
Binary file not shown
View
BIN  extensions/exquery/lib/exquery-annotations-common-api-1.0-SNAPSHOT.jar
Binary file not shown
View
BIN  extensions/exquery/lib/exquery-common-1.0-SNAPSHOT.jar
Binary file not shown
View
BIN  extensions/exquery/lib/exquery-serialization-annotations-1.0-SNAPSHOT.jar
Binary file not shown
View
BIN  extensions/exquery/lib/exquery-serialization-annotations-api-1.0-SNAPSHOT.jar
Binary file not shown
View
BIN  extensions/exquery/lib/exquery-xquery-1.0-SNAPSHOT.jar
Binary file not shown
View
BIN  extensions/exquery/lib/exquery-xquery3-1.0-SNAPSHOT.jar
Binary file not shown
View
BIN  extensions/exquery/restxq/lib/exquery-restxq-1.0-SNAPSHOT.jar
Binary file not shown
View
BIN  extensions/exquery/restxq/lib/exquery-restxq-api-1.0-SNAPSHOT.jar
Binary file not shown
View
37 ...ons/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/adapters/EXQueryErrorCode.java
@@ -0,0 +1,37 @@
+/*
+Copyright (c) 2013, Adam Retter
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Adam Retter Consulting nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Adam Retter BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.exist.extensions.exquery.restxq.impl.adapters;
+
+import org.exist.dom.QName;
+import org.exist.xquery.ErrorCodes.ErrorCode;
+
+public class EXQueryErrorCode extends ErrorCode {
+
+ public EXQueryErrorCode(final org.exquery.ErrorCodes.ErrorCode errorCode) {
+ super(new QName(errorCode.getErrorQName().getLocalPart(), errorCode.getErrorQName().getNamespaceURI(), errorCode.getErrorQName().getPrefix()), errorCode.getDescription());
+ }
+}
View
10 extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/xquery/UriFunctions.java
@@ -28,6 +28,7 @@
import org.exist.dom.QName;
import org.exist.extensions.exquery.restxq.impl.ResourceFunctionExecutorImpl;
+import org.exist.extensions.exquery.restxq.impl.adapters.EXQueryErrorCode;
import org.exist.xquery.BasicFunction;
import org.exist.xquery.Cardinality;
import org.exist.xquery.FunctionSignature;
@@ -37,6 +38,7 @@
import org.exist.xquery.value.FunctionReturnSequenceType;
import org.exist.xquery.value.Sequence;
import org.exist.xquery.value.Type;
+import org.exquery.restxq.RestXqErrorCodes;
/**
*
@@ -75,7 +77,11 @@ public Sequence eval(final Sequence[] args, final Sequence contextSequence) thro
} else {
var = context.resolveVariable(ResourceFunctionExecutorImpl.XQ_VAR_URI);
}
-
- return var.getValue();
+
+ if(var == null) {
+ throw new XPathException(new EXQueryErrorCode(RestXqErrorCodes.RQDY0101), getLine(), getColumn());
+ } else {
+ return var.getValue();
+ }
}
}
View
18 extensions/security/ldap/src/org/exist/security/realm/ldap/LDAPRealm.java
@@ -435,17 +435,15 @@ private Group createGroupInDatabase(final String groupname) throws Authenticatio
}
private LdapContext getContext(final Subject invokingUser) throws NamingException {
- final Map<String, Object> additionalEnv = new HashMap<String, Object>();
- additionalEnv.put("java.naming.ldap.attributes.binary", "objectSID");
final LdapContextFactory ctxFactory = ensureContextFactory();
final LdapContext ctx;
if(invokingUser != null && invokingUser instanceof AuthenticatedLdapSubjectAccreditedImpl) {
//use the provided credentials for the lookup
- ctx = ctxFactory.getLdapContext(invokingUser.getUsername(), ((AuthenticatedLdapSubjectAccreditedImpl) invokingUser).getAuthenticatedCredentials(), additionalEnv);
+ ctx = ctxFactory.getLdapContext(invokingUser.getUsername(), ((AuthenticatedLdapSubjectAccreditedImpl) invokingUser).getAuthenticatedCredentials(), null);
} else {
//use the default credentials for lookup
LDAPSearchContext searchCtx = ctxFactory.getSearch();
- ctx = ctxFactory.getLdapContext(searchCtx.getDefaultUsername(), searchCtx.getDefaultPassword(), additionalEnv);
+ ctx = ctxFactory.getLdapContext(searchCtx.getDefaultUsername(), searchCtx.getDefaultPassword(), null);
}
return ctx;
}
@@ -504,10 +502,10 @@ public final synchronized Account getAccount(final LdapContext ctx, String name)
} else {
//found a user from ldap so cache them and return
try {
- final String group = getPrimaryGroupSID(ldapUser);
- final String primaryGroup = findGroupBySID(ctx, group);
+ final String primaryGroupSID = getPrimaryGroupSID(ldapUser);
+ final String primaryGroup = findGroupBySID(ctx, primaryGroupSID);
if (LOG.isDebugEnabled()) {
- LOG.debug("LDAP search for primary group '"+group+"' return '"+primaryGroup+"'.");
+ LOG.debug("LDAP search for primary group by SID '" + primaryGroupSID + "', found '" + primaryGroup + "'.");
}
if (primaryGroup == null) {
//or exception?
@@ -587,11 +585,7 @@ private String getPrimaryGroupSID(final SearchResult ldapUser) throws NamingExce
final Object objSID = ldapUser.getAttributes().get(search.getSearchAccount().getSearchAttribute(LDAPSearchAttributeKey.OBJECT_SID)).get();
final String strObjectSid;
if (objSID instanceof String) {
- if (objSID.toString().lastIndexOf('-') == -1) {
- strObjectSid = decodeSID(((String)objSID).getBytes());
- } else {
- strObjectSid = objSID.toString();
- }
+ strObjectSid = objSID.toString();
} else {
strObjectSid = decodeSID((byte[])objSID);
}
View
7 extensions/security/ldap/src/org/exist/security/realm/ldap/LdapContextFactory.java
@@ -22,6 +22,7 @@
package org.exist.security.realm.ldap;
import java.text.MessageFormat;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import javax.naming.Context;
@@ -88,12 +89,13 @@ public LdapContextFactory(final Configuration config) {
public LdapContext getSystemLdapContext() throws NamingException {
return getLdapContext(systemUsername, systemPassword);
}
-
+
public LdapContext getLdapContext(final String username, final String password) throws NamingException {
return getLdapContext(username, password, null);
}
public LdapContext getLdapContext(String username, final String password, final Map<String, Object>additionalEnv) throws NamingException {
+
if (url == null) {
throw new IllegalStateException("An LDAP URL must be specified of the form ldap://<hostname>:<port>");
}
@@ -120,6 +122,9 @@ public LdapContext getLdapContext(String username, final String password, final
env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactoryClassName);
env.put(Context.PROVIDER_URL, url);
+ //Absolutely nessecary for working with Active Directory
+ env.put("java.naming.ldap.attributes.binary", "objectSid");
+
// the following is helpful in debugging errors
//env.put("com.sun.jndi.ldap.trace.ber", System.err);
View
41 extensions/webdav/src/org/exist/webdav/ExistCollection.java
@@ -63,10 +63,16 @@
*/
public class ExistCollection extends ExistResource {
+ /**
+ * Constructor.
+ *
+ * @param uri URI of document
+ * @param pool Reference to brokerpool
+ */
public ExistCollection(XmldbURI uri, BrokerPool pool) {
if(LOG.isTraceEnabled()) {
- LOG.trace("New collection object for " + uri);
+ LOG.trace(String.format("New collection object for %s", uri));
}
brokerPool = pool;
@@ -98,7 +104,7 @@ public void initMetadata() {
collection = broker.openCollection(xmldbUri, Lock.READ_LOCK);
if (collection == null) {
- LOG.error("Collection for " + xmldbUri + " cannot be opened for metadata");
+ LOG.error(String.format("Collection for %s cannot be opened for metadata", xmldbUri));
return;
}
@@ -224,7 +230,7 @@ public void initMetadata() {
void delete() {
if(LOG.isDebugEnabled())
- LOG.debug("Deleting '" + xmldbUri + "'");
+ LOG.debug(String.format("Deleting '%s'", xmldbUri));
DBBroker broker = null;
Collection collection = null;
@@ -287,7 +293,7 @@ void delete() {
public XmldbURI createCollection(String name) throws PermissionDeniedException, CollectionExistsException, EXistException {
if(LOG.isDebugEnabled())
- LOG.debug("Create '" + name + "' in '" + xmldbUri + "'");
+ LOG.debug(String.format("Create '%s' in '%s'", name, xmldbUri));
XmldbURI newCollection = xmldbUri.append(name);
@@ -305,12 +311,13 @@ public XmldbURI createCollection(String name) throws PermissionDeniedException,
// checked by ResourceFactory
collection = broker.openCollection(newCollection, Lock.WRITE_LOCK);
if (collection != null) {
+ final String msg = "Collection already exists";
- LOG.debug("Collection already exists");
+ LOG.debug(msg);
//XXX: double "abort" is bad thing!!!
txnManager.abort(txn);
- throw new CollectionExistsException("Collection already exists");
+ throw new CollectionExistsException(msg);
}
// Create collection
@@ -365,7 +372,7 @@ public XmldbURI createFile(String newName, InputStream is, Long length, String c
throws IOException, PermissionDeniedException, CollectionDoesNotExistException {
if(LOG.isDebugEnabled())
- LOG.debug("Create '" + newName + "' in '" + xmldbUri + "'");
+ LOG.debug(String.format("Create '%s' in '%s'", newName, xmldbUri));
XmldbURI newNameUri = XmldbURI.create(newName);
@@ -397,7 +404,7 @@ public XmldbURI createFile(String newName, InputStream is, Long length, String c
if (mime.isXMLType() && vtf.length() == 0L) {
if(LOG.isDebugEnabled())
- LOG.debug("Creating dummy XML file for null resource lock '" + newNameUri + "'");
+ LOG.debug(String.format("Creating dummy XML file for null resource lock '%s'", newNameUri));
vtf = new VirtualTempFile();
IOUtils.write("<null_resource/>", vtf);
@@ -415,7 +422,7 @@ public XmldbURI createFile(String newName, InputStream is, Long length, String c
// by ResourceFactory
collection = broker.openCollection(xmldbUri, Lock.WRITE_LOCK);
if (collection == null) {
- LOG.debug("Collection " + xmldbUri + " does not exist");
+ LOG.debug(String.format("Collection %s does not exist", xmldbUri));
txnManager.abort(txn);
throw new CollectionDoesNotExistException(xmldbUri + "");
}
@@ -424,7 +431,7 @@ public XmldbURI createFile(String newName, InputStream is, Long length, String c
if (mime.isXMLType()) {
if(LOG.isDebugEnabled())
- LOG.debug("Inserting XML document '" + mime.getName() + "'");
+ LOG.debug(String.format("Inserting XML document '%s'", mime.getName()));
// Stream into database
VirtualTempFileInputSource vtfis = new VirtualTempFileInputSource(vtf);
@@ -436,7 +443,7 @@ public XmldbURI createFile(String newName, InputStream is, Long length, String c
} else {
if(LOG.isDebugEnabled())
- LOG.debug("Inserting BINARY document '" + mime.getName() + "'");
+ LOG.debug(String.format("Inserting BINARY document '%s'", mime.getName()));
// Stream into database
InputStream fis = vtf.getByteStream();
@@ -508,8 +515,7 @@ public XmldbURI createFile(String newName, InputStream is, Long length, String c
void resourceCopyMove(XmldbURI destCollectionUri, String newName, Mode mode) throws EXistException {
if(LOG.isDebugEnabled())
- LOG.debug(mode + " '" + xmldbUri + "' to '" +
- destCollectionUri + "' named '" + newName + "'");
+ LOG.debug(String.format("%s '%s' to '%s' named '%s'", mode, xmldbUri, destCollectionUri, newName));
XmldbURI newNameUri = null;
try {
@@ -545,7 +551,7 @@ void resourceCopyMove(XmldbURI destCollectionUri, String newName, Mode mode) thr
// Open collection if possible, else abort
destCollection = broker.openCollection(destCollectionUri, Lock.WRITE_LOCK);
if (destCollection == null) {
- LOG.debug("Destination collection " + xmldbUri + " does not exist.");
+ LOG.debug(String.format("Destination collection %s does not exist.", xmldbUri));
txnManager.abort(txn);
return; // TODO throw?
}
@@ -562,7 +568,7 @@ void resourceCopyMove(XmldbURI destCollectionUri, String newName, Mode mode) thr
txnManager.commit(txn);
if(LOG.isDebugEnabled())
- LOG.debug("Collection " + mode + "d sucessfully");
+ LOG.debug(String.format("Collection %sd sucessfully", mode));
} catch (LockException e) {
LOG.error("Resource is locked.", e);
@@ -602,8 +608,9 @@ void resourceCopyMove(XmldbURI destCollectionUri, String newName, Mode mode) thr
txnManager.close(txn);
brokerPool.release(broker);
- if(LOG.isDebugEnabled())
- LOG.debug("Finished " + mode);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(String.format("Finished %s", mode));
+ }
}
}
}
View
82 extensions/webdav/src/org/exist/webdav/ExistDocument.java
@@ -26,8 +26,7 @@
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.URISyntaxException;
-import java.util.Properties;
-import javax.xml.transform.OutputKeys;
+
import org.exist.EXistException;
import org.exist.collections.Collection;
import org.exist.collections.triggers.TriggerException;
@@ -40,7 +39,6 @@
import org.exist.storage.BrokerPool;
import org.exist.storage.DBBroker;
import org.exist.storage.lock.Lock;
-import org.exist.storage.serializers.EXistOutputKeys;
import org.exist.storage.serializers.Serializer;
import org.exist.storage.txn.TransactionManager;
import org.exist.storage.txn.Txn;
@@ -49,6 +47,7 @@
import org.exist.webdav.exceptions.DocumentAlreadyLockedException;
import org.exist.webdav.exceptions.DocumentNotLockedException;
import org.exist.xmldb.XmldbURI;
+
import org.xml.sax.SAXException;
/**
@@ -58,21 +57,16 @@
*/
public class ExistDocument extends ExistResource {
- // default output properties for the XML serialization
- public final static Properties WEBDAV_OUTPUT_PROPERTIES = new Properties();
-
- static {
- WEBDAV_OUTPUT_PROPERTIES.setProperty(OutputKeys.INDENT, "yes");
- WEBDAV_OUTPUT_PROPERTIES.setProperty(OutputKeys.ENCODING, "UTF-8");
- WEBDAV_OUTPUT_PROPERTIES.setProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
- WEBDAV_OUTPUT_PROPERTIES.setProperty(EXistOutputKeys.EXPAND_XINCLUDES, "no");
- WEBDAV_OUTPUT_PROPERTIES.setProperty(EXistOutputKeys.PROCESS_XSL_PI, "no");
- }
-
+ /**
+ * Constructor.
+ *
+ * @param uri URI of document
+ * @param pool Reference to brokerpool
+ */
public ExistDocument(XmldbURI uri, BrokerPool pool) {
if (LOG.isTraceEnabled()) {
- LOG.trace("New document object for " + uri);
+ LOG.trace(String.format("New document object for %s", uri));
}
brokerPool = pool;
@@ -188,8 +182,10 @@ public void stream(OutputStream os) throws IOException, PermissionDeniedExceptio
Serializer serializer = broker.getSerializer();
serializer.reset();
try {
- serializer.setProperties(WEBDAV_OUTPUT_PROPERTIES);
+ // Set serialization options
+ serializer.setProperties(configuration);
+ // Serialize document
Writer w = new OutputStreamWriter(os, "UTF-8");
serializer.serialize(document, w);
w.flush();
@@ -202,7 +198,7 @@ public void stream(OutputStream os) throws IOException, PermissionDeniedExceptio
} catch (SAXException e) {
LOG.error(e);
- throw new IOException("Error while serializing XML document: " + e.getMessage(), e);
+ throw new IOException(String.format("Error while serializing XML document: %s", e.getMessage()), e);
}
} else {
@@ -228,7 +224,7 @@ public void stream(OutputStream os) throws IOException, PermissionDeniedExceptio
brokerPool.release(broker);
if (LOG.isDebugEnabled()) {
- LOG.debug("Stream stopped, duration " + (System.currentTimeMillis() - startTime) + " msec.");
+ LOG.debug(String.format("Stream stopped, duration %s msec.", System.currentTimeMillis() - startTime));
}
}
@@ -240,7 +236,7 @@ public void stream(OutputStream os) throws IOException, PermissionDeniedExceptio
void delete() {
if (LOG.isDebugEnabled()) {
- LOG.debug("Deleting " + xmldbUri);
+ LOG.debug(String.format("Deleting %s", xmldbUri));
}
DBBroker broker = null;
@@ -268,7 +264,7 @@ void delete() {
// Open document if possible, else abort
resource = collection.getDocument(broker, docName);
if (resource == null) {
- LOG.debug("No resource found for path: " + xmldbUri);
+ LOG.debug(String.format("No resource found for path: %s", xmldbUri));
txnManager.abort(txn);
return;
}
@@ -415,7 +411,7 @@ public LockToken lock(LockToken inputToken) throws PermissionDeniedException,
if (document == null) {
if (LOG.isDebugEnabled()) {
- LOG.debug("No resource found for path: " + xmldbUri);
+ LOG.debug(String.format("No resource found for path: %s", xmldbUri));
}
//return null; // throw exception?
throw new EXistException("No resource found.");
@@ -435,7 +431,7 @@ public LockToken lock(LockToken inputToken) throws PermissionDeniedException,
&& !userLock.getName().equals(subject.getName())
&& !subject.hasDbaRole() ) {
if (LOG.isDebugEnabled()) {
- LOG.debug("Resource is locked by user " + userLock.getName() + ".");
+ LOG.debug(String.format("Resource is locked by user %s.", userLock.getName()));
}
throw new PermissionDeniedException(userLock.getName());
}
@@ -503,7 +499,10 @@ public LockToken lock(LockToken inputToken) throws PermissionDeniedException,
document.getUpdateLock().release(Lock.WRITE_LOCK);
}
- txnManager.close(txn);
+ if (txnManager != null) {
+ txnManager.close(txn);
+ }
+
brokerPool.release(broker);
if (LOG.isDebugEnabled()) {
@@ -535,8 +534,9 @@ void unlock() throws PermissionDeniedException, DocumentNotLockedException, EXis
document = broker.getXMLResource(xmldbUri, Lock.WRITE_LOCK);
if (document == null) {
- LOG.debug("No resource found for path: " + xmldbUri);
- throw new EXistException("No resource found for path: " + xmldbUri);
+ final String msg = String.format("No resource found for path: %s", xmldbUri);
+ LOG.debug(msg);
+ throw new EXistException(msg);
}
// Get current userlock
@@ -544,13 +544,13 @@ void unlock() throws PermissionDeniedException, DocumentNotLockedException, EXis
// Check if Resource is already locked.
if (lock == null) {
- LOG.debug("Resource " + xmldbUri + " is not locked.");
+ LOG.debug(String.format("Resource %s is not locked.", xmldbUri));
throw new DocumentNotLockedException("" + xmldbUri);
}
// Check if Resource is from subject
if (!lock.getName().equals(subject.getName()) && !subject.hasDbaRole() ) {
- LOG.debug("Resource lock is from user " + lock.getName());
+ LOG.debug(String.format("Resource lock is from user %s", lock.getName()));
throw new PermissionDeniedException(lock.getName());
}
@@ -597,7 +597,7 @@ void unlock() throws PermissionDeniedException, DocumentNotLockedException, EXis
void resourceCopyMove(XmldbURI destCollectionUri, String newName, Mode mode) throws EXistException {
if (LOG.isDebugEnabled()) {
- LOG.debug(mode + " " + xmldbUri + " to " + destCollectionUri + " named " + newName);
+ LOG.debug(String.format("%s %s to %s named %s", mode, xmldbUri, destCollectionUri, newName));
}
XmldbURI newNameUri = null;
@@ -635,7 +635,7 @@ void resourceCopyMove(XmldbURI destCollectionUri, String newName, Mode mode) thr
// Open document if possible, else abort
srcDocument = srcCollection.getDocument(broker, srdDocumentUri);
if (srcDocument == null) {
- LOG.debug("No resource found for path: " + xmldbUri);
+ LOG.debug(String.format("No resource found for path: %s", xmldbUri));
txnManager.abort(txn);
return;
}
@@ -643,7 +643,7 @@ void resourceCopyMove(XmldbURI destCollectionUri, String newName, Mode mode) thr
// Open collection if possible, else abort
destCollection = broker.openCollection(destCollectionUri, Lock.WRITE_LOCK);
if (destCollection == null) {
- LOG.debug("Destination collection " + xmldbUri + " does not exist.");
+ LOG.debug(String.format("Destination collection %s does not exist.", xmldbUri));
txnManager.abort(txn);
return;
}
@@ -662,7 +662,7 @@ void resourceCopyMove(XmldbURI destCollectionUri, String newName, Mode mode) thr
txnManager.commit(txn);
if (LOG.isDebugEnabled()) {
- LOG.debug("Document " + mode + "d sucessfully");
+ LOG.debug(String.format("Document %sd sucessfully", mode));
}
} catch (LockException e) {
@@ -713,9 +713,8 @@ void resourceCopyMove(XmldbURI destCollectionUri, String newName, Mode mode) thr
public LockToken refreshLock(String token) throws PermissionDeniedException,
DocumentAlreadyLockedException, EXistException, DocumentNotLockedException {
-
if (LOG.isDebugEnabled()) {
- LOG.debug("refresh lock " + xmldbUri + " lock=" + token);
+ LOG.debug(String.format("refresh lock %s lock=%s", xmldbUri, token));
}
DBBroker broker = null;
@@ -740,7 +739,7 @@ public LockToken refreshLock(String token) throws PermissionDeniedException,
if (document == null) {
if (LOG.isDebugEnabled()) {
- LOG.debug("No resource found for path: " + xmldbUri);
+ LOG.debug(String.format("No resource found for path: %s", xmldbUri));
}
//return null; // throw exception?
throw new EXistException("No resource found.");
@@ -751,16 +750,17 @@ public LockToken refreshLock(String token) throws PermissionDeniedException,
// Check if Resource is already locked.
if (userLock == null) {
+ final String msg = "Resource was not locked.";
if (LOG.isDebugEnabled()) {
- LOG.debug("Resource was not locked.");
+ LOG.debug(msg);
}
- throw new DocumentNotLockedException("Resource was not locked.");
+ throw new DocumentNotLockedException(msg);
}
if (userLock.getName() != null && !userLock.getName().equals(subject.getName())
&& !subject.hasDbaRole()) {
if (LOG.isDebugEnabled()) {
- LOG.debug("Resource is locked by " + userLock.getName());
+ LOG.debug(String.format("Resource is locked by %s", userLock.getName()));
}
throw new PermissionDeniedException(userLock.getName());
}
@@ -771,7 +771,7 @@ public LockToken refreshLock(String token) throws PermissionDeniedException,
if (LOG.isDebugEnabled()) {
LOG.debug("Token does not match");
}
- throw new PermissionDeniedException("Token " + token + " does not match " + lockToken.getOpaqueLockToken());
+ throw new PermissionDeniedException(String.format("Token %s does not match %s", token, lockToken.getOpaqueLockToken()));
}
lockToken.setTimeOut(LockToken.LOCK_TIMEOUT_INFINITE);
@@ -810,7 +810,11 @@ public LockToken refreshLock(String token) throws PermissionDeniedException,
if (document != null) {
document.getUpdateLock().release(Lock.WRITE_LOCK);
}
- txnManager.close(txn);
+
+ if (txnManager != null) {
+ txnManager.close(txn);
+ }
+
if(broker != null) {
brokerPool.release(broker);
}
View
15 extensions/webdav/src/org/exist/webdav/ExistResource.java
@@ -21,6 +21,7 @@
*/
package org.exist.webdav;
+import java.util.Properties;
import org.apache.log4j.Logger;
import org.exist.security.SecurityManager;
@@ -48,10 +49,12 @@
protected boolean readAllowed = false;
protected boolean writeAllowed = false;
protected boolean executeAllowed = false;
- protected ExistResource existResource;
+// protected ExistResource existResource;
protected String ownerUser;
protected String ownerGroup;
+
+ protected Properties configuration = new Properties();
protected enum Mode {
MOVE, COPY
@@ -98,6 +101,14 @@ public String getOwnerGroup() {
public String getOwnerUser() {
return ownerUser;
}
+
+ public Properties getConfiguration(){
+ return configuration;
+ }
+
+ public void setConfiguration(Properties config){
+ configuration = config;
+ }
/**
* Authenticate subject with password. NULL is returned when
@@ -114,7 +125,7 @@ protected Subject authenticate(String username, String password) {
subject = securityManager.authenticate(username, password);
} catch (AuthenticationException e) {
- LOG.info("User " + username + " could not be authenticated. " + e.getMessage());
+ LOG.info(String.format("User %s could not be authenticated. %s", username, e.getMessage()));
}
return subject;
}
View
87 extensions/webdav/src/org/exist/webdav/ExistResourceFactory.java
@@ -26,8 +26,12 @@
import com.bradmcevoy.http.Resource;
import com.bradmcevoy.http.ResourceFactory;
+import java.io.File;
+import java.io.FileInputStream;
import java.net.URISyntaxException;
+import java.util.Properties;
+import javax.xml.transform.OutputKeys;
import org.exist.EXistException;
import org.exist.collections.Collection;
@@ -35,6 +39,7 @@
import org.exist.storage.BrokerPool;
import org.exist.storage.DBBroker;
import org.exist.storage.lock.Lock;
+import org.exist.storage.serializers.EXistOutputKeys;
import org.exist.xmldb.XmldbURI;
/**
@@ -46,13 +51,30 @@
private final static Logger LOG = Logger.getLogger(ExistResourceFactory.class);
private BrokerPool brokerPool = null;
+
+ // default output properties for the XML serialization
+ public final static Properties DEFAULT_WEBDAV_OPTIONS = new Properties();
+
+ /** XML serialization options */
+ private Properties webDavOptions = new Properties();
+
+ /**
+ * Default serialization options
+ */
+ static {
+ DEFAULT_WEBDAV_OPTIONS.setProperty(OutputKeys.INDENT, "yes");
+ DEFAULT_WEBDAV_OPTIONS.setProperty(OutputKeys.ENCODING, "UTF-8");
+ DEFAULT_WEBDAV_OPTIONS.setProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
+ DEFAULT_WEBDAV_OPTIONS.setProperty(EXistOutputKeys.EXPAND_XINCLUDES, "no");
+ DEFAULT_WEBDAV_OPTIONS.setProperty(EXistOutputKeys.PROCESS_XSL_PI, "no");
+ }
private enum ResourceType {
DOCUMENT, COLLECTION, IGNORABLE, NOT_EXISTING
};
/**
- * Default constructor. Get access to instance of exist-db brokerpool.
+ * Default constructor. Get access to instance of exist-db broker pool.
*/
public ExistResourceFactory() {
@@ -62,7 +84,31 @@ public ExistResourceFactory() {
} catch (EXistException e) {
LOG.error("Unable to initialize WebDAV interface.", e);
}
-
+
+ // Set default values
+ webDavOptions.putAll(DEFAULT_WEBDAV_OPTIONS);
+
+ // load specific options
+ try {
+ // Find right file
+ File eXistHome = brokerPool.getConfiguration().getExistHome();
+ File config = new File(eXistHome, "webdav.properties");
+
+ // Read from file if existent
+ if(config.canRead()){
+ LOG.info(String.format("Read WebDAV configuration from %s", config.getCanonicalPath()));
+ FileInputStream fis = new FileInputStream(config);
+ webDavOptions.load(fis);
+ fis.close();
+
+ } else {
+ LOG.info("Using WebDAV default serialization options.");
+ }
+
+ } catch (Throwable ex) {
+ LOG.error(ex.getMessage());
+ }
+
}
/*
@@ -90,27 +136,23 @@ public Resource getResource(String host, String path) {
}
if(LOG.isDebugEnabled()) {
- LOG.debug("host='" + host + "' path='" + path + "'");
+ LOG.debug(String.format("host='%s' path='%s'", host, path));
}
// Create uri inside database
xmldbUri = XmldbURI.xmldbUriFor(path);
- // MacOsX finder specific files
- String documentSeqment = xmldbUri.lastSegment().toString();
- if(documentSeqment.startsWith("._") || documentSeqment.equals(".DS_Store")){
- LOG.debug("skipping MacOsX file '"+xmldbUri.lastSegment().toString()+"'");
- }
-
} catch (URISyntaxException e) {
- LOG.error("Unable to convert path '" + path + "'into a XmldbURI representation.");
+ LOG.error(String.format("Unable to convert path '%s'into a XmldbURI representation.", path));
return null;
}
// Return appropriate resource
switch (getResourceType(brokerPool, xmldbUri)) {
case DOCUMENT:
- return new MiltonDocument(host, xmldbUri, brokerPool);
+ MiltonDocument doc = new MiltonDocument(host, xmldbUri, brokerPool);
+ doc.setConfiguration(webDavOptions);
+ return doc;
case COLLECTION:
return new MiltonCollection(host, xmldbUri, brokerPool);
@@ -123,12 +165,12 @@ public Resource getResource(String host, String path) {
case NOT_EXISTING:
if (LOG.isDebugEnabled()) {
- LOG.debug("Resource does not exist: '" + xmldbUri + "'");
+ LOG.debug(String.format("Resource does not exist: '%s'", xmldbUri));
}
return null;
default:
- LOG.error("Unkown resource type for " + xmldbUri);
+ LOG.error(String.format("Unkown resource type for %s", xmldbUri));
return null;
}
}
@@ -142,10 +184,23 @@ private ResourceType getResourceType(BrokerPool brokerPool, XmldbURI xmldbUri) {
Collection collection = null;
DocumentImpl document = null;
ResourceType type = ResourceType.NOT_EXISTING;
+
+ // MacOsX finder specific files
+ String documentSeqment = xmldbUri.lastSegment().toString();
+ if(documentSeqment.startsWith("._") || documentSeqment.equals(".DS_Store")){
+ //LOG.debug(String.format("Ignoring MacOSX file '%s'", xmldbUri.lastSegment().toString()));
+ //return ResourceType.IGNORABLE;
+ }
+
+ // Documents that start with a dot
+ if(documentSeqment.startsWith(".")){
+ //LOG.debug(String.format("Ignoring '.' file '%s'", xmldbUri.lastSegment().toString()));
+ //return ResourceType.IGNORABLE;
+ }
try {
if(LOG.isDebugEnabled()) {
- LOG.debug("Path: " + xmldbUri.toString());
+ LOG.debug(String.format("Path: %s", xmldbUri.toString()));
}
// Try to read as system user. Note that the actual user is not know
@@ -179,7 +234,7 @@ private ResourceType getResourceType(BrokerPool brokerPool, XmldbURI xmldbUri) {
} catch (Exception ex) {
- LOG.error("Error determining nature of resource " + xmldbUri.toString(), ex);
+ LOG.error(String.format("Error determining nature of resource %s", xmldbUri.toString()), ex);
type = ResourceType.NOT_EXISTING;
} finally {
@@ -201,7 +256,7 @@ private ResourceType getResourceType(BrokerPool brokerPool, XmldbURI xmldbUri) {
}
if(LOG.isDebugEnabled()) {
- LOG.debug("Resource type=" + type.toString());
+ LOG.debug(String.format("Resource type=%s", type.toString()));
}
return type;
View
28 extensions/webdav/src/org/exist/webdav/MiltonCollection.java
@@ -105,7 +105,7 @@ public MiltonCollection(String host, XmldbURI uri, BrokerPool pool, Subject subj
super();
if(LOG.isDebugEnabled()) {
- LOG.debug("COLLECTION:" + uri.toString());
+ LOG.debug(String.format("COLLECTION=%s", uri.toString()));
}
resourceXmldbUri = uri;
@@ -131,7 +131,7 @@ public MiltonCollection(String host, XmldbURI uri, BrokerPool pool, Subject subj
public Resource child(String childName) {
if(LOG.isDebugEnabled()) {
- LOG.debug("get child=" + childName);
+ LOG.debug(String.format("get child=%s", childName));
}
// Safe guard value
@@ -178,7 +178,7 @@ public Resource child(String childName) {
allResources.addAll(getDocumentResources());
if(LOG.isDebugEnabled()) {
- LOG.debug("Nr of children=" + allResources.size());
+ LOG.debug(String.format("Nr of children=%s", allResources.size()));
}
return allResources;
@@ -199,7 +199,7 @@ public Date getCreateDate() {
}
if(LOG.isTraceEnabled()) {
- LOG.trace("Create date=" + createDate);
+ LOG.trace(String.format("Create date=%s", createDate));
}
return createDate;
@@ -212,7 +212,7 @@ public Date getCreateDate() {
public void delete() throws NotAuthorizedException, ConflictException, BadRequestException {
if(LOG.isDebugEnabled()) {
- LOG.debug("Delete collection '" + resourceXmldbUri + "'.");
+ LOG.debug(String.format("Delete collection '%s'.", resourceXmldbUri));
}
existCollection.delete();
@@ -226,7 +226,7 @@ public CollectionResource createCollection(String name)
throws NotAuthorizedException, ConflictException {
if (LOG.isTraceEnabled()) {
- LOG.trace("Create collection '" + name + "' in '" + resourceXmldbUri + "'.");
+ LOG.trace(String.format("Create collection '%s' in '%s'.", name, resourceXmldbUri));
}
CollectionResource collection = null;
@@ -259,7 +259,7 @@ public Resource createNew(String newName, InputStream is, Long length, String co
throws IOException, ConflictException {
if (LOG.isTraceEnabled()) {
- LOG.trace("Create '" + newName + "' in '" + resourceXmldbUri + "'");
+ LOG.trace(String.format("Create '%s' in '%s'", newName, resourceXmldbUri));
}
Resource resource = null;
@@ -291,7 +291,7 @@ public Resource createNew(String newName, InputStream is, Long length, String co
public LockToken createAndLock(String name, LockTimeout timeout, LockInfo lockInfo) throws NotAuthorizedException {
if(LOG.isDebugEnabled()) {
- LOG.debug("'" + resourceXmldbUri + "' name='" + name + "'");
+ LOG.debug(String.format("'%s' name='%s'", resourceXmldbUri, name));
}
String token = UUID.randomUUID().toString();
@@ -308,7 +308,7 @@ public LockResult lock(LockTimeout timeout, LockInfo lockInfo)
throws NotAuthorizedException, PreConditionFailedException, LockedException {
if (LOG.isDebugEnabled()) {
- LOG.debug("'" + resourceXmldbUri + "' -- " + lockInfo.toString());
+ LOG.debug(String.format("'%s' -- %s", resourceXmldbUri, lockInfo.toString()));
}
return refreshLock(UUID.randomUUID().toString());
@@ -318,7 +318,7 @@ public LockResult lock(LockTimeout timeout, LockInfo lockInfo)
public LockResult refreshLock(String token) throws NotAuthorizedException, PreConditionFailedException {
if(LOG.isDebugEnabled()) {
- LOG.debug("'" + resourceXmldbUri + "' token='" + token + "'");
+ LOG.debug(String.format("'%s' token='%s'", resourceXmldbUri, token));
}
LockInfo lockInfo = new LockInfo(LockInfo.LockScope.NONE, LockInfo.LockType.READ, token, LockInfo.LockDepth.ZERO);
@@ -333,14 +333,14 @@ public LockResult refreshLock(String token) throws NotAuthorizedException, PreCo
public void unlock(String tokenId) throws NotAuthorizedException, PreConditionFailedException {
// Just do nothing
if(LOG.isDebugEnabled()) {
- LOG.debug("'" + resourceXmldbUri + "' token='" + tokenId + "'");
+ LOG.debug(String.format("'%s' token='%s'", resourceXmldbUri, tokenId));
}
}
@Override
public LockToken getCurrentLock() {
if(LOG.isDebugEnabled()) {
- LOG.debug("'" + resourceXmldbUri + "'");
+ LOG.debug(String.format("'%s'", resourceXmldbUri));
}
return null; // null is allowed
}
@@ -353,7 +353,7 @@ public LockToken getCurrentLock() {
public void moveTo(CollectionResource rDest, String newName) throws ConflictException {
if(LOG.isDebugEnabled()) {
- LOG.debug("Move '"+ resourceXmldbUri + "' to '" + newName + "' in '" + rDest.getName() + "'");
+ LOG.debug(String.format("Move '%s' to '%s' in '%s'", resourceXmldbUri, newName, rDest.getName()));
}
XmldbURI destCollection = ((MiltonCollection) rDest).getXmldbUri();
@@ -373,7 +373,7 @@ public void moveTo(CollectionResource rDest, String newName) throws ConflictExce
public void copyTo(CollectionResource toCollection, String newName) {
if(LOG.isDebugEnabled()) {
- LOG.debug("Move '"+ resourceXmldbUri + "' to '" + newName + "' in '" + toCollection.getName() + "'");
+ LOG.debug(String.format("Move '%s' to '%s' in '%s'", resourceXmldbUri, newName, toCollection.getName()));
}
XmldbURI destCollection = ((MiltonCollection) toCollection).getXmldbUri();
View
38 extensions/webdav/src/org/exist/webdav/MiltonDocument.java
@@ -48,6 +48,7 @@
import java.io.OutputStream;
import java.util.Date;
import java.util.Map;
+import java.util.Properties;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
@@ -128,7 +129,7 @@ public MiltonDocument(String host, XmldbURI uri, BrokerPool pool, Subject subjec
}
if(LOG.isTraceEnabled()) {
- LOG.trace("DOCUMENT:" + uri.toString());
+ LOG.trace(String.format("DOCUMENT:%s", uri.toString()));
}
resourceXmldbUri = uri;
@@ -287,8 +288,8 @@ public Long getContentLength() {
// or when set by a system property
if(LOG.isDebugEnabled()){
- LOG.debug("Serializing XML to /dev/null to determine size"
- + " (" + resourceXmldbUri + ") MacFinder="+isMacFinder );
+ LOG.debug(String.format("Serializing XML to /dev/null to determine size (%s) MacFinder=%s",
+ resourceXmldbUri, isMacFinder));
}
// Stream document to '/dev/null' and count bytes
@@ -331,7 +332,7 @@ public Long getContentLength() {
try {
if(LOG.isDebugEnabled()) {
- LOG.debug("Serializing XML to virtual file" + " (" + resourceXmldbUri + ")");
+ LOG.debug(String.format("Serializing XML to virtual file (%s)", resourceXmldbUri));
}
vtf = new VirtualTempFile();
@@ -369,7 +370,7 @@ public Long getContentLength() {
}
if(LOG.isDebugEnabled()) {
- LOG.debug("Size=" + size + " (" + resourceXmldbUri + ")");
+ LOG.debug(String.format("Size=%s (%s)", size, resourceXmldbUri));
}
return size;
@@ -412,7 +413,7 @@ public LockResult lock(LockTimeout timeout, LockInfo lockInfo)
org.exist.dom.LockToken inputToken = convertToken(timeout, lockInfo);
if (LOG.isDebugEnabled()) {
- LOG.debug("Lock: " + resourceXmldbUri);
+ LOG.debug(String.format("Lock: %s", resourceXmldbUri));
}
LockResult lr = null;
@@ -444,7 +445,7 @@ public LockResult lock(LockTimeout timeout, LockInfo lockInfo)
public LockResult refreshLock(String token) throws NotAuthorizedException, PreConditionFailedException {
if(LOG.isDebugEnabled()) {
- LOG.debug("Refresh: " + resourceXmldbUri + " token=" + token);
+ LOG.debug(String.format("Refresh: %s token=%s", resourceXmldbUri, token));
}
LockResult lr = null;
@@ -480,7 +481,7 @@ public LockResult refreshLock(String token) throws NotAuthorizedException, PreCo
public void unlock(String tokenId) throws NotAuthorizedException, PreConditionFailedException {
if(LOG.isDebugEnabled()) {
- LOG.debug("Unlock: " + resourceXmldbUri);
+ LOG.debug(String.format("Unlock: %s", resourceXmldbUri));
}
try {
@@ -503,7 +504,7 @@ public void unlock(String tokenId) throws NotAuthorizedException, PreConditionFa
public LockToken getCurrentLock() {
if(LOG.isDebugEnabled()) {
- LOG.debug("getLock: " + resourceXmldbUri);
+ LOG.debug(String.format("getCurrentLock: %s", resourceXmldbUri));
}
org.exist.dom.LockToken existLT = existDocument.getCurrentLock();
@@ -529,7 +530,7 @@ public LockToken getCurrentLock() {
public void moveTo(CollectionResource rDest, String newName) throws ConflictException {
if(LOG.isDebugEnabled()) {
- LOG.debug("moveTo: " + resourceXmldbUri + " newName=" + newName);
+ LOG.debug(String.format("moveTo: %s newName=%s", resourceXmldbUri, newName));
}
XmldbURI destCollection = ((MiltonCollection) rDest).getXmldbUri();
@@ -550,7 +551,7 @@ public void moveTo(CollectionResource rDest, String newName) throws ConflictExce
public void copyTo(CollectionResource rDest, String newName) {
if(LOG.isDebugEnabled()) {
- LOG.debug("copyTo: " + resourceXmldbUri + " newName=" + newName);
+ LOG.debug(String.format("copyTo: %s newName=%s", resourceXmldbUri, newName));
}
XmldbURI destCollection = ((MiltonCollection) rDest).getXmldbUri();
@@ -568,6 +569,12 @@ public void copyTo(CollectionResource rDest, String newName) {
* StAX serializer
* ================ */
+ /**
+ * Serialize document properties
+ *
+ * @param writer STAX writer
+ * @throws XMLStreamException Thrown when writing data failed
+ */
public void writeXML(XMLStreamWriter writer) throws XMLStreamException {
writer.writeStartElement("exist", "document", "http://exist.sourceforge.net/NS/exist");
writer.writeAttribute("name", resourceXmldbUri.lastSegment().toString());
@@ -579,4 +586,13 @@ public void writeXML(XMLStreamWriter writer) throws XMLStreamException {
writer.writeAttribute("size", "" + existDocument.getContentLength());
writer.writeEndElement();
}
+
+ /**
+ * Set specific WebDAV serialization options
+ *
+ * @param config XML serialization options
+ */
+ public void setConfiguration(Properties config){
+ existDocument.setConfiguration(config);
+ }
}
View
20 extensions/webdav/src/org/exist/webdav/MiltonResource.java
@@ -303,7 +303,7 @@ public String getName() {
public Object authenticate(String username, String password) {
if(LOG.isDebugEnabled())
- LOG.debug("Authenticating user " + username + " for " + resourceXmldbUri);
+ LOG.debug(String.format("Authenticating user %s for %s", username, resourceXmldbUri));
// Check if username is provided.
if (username == null) {
@@ -330,7 +330,7 @@ public Object authenticate(String username, String password) {
// Guest is not allowed to access.
Subject guest = brokerPool.getSecurityManager().getGuestSubject();
if (guest.equals(subject)) {
- LOG.error("The user " + guest.getName() + " is prohibited from logging in through WebDAV.");
+ LOG.error(String.format("The user %s is prohibited from logging in through WebDAV.", guest.getName()));
return null;
}
@@ -340,14 +340,14 @@ public Object authenticate(String username, String password) {
existResource.initMetadata();
if(LOG.isDebugEnabled())
- LOG.debug("User '" + subject.getName() + "' has been authenticated.");
+ LOG.debug(String.format("User '%s' has been authenticated.", subject.getName()));
return AUTHENTICATED;
}
@Override
public boolean authorise(Request request, Method method, Auth auth) {
- LOG.info(method.toString() + " " + resourceXmldbUri + " (write="+ method.isWrite+")");
+ LOG.info(String.format("%s %s (write=%s)", method.toString(), resourceXmldbUri, method.isWrite));
/*
* First perform checks on Milton authentication
@@ -370,7 +370,7 @@ public boolean authorise(Request request, Method method, Auth auth) {
// If object does not exist, there was no successfull authentication
if (tag == null) {
if(LOG.isDebugEnabled())
- LOG.debug("No tag, user " + userName + " not authenticated");
+ LOG.debug(String.format("No tag, user %s not authenticated", userName));
return false;
} else if (tag instanceof String) {
@@ -380,8 +380,7 @@ public boolean authorise(Request request, Method method, Auth auth) {
} else {
if(LOG.isDebugEnabled())
- LOG.debug("Authentication tag contains wrong value, user "
- + userName + " is not authenticated");
+ LOG.debug(String.format("Authentication tag contains wrong value, user %s is not authenticated", userName));
return false;
}
}
@@ -392,14 +391,14 @@ public boolean authorise(Request request, Method method, Auth auth) {
if (method.isWrite) {
if (!existResource.writeAllowed) {
if(LOG.isDebugEnabled())
- LOG.debug("User " + userName + " is NOT authorized to write resource, abort.");
+ LOG.debug(String.format("User %s is NOT authorized to write resource, abort.", userName));
return false;
}
} else {
if (!existResource.readAllowed) {
if(LOG.isDebugEnabled())
- LOG.debug("User " + userName + " is NOT authorized to read resource, abort.");
+ LOG.debug(String.format("User %s is NOT authorized to read resource, abort.", userName));
return false;
}
}
@@ -412,8 +411,7 @@ public boolean authorise(Request request, Method method, Auth auth) {
String action = method.isWrite ? "write" : "read";
if(LOG.isDebugEnabled())
- LOG.debug("User " + userName + " is authorized to " + action
- + " resource " + resourceXmldbUri.toString());
+ LOG.debug(String.format("User %s is authorized to %s resource %s", userName, action, resourceXmldbUri.toString()));
return true;
}
View
5 extensions/webdav/src/org/exist/webdav/MiltonWebDAVServlet.java
@@ -24,11 +24,14 @@
import com.bradmcevoy.http.MiltonServlet;
import com.bradmcevoy.http.http11.DefaultHttp11ResponseHandler;
+
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
+
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
+
import org.apache.log4j.Logger;
/**
@@ -83,6 +86,6 @@ public void init(ServletConfig config) throws ServletException {
// Pass value to Milton
httpManager.setEnableExpectContinue(enableExpectContinue);
- LOG.debug("Set 'Enable Expect Continue' to " + enableExpectContinue);
+ LOG.debug(String.format("Set 'Enable Expect Continue' to %s", enableExpectContinue));
}
}
View
8 extensions/webdav/webdav.properties
@@ -0,0 +1,8 @@
+## XML Serialization options for the WevDAV
+## The file is read from EXIST_HOME
+## Be carefull changing the default values !
+#indent=yes
+#expand-xincludes=no
+#process-xsl-pi=no
+#encoding=UTF-8
+#omit-xml-declaration=no
View
BIN  lib/optional/commons-fileupload-1.2.2.jar
Binary file not shown
View
BIN  lib/optional/commons-fileupload-1.3.jar
Binary file not shown
View
2  nbbuild.xml
@@ -78,7 +78,7 @@
</target>
<!-- Add an AspectJ build target -->
- <taskdef classpath="tools/aspectj/lib/aspectjtools-1.7.1.jar" resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties"/>
+ <taskdef classpath="tools/aspectj/lib/aspectjtools-1.7.3.jar" resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties"/>
<target name="aspectj">
<echo level="info">--- aspectj (start) ---</echo>
<iajc
View
20 nbproject/project.properties
@@ -1,9 +1,9 @@
annotation.processing.processors.list=
application.homepage=http://www.exist-db.org
file.reference.apache-mime4j-0.6.1.jar=extensions/expath/lib/apache-mime4j-0.6.1.jar
-file.reference.aspectjrt-1.7.1.jar=tools/aspectj/lib/aspectjrt-1.7.1.jar
-file.reference.aspectjtools-1.7.1.jar=tools/aspectj/lib/aspectjtools-1.7.1.jar
-file.reference.aspectjweaver-1.7.1.jar=tools/aspectj/lib/aspectjweaver-1.7.1.jar
+file.reference.aspectjrt-1.7.3.jar=tools/aspectj/lib/aspectjrt-1.7.3.jar
+file.reference.aspectjtools-1.7.3.jar=tools/aspectj/lib/aspectjtools-1.7.3.jar
+file.reference.aspectjweaver-1.7.3.jar=tools/aspectj/lib/aspectjweaver-1.7.3.jar
file.reference.cglib-nodep-2.2.jar=lib/core/cglib-nodep-2.2.jar
file.reference.clj-ds-0.0.1.jar=lib/core/clj-ds-0.0.1.jar
file.reference.commons-lang3-3.1.jar=lib/optional/commons-lang3-3.1.jar
@@ -21,7 +21,7 @@ file.reference.exquery-xquery-1.0-SNAPSHOT.jar=extensions/exquery/lib/exquery-xq
file.reference.exquery-xquery3-1.0-SNAPSHOT.jar=extensions/exquery/lib/exquery-xquery3-1.0-SNAPSHOT.jar
file.reference.fluent-hc-4.2.3.jar=lib/optional/fluent-hc-4.2.3.jar
file.reference.gnu-crypto-2.0.1-min.jar=lib/core/gnu-crypto-2.0.1-min.jar
-file.reference.http-client-java-0.3.0.jar=extensions/expath/lib/http-client-java-0.3.0.jar
+file.reference.http-client-java-1.0-SNAPSHOT.jar=extensions/expath/lib/http-client-java-1.0-SNAPSHOT.jar
file.reference.httpclient-4.2.3.jar=lib/optional/httpclient-4.2.3.jar
file.reference.httpclient-cache-4.2.3.jar=lib/optional/httpclient-cache-4.2.3.jar
file.reference.httpcore-4.2.2.jar=lib/optional/httpcore-4.2.2.jar
@@ -159,7 +159,7 @@ javac.processorpath=\
javadoc.splitindex=true
file.reference.commons-codec-1.7.jar=lib/core/commons-codec-1.7.jar
jmx.jconsole.classpath.plugins=true
-file.reference.commons-fileupload-1.2.2.jar=lib/optional/commons-fileupload-1.2.2.jar
+file.reference.commons-fileupload-1.3.jar=lib/optional/commons-fileupload-1.3.jar
file.reference.activation-1.1.1.jar=lib/user/activation-1.1.1.jar
file.reference.jdom-1.1.jar=extensions/webdav/lib/jdom-1.1.jar
file.reference.easymockclassextension-2.5.2.jar=lib/test/easymockclassextension-2.5.2.jar
@@ -251,7 +251,7 @@ javac.classpath=\
${file.reference.gnu-crypto-2.0.1-min.jar}:\
${file.reference.commons-compress-1.4.1.jar}:\
${file.reference.commons-discovery-0.5.jar}:\
- ${file.reference.commons-fileupload-1.2.2.jar}:\
+ ${file.reference.commons-fileupload-1.3.jar}:\
${file.reference.commons-httpclient-3.1.jar}:\
${file.reference.xqjapi-1.0-fr.jar}:\
${file.reference.servlet-api-3.0.jar}:\
@@ -281,9 +281,9 @@ javac.classpath=\
${file.reference.ant.jar}:\
${file.reference.xmlunit-1.3.jar}:\
${file.reference.wrapper.jar}:\
- ${file.reference.aspectjtools-1.7.1.jar}:\
- ${file.reference.aspectjrt-1.7.1.jar}:\
- ${file.reference.aspectjweaver-1.7.1.jar}:\
+ ${file.reference.aspectjtools-1.7.3.jar}:\
+ ${file.reference.aspectjrt-1.7.3.jar}:\
+ ${file.reference.aspectjweaver-1.7.3.jar}:\
${file.reference.existdb-favicon.jar}:\
${file.reference.jetty-continuation-8.1.9.v20130131.jar}:\
${file.reference.jetty-http-8.1.9.v20130131.jar}:\
@@ -310,7 +310,7 @@ javac.classpath=\
${file.reference.mime-util-2.1.3.jar}:\
${file.reference.mina-core-2.0.5.jar}:\
${file.reference.apache-mime4j-0.6.1.jar}:\
- ${file.reference.http-client-java-0.3.0.jar}:\
+ ${file.reference.http-client-java-1.0-SNAPSHOT.jar}:\
${file.reference.tagsoup-1.2.jar}:\
${file.reference.lucene-analyzers-3.6.1.jar}:\
${file.reference.lucene-core-3.6.1.jar}:\
View
4 src/org/exist/Database.java
@@ -56,9 +56,7 @@
//TODO: javadocs
- public String getId();
-
- public void addObserver(Observer o);
+ public String getId();
/**
*
View
5 src/org/exist/http/servlets/HttpRequestWrapper.java
@@ -201,12 +201,11 @@ private void parseMultipartContent() {
try {
- final List items = upload.parseRequest(servletRequest);
+ final List<FileItem> items = upload.parseRequest(servletRequest);
// Iterate over all mult-part formdata items and
// add all data (field and files) to parmeters
- for (final Object i : items) {
- final FileItem item = (FileItem) i;
+ for (final FileItem item : items) {
addParameter(params, item.getFieldName(), item);
}
View
33 src/org/exist/storage/BrokerPool.java
@@ -92,7 +92,7 @@
*/
//TODO : in the future, separate the design between the Map of DBInstances and their non static implementation
@ConfigurationClass("pool")
-public class BrokerPool extends Observable implements Database {
+public class BrokerPool implements Database {
private final static Logger LOG = Logger.getLogger(BrokerPool.class);
@@ -617,9 +617,6 @@ private BrokerPool(String instanceName, int minBrokers, int maxBrokers, Configur
Boolean aBoolean;
final NumberFormat nf = NumberFormat.getNumberInstance();
- if (statusObserver != null)
- {addObserver(statusObserver);}
-
this.classLoader = Thread.currentThread().getContextClassLoader();
//TODO : ensure that the instance name is unique ?
@@ -813,7 +810,11 @@ protected void initialize() throws EXistException, DatabaseConfigurationExceptio
synchronized (this) {
try {
statusReporter = new StatusReporter(SIGNAL_STARTUP);
- statusReporter.start();
+ if (statusObserver != null) {
+ statusReporter.addObserver(statusObserver);
+ }
+ Thread statusThread = new Thread(statusReporter);
+ statusThread.start();
// statusReporter may have to be terminated or the thread can/will hang.
try {
@@ -1886,7 +1887,11 @@ public void shutdown(boolean killed) {
// these may be used and set by other threads for the same or some other purpose
// (unlikely). Take no chances.
statusReporter = new StatusReporter(SIGNAL_SHUTDOWN);
- statusReporter.start();
+ if (statusObserver != null) {
+ statusReporter.addObserver(statusObserver);
+ }
+ Thread statusThread = new Thread(statusReporter);
+ statusThread.start();
// release transaction log to allow remaining brokers to complete
// their job
@@ -2084,7 +2089,7 @@ public void printSystemInfo() {
System.err.println(s);
}
- private class StatusReporter extends Thread {
+ private class StatusReporter extends Observable implements Runnable {
private String status;
private volatile boolean terminate = false;
@@ -2095,27 +2100,27 @@ public StatusReporter(String status) {
public synchronized void setStatus(String status) {
this.status = status;
- BrokerPool.this.setChanged();
- BrokerPool.this.notifyObservers(status);
+ this.setChanged();
+ this.notifyObservers(status);
}
- public void terminate() {
+ public synchronized void terminate() {
this.terminate = true;
- interrupt();
+ this.notifyAll();
}
public void run() {
while (!terminate) {
synchronized (this) {
try {
- wait(300);
+ wait(500);
} catch (final InterruptedException e) {
// nothing to do
}
}
+ this.setChanged();
+ this.notifyObservers(status);
}
- BrokerPool.this.setChanged();
- BrokerPool.this.notifyObservers(status);
}
}
View
BIN  tools/aspectj/lib/aspectjrt-1.7.1.jar → tools/aspectj/lib/aspectjrt-1.7.3.jar
Binary file not shown
View
BIN  tools/aspectj/lib/aspectjtools-1.7.1.jar → tools/aspectj/lib/aspectjtools-1.7.3.jar
Binary file not shown
View
BIN  tools/aspectj/lib/aspectjweaver-1.7.1.jar → tools/aspectj/lib/aspectjweaver-1.7.3.jar
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.