AnsweredAssumed Answered

Crear contenido con JAVA-API falla

Question asked by magarcia_sm on Mar 17, 2016
Latest reply on Mar 18, 2016 by magarcia_sm
Buenos días

Estoy intentando mover un contenido de un fichero TIFF a un fichero PDF siguiendo las funcionalidades que la API de JAVA de alfresco 4.2 Community ofrece.

El código funciona correctamente, hasta el momento en que al tener el nodo creado del fichero PDF, pasamos  el contenido de un File que hemos generado con iText (al pasar el TIFF a PDF).


El código que tenemos es este:


NodeRef fileNodeRef = this.nodeService.createNode(
                    containerNodeRef,
                    ContentModel.ASSOC_CONTAINS,
                    QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, fileName),
                    ContentModel.TYPE_CONTENT,
                    props).getChildRef();

// get a writer for the content and put the file
ContentWriter writer = this.services.getContentService().getWriter(fileNodeRef, ContentModel.PROP_CONTENT, true);

// set the mimetype and encoding
writer.setMimetype(MimetypeMap.MIMETYPE_PDF);
writer.setEncoding(Charset.defaultCharset().name());

if (fileContent != null) {

    writer.putContent(fileContent);
    logger.info("Añadimos contenido al nuevo fichero pdf");

}


donde la variable fileContent, es un File que se ha creado con iText y que contiene un PDF con el TIFF encapsulado.

Todo funciona correctamente excepto en la llamada
writer.putContent(fileContent);


si comentamos esta línea, el código crea el fichero PDF correctamente en Alfresco, pero vacío (0KB).

El usuario que ejecuta esta acción tiene permisos de Coordinador en el espacio al que se refiere la variable containerNodeRef… y podemos mover ahí ficheros PDF con contenido desde otros espacios.

Este es el toda la traza de error que estamos teniendo


2016-03-17 11:19:56,920  ERROR [repo.action.AsynchronousActionExecutionQueueImpl] [defaultAsyncAction2] Failed to execute asynchronous action: Action[ id=59f9246d-68b6-46b5-a5f8-beb9ffd0c401, node=null ]: 02170009 A value for the mandatory parameter script-ref has not been set on the rule item script
org.alfresco.service.cmr.rule.RuleServiceException: 02170009 A value for the mandatory parameter script-ref has not been set on the rule item script
   at org.alfresco.repo.action.ParameterizedItemAbstractBase.checkMandatoryProperties(ParameterizedItemAbstractBase.java:173)
   at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:240)
   at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:838)
   at org.alfresco.repo.action.executer.CompositeActionExecuter.executeImpl(CompositeActionExecuter.java:66)
   at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:258)
   at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:838)
   at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:738)
   at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:572)
   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:498)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:34)
   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:161)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at com.sun.proxy.$Proxy54.executeAction(Unknown Source)
   at org.alfresco.repo.rule.RuleServiceImpl.executeAction(RuleServiceImpl.java:1250)
   at org.alfresco.repo.rule.RuleServiceImpl.executeRule(RuleServiceImpl.java:1244)
   at org.alfresco.repo.rule.RuleServiceImpl$3.doWork(RuleServiceImpl.java:1183)
   at org.alfresco.repo.rule.RuleServiceImpl$3.doWork(RuleServiceImpl.java:1180)
   at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:548)
   at org.alfresco.repo.rule.RuleServiceImpl.executePendingRule(RuleServiceImpl.java:1179)
   at org.alfresco.repo.rule.RuleServiceImpl.executePendingRulesImpl(RuleServiceImpl.java:1119)
   at org.alfresco.repo.rule.RuleServiceImpl.executePendingRules(RuleServiceImpl.java:1092)
   at org.alfresco.repo.rule.RuleTransactionListener.beforeCommit(RuleTransactionListener.java:57)
   at org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionSynchronizationImpl.doBeforeCommit(AlfrescoTransactionSupport.java:737)
   at org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionSynchronizationImpl.doBeforeCommit(AlfrescoTransactionSupport.java:717)
   at org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionSynchronizationImpl.beforeCommit(AlfrescoTransactionSupport.java:683)
   at org.springframework.transaction.support.TransactionSynchronizationUtils.triggerBeforeCommit(TransactionSynchronizationUtils.java:95)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCommit(AbstractPlatformTransactionManager.java:927)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:737)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
   at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393)
   at org.alfresco.util.transaction.SpringAwareUserTransaction.commit(SpringAwareUserTransaction.java:472)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:474)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:323)
   at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper$1.doWork(AsynchronousActionExecutionQueueImpl.java:437)
   at org.alfresco.repo.tenant.TenantUtil.runAsWork(TenantUtil.java:119)
   at org.alfresco.repo.tenant.TenantUtil.runAsTenant(TenantUtil.java:88)
   at org.alfresco.repo.tenant.TenantUtil$1.doWork(TenantUtil.java:62)
   at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:548)
   at org.alfresco.repo.tenant.TenantUtil.runAsUserTenant(TenantUtil.java:58)
   at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper.run(AsynchronousActionExecutionQueueImpl.java:440)
   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)


¿alguna idea de qué necesitamos hacer?

Muchas gracias

Outcomes