jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From AnupChatterjee <anup.chatter...@marketlive.com>
Subject Problems with Cloning of folders within workspaces
Date Sun, 27 Apr 2008 07:17:53 GMT

Hi,

I have this setup -

A folder within a workspace which has files that I want to clone into
another workspace within the same repository.

nt:Folder -> nt:file -> nt:resource (mix:referenceable)
...
                Node fileNode = folderNode.addNode(fileName, "nt:file");
                Node resourceNode =
fileNode.addNode(JcrConstants.JCR_CONTENT, "nt:resource");
                // resourceNode.addMixin("mix:versionable"); // For
Versioning this node
                resourceNode.setProperty(JcrConstants.JCR_MIMETYPE,
"text/plain");
                resourceNode.setProperty(JcrConstants.JCR_LASTMODIFIED,
GregorianCalendar.getInstance());
                // resNode.setProperty("jcr:encoding",
                // request.getCharacterEncoding());
                resourceNode.setProperty(JcrConstants.JCR_DATA, nodeText);
...
I want to make the folder structure and the file node correspond between src
and target, hence need the clone operation.

When I request for clone of the folder which has the fileNode on the target
it gives me an itemExistsException while I'm sure it doesn't.
...
                        //Get the last parent of this file which exists in
target until Root.
                        Node parentNode = fileNode.getParent();
                        while(!parentNode.getPath().equals("/") &&
!targetRoot.hasNode(removeLeadingSlash(parentNode.getPath()))){
                            //Current Parent doesn't exists in Target move
up one generation.
                            fileNode = parentNode;
                            parentNode = parentNode.getParent();
                        }
                       
targetSession.getWorkspace().clone(srcSession.getWorkspace().getName(),
fileNode.getPath(), fileNode.getPath(), false);
...

I think the problem is with stateMgr.hasItemState(id) in
BatchedItemOperations.java which returns true on the UUID which isn't in
that particular workspace but another one in the same repository which might
be sharing the same cache.

                case CLONE:
                    if (!referenceable) {
                        // non-referenceable node: always create new uuid
                        id = new NodeId(UUID.randomUUID());
                        break;
                    }
                    // use same uuid as source node
                    id = srcState.getNodeId();
                    if (stateMgr.hasItemState(id)) { 
                        // node with this uuid already exists
                        throw new ItemExistsException(safeGetJCRPath(id));
                    }
                    break;



I would appreciate if you can let me know if this is a bug or if something
is wrong with my settings.

Thanks,
Anup Chatterjee
-- 
View this message in context: http://www.nabble.com/Problems-with-Cloning-of-folders-within-workspaces-tp16921068p16921068.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Mime
View raw message