Permalink
Browse files

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

  • Loading branch information...
2 parents 9257c27 + 9953d0f commit d336126e41262807a2d80cad199042e8088a8b07 @wolfgangmm wolfgangmm committed Aug 29, 2013
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 ...uery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/adapters/EXQueryErrorCode.java
  18. +8 −2 ...ns/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
@@ -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
@@ -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/
@@ -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"/>
@@ -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"/>
Binary file not shown.
Binary file not shown.
@@ -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);
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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());
+ }
+}
@@ -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();
+ }
}
}
@@ -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);
}
@@ -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);
Oops, something went wrong.

0 comments on commit d336126

Please sign in to comment.