Permalink
Browse files

Merge remote-tracking branch 'eXist/develop' into develop

  • Loading branch information...
2 parents c82f6f4 + 3552203 commit 6aec88a59ada9e75741f8fca5483a7fd2a4a6ac8 @shabanovd shabanovd committed Mar 1, 2014
Showing with 4,820 additions and 1,043 deletions.
  1. BIN extensions/betterform/main/lib/betterform.jar
  2. +6 −16 ...ions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqServiceImpl.java
  3. +9 −3 extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqServlet.java
  4. +10 −2 extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexWorker.java
  5. +2 −2 extensions/indexes/ngram/src/org/exist/indexing/ngram/NGramIndexWorker.java
  6. +11 −4 extensions/indexes/range/src/org/exist/indexing/range/RangeIndexWorker.java
  7. +71 −4 extensions/indexes/range/src/org/exist/xquery/modules/range/Lookup.java
  8. +207 −0 extensions/indexes/range/src/org/exist/xquery/modules/range/OptimizeFieldPragma.java
  9. +63 −178 extensions/indexes/range/src/org/exist/xquery/modules/range/RangeQueryRewriter.java
  10. +3 −3 extensions/indexes/sort/src/org/exist/indexing/sort/SortIndexWorker.java
  11. +2 −2 extensions/indexes/spatial/src/org/exist/indexing/spatial/AbstractGMLJDBCIndexWorker.java
  12. +20 −12 extensions/modules/src/org/exist/xquery/modules/file/SerializeToFile.java
  13. +1 −1 extensions/versioning/src/org/exist/versioning/VersioningTrigger.java
  14. +49 −0 src/org/exist/client/LabelledBoolean.java
  15. +65 −0 src/org/exist/client/LabelledBooleanEditor.java
  16. +79 −0 src/org/exist/client/LabelledBooleanRenderer.java
  17. +17 −13 src/org/exist/client/ResourceDescriptor.java
  18. +30 −9 src/org/exist/client/security/BasicPermissionsTableModel.java
  19. +9 −24 src/org/exist/client/security/EditPropertiesDialog.form
  20. +9 −4 src/org/exist/client/security/EditPropertiesDialog.java
  21. +4 −4 src/org/exist/collections/Collection.java
  22. +2 −2 src/org/exist/collections/CollectionCache.java
  23. +3 −2 src/org/exist/collections/CollectionConfigurationManager.java
  24. +28 −13 src/org/exist/dom/DocumentImpl.java
  25. +9 −7 src/org/exist/dom/ElementImpl.java
  26. +2 −2 src/org/exist/fulltext/FTIndexWorker.java
  27. +11 −14 src/org/exist/indexing/IndexController.java
  28. +6 −5 src/org/exist/indexing/IndexWorker.java
  29. +38 −10 src/org/exist/security/AbstractUnixStylePermission.java
  30. +284 −0 src/org/exist/security/EffectiveSubject.java
  31. +34 −21 src/org/exist/security/Permission.java
  32. +6 −1 src/org/exist/security/PermissionRequired.java
  33. +9 −0 src/org/exist/security/PermissionRequiredAspect.java
  34. +63 −42 src/org/exist/security/UnixStylePermission.java
  35. +44 −25 src/org/exist/security/internal/aider/UnixStylePermissionAider.java
  36. +58 −33 src/org/exist/source/DBSource.java
  37. +1 −0 src/org/exist/start/start.config
  38. +1 −1 src/org/exist/storage/DBBroker.java
  39. +67 −35 src/org/exist/storage/NativeBroker.java
  40. +2 −2 src/org/exist/storage/statistics/IndexStatisticsWorker.java
  41. +63 −4 src/org/exist/storage/structural/NativeStructuralIndexWorker.java
  42. +11 −10 src/org/exist/xmldb/LocalCollectionManagementService.java
  43. +88 −0 src/org/exist/xmldb/LocalUserManagementService.java
  44. +108 −31 src/org/exist/xmldb/RemoteUserManagementService.java
  45. +47 −12 src/org/exist/xmldb/UserManagementService.java
  46. +23 −13 src/org/exist/xmlrpc/RpcAPI.java
  47. +60 −12 src/org/exist/xmlrpc/RpcConnection.java
  48. +1 −3 src/org/exist/xquery/ExtensionExpression.java
  49. +19 −4 src/org/exist/xquery/Optimizer.java
  50. +4 −4 src/org/exist/xquery/QueryRewriter.java
  51. +53 −17 src/org/exist/xquery/XQuery.java
  52. +42 −5 src/org/exist/xquery/XQueryContext.java
  53. +0 −7 src/org/exist/xquery/functions/fn/FunDoc.java
  54. +4 −26 src/org/exist/xquery/functions/fn/FunSerialize.java
  55. +2 −2 ...t/xquery/functions/securitymanager/{GroupMembershipFunctions.java → GroupMembershipFunction.java}
  56. +105 −0 src/org/exist/xquery/functions/securitymanager/IdFunction.java
  57. +7 −6 src/org/exist/xquery/functions/securitymanager/{IsAuthenticated.java → IsAuthenticatedFunction.java}
  58. +4 −4 ...org/exist/xquery/functions/securitymanager/{PermissionsFunctions.java → PermissionsFunction.java}
  59. +27 −24 src/org/exist/xquery/functions/securitymanager/SecurityManagerModule.java
  60. +45 −41 src/org/exist/xquery/functions/system/AsUser.java
  61. +22 −14 src/org/exist/xquery/functions/util/Serialize.java
  62. +3 −2 src/org/exist/xquery/functions/xmldb/XMLDBAddUserToGroup.java
  63. +1 −0 src/org/exist/xquery/functions/xmldb/XMLDBChangeUser.java
  64. +3 −3 src/org/exist/xquery/functions/xmldb/XMLDBChmodCollection.java
  65. +3 −4 src/org/exist/xquery/functions/xmldb/XMLDBChmodResource.java
  66. +1 −0 src/org/exist/xquery/functions/xmldb/XMLDBCreateGroup.java
  67. +1 −0 src/org/exist/xquery/functions/xmldb/XMLDBCreateUser.java
  68. +1 −0 src/org/exist/xquery/functions/xmldb/XMLDBDeleteUser.java
  69. +22 −25 src/org/exist/xquery/functions/xmldb/XMLDBGetCurrentUser.java
  70. +1 −0 src/org/exist/xquery/functions/xmldb/XMLDBGetCurrentUserAttribute.java
  71. +1 −0 src/org/exist/xquery/functions/xmldb/XMLDBGetCurrentUserAttributeNames.java
  72. +6 −5 src/org/exist/xquery/functions/xmldb/XMLDBGetUserOrGroup.java
  73. +3 −2 src/org/exist/xquery/functions/xmldb/XMLDBGetUsers.java
  74. +1 −0 src/org/exist/xquery/functions/xmldb/XMLDBGroupExists.java
  75. +3 −2 src/org/exist/xquery/functions/xmldb/XMLDBIsAdmin.java
  76. +21 −20 src/org/exist/xquery/functions/xmldb/XMLDBIsAuthenticated.java
  77. +4 −3 src/org/exist/xquery/functions/xmldb/XMLDBPermissions.java
  78. +4 −3 src/org/exist/xquery/functions/xmldb/XMLDBPermissionsToString.java
  79. +3 −2 src/org/exist/xquery/functions/xmldb/XMLDBRemoveUserFromGroup.java
  80. +1 −0 src/org/exist/xquery/functions/xmldb/XMLDBSetCollectionPermissions.java
  81. +1 −0 src/org/exist/xquery/functions/xmldb/XMLDBSetResourcePermissions.java
  82. +1 −0 src/org/exist/xquery/functions/xmldb/XMLDBUserAccess.java
  83. +1 −1 src/org/exist/xquery/lib/test.xq
  84. +56 −0 src/org/exist/xquery/util/SerializerUtils.java
  85. +63 −0 test/src/org/exist/client/security/BasicPermissionsTableModelTest.java
  86. +3 −3 test/src/org/exist/dom/DocumentImplTest.java
  87. +148 −6 test/src/org/exist/security/UnixStylePermissionTest.java
  88. +1,430 −165 test/src/org/exist/security/XMLDBSecurityTest.java
  89. +111 −0 test/src/org/exist/security/internal/aider/UnixStylePermissionAiderTest.java
  90. +0 −58 test/src/org/exist/security/internal/aider/UnixStylePermissionTest.java
  91. +701 −0 test/src/org/exist/storage/NativeBrokerTest.java
  92. +148 −0 test/src/org/exist/xquery/functions/securitymanager/IdFunctionTest.java
  93. +4 −4 ...t/xquery/functions/securitymanager/{PermissionsFunctionsTest.java → PermissionFunctionsTest.java}
Binary file not shown.
@@ -133,10 +133,8 @@ protected Sequence extractRequestBody(final HttpRequest request) throws RestXqSe
//first, get the content of the request
is = new CloseShieldInputStream(request.getInputStream());
-
- //if the content length is unknown or 0, return
- final int contentLength = request.getContentLength();
- if(contentLength == -1 || contentLength == 0) {
+
+ if(is.available() <= 0) {
return null;
}
@@ -162,18 +160,7 @@ public String getCacheClass() {
try {
//was there any POST content?
-
-
- /**
- * There is a bug in HttpInput.available() in Jetty 7.2.2.v20101205
- * This has been filed as Bug 333415 - https://bugs.eclipse.org/bugs/show_bug.cgi?id=333415
- * It is expected to be fixed in the Jetty 7.3.0 release
- */
-
- //TODO reinstate call to .available() when Jetty 7.3.0 is released, use of .getContentLength() is not reliable because of http mechanics
- //if(is != null && is.available() > 0) {
- final int contentLength = request.getContentLength();
- if(is != null && contentLength > 0) {
+ if(is != null && is.available() > 0) {
String contentType = request.getContentType();
// 1) determine if exists mime database considers this binary data
if(contentType != null) {
@@ -227,6 +214,8 @@ public String getCacheClass() {
}
}
}
+ } catch (IOException e) {
+ throw new RestXqServiceException(e.getMessage());
} finally {
if(cache != null) {
@@ -281,6 +270,7 @@ private DocumentImpl parseAsXml(final InputStream is) {
builder.startDocument();
final DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(builder, true);
reader.setContentHandler(receiver);
+ reader.setProperty("http://xml.org/sax/properties/lexical-handler", receiver);
reader.parse(src);
builder.endDocument();
final Document doc = receiver.getDocument();
@@ -36,6 +36,8 @@
import org.exist.extensions.exquery.restxq.impl.adapters.HttpServletRequestAdapter;
import org.exist.extensions.exquery.restxq.impl.adapters.HttpServletResponseAdapter;
import org.exist.http.servlets.AbstractExistHttpServlet;
+import org.exist.http.servlets.BasicAuthenticator;
+import org.exist.security.PermissionDeniedException;
import org.exist.security.Subject;
import org.exist.storage.DBBroker;
import org.exist.util.Configuration;
@@ -114,9 +116,13 @@ public String getCacheClass() {
getLog().error(ee.getMessage(), ee);
throw new ServletException(ee.getMessage(), ee);
} catch(RestXqServiceException rqse) {
- //TODO should probably be caught higher up and returned as a HTTP Response? maybe need two different types of exception to differentiate critical vs processing exception
- getLog().error(rqse.getMessage(), rqse);
- throw new ServletException(rqse.getMessage(), rqse);
+ if (rqse.getCause() instanceof PermissionDeniedException) {
+ getAuthenticator().sendChallenge(request, response);
+ } else {
+ //TODO should probably be caught higher up and returned as a HTTP Response? maybe need two different types of exception to differentiate critical vs processing exception
+ getLog().error(rqse.getMessage(), rqse);
+ throw new ServletException(rqse.getMessage(), rqse);
+ }
} finally {
if(broker != null) {
getPool().release(broker);
@@ -46,6 +46,7 @@
import org.exist.numbering.NodeId;
import org.exist.security.PermissionDeniedException;
import org.exist.storage.*;
+import org.exist.storage.btree.DBException;
import org.exist.storage.lock.Lock;
import org.exist.storage.txn.Txn;
import org.exist.util.ByteConversion;
@@ -201,7 +202,7 @@ public int getMode() {
return this.mode;
}
- public StoredNode getReindexRoot(StoredNode node, NodePath path, boolean includeSelf) {
+ public StoredNode getReindexRoot(StoredNode node, NodePath path, boolean insert, boolean includeSelf) {
if (node.getNodeType() == Node.ATTRIBUTE_NODE)
return null;
if (config == null)
@@ -290,7 +291,7 @@ protected void removePlainTextIndexes() {
}
}
- public void removeCollection(Collection collection, DBBroker broker) {
+ public void removeCollection(Collection collection, DBBroker broker, boolean reindex) {
if (LOG.isDebugEnabled())
LOG.debug("Removing collection " + collection.getURI());
IndexWriter writer = null;
@@ -309,6 +310,13 @@ public void removeCollection(Collection collection, DBBroker broker) {
LOG.error("Error while removing lucene index: " + e.getMessage(), e);
} finally {
index.releaseWriter(writer);
+ if (reindex) {
+ try {
+ index.sync();
+ } catch (DBException e) {
+ LOG.warn("Exception during reindex: " + e.getMessage(), e);
+ }
+ }
mode = StreamListener.STORE;
}
if (LOG.isDebugEnabled())
@@ -343,7 +343,7 @@ private void dropIndex(int mode) {
}
@Override
- public void removeCollection(Collection collection, DBBroker broker) {
+ public void removeCollection(Collection collection, DBBroker broker, boolean reindex) {
if (LOG.isDebugEnabled())
LOG.debug("Dropping NGram index for collection " + collection.getURI());
final Lock lock = index.db.getLock();
@@ -512,7 +512,7 @@ public MatchListener getMatchListener(DBBroker broker, NodeProxy proxy, NGramMat
}
@Override
- public StoredNode getReindexRoot(StoredNode node, NodePath path, boolean includeSelf) {
+ public StoredNode getReindexRoot(StoredNode node, NodePath path, boolean insert, boolean includeSelf) {
if (node.getNodeType() == Node.ATTRIBUTE_NODE)
return null;
IndexSpec indexConf = node.getDocument().getCollection().getIndexConfiguration(broker);
@@ -43,6 +43,7 @@
import org.exist.storage.ElementValue;
import org.exist.storage.IndexSpec;
import org.exist.storage.NodePath;
+import org.exist.storage.btree.DBException;
import org.exist.storage.txn.Txn;
import org.exist.util.ByteConversion;
import org.exist.util.DatabaseConfigurationException;
@@ -254,7 +255,7 @@ public int getMode() {
}
@Override
- public StoredNode getReindexRoot(StoredNode node, NodePath path, boolean includeSelf) {
+ public StoredNode getReindexRoot(StoredNode node, NodePath path, boolean insert, boolean includeSelf) {
// if (node.getNodeType() == Node.ATTRIBUTE_NODE)
// return null;
if (config == null)
@@ -289,8 +290,7 @@ public StoredNode getReindexRoot(StoredNode node, NodePath path, boolean include
@Override
public QueryRewriter getQueryRewriter(XQueryContext context) {
- List<Object> configs = index.getBrokerPool().getConfigurationManager().getCustomIndexSpecs(getIndexId());
- return new RangeQueryRewriter(this, configs, context);
+ return new RangeQueryRewriter(context);
}
@Override
@@ -320,7 +320,7 @@ public void flush() {
}
@Override
- public void removeCollection(Collection collection, DBBroker broker) throws PermissionDeniedException {
+ public void removeCollection(Collection collection, DBBroker broker, boolean reindex) throws PermissionDeniedException {
if (LOG.isDebugEnabled())
LOG.debug("Removing collection " + collection.getURI());
IndexWriter writer = null;
@@ -339,6 +339,13 @@ public void removeCollection(Collection collection, DBBroker broker) throws Perm
LOG.error("Error while removing lucene index: " + e.getMessage(), e);
} finally {
index.releaseWriter(writer);
+ if (reindex) {
+ try {
+ index.sync();
+ } catch (DBException e) {
+ LOG.warn("Exception during reindex: " + e.getMessage(), e);
+ }
+ }
mode = StreamListener.STORE;
}
if (LOG.isDebugEnabled())
@@ -21,19 +21,26 @@
*/
package org.exist.xquery.modules.range;
+import org.exist.collections.Collection;
import org.exist.dom.DocumentSet;
import org.exist.dom.NodeSet;
import org.exist.dom.QName;
import org.exist.dom.VirtualNodeSet;
import org.exist.indexing.range.RangeIndex;
+import org.exist.indexing.range.RangeIndexConfig;
+import org.exist.indexing.range.RangeIndexConfigElement;
import org.exist.indexing.range.RangeIndexWorker;
import org.exist.storage.ElementValue;
+import org.exist.storage.IndexSpec;
+import org.exist.storage.NodePath;
+import org.exist.xmldb.XmldbURI;
import org.exist.xquery.*;
import org.exist.xquery.value.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Iterator;
import java.util.List;
public class Lookup extends Function implements Optimizable {
@@ -120,10 +127,10 @@
)
};
- public static Lookup create(XQueryContext context, RangeIndex.Operator operator) {
+ public static Lookup create(XQueryContext context, RangeIndex.Operator operator, NodePath contextPath) {
for (FunctionSignature sig: signatures) {
if (sig.getName().getLocalName().equals(operator.toString())) {
- return new Lookup(context, sig);
+ return new Lookup(context, sig, contextPath);
}
}
return null;
@@ -133,18 +140,32 @@ public static Lookup create(XQueryContext context, RangeIndex.Operator operator)
protected QName contextQName = null;
protected int axis = Constants.UNKNOWN_AXIS;
private NodeSet preselectResult = null;
+ protected boolean canOptimize = false;
protected boolean optimizeSelf = false;
protected boolean optimizeChild = false;
protected Expression fallback = null;
+ protected NodePath contextPath = null;
public Lookup(XQueryContext context, FunctionSignature signature) {
+ this(context, signature, null);
+ }
+
+ public Lookup(XQueryContext context, FunctionSignature signature, NodePath contextPath) {
super(context, signature);
+ this.contextPath = contextPath;
}
public void setFallback(Expression expression) {
+ if (expression instanceof InternalFunctionCall) {
+ expression = ((InternalFunctionCall)expression).getFunction();
+ }
this.fallback = expression;
}
+ public Expression getFallback() {
+ return fallback;
+ }
+
public void setArguments(List<Expression> arguments) throws XPathException {
steps.clear();
Expression path = arguments.get(0);
@@ -205,6 +226,9 @@ else if (test.isWildcardTest())
@Override
public NodeSet preSelect(Sequence contextSequence, boolean useContext) throws XPathException {
+ if (!canOptimize) {
+ return ((Optimizable)fallback).preSelect(contextSequence, useContext);
+ }
if (contextSequence != null && !contextSequence.isPersistentSet())
// in-memory docs won't have an index
return NodeSet.EMPTY_SET;
@@ -262,6 +286,9 @@ public NodeSet preSelect(Sequence contextSequence, boolean useContext) throws XP
@Override
public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException {
+ if (!canOptimize && fallback != null) {
+ return fallback.eval(contextSequence, contextItem);
+ }
if (contextItem != null)
contextSequence = contextItem.toSequence();
@@ -273,7 +300,7 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc
return fallback.eval(contextSequence, contextItem);
}
}
- NodeSet result = NodeSet.EMPTY_SET;
+ NodeSet result;
if (preselectResult == null) {
long start = System.currentTimeMillis();
Sequence input = getArgument(0).eval(contextSequence);
@@ -321,12 +348,52 @@ public void resetState(boolean postOptimization) {
}
if (!postOptimization) {
preselectResult = null;
+ canOptimize = false;
}
}
@Override
public boolean canOptimize(Sequence contextSequence) {
- return contextQName != null;
+ if (contextQName == null) {
+ return false;
+ }
+ RangeIndexConfigElement rice = findConfiguration(contextSequence);
+ if (rice == null) {
+ canOptimize = false;
+ if (fallback instanceof Optimizable) {
+ return ((Optimizable)fallback).canOptimize(contextSequence);
+ }
+ return false;
+ }
+ canOptimize = true;
+ return canOptimize;
+ }
+
+ private RangeIndexConfigElement findConfiguration(Sequence contextSequence) {
+ NodePath path = contextPath;
+ if (path == null) {
+ if (contextQName == null) {
+ return null;
+ }
+ path = new NodePath(contextQName);
+ }
+ for (final Iterator<Collection> i = contextSequence.getCollectionIterator(); i.hasNext(); ) {
+ final Collection collection = i.next();
+ if (collection.getURI().startsWith(XmldbURI.SYSTEM_COLLECTION_URI)) {
+ continue;
+ }
+ IndexSpec idxConf = collection.getIndexConfiguration(context.getBroker());
+ if (idxConf != null) {
+ RangeIndexConfig config = (RangeIndexConfig) idxConf.getCustomIndexSpec(RangeIndex.ID);
+ if (config != null) {
+ RangeIndexConfigElement rice = config.find(path);
+ if (rice != null && !rice.isComplex()) {
+ return rice;
+ }
+ }
+ }
+ }
+ return null;
}
@Override
Oops, something went wrong.

0 comments on commit 6aec88a

Please sign in to comment.