I had a table in my DB: like for the nodes Person I have nodes Ps in ThePs in system. I am trying to copy one node Ps in these ThePs but get the following error:
My eventual problem was that I was passing the wrong association type:
I changed this:
params.put(CopyActionExecuter.PARAM_DESTINATION_FOLDER, location); params.put(CopyActionExecuter.PARAM_DEEP_COPY, new Boolean(false)); params.put(CopyActionExecuter.PARAM_OVERWRITE_COPY, new Boolean(false)); params.put(CopyActionExecuter.PARAM_ASSOC_TYPE_QNAME, ContentModel.ASSOC_CHILDREN); params.put(CopyActionExecuter.PARAM_ASSOC_QNAME, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy")); Action action = this.actionService.createAction(CopyActionExecuter.NAME, params); this.actionService.executeAction(action, document);
To This:
params.put(CopyActionExecuter.PARAM_DESTINATION_FOLDER, location); params.put(CopyActionExecuter.PARAM_DEEP_COPY, new Boolean(false)); params.put(CopyActionExecuter.PARAM_OVERWRITE_COPY, new Boolean(false)); params.put(CopyActionExecuter.PARAM_ASSOC_TYPE_QNAME, ContentModel.ASSOC_CONTAINS); params.put(CopyActionExecuter.PARAM_ASSOC_QNAME, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy")); Action action = this.actionService.createAction(CopyActionExecuter.NAME, params); this.actionService.executeAction(action, document);
The difference being that I used an association "contains" instead of "children"… it seems that a folder can contain things, but a container has children. Hard to imagine how I missed that with the wealth of documentation on executing actions via java code.
I apologize for the tone. I'm having a familiar Alfresco frustrated moment.
Am I being unfair, though? Is there any documentation on how to use the copy action or any action via the Java APIs like this? I've spent a good deal of guessing, sifting through source code, and trial and error to get anything to work here.