<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Neeed the Java api code for copy a smart folder aspect and association in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/neeed-the-java-api-code-for-copy-a-smart-folder-aspect-and/m-p/138694#M37132</link>
    <description>&lt;P&gt;Ty for the response.&lt;/P&gt;&lt;P&gt;I finally get it hte error i'm try to copy a virtual store node to a workspace node.&lt;/P&gt;&lt;PRE&gt;Impossible to copy the noderef 'workspace://SpacesStore/vH1-6-1-1-11e6ipgfd7tkjidskpij3aaq707-31-1-113s6e6pve8gctt7tquiv79cw20' to 'workspace://SpacesStore/d9621ce6-59eb-4202-9bc9-3a3e1a506e95'&lt;/PRE&gt;&lt;P&gt;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&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jan 2021 17:58:43 GMT</pubDate>
    <dc:creator>AlfrescoZZZ</dc:creator>
    <dc:date>2021-01-28T17:58:43Z</dc:date>
    <item>
      <title>Neeed the Java api code for copy a smart folder aspect and association</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/neeed-the-java-api-code-for-copy-a-smart-folder-aspect-and/m-p/138692#M37130</link>
      <description>&lt;P&gt;I need to copy a smart folder aspect and association from a source folder node to a target node.&lt;/P&gt;&lt;P&gt;Here the java code i'm using:&lt;/P&gt;&lt;PRE&gt;List&amp;lt;ChildAssociationRef&amp;gt; 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) {&lt;BR /&gt;                // HERE THE ERROR
		logger.warn("Impossible to copy the noderef '"+child+"' to '"+targetFolder+"'");
	}
}&lt;/PRE&gt;&lt;P&gt;Here the error:&lt;/P&gt;&lt;PRE&gt;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&lt;/PRE&gt;&lt;P&gt;how can i accoomplish this with thre java api?????&lt;/P&gt;&lt;P&gt;Here another piece of code i made, but it's seem not working:&lt;/P&gt;&lt;PRE&gt;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&amp;lt;ChildAssociationRef&amp;gt; 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&amp;lt;ChildAssociationRef&amp;gt; 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&amp;lt;QName, Serializable&amp;gt;());
		nodeService.setAssociations(parentFolder, QName.createQName(SmartFolderModelParameters.ASPECT_CUSTOM_CONFIG_SMART_FOLDER_ASSOC.toString()), Arrays.asList(jsonTemplate));
	}
	return result;
}&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Jan 2021 15:59:10 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/neeed-the-java-api-code-for-copy-a-smart-folder-aspect-and/m-p/138692#M37130</guid>
      <dc:creator>AlfrescoZZZ</dc:creator>
      <dc:date>2021-01-28T15:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: Neeed the Java api code for copy a smart folder aspect and association</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/neeed-the-java-api-code-for-copy-a-smart-folder-aspect-and/m-p/138693#M37131</link>
      <description>&lt;PRE&gt;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&lt;/PRE&gt;&lt;P&gt;You have an error on CopyDetails' data:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; if (copiedNodeRef == null)
        {
            CopyDetails copyDetails = getCopyDetails(sourceNodeRef, targetParentRef, null, assocTypeQName, assocQName);
            // Denied!
            throw new CopyServiceException(
                    "A bound policy denied copy: \n" +
                    "   " + copyDetails);
        }&lt;/PRE&gt;&lt;P&gt;Source here:&amp;nbsp;&lt;A href="https://github.com/Alfresco/alfresco-repository/blob/master/src/main/java/org/alfresco/repo/copy/CopyServiceImpl.java" target="_blank" rel="nofollow noopener noreferrer"&gt;https://github.com/Alfresco/alfresco-repository/blob/master/src/main/java/org/alfresco/repo/copy/CopyServiceImpl.java&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I will sugest you to check those nodes references:&lt;/P&gt;&lt;PRE&gt;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&lt;/PRE&gt;&lt;P&gt;Use the &lt;A href="https://docs.alfresco.com/6.2/tasks/adminconsole-nodebrowser.html" target="_self" rel="nofollow noopener noreferrer"&gt;node Browser&lt;/A&gt; for this is a good idea&amp;nbsp;&lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://connect.hyland.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 16:17:27 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/neeed-the-java-api-code-for-copy-a-smart-folder-aspect-and/m-p/138693#M37131</guid>
      <dc:creator>cristinamr</dc:creator>
      <dc:date>2021-01-28T16:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: Neeed the Java api code for copy a smart folder aspect and association</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/neeed-the-java-api-code-for-copy-a-smart-folder-aspect-and/m-p/138694#M37132</link>
      <description>&lt;P&gt;Ty for the response.&lt;/P&gt;&lt;P&gt;I finally get it hte error i'm try to copy a virtual store node to a workspace node.&lt;/P&gt;&lt;PRE&gt;Impossible to copy the noderef 'workspace://SpacesStore/vH1-6-1-1-11e6ipgfd7tkjidskpij3aaq707-31-1-113s6e6pve8gctt7tquiv79cw20' to 'workspace://SpacesStore/d9621ce6-59eb-4202-9bc9-3a3e1a506e95'&lt;/PRE&gt;&lt;P&gt;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&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 17:58:43 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/neeed-the-java-api-code-for-copy-a-smart-folder-aspect-and/m-p/138694#M37132</guid>
      <dc:creator>AlfrescoZZZ</dc:creator>
      <dc:date>2021-01-28T17:58:43Z</dc:date>
    </item>
  </channel>
</rss>

