02-18-2016 12:37 PM
<bean id="processFra-action" class="org.alfresco.web.actions.ProcessFraActionExecuter" parent="action-executer" >
<property name="nodeService">
<ref bean="NodeService" />
</property>
<property name="services">
<ref bean="ServiceRegistry" />
</property>
<property name="facturaService">
<ref bean="facturaService" />
</property>
<property name="authenticationComponent">
<ref bean="AuthenticationComponent" />
</property>
<property name="accountService">
<ref bean="accountService" />
</property>
<property name="lockService">
<ref bean="LockService" />
</property>
</bean>
ww.alfresco.org/ws/service/content/1.0}ContentFault:<ns1:errorCode>0</ns1:errorCode><ns1:message>01090010 A value for the mandatory parameter script-ref has not been set on the rule item script</ns1:message>
{http://xml.apache.org/axis/}exceptionName:org.alfresco.repo.webservice.content.ContentFault
{http://xml.apache.org/axis/}stackTrace:
at org.alfresco.repo.webservice.content.ContentWebService.write(ContentWebService.java:228)
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.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
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.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:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
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)
{http://xml.apache.org/axis/}hostname:SM-PC
public void execute(Action action, NodeRef actionedUponNodeRef)
not to perform validation however,it does not work, we are still getting this same situation.
A value for the mandatory parameter script-ref has not been set on the rule item script
02-19-2016 05:23 AM
02-24-2016 08:36 AM
02-24-2016 09:18 AM
02-24-2016 12:02 PM
var process = actions.create("processFra-action");
process.execute(document);
<bean id="processFra-action" class="org.alfresco.web.actions.ProcessFraActionExecuter" parent="action-executer" >
<property name="nodeService">
<ref bean="NodeService" />
</property>
<property name="services">
<ref bean="ServiceRegistry" />
</property>
<property name="facturaService">
<ref bean="facturaService" />
</property>
<property name="authenticationComponent">
<ref bean="AuthenticationComponent" />
</property>
<property name="accountService">
<ref bean="accountService" />
</property>
<property name="lockService">
<ref bean="LockService" />
</property>
</bean>
public class ProcessFraActionExecuter extends ActionExecuterAbstractBase {
private static Log logger = LogFactory.getLog(ProcessFraActionExecuter.class);
/**
* Action constants
*/
public static final String NAME = "ProcessFra";
/**
* Indicates whether the action should be ignored if the actioned upon node is locked
*/
private boolean ignoreLock = true;
/**
* Injected services
*/
private NodeService mlAwareNodeService;
private LockService lockService;
private NodeService nodeService;
private ServiceRegistry services;
private AuthenticationComponent authenticationComponent;
private FacturaService facturaService;
private AccountService accountService;
private NodeRef espacioSubirFras;
public void setNodeService(NodeService nodeService) {
this.nodeService = nodeService;
}
public NodeService getNodeService() {
return nodeService;
}
public void setServices(ServiceRegistry services) {
this.services = services;
}
public ServiceRegistry getServices() {
return this.services;
}
public void setAuthenticationComponent(AuthenticationComponent authenticationComponent) {
this.authenticationComponent = authenticationComponent;
}
public AuthenticationComponent getAuthenticationComponent() {
return authenticationComponent;
}
public void setFacturaService(FacturaService facturaService) {
this.facturaService = facturaService;
}
public FacturaService getFacturaService() {
return facturaService;
}
public void setAccountService(AccountService accountService) {
this.accountService = accountService;
}
public AccountService getAccountService() {
return accountService;
}
@Override
protected void executeImpl(
Action ruleAction,
NodeRef actionedUponNodeRef) {
logger.info("Ejecutandose action automaticamente");
logger.info("actionedUponNodeRef " + actionedUponNodeRef);
long time = System.currentTimeMillis();
if (this.nodeService.exists(actionedUponNodeRef) == false) {
logger.info("Nodo no existe");
// node doesn't exist - can't do anything
return;
}
// First check that the node is a sub-type of content
QName typeQName = this.nodeService.getType(actionedUponNodeRef);
if (this.services.getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_CONTENT) == false) {
// it is not content, so can't transform
return;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// String usuActual = this.services.getAuthenticationService().getCurrentUserName();
// logger.info("usuActual " + usuActual);
try {
File fileTemp = File.createTempFile("scan_", ".tiff");
ContentReader cr = this.services.getContentService().getReader(actionedUponNodeRef,
ContentModel.PROP_CONTENT);
cr.getContent(fileTemp);
//Se obtiene el numero de paginas para contabilizarlas
FileSeekableStream ss = new FileSeekableStream(fileTemp);
ImageDecoder dec = ImageCodec.createImageDecoder("tiff", ss, null);
int count = dec.getNumPages();
NodeRef pdfNodeRef = null;
Boolean ocr = (Boolean) this.nodeService.getProperty(actionedUponNodeRef, FacturaModel.Alf_OCRapply);
String userCIF = (String) this.nodeService.getProperty(actionedUponNodeRef, FacturaModel.Alf_CIFempresa);
String userName = (String) this.nodeService.getProperty(actionedUponNodeRef, FacturaModel.Alf_UserName);
logger.info("OCR " + ocr);
espacioSubirFras = this.nodeService.getPrimaryParent(actionedUponNodeRef).getParentRef();
ChildAssociationRef parentChildAsoc = this.getNodeService().getPrimaryParent(espacioSubirFras);
NodeRef empresaNodeRef = parentChildAsoc.getParentRef();
NodeRef certificado = this.getCertificado();
File filecert = File.createTempFile("prefCertif", "sufCertif");
this.services.getFileFolderService().getReader(certificado).getReader().getContent(filecert);
String clave = new String();
if ((certificado != null) && (this.getNodeService().hasAspect(certificado, FacturaModel.ASPECT_CERTIFICADO))
&& (this.getNodeService().getProperty(certificado, FacturaModel.PROP_CLAVE) != null)) {
clave = (String) this.getNodeService().getProperty(certificado, FacturaModel.PROP_CLAVE);
}
if (!this.getNodeService().hasAspect(actionedUponNodeRef, FacturaModel.ASPECT_DETALLE_IVA_ANT)) {
Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>();
this.getNodeService().addAspect(actionedUponNodeRef, FacturaModel.ASPECT_DETALLE_IVA_ANT, aspectProperties);
}
if (!this.getNodeService().hasAspect(actionedUponNodeRef, FacturaModel.ASPECT_DETALLE_IVA_POS)) {
Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>();
this.getNodeService().addAspect(actionedUponNodeRef, FacturaModel.ASPECT_DETALLE_IVA_POS, aspectProperties);
}
long time2 = System.currentTimeMillis();
if (!ocr) {
logger.info("Inicio tranform sin OCR " + time2);
pdfNodeRef = this.doTransform(fileTemp, espacioSubirFras, ocr, userCIF, userName);
time2 = System.currentTimeMillis() - time2;
logger.info("Fin tranform sin OCR " + time2);
if (pdfNodeRef != null) {
logger.info("Registro no ocr");
this.getAccountService().registerCountNoOCR(userCIF, count);
time2 = System.currentTimeMillis() - time2;
logger.info("Fin Registro ocr " + time2);
logger.info("Type fra");
this.getFacturaService().addTypeFra(pdfNodeRef);
time2 = System.currentTimeMillis() - time2;
logger.info("Type fra " + time2);
logger.info("Registro metadatos y firma");
this.getFacturaService().addFirmaMetadatosDoc(pdfNodeRef, filecert, clave);
time2 = System.currentTimeMillis() - time2;
logger.info("Registro metadatos y firma " + time2);
logger.info("Mover a revisar");
this.getFacturaService().moverRevisar(pdfNodeRef, empresaNodeRef);
time2 = System.currentTimeMillis() - time2;
logger.info("Mover a revisar " + time2);
} else {
Utils.addErrorMessage(Application.getMessage(
FacesContext.getCurrentInstance(), "error_transform_NO_OCR"));
}
} else {
logger.info("Inicio tranform con OCR " + time2);
pdfNodeRef = this.doTransformOCR(actionedUponNodeRef);
time2 = System.currentTimeMillis() - time2;
logger.info("Fin tranform con OCR " + time2);
if (pdfNodeRef != null) {
logger.info("Registro ocr");
this.getAccountService().registerCountOCR(userCIF, count);
time2 = System.currentTimeMillis() - time2;
logger.info("Fin Registro ocr " + time2);
logger.info("type fra y lectura datos");
String cifDescarte = (String) this.getNodeService().getProperty(certificado, FacturaModel.PROP_CIF_DESCARTE);
Boolean applyRE = (Boolean) this.getNodeService().getProperty(certificado, FacturaModel.PROP_APPLY_RE);
this.getFacturaService().leerDoc(pdfNodeRef, cifDescarte, applyRE);
time2 = System.currentTimeMillis() - time2;
logger.info("lectura datos " + time2);
logger.info("Registro metadatos y firma");
this.getFacturaService().addFirmaMetadatosDoc(pdfNodeRef, filecert, clave);
time2 = System.currentTimeMillis() - time2;
logger.info("Registro metadatos y firma " + time2);
logger.info("Mover a revisar");
this.getFacturaService().moverRevisar(pdfNodeRef, empresaNodeRef);
time2 = System.currentTimeMillis() - time2;
logger.info("Mover a revisar " + time2);
} else {
Utils.addErrorMessage(Application.getMessage(
FacesContext.getCurrentInstance(), "error_transform_OCR"));
}
}
//Obtiene el usuario actual y lo cambia internamente por el usuario sistema, que tiene todos los permisos
// authenticationComponent.setSystemUserAsCurrentUser();
if (this.services.getNodeService().exists(actionedUponNodeRef)) {
long time3 = System.currentTimeMillis();
logger.info("Eliminamos nodo tiff " + time3);
this.services.getNodeService().deleteNode(actionedUponNodeRef);
time3 = System.currentTimeMillis() - time3;
logger.info("Eliminado nodo tiff " + time3);
}
//Vuelve a cambiar el usuario sistema al usuario que cerro el mes
// authenticationComponent.clearCurrentSecurityContext();
// authenticationComponent.setCurrentUser(usuActual);
// logger.info("El usuario vuelve a ser "+usuActual);
if (fileTemp.exists()) {
fileTemp.delete();
}
if (filecert.exists()) {
filecert.delete();
}
time = System.currentTimeMillis() - time;
Node node = new Node(pdfNodeRef);
logger.info("Tiempo en procesar factura " + node.getName() + ": " + time);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//////////////////////////////////////////////////////////////////////////////////////////////////
logger.info("Fin action");
}
02-27-2016 04:31 AM
03-17-2016 08:17 AM
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList) {
// paramList.add(new ParameterDefinitionImpl("script-ref", DataTypeDefinition.TEXT, true, getParamDisplayLabel("script-ref")));
}
public NodeRef saveInAlfresco(File fileContent, NodeRef containerNodeRef, String userName) throws Exception {
String fileName = fileContent.getName();
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.serviceRegistry.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");
}
return fileNodeRef;
}
writer.putContent(fileContent);
03-21-2016 08:55 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.