I need to copy a smart folder aspect and association from a source folder node to a target node.
Here the java code i'm using:
List<ChildAssociationRef> children = nodeService.getChildAssocs(sourceFolder); for (ChildAssociationRef childRef : children) { // we only want contains associations if (childRef.getQName().equals(ContentModel.ASSOC_CONTAINS)) { continue; } NodeRef child = childRef.getChildRef(); try { fileFolderService.copy(child, targetFolder, null); logger.warn("Successfully copied a child node from the template"); } catch (FileExistsException e) { logger.warn("XXX"); } catch(FileNotFoundException e) { //can't find the space template, just bail logger.warn("XXX"); } catch(Exception e) {
// HERE THE ERROR logger.warn("Impossible to copy the noderef '"+child+"' to '"+targetFolder+"'"); } }
Here the error:
Impossible to copy the noderef 'workspace://SpacesStore/vH1-6-1-1-11e6ipgfd7tkjidskpij3aaq707-31-1-113s6e6pve8gctt7tquiv79cw20' to 'workspace://SpacesStore/11b9209b-9192-432c-8663-003e32ee4add' 2021-01-28 10:19:25,564 ERROR [extensions.webscripts.AbstractRuntime] [http-apr-8080-exec-6] Exception from executeScript: 00280085 Failed to execute transaction-level behaviour public abstract void org.alfresco.repo.node.NodeServicePolicies$OnCreateNodePolicy.onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) in transaction 7cbd487b-fd07-4aab-985e-e5b54c1001d0 org.alfresco.error.AlfrescoRuntimeException: 00280085 Failed to execute transaction-level behaviour public abstract void org.alfresco.repo.node.NodeServicePolicies$OnCreateNodePolicy.onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) in transaction 7cbd487b-fd07-4aab-985e-e5b54c1001d0 at org.alfresco.repo.policy.TransactionBehaviourQueue.execute(TransactionBehaviourQueue.java:262) at org.alfresco.repo.policy.TransactionBehaviourQueue.beforeCommit(TransactionBehaviourQueue.java:141) at org.alfresco.util.transaction.TransactionSupportUtil$TransactionSynchronizationImpl.doBeforeCommit(TransactionSupportUtil.java:535) at org.alfresco.util.transaction.TransactionSupportUtil$TransactionSynchronizationImpl.doBeforeCommit(TransactionSupportUtil.java:514) at org.alfresco.util.transaction.TransactionSupportUtil$TransactionSynchronizationImpl.beforeCommit(TransactionSupportUtil.java:479) at org.springframework.transaction.support.TransactionSynchronizationUtils.triggerBeforeCommit(TransactionSynchronizationUtils.java:95) at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCommit(AbstractPlatformTransactionManager.java:925) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:738) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:724) at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:475) at org.alfresco.util.transaction.SpringAwareUserTransaction.commit(SpringAwareUserTransaction.java:482) at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:486) at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:587) at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:656) at org.alfresco.repo.web.scripts.RepositoryContainer.executeScriptInternal(RepositoryContainer.java:428) at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:308) at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:399) at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:210) at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.alfresco.module.aosmodule.service.ContextRootFilter.doFilter(ContextRootFilter.java:93) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:239) at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:215) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:68) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2549) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2538) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) Caused by: org.alfresco.error.AlfrescoRuntimeException: 00280084 A bound policy denied copy: CopyDetails [source=workspace://SpacesStore/vH1-6-1-1-11e6ipgfd7tkjidskpij3aaq707-31-1-113s6e6pve8gctt7tquiv79cw20, targetParent=workspace://SpacesStore/11b9209b-9192-432c-8663-003e32ee4add, targetNode=workspace://SpacesStore/bda964c2-f79c-409d-b7e3-72969af49c18, targetNodeIsNew=true, assocTypeQName={http://www.alfresco.org/model/content/1.0}contains, assocQName={http://www.alfresco.org/model/content/smartfolder/1.0}Cruscotto], null
how can i accoomplish this with thre java api?????
Here another piece of code i made, but it's seem not working:
private NodeRef copySmartFolder(NodeRef parentFolder, NodeRef jsonTemplate, NodeService nodeService) { if(parentFolder==null || !nodeService.exists(parentFolder)) { logger.error("Can't copy the smart folder the parent folder is null or empty '"+parentFolder+"'"); throw new AlfrescoRuntimeException("Can't create the smart folder the parent folder is null or empty '"+parentFolder+"'"); } if(jsonTemplate==null || !nodeService.exists(jsonTemplate)) { logger.error("Can't copy the smart folder the json template is null or empty '"+jsonTemplate+"'"); throw new AlfrescoRuntimeException("Can't create the smart folder the json template is null or empty '"+jsonTemplate+"'"); } NodeRef result = null; if(nodeService.hasAspect(parentFolder, QName.createQName(SmartFolderModelParameters.ASPECT_SYSTEM_CONFIG_SMART_FOLDER.toString()))){ List<ChildAssociationRef> results = nodeService.getChildAssocs(parentFolder, RegexQNamePattern.MATCH_ALL, QName.createQName(SmartFolderModelParameters.ASPECT_SYSTEM_CONFIG_SMART_FOLDER_PROP_SYSTEM_TEMPLATE_LOCATION.toString())); if (results.size() == 0) { throw new AlfrescoRuntimeException("Required property not found: " + SmartFolderModelParameters.ASPECT_SYSTEM_CONFIG_SMART_FOLDER_PROP_SYSTEM_TEMPLATE_LOCATION.toString()); } else { result = results.get(0).getChildRef(); } if(result!=jsonTemplate) { nodeService.setAssociations(parentFolder, QName.createQName(SmartFolderModelParameters.ASPECT_SYSTEM_CONFIG_SMART_FOLDER_PROP_SYSTEM_TEMPLATE_LOCATION.toString()), Arrays.asList(jsonTemplate)); } } else if(nodeService.hasAspect(parentFolder, QName.createQName(SmartFolderModelParameters.ASPECT_CUSTOM_CONFIG_SMART_FOLDER.toString()))) { List<ChildAssociationRef> results = nodeService.getChildAssocs(parentFolder, RegexQNamePattern.MATCH_ALL, QName.createQName(SmartFolderModelParameters.ASPECT_CUSTOM_CONFIG_SMART_FOLDER_ASSOC.toString())); if (results.size() == 0) { throw new AlfrescoRuntimeException("Required property not found: " + SmartFolderModelParameters.ASPECT_CUSTOM_CONFIG_SMART_FOLDER_ASSOC.toString()); } else { result = results.get(0).getChildRef(); } if(result!=jsonTemplate) { nodeService.setAssociations(parentFolder, QName.createQName(SmartFolderModelParameters.ASPECT_CUSTOM_CONFIG_SMART_FOLDER_ASSOC.toString()), Arrays.asList(jsonTemplate)); } }else { nodeService.addAspect(parentFolder, QName.createQName(SmartFolderModelParameters.ASPECT_CUSTOM_CONFIG_SMART_FOLDER.toString()), new HashMap<QName, Serializable>()); nodeService.setAssociations(parentFolder, QName.createQName(SmartFolderModelParameters.ASPECT_CUSTOM_CONFIG_SMART_FOLDER_ASSOC.toString()), Arrays.asList(jsonTemplate)); } return result; }
Caused by: org.alfresco.error.AlfrescoRuntimeException: 00280084 A bound policy denied copy: CopyDetails [source=workspace://SpacesStore/vH1-6-1-1-11e6ipgfd7tkjidskpij3aaq707-31-1-113s6e6pve8gctt7tquiv79cw20, targetParent=workspace://SpacesStore/11b9209b-9192-432c-8663-003e32ee4add, targetNode=workspace://SpacesStore/bda964c2-f79c-409d-b7e3-72969af49c18, targetNodeIsNew=true, assocTypeQName={http://www.alfresco.org/model/content/1.0}contains, assocQName={http://www.alfresco.org/model/content/smartfolder/1.0}Cruscotto], null
You have an error on CopyDetails' data:
if (copiedNodeRef == null) { CopyDetails copyDetails = getCopyDetails(sourceNodeRef, targetParentRef, null, assocTypeQName, assocQName); // Denied! throw new CopyServiceException( "A bound policy denied copy: \n" + " " + copyDetails); }
Source here: https://github.com/Alfresco/alfresco-repository/blob/master/src/main/java/org/alfresco/repo/copy/Cop...
I will sugest you to check those nodes references:
source=workspace://SpacesStore/vH1-6-1-1-11e6ipgfd7tkjidskpij3aaq707-31-1-113s6e6pve8gctt7tquiv79cw20 targetParent=workspace://SpacesStore/11b9209b-9192-432c-8663-003e32ee4add targetNode=workspace://SpacesStore/bda964c2-f79c-409d-b7e3-72969af49c18 targetNodeIsNew=true assocTypeQName={http://www.alfresco.org/model/content/1.0}contains assocQName={http://www.alfresco.org/model/content/smartfolder/1.0}Cruscotto] null
Use the node Browser for this is a good idea
Ty for the response.
I finally get it hte error i'm try to copy a virtual store node to a workspace node.
Impossible to copy the noderef 'workspace://SpacesStore/vH1-6-1-1-11e6ipgfd7tkjidskpij3aaq707-31-1-113s6e6pve8gctt7tquiv79cw20' to 'workspace://SpacesStore/d9621ce6-59eb-4202-9bc9-3a3e1a506e95'
I don't know how can i solve that i'll probalby set the aspect and association with the nodeservice for avoid problems with the virtual store, bu any suggestion is more than welcome
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.