jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1176340 [2/2] - in /jackrabbit/branches/JCR-2272: ./ jackrabbit-api/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/management/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/observation/ jackrabbit-api/src/main/java/org/ap...
Date Tue, 27 Sep 2011 11:53:12 GMT
Modified: jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ExcerptTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ExcerptTest.java?rev=1176340&r1=1176339&r2=1176340&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ExcerptTest.java
(original)
+++ jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ExcerptTest.java
Tue Sep 27 11:53:10 2011
@@ -16,9 +16,9 @@
  */
 package org.apache.jackrabbit.core.query;
 
+import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
-import javax.jcr.Node;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.Row;
 import javax.jcr.query.RowIterator;
@@ -104,6 +104,10 @@ public class ExcerptTest extends Abstrac
                 "apache jackrabbit");
     }
 
+    /**
+     * Verifies character encoding on a node property that does not contain any
+     * excerpt info
+     */
     public void testEncodeIllegalCharsNoHighlights() throws RepositoryException {
         String text = "bla <strong>bla</strong> bla";
         String excerpt = createExcerpt("bla &lt;strong&gt;bla&lt;/strong&gt;
bla");
@@ -116,9 +120,126 @@ public class ExcerptTest extends Abstrac
         QueryResult result = executeQuery(stmt);
         RowIterator rows = result.getRows();
         assertEquals(1, rows.getSize());
-        assertEquals(excerpt, rows.nextRow().getValue("rep:excerpt(text)").getString());
+        String ex = rows.nextRow().getValue("rep:excerpt(text)").getString();
+        assertEquals("Expected " + excerpt + ", but got ", excerpt, ex);
     }
 
+    /**
+     * Verifies character encoding on a node property that contains excerpt info
+     */
+    public void testEncodeIllegalCharsHighlights() throws RepositoryException {
+        checkExcerpt("bla <strong>bla</strong> foo",
+                "bla &lt;strong&gt;bla&lt;/strong&gt; <strong>foo</strong>",
+                "foo");
+    }
+
+    /**
+     * test for https://issues.apache.org/jira/browse/JCR-3077
+     * 
+     * when given a quoted phrase, the excerpt should evaluate it whole as a
+     * token (not break is down)
+     * 
+     */
+    public void testQuotedPhrase() throws RepositoryException {
+        checkExcerpt("one two three four",
+                "one <strong>two three</strong> four", "\"two three\"");
+    }
+
+    /**
+     * Verifies excerpt generation on a node property that does not contain any
+     * excerpt info for a quoted phrase
+     */
+    public void testQuotedPhraseNoMatch() throws RepositoryException {
+        String text = "one two three four";
+        String excerpt = createExcerpt("one two three four");
+        String terms = "\"five six\"";
+
+        Node n = testRootNode.addNode(nodeName1);
+        n.setProperty("text", text);
+        n.setProperty("other", terms);
+        superuser.save();
+
+        String stmt = getStatement(terms);
+        QueryResult result = executeQuery(stmt);
+        RowIterator rows = result.getRows();
+        assertEquals(1, rows.getSize());
+        String ex = rows.nextRow().getValue("rep:excerpt(text)").getString();
+        assertEquals("Expected " + excerpt + ", but got ", excerpt, ex);
+    }
+
+    /**
+     * 
+     * Verifies excerpt generation on a node property that contains the exact
+     * quoted phrase but with scrambled words.
+     * 
+     * More clearly it actually checks that the order of tokens is respected for
+     * a quoted phrase.
+     */
+    public void testQuotedPhraseNoMatchScrambled() throws RepositoryException {
+        String text = "one two three four";
+        String excerpt = createExcerpt("one two three four");
+        String terms = "\"three two\"";
+
+        Node n = testRootNode.addNode(nodeName1);
+        n.setProperty("text", text);
+        n.setProperty("other", terms);
+        superuser.save();
+
+        String stmt = getStatement(terms);
+        QueryResult result = executeQuery(stmt);
+        RowIterator rows = result.getRows();
+        assertEquals(1, rows.getSize());
+        String ex = rows.nextRow().getValue("rep:excerpt(text)").getString();
+        assertEquals("Expected " + excerpt + ", but got ", excerpt, ex);
+    }
+    
+    /**
+     * Verifies excerpt generation on a node property that does not contain the
+     * exact quoted phrase, but contains fragments of it.
+     * 
+     */
+    public void testQuotedPhraseNoMatchGap() throws RepositoryException {
+        String text = "one two three four";
+        String excerpt = createExcerpt("one two three four");
+        String terms = "\"two four\"";
+
+        Node n = testRootNode.addNode(nodeName1);
+        n.setProperty("text", text);
+        n.setProperty("other", terms);
+        superuser.save();
+
+        String stmt = getStatement(terms);
+        QueryResult result = executeQuery(stmt);
+        RowIterator rows = result.getRows();
+        assertEquals(1, rows.getSize());
+        String ex = rows.nextRow().getValue("rep:excerpt(text)").getString();
+        assertEquals("Expected " + excerpt + ", but got ", excerpt, ex);
+    }
+    
+    /**
+     * test for https://issues.apache.org/jira/browse/JCR-3077
+     * 
+     * JA search acts as a PhraseQuery, thanks to LUCENE-2458. so it should be
+     * covered by the QuotedTest search.
+     * 
+     */
+    public void testHighlightJa() throws RepositoryException {
+
+        // http://translate.google.com/#auto|en|%E3%82%B3%E3%83%B3%E3%83%86%E3%83%B3%E3%83%88
+        String jContent = "\u30b3\u30fe\u30c6\u30f3\u30c8";
+        // http://translate.google.com/#auto|en|%E3%83%86%E3%82%B9%E3%83%88
+        String jTest = "\u30c6\u30b9\u30c8";
+
+        String content = "some text with japanese: " + jContent + " (content)"
+                + " and " + jTest + " (test).";
+
+        // expected excerpt; note this may change if excerpt providers change
+        String expectedExcerpt = "some text with japanese: " + jContent
+                + " (content) and <strong>" + jTest + "</strong> (test).";
+        checkExcerpt(content, expectedExcerpt, jTest);
+    }
+
+
     private void checkExcerpt(String text, String fragmentText, String terms)
             throws RepositoryException {
         String excerpt = createExcerpt(fragmentText);
@@ -137,7 +258,7 @@ public class ExcerptTest extends Abstrac
     private void createTestData(String text) throws RepositoryException {
         Node n = testRootNode.addNode(nodeName1);
         n.setProperty("text", text);
-        testRootNode.save();
+        superuser.save();
     }
 
     private String getExcerpt(Row row) throws RepositoryException {

Modified: jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authentication/SimpleCredentialsAuthenticationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authentication/SimpleCredentialsAuthenticationTest.java?rev=1176340&r1=1176339&r2=1176340&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authentication/SimpleCredentialsAuthenticationTest.java
(original)
+++ jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authentication/SimpleCredentialsAuthenticationTest.java
Tue Sep 27 11:53:10 2011
@@ -134,6 +134,9 @@ public class SimpleCredentialsAuthentica
         public void changePassword(String password) throws RepositoryException {
         }
 
+        public void changePassword(String password, String oldPassword) throws RepositoryException
{
+        }
+
         public void disable(String reason) throws RepositoryException {
         }
 

Modified: jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/CustomPrivilegeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/CustomPrivilegeTest.java?rev=1176340&r1=1176339&r2=1176340&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/CustomPrivilegeTest.java
(original)
+++ jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/CustomPrivilegeTest.java
Tue Sep 27 11:53:10 2011
@@ -375,7 +375,7 @@ public class CustomPrivilegeTest extends
     }
 
     public void testRegister100CustomPrivileges() throws RepositoryException, FileSystemException
{
-        PrivilegeBits previous = privilegeRegistry.getBits(privilegeRegistry.get(NameConstants.JCR_RETENTION_MANAGEMENT)).unmodifiable();
+        PrivilegeBits previous = privilegeRegistry.getBits(privilegeRegistry.get(PrivilegeRegistry.REP_PRIVILEGE_MANAGEMENT_NAME)).unmodifiable();
         for (int i = 0; i < 100; i++) {
             boolean isAbstract = true;
             Name name = ((SessionImpl) superuser).getQName("test"+i);

Modified: jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/ImpersonationImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/ImpersonationImplTest.java?rev=1176340&r1=1176339&r2=1176340&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/ImpersonationImplTest.java
(original)
+++ jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/ImpersonationImplTest.java
Tue Sep 27 11:53:10 2011
@@ -155,13 +155,13 @@ public class ImpersonationImplTest exten
         Principal systemPrincipal = new SystemPrincipal();
         assertNull(userMgr.getAuthorizable(systemPrincipal));
 
-        // system cannot be add/remove to set of impersonators of 'u' but
-        // it should be allowed to impersonate a given user...
+        // system cannot be add/remove to set of impersonators of 'u' nor
+        // should it be allowed to impersonate a given user...
         User u = (User) userMgr.getAuthorizable(uID);
         Impersonation impersonation = u.getImpersonation();
 
         assertFalse(impersonation.grantImpersonation(systemPrincipal));
         assertFalse(impersonation.revokeImpersonation(systemPrincipal));
-        assertTrue(impersonation.allows(buildSubject(systemPrincipal)));
+        assertFalse(impersonation.allows(buildSubject(systemPrincipal)));
     }
 }
\ No newline at end of file

Modified: jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserImporterTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserImporterTest.java?rev=1176340&r1=1176339&r2=1176340&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserImporterTest.java
(original)
+++ jackrabbit/branches/JCR-2272/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserImporterTest.java
Tue Sep 27 11:53:10 2011
@@ -19,7 +19,13 @@ package org.apache.jackrabbit.core.secur
 import org.apache.jackrabbit.api.JackrabbitSession;
 import org.apache.jackrabbit.api.security.principal.PrincipalIterator;
 import org.apache.jackrabbit.api.security.principal.PrincipalManager;
-import org.apache.jackrabbit.api.security.user.*;
+import org.apache.jackrabbit.api.security.user.Authorizable;
+import org.apache.jackrabbit.api.security.user.AuthorizableExistsException;
+import org.apache.jackrabbit.api.security.user.Group;
+import org.apache.jackrabbit.api.security.user.Impersonation;
+import org.apache.jackrabbit.api.security.user.Query;
+import org.apache.jackrabbit.api.security.user.User;
+import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.jackrabbit.commons.xml.ParsingContentHandler;
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.SessionImpl;
@@ -36,7 +42,29 @@ import org.apache.jackrabbit.test.NotExe
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 
-import javax.jcr.*;
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Credentials;
+import javax.jcr.ImportUUIDBehavior;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.InvalidSerializedDataException;
+import javax.jcr.Item;
+import javax.jcr.ItemExistsException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.LoginException;
+import javax.jcr.NamespaceException;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Property;
+import javax.jcr.PropertyType;
+import javax.jcr.ReferentialIntegrityException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.Workspace;
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
@@ -50,7 +78,12 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.security.AccessControlException;
 import java.security.Principal;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.UUID;
 
 /**
  * <code>UserImporterTest</code>...
@@ -1364,6 +1397,10 @@ public class UserImporterTest extends Ab
                     return null;
                 }
 
+                public Authorizable getAuthorizableByPath(String path) throws UnsupportedRepositoryOperationException,
RepositoryException {
+                    return null;
+                }
+
                 public Iterator<Authorizable> findAuthorizables(String relPath, String
value) throws RepositoryException {
                     return null;
                 }

Modified: jackrabbit/branches/JCR-2272/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/FilterContentPackage.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2272/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/FilterContentPackage.java?rev=1176340&r1=1176339&r2=1176340&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2272/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/FilterContentPackage.java
(original)
+++ jackrabbit/branches/JCR-2272/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/FilterContentPackage.java
Tue Sep 27 11:53:10 2011
@@ -32,7 +32,7 @@ import org.apache.jackrabbit.commons.pre
 
 public class FilterContentPackage implements ContentPackage {
 
-    protected final List content = new ArrayList();
+    protected final List<Content> content = new ArrayList<Content>();
 
     protected boolean includeProperties = false;
 
@@ -47,9 +47,9 @@ public class FilterContentPackage implem
     /**
      * @see org.apache.jackrabbit.commons.packaging.ContentPackage#getItems(javax.jcr.Session)
      */
-    public Iterator getItems(Session session)
+    public Iterator<Item> getItems(Session session)
     throws RepositoryException {
-        return new FilteringIterator(session, new ArrayList(this.content), this.includeProperties);
+        return new FilteringIterator(session, new ArrayList<Content>(this.content),
this.includeProperties);
     }
 
     protected static class Content {
@@ -65,7 +65,7 @@ public class FilterContentPackage implem
     public static class FilteringIterator implements Iterator {
 
         /** The content we will iterate over. */
-        protected final List content;
+        protected final List<Content> content;
 
         /**
          * Filter that defines which items are included
@@ -80,7 +80,7 @@ public class FilterContentPackage implem
 
         protected final Session session;
 
-        protected final List nodeIteratorStack = new ArrayList();
+        protected final List<NodeIterator> nodeIteratorStack = new ArrayList<NodeIterator>();
 
         protected final boolean includeProperties;
 
@@ -95,7 +95,7 @@ public class FilterContentPackage implem
          * @param includeProperties Should properties be included.
          */
         public FilteringIterator(final Session session,
-                                 final List contentList,
+                                 final List<Content> contentList,
                                  final boolean includeProperties) {
             this.content = contentList;
             this.session = session;

Modified: jackrabbit/branches/JCR-2272/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2272/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java?rev=1176340&r1=1176339&r2=1176340&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2272/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java
(original)
+++ jackrabbit/branches/JCR-2272/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/io/DefaultHandler.java
Tue Sep 27 11:53:10 2011
@@ -20,7 +20,10 @@ import org.apache.jackrabbit.JcrConstant
 import org.apache.jackrabbit.commons.NamespaceHelper;
 import org.apache.jackrabbit.util.ISO9075;
 import org.apache.jackrabbit.util.Text;
+import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.jcr.JcrDavException;
 import org.apache.jackrabbit.webdav.xml.Namespace;
 import org.apache.jackrabbit.webdav.property.DavPropertyName;
 import org.apache.jackrabbit.webdav.property.DavProperty;
@@ -32,6 +35,7 @@ import org.slf4j.LoggerFactory;
 import javax.jcr.Item;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
+import javax.jcr.PathNotFoundException;
 import javax.jcr.Property;
 import javax.jcr.RepositoryException;
 import javax.jcr.PropertyIterator;
@@ -67,7 +71,7 @@ import java.util.HashMap;
  * Subclasses therefore should provide their own {@link #importData(ImportContext, boolean,
Node)
  * importData} method, that handles the data according their needs.
  */
-public class DefaultHandler implements IOHandler, PropertyHandler {
+public class DefaultHandler implements IOHandler, PropertyHandler, CopyMoveHandler {
 
     private static Logger log = LoggerFactory.getLogger(DefaultHandler.class);
 
@@ -574,9 +578,9 @@ public class DefaultHandler implements I
                     continue;
                 }
                 if (JcrConstants.JCR_DATA.equals(name)
-                    || JcrConstants.JCR_MIMETYPE.equals(name)
-                    || JcrConstants.JCR_ENCODING.equals(name)
-                    || JcrConstants.JCR_LASTMODIFIED.equals(name)) {
+                        || JcrConstants.JCR_MIMETYPE.equals(name)
+                        || JcrConstants.JCR_ENCODING.equals(name)
+                        || JcrConstants.JCR_LASTMODIFIED.equals(name)) {
                     continue;
                 }
 
@@ -671,6 +675,54 @@ public class DefaultHandler implements I
         }
     }
 
+    //----------------------------------------------------< CopyMoveHandler >---
+    /**
+     * @see CopyMoveHandler#canCopy(CopyMoveContext, org.apache.jackrabbit.webdav.DavResource,
org.apache.jackrabbit.webdav.DavResource)
+     */
+    public boolean canCopy(CopyMoveContext context, DavResource source, DavResource destination)
{
+        return true;
+    }
+
+    /**
+     * @see CopyMoveHandler#copy(CopyMoveContext, org.apache.jackrabbit.webdav.DavResource,
org.apache.jackrabbit.webdav.DavResource)
+     */
+    public boolean copy(CopyMoveContext context, DavResource source, DavResource destination)
throws DavException {
+        if (context.isShallowCopy() && source.isCollection()) {
+            // TODO: currently no support for shallow copy; however this is
+            // only relevant if the source resource is a collection, because
+            // otherwise it doesn't make a difference
+            throw new DavException(DavServletResponse.SC_FORBIDDEN, "Unable to perform shallow
copy.");
+        }
+        try {
+            context.getSession().getWorkspace().copy(source.getLocator().getRepositoryPath(),
destination.getLocator().getRepositoryPath());
+            return true;
+        }  catch (PathNotFoundException e) {
+            // according to rfc 2518: missing parent
+            throw new DavException(DavServletResponse.SC_CONFLICT, e.getMessage());
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
+    }
+
+    /**
+     * @see CopyMoveHandler#canMove(CopyMoveContext, org.apache.jackrabbit.webdav.DavResource,
org.apache.jackrabbit.webdav.DavResource)
+     */
+    public boolean canMove(CopyMoveContext context, DavResource source, DavResource destination)
{
+        return true;
+    }
+
+    /**
+     * @see CopyMoveHandler#move(CopyMoveContext, org.apache.jackrabbit.webdav.DavResource,
org.apache.jackrabbit.webdav.DavResource) 
+     */
+    public boolean move(CopyMoveContext context, DavResource source, DavResource destination)
throws DavException {
+        try {
+            context.getWorkspace().move(source.getLocator().getRepositoryPath(), destination.getLocator().getRepositoryPath());
+            return true;
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
+    }
+
     //------------------------------------------------------------< private >---
     /**
      * Builds a webdav property name from the given jcrName. In case the jcrName
@@ -784,9 +836,9 @@ public class DefaultHandler implements I
     private static boolean isDefinedByFilteredNodeType(PropertyDefinition def) {
         String ntName = def.getDeclaringNodeType().getName();
         return ntName.equals(JcrConstants.NT_BASE)
-               || ntName.equals(JcrConstants.MIX_REFERENCEABLE)
-               || ntName.equals(JcrConstants.MIX_VERSIONABLE)
-               || ntName.equals(JcrConstants.MIX_LOCKABLE);
+                || ntName.equals(JcrConstants.MIX_REFERENCEABLE)
+                || ntName.equals(JcrConstants.MIX_VERSIONABLE)
+                || ntName.equals(JcrConstants.MIX_LOCKABLE);
     }
 
     //-------------------------------------------< setter for configuration >---

Modified: jackrabbit/branches/JCR-2272/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2272/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java?rev=1176340&r1=1176339&r2=1176340&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2272/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java
(original)
+++ jackrabbit/branches/JCR-2272/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java
Tue Sep 27 11:53:10 2011
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.webdav.sim
 
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.server.io.AbstractExportContext;
+import org.apache.jackrabbit.server.io.CopyMoveContextImpl;
 import org.apache.jackrabbit.server.io.DefaultIOListener;
 import org.apache.jackrabbit.server.io.ExportContext;
 import org.apache.jackrabbit.server.io.ExportContextImpl;
@@ -68,7 +69,6 @@ import org.slf4j.LoggerFactory;
 import javax.jcr.Item;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
-import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Workspace;
@@ -599,11 +599,8 @@ public class DavResourceImpl implements 
         }
         // make sure, that src and destination belong to the same workspace
         checkSameWorkspace(destination.getLocator());
-        try {
-            String destItemPath = destination.getLocator().getRepositoryPath();
-            getJcrSession().getWorkspace().move(locator.getRepositoryPath(), destItemPath);
-        } catch (RepositoryException e) {
-            throw new JcrDavException(e);
+        if (!config.getCopyMoveManager().move(new CopyMoveContextImpl(getJcrSession()), this,
destination)) {
+            throw new DavException(DavServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
         }
     }
 
@@ -620,22 +617,10 @@ public class DavResourceImpl implements 
         if (isFilteredResource(destination)) {
             throw new DavException(DavServletResponse.SC_FORBIDDEN);
         }
-        if (shallow && isCollection()) {
-            // TODO: currently no support for shallow copy; however this is
-            // only relevant if the source resource is a collection, because
-            // otherwise it doesn't make a difference
-            throw new DavException(DavServletResponse.SC_FORBIDDEN, "Unable to perform shallow
copy.");
-        }
         // make sure, that src and destination belong to the same workspace
         checkSameWorkspace(destination.getLocator());
-        try {
-            String destItemPath = destination.getLocator().getRepositoryPath();
-            getJcrSession().getWorkspace().copy(locator.getRepositoryPath(), destItemPath);
-        } catch (PathNotFoundException e) {
-            // according to rfc 2518: missing parent
-            throw new DavException(DavServletResponse.SC_CONFLICT, e.getMessage());
-        } catch (RepositoryException e) {
-            throw new JcrDavException(e);
+        if (!config.getCopyMoveManager().copy(new CopyMoveContextImpl(getJcrSession(), shallow),
this, destination)) {
+            throw new DavException(DavServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
         }
     }
 

Modified: jackrabbit/branches/JCR-2272/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2272/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java?rev=1176340&r1=1176339&r2=1176340&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2272/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java
(original)
+++ jackrabbit/branches/JCR-2272/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceConfig.java
Tue Sep 27 11:53:10 2011
@@ -31,6 +31,9 @@ import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.xml.parsers.ParserConfigurationException;
 
+import org.apache.jackrabbit.server.io.CopyMoveHandler;
+import org.apache.jackrabbit.server.io.CopyMoveManager;
+import org.apache.jackrabbit.server.io.CopyMoveManagerImpl;
 import org.apache.jackrabbit.server.io.DefaultIOManager;
 import org.apache.jackrabbit.server.io.IOHandler;
 import org.apache.jackrabbit.server.io.IOManager;
@@ -59,6 +62,9 @@ public class ResourceConfig {
     private static final String ELEMENT_PROPERTYMANAGER = "propertymanager";
     private static final String ELEMENT_PROPERTYHANDLER = "propertyhandler";
 
+    private static final String ELEMENT_COPYMOVEMANAGER = "copymovemanager";
+    private static final String ELEMENT_COPYMOVEHANDLER = "copymovehandler";
+
     private static final String ELEMENT_CLASS = "class";
 
     private static final String ELEMENT_PARAM = "param";
@@ -72,6 +78,7 @@ public class ResourceConfig {
 
     private ItemFilter itemFilter;
     private IOManager ioManager;
+    private CopyMoveManager cmManager;
     private PropertyManager propManager;
     private String[] nodetypeNames = new String[0];
     private boolean collectionNames = false;
@@ -225,6 +232,33 @@ public class ResourceConfig {
                 log.debug("'propertymanager' element is missing.");
             }
 
+            // copymovemanager config entry
+            el = DomUtil.getChildElement(config, ELEMENT_COPYMOVEMANAGER, null);
+            if (el != null) {
+                Object inst = buildClassFromConfig(el);
+                if (inst != null && inst instanceof CopyMoveManager) {
+                    cmManager = (CopyMoveManager) inst;
+                    // get optional 'copymovehandler' child elements and populate
+                    // the copy move manager with the instances
+                    ElementIterator iohElements = DomUtil.getChildren(el, ELEMENT_COPYMOVEHANDLER,
null);
+                    while (iohElements.hasNext()) {
+                        Element iohEl = iohElements.nextElement();
+                        inst = buildClassFromConfig(iohEl);
+                        if (inst != null && inst instanceof CopyMoveHandler) {
+                            CopyMoveHandler handler = (CopyMoveHandler) inst;
+                            setParameters(handler, iohEl);
+                            cmManager.addCopyMoveHandler(handler);
+                        } else {
+                            log.warn("Not a valid CopyMoveHandler : " + getClassName(iohEl));
+                        }
+                    }
+                } else {
+                    log.warn("'copymovemanager' element does not define a valid CopyMoveManager.");
+                }
+            } else {
+                log.debug("'copymovemanager' element is missing.");
+            }
+
             // collection/non-collection config entry
             el = DomUtil.getChildElement(config, "collection", null);
             if (el != null) {
@@ -427,6 +461,18 @@ public class ResourceConfig {
     }
 
     /**
+     *
+     * @return
+     */
+    public CopyMoveManager getCopyMoveManager() {
+        if (cmManager == null) {
+            log.debug("Missing copymove-manager > building default.");
+            cmManager = CopyMoveManagerImpl.getDefaultManager();
+        }
+        return cmManager;
+    }
+
+    /**
      * Returns true, if the given item represents a {@link Node node} that is
      * either any of the nodetypes specified to represent a collection or
      * none of the nodetypes specified to represent a non-collection, respectively.

Modified: jackrabbit/branches/JCR-2272/test/performance/base/src/main/java/org/apache/jackrabbit/performance/SmallFileWriteTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2272/test/performance/base/src/main/java/org/apache/jackrabbit/performance/SmallFileWriteTest.java?rev=1176340&r1=1176339&r2=1176340&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2272/test/performance/base/src/main/java/org/apache/jackrabbit/performance/SmallFileWriteTest.java
(original)
+++ jackrabbit/branches/JCR-2272/test/performance/base/src/main/java/org/apache/jackrabbit/performance/SmallFileWriteTest.java
Tue Sep 27 11:53:10 2011
@@ -50,6 +50,7 @@ public class SmallFileWriteTest extends 
             content.setProperty(
                     "jcr:data", new TestInputStream(FILE_SIZE * 1024));
         }
+        session.save();
     }
 
     public void afterTest() throws RepositoryException {



Mime
View raw message