AnsweredAssumed Answered

Exception on Create Node Policy while uploading new version action

Question asked by hiten.rastogi on Feb 4, 2016
Latest reply on Feb 5, 2016 by hiten.rastogi
Hello,

I am facing exception on Create Node Policy in my project. In my behavior class I am trying to fetch the <strong>node-dbid</strong> of the doc. I am facing this issue when I try to upload the new version of the document. For e.g. I upload a normal document and change it's type to {my_type}, after editing the document properties,I have another behavior implemented OnUpdatePropertiesPolicy, I am able to generate the all the required fields including node-dbid but, when I try to upload the new version of the document from the Document Actions I get an exception.

Below is my code and exception.

<strong>custom-model</strong>

<!– DBId of the node –>
            <property name="evl:docId">
               <title>Doc Id</title>
               <type>d:text</type>
               <multiple>false</multiple>
               <index enabled="true">
                  <tokenised>false</tokenised>
               </index>
            </property>


<strong>Behavior - LegalPropertyGenerator.java</strong>

public class LegalPropertyGenerator implements
      NodeServicePolicies.OnCreateNodePolicy,
      NodeServicePolicies.OnUpdatePropertiesPolicy {

   // Dependencies
   private NodeService nodeService;
   private PolicyComponent policyComponent;

   // Behaviours
   private Behaviour onCreateNode;
   private Behaviour onUpdateProperties;

   private Logger logger = Logger.getLogger(LegalPropertyGenerator.class);

   public void init() {

      if (logger.isDebugEnabled())
         logger.debug("******************* Initializing legal property generator behavior *******************");

      // Create behaviours
      this.onCreateNode = new JavaBehaviour(this, "onCreateNode",
            NotificationFrequency.TRANSACTION_COMMIT);

      this.onUpdateProperties = new JavaBehaviour(this, "onUpdateProperties",
            NotificationFrequency.TRANSACTION_COMMIT);

      // Bind behaviours to node policies
      this.policyComponent.bindClassBehaviour(QName.createQName(
            NamespaceService.ALFRESCO_URI, "onCreateNode"), LegalDocumentModel.TYPE_LEGAL_DOCUMENT,
            this.onCreateNode);

      this.policyComponent.bindClassBehaviour(QName.createQName(
            NamespaceService.ALFRESCO_URI, "onUpdateProperties"), LegalDocumentModel.TYPE_LEGAL_DOCUMENT,
            this.onUpdateProperties);

   }

   @Override
   public void onCreateNode(ChildAssociationRef childAssocRef) {
      if (logger.isDebugEnabled())
         logger.debug("Inside onCreateNode");
      generateDBIdField(childAssocRef.getChildRef());

   }

   @Override
   public void onUpdateProperties(NodeRef nodeRef,
         Map<QName, Serializable> before, Map<QName, Serializable> after) {
      if (logger.isDebugEnabled())
         logger.debug("Inside onUpdateProperties");
      generateDBIdField(nodeRef);
   }
   
   private void generateDBIdField(NodeRef noderef){
      String docId = "EV"+nodeService.getProperty(noderef, ContentModel.PROP_NODE_DBID);
        nodeService.setProperty(noderef, LegalDocumentModel.PROP_DOC_ID, docId);
   }

   public void setNodeService(NodeService nodeService) {
      this.nodeService = nodeService;
   }

   public void setPolicyComponent(PolicyComponent policyComponent) {
      this.policyComponent = policyComponent;
   }

}


<strong>Exception</strong>

2016-02-04 17:04:32,494  WARN  [content.metadata.AbstractMappingMetadataExtracter] [http-bio-8040-exec-4] Metadata extraction failed (turn on DEBUG for full error):
   Extracter: org.alfresco.repo.content.metadata.TikaAutoMetadataExtracter@718601fb
   Content:   ContentAccessor[ contentUrl=store://2016/2/4/17/4/d2a3e2f9-5f6d-4db8-bb3e-ff8f524964d6.bin, mimetype=text/xml, size=1789, encoding=ISO-8859-1, locale=en_US]
   Failure:   XML parse errornull
2016-02-04 17:04:32,800  ERROR [extensions.webscripts.AbstractRuntime] [http-bio-8040-exec-4] Exception from executeScript - redirecting to status template error: 01040028 Failed to execute transaction-level behaviour public abstract void org.alfresco.repo.node.NodeServicePolicies$OnCreateNodePolicy.onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) in transaction f99b17ef-7c31-4ce0-bdae-7dca2b5914c0
org.alfresco.error.AlfrescoRuntimeException: 01040028 Failed to execute transaction-level behaviour public abstract void org.alfresco.repo.node.NodeServicePolicies$OnCreateNodePolicy.onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) in transaction f99b17ef-7c31-4ce0-bdae-7dca2b5914c0
   at org.alfresco.repo.policy.TransactionBehaviourQueue.execute(TransactionBehaviourQueue.java:257)
   at org.alfresco.repo.policy.TransactionBehaviourQueue.beforeCommit(TransactionBehaviourQueue.java:134)
   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:479)
   at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:551)
   at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:619)
   at org.alfresco.repo.web.scripts.RepositoryContainer.executeScriptInternal(RepositoryContainer.java:399)
   at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:280)
   at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:378)
   at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
   at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
   at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
   at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
   at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   at java.lang.Thread.run(Thread.java:745)
Caused by: org.alfresco.service.cmr.repository.InvalidNodeRefException: Node does not exist: workspace://SpacesStore/a56cbdd2-5617-4457-a37b-5bb5ff25e11a (status:Status[id=926changeTxnId=f99b17ef-7c31-4ce0-bdae-7dca2b5914c0, dbTxnId=70, deleted=true])
   at org.alfresco.repo.node.db.DbNodeServiceImpl.getNodePairNotNull(DbNodeServiceImpl.java:182)
   at org.alfresco.repo.node.db.DbNodeServiceImpl.hasAspect(DbNodeServiceImpl.java:997)
   at sun.reflect.GeneratedMethodAccessor238.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:497)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at org.alfresco.repo.lock.mem.LockableAspectInterceptor.invoke(LockableAspectInterceptor.java:111)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   at com.sun.proxy.$Proxy34.hasAspect(Unknown Source)
   at sun.reflect.GeneratedMethodAccessor238.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:497)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at org.alfresco.repo.tenant.MultiTNodeServiceInterceptor.invoke(MultiTNodeServiceInterceptor.java:104)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   at com.sun.proxy.$Proxy34.hasAspect(Unknown Source)
   at sun.reflect.GeneratedMethodAccessor238.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:497)
   at org.alfresco.repo.service.StoreRedirectorProxyFactory$RedirectorInvocationHandler.invoke(StoreRedirectorProxyFactory.java:224)
   at com.sun.proxy.$Proxy54.hasAspect(Unknown Source)
   at org.alfresco.repo.node.MLPropertyInterceptor.getPivotNodeRef(MLPropertyInterceptor.java:323)
   at org.alfresco.repo.node.MLPropertyInterceptor.invoke(MLPropertyInterceptor.java:162)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.node.NodeRefPropertyMethodInterceptor.invoke(NodeRefPropertyMethodInterceptor.java:198)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   at com.sun.proxy.$Proxy34.getProperty(Unknown Source)
   at sun.reflect.GeneratedMethodAccessor239.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:497)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
   at com.sun.proxy.$Proxy34.getProperty(Unknown Source)
   at sun.reflect.GeneratedMethodAccessor239.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:497)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at org.alfresco.repo.audit.DisableAuditableBehaviourInterceptor.invoke(DisableAuditableBehaviourInterceptor.java:113)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:80)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:46)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:159)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.transaction.RetryingTransactionInterceptor$1.execute(RetryingTransactionInterceptor.java:79)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:457)
   at org.alfresco.repo.transaction.RetryingTransactionInterceptor.invoke(RetryingTransactionInterceptor.java:69)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   at com.sun.proxy.$Proxy34.getProperty(Unknown Source)
   at com.legal.helpers.LegalPropertyGenerator.generateLegalTypeFields(LegalPropertyGenerator.java:102)
   at com.legal.helpers.LegalPropertyGenerator.onCreateNode(LegalPropertyGenerator.java:69)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:497)
   at org.alfresco.repo.policy.JavaBehaviour$JavaMethodInvocationHandler.invoke(JavaBehaviour.java:174)
   at com.sun.proxy.$Proxy62.onCreateNode(Unknown Source)
   at sun.reflect.GeneratedMethodAccessor664.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:497)
   at org.alfresco.repo.policy.TransactionBehaviourQueue.execute(TransactionBehaviourQueue.java:245)
   … 41 more



Thanks

Outcomes