04-01-2009 09:46 AM
14:34:24,572 ERROR [org.alfresco.web.ui.common.Utils] Unable to check in Content Node due to system error:org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
org.alfresco.service.cmr.repository.AssociationExistsException: org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl.newNodeAssoc(HibernateNodeDaoServiceImpl.java:2765)
at sun.reflect.GeneratedMethodAccessor721.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.alfresco.repo.transaction.TransactionalDaoInterceptor.invoke(TransactionalDaoInterceptor.java:68)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.alfresco.repo.domain.hibernate.DirtySessionMethodInterceptor.invoke(DirtySessionMethodInterceptor.java:381)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy2.newNodeAssoc(Unknown Source)
at org.alfresco.repo.node.db.DbNodeServiceImpl.createAssociation(DbNodeServiceImpl.java:1460)
at sun.reflect.GeneratedMethodAccessor582.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.alfresco.repo.transaction.SingleEntryTransactionResourceInterceptor.invokeInternal(SingleEntryTransactionResourceInterceptor.java:163)
at org.alfresco.repo.transaction.SingleEntryTransactionResourceInterceptor.invoke(SingleEntryTransactionResourceInterceptor.java:138)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy7.createAssociation(Unknown Source)
at sun.reflect.GeneratedMethodAccessor582.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.alfresco.repo.tenant.MultiTNodeServiceInterceptor.invoke(MultiTNodeServiceInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy7.createAssociation(Unknown Source)
at sun.reflect.GeneratedMethodAccessor582.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.alfresco.repo.service.StoreRedirectorProxyFactory$RedirectorInvocationHandler.invoke(StoreRedirectorProxyFactory.java:221)
at $Proxy8.createAssociation(Unknown Source)
at sun.reflect.GeneratedMethodAccessor582.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.alfresco.repo.node.MLPropertyInterceptor.invoke(MLPropertyInterceptor.java:285)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.alfresco.repo.node.MLPropertyInterceptor.invoke(MLPropertyInterceptor.java:285)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.alfresco.repo.node.NodeRefPropertyMethodInterceptor.invoke(NodeRefPropertyMethodInterceptor.java:274)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.alfresco.repo.node.NodeRefPropertyMethodInterceptor.invoke(NodeRefPropertyMethodInterceptor.java:274)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy7.createAssociation(Unknown Source)
at sun.reflect.GeneratedMethodAccessor582.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:80)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:275)
at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy7.createAssociation(Unknown Source)
at org.alfresco.repo.copy.CopyServiceImpl.defaultOnCopyComplete(CopyServiceImpl.java:424)
at org.alfresco.repo.copy.CopyServiceImpl.invokeCopyComplete(CopyServiceImpl.java:342)
at org.alfresco.repo.copy.CopyServiceImpl.invokeCopyComplete(CopyServiceImpl.java:321)
at org.alfresco.repo.copy.CopyServiceImpl.copy(CopyServiceImpl.java:933)
at sun.reflect.GeneratedMethodAccessor735.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:40)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:275)
at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy38.copy(Unknown Source)
at org.alfresco.repo.coci.CheckOutCheckInServiceImpl.checkin(CheckOutCheckInServiceImpl.java:375)
at sun.reflect.GeneratedMethodAccessor734.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:80)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:275)
at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy51.checkin(Unknown Source)
at org.alfresco.web.bean.coci.CheckinCheckoutDialog$1.execute(CheckinCheckoutDialog.java:511)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:320)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:227)
at org.alfresco.web.bean.coci.CheckinCheckoutDialog.checkinFileOK(CheckinCheckoutDialog.java:516)
at org.alfresco.web.bean.coci.DoneEditingDialog.handle(DoneEditingDialog.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
at javax.faces.component.UICommand.broadcast(UICommand.java:89)
at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:622)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:377)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:338)
at org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl.newNodeAssoc(HibernateNodeDaoServiceImpl.java:2759)
… 143 more
Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:309)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:182)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at sun.reflect.GeneratedMethodAccessor537.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.orm.hibernate3.HibernateTemplate$CloseSuppressingInvocationHandler.invoke(HibernateTemplate.java:1202)
at $Proxy68.flush(Unknown Source)
at org.alfresco.repo.domain.hibernate.DirtySessionMethodInterceptor.flushSession(DirtySessionMethodInterceptor.java:304)
at org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl$29.doInHibernate(HibernateNodeDaoServiceImpl.java:2750)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
… 145 more
Caused by: java.sql.BatchUpdateException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL090331121152281' defined on 'ALF_NODE_ASSOC'.
at org.apache.derby.impl.jdbc.EmbedStatement.executeBatch(Unknown Source)
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:294)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
… 158 more
Caused by: java.sql.SQLIntegrityConstraintViolationException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL090331121152281' defined on 'ALF_NODE_ASSOC'.
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeBatchElement(Unknown Source)
… 162 more
Caused by: java.sql.SQLException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL090331121152281' defined on 'ALF_NODE_ASSOC'.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
… 170 more
Caused by: ERROR 23505: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL090331121152281' defined on 'ALF_NODE_ASSOC'.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.sql.execute.IndexChanger.insertAndCheckDups(Unknown Source)
at org.apache.derby.impl.sql.execute.IndexChanger.doInsert(Unknown Source)
at org.apache.derby.impl.sql.execute.IndexChanger.insert(Unknown Source)
at org.apache.derby.impl.sql.execute.IndexSetChanger.insert(Unknown Source)
at org.apache.derby.impl.sql.execute.RowChangerImpl.insertRow(Unknown Source)
at org.apache.derby.impl.sql.execute.InsertResultSet.normalInsertCore(Unknown Source)
at org.apache.derby.impl.sql.execute.InsertResultSet.open(Unknown Source)
at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
… 164 more
public class ContentChanger implements
NodeServicePolicies.OnUpdatePropertiesPolicy {
// Constants
private final String NAMESPACE = "{http://www.....pt/model/content/1.0}";
// Dependencies
private NodeService nodeService;
private PolicyComponent policyComponent;
private ServiceRegistry serviceRegistry;
private OpenOfficeConnection connection;
// Behaviors
private Behaviour onUpdateProperties;
File tempFromFile;
private Logger logger = Logger.getLogger(ContentChanger.class);
public synchronized void init() {
PropertyCheck.mandatory("ContentChanger", "connection", connection);
if (logger.isDebugEnabled())
logger.debug("Initializing Enumerator behaviors");
// Create behaviors
this.onUpdateProperties = new JavaBehaviour(this, "onUpdateProperties",
NotificationFrequency.TRANSACTION_COMMIT);
// Bind behaviors to node policies
this.policyComponent.bindClassBehaviour(QName.createQName(
NamespaceService.ALFRESCO_URI, "onUpdateProperties"), QName
.createQName(this.NAMESPACE + "doc"), this.onUpdateProperties);
}
public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after) {
String codAntes = (String) before.get(QName.createQName(this.NAMESPACE
+ "codigo"));
String lockStatus = (String) before.get(ContentModel.PROP_LOCK_TYPE);
logger.error("Working copy: " + before
.containsKey(ContentModel.PROP_WORKING_COPY_MODE));
logger.error("Locked copy: " + before
.containsKey(ContentModel.PROP_LOCK_TYPE));
if (lockStatus == null
&& (!before.containsKey(ContentModel.PROP_LOCK_TYPE) && !before.containsKey(ContentModel.PROP_WORKING_COPY_MODE))) {
String type = (nodeService.getType(nodeRef)).getLocalName();
logger.error("Dentro do Changer");
if (codAntes != null
&& (type.compareTo("if") == 0 || type.compareTo("of") == 0)) {
System.out.println("Executou ContentChanger");
try {
ContentData cd = (ContentData) nodeService.getProperty(
nodeRef, ContentModel.PROP_CONTENT);
String mtype = cd.getMimetype();
System.out.println("Mime/Type: " + mtype);
ContentReader reader;
if (mtype
.compareTo("application/vnd.oasis.opendocument.text") != 0) {
logger.debug("New Document Found");
reader = this.getTemplateReader(nodeRef);
logger.debug("Template Read");
ContentData newCD = ContentData.setMimetype(cd,
"application/vnd.oasis.opendocument.text");
nodeService.setProperty(nodeRef,
ContentModel.PROP_CONTENT, newCD);
logger.debug("Document Type Changed");
} else {
logger.debug("Document already exists");
reader = this.getDocumentReader(nodeRef);
}
XComponent template = this.openTemplate(nodeRef, reader);
this.templateFill(template, nodeRef);
this.documentWrite(template, nodeRef);
// template.dispose();
this.setAssociations(nodeRef);
} catch (Exception e) {
logger.error(e.getMessage());
logger.error(e.getStackTrace().toString());
}
}
System.out.println("Saiu ContentChanger");
}
}
private void setAssociations(NodeRef nodeRef) {
String query = "@" + "me\\:proc:\"" +
((Integer) nodeService.getProperty(nodeRef,
QName.createQName(this.NAMESPACE + "proc"))).toString() + "\"";
SearchService searchService = serviceRegistry.getSearchService();
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE,
"SpacesStore");
ResultSet resultSet = searchService.query(storeRef,
SearchService.LANGUAGE_LUCENE, query);
System.out.println("Num de docs no mesmo proc: " + resultSet.length());
NodeRef nodeForAssoc;
for(int x=0; x < resultSet.length(); x++ ){
nodeForAssoc = resultSet.getNodeRef(x);
System.out.println("Nome ficheiro: " + nodeService.getProperty(nodeForAssoc,
ContentModel.PROP_NAME).toString());
if(!this.hasAssociation(nodeRef, nodeForAssoc))
{
nodeService.createAssociation(nodeRef, nodeForAssoc, QName.createQName(this.NAMESPACE + "relatedDocs"));
//pesado mas necessário para evitar conflitos em de mudança de processo
if(!this.hasAssociation(nodeForAssoc, nodeRef))
nodeService.createAssociation(nodeForAssoc, nodeRef, QName.createQName(this.NAMESPACE + "relatedDocs"));
}
else
{
System.out.println("Association Already exists!!!");
}
}
}
private boolean hasAssociation(NodeRef nodeRef, NodeRef assoc)
{
List<AssociationRef> tmp = nodeService.getTargetAssocs(nodeRef, QName.createQName(this.NAMESPACE + "relatedDocs"));
NodeRef otherNode;
for(Iterator<AssociationRef> it = tmp.iterator(); it.hasNext();){
otherNode = it.next().getTargetRef();
if(assoc.equals(otherNode)){
return true;
}
}
return false;
}
private ContentReader getTemplateReader(NodeRef nodeRef) {
String query = "+PATH:\"app:company_home/app:dictionary/app:email_templates/cm:"
+ (nodeService.getType(nodeRef)).getLocalName() + ".ott\"";
System.out.println("Search");
SearchService searchService = serviceRegistry.getSearchService();
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE,
"SpacesStore");
ResultSet resultSet = searchService.query(storeRef,
SearchService.LANGUAGE_LUCENE, query);
System.out.println("Before Array");
NodeRef docTemplate = resultSet.getNodeRef(0);
System.out.println("After Array");
ContentService cs = serviceRegistry.getContentService();
ContentReader cr = cs.getReader(docTemplate, ContentModel.PROP_CONTENT);
return cr;
}
private ContentReader getDocumentReader(NodeRef nodeRef) {
NodeRef docTemplate = nodeRef;
ContentService cs = serviceRegistry.getContentService();
ContentReader cr = cs.getReader(docTemplate, ContentModel.PROP_CONTENT);
return cr;
}
private XComponent openTemplate(NodeRef nodeRef, ContentReader reader)
throws java.lang.Exception {
tempFromFile = TempFileProvider.createTempFile(
"OpenOfficeMetadataExtracter-", ".ott");
reader.getContent(tempFromFile);
String sourceUrl = toUrl(tempFromFile, connection);
XComponentLoader desktop = connection.getDesktop();
PropertyValue[] loadProps = new PropertyValue[2];
loadProps[0] = new PropertyValue();
loadProps[0].Name = "AsTemplate";
loadProps[0].Value = new Boolean(true);
loadProps[1] = new PropertyValue();
loadProps[1].Name = "Hidden";
loadProps[1].Value = new Boolean(true);
// load
return desktop.loadComponentFromURL(sourceUrl, "_blank", 0, loadProps);
}
private void templateFill(XComponent template, NodeRef nodeRef)
throws java.lang.Exception {
String type = (nodeService.getType(nodeRef)).getLocalName();
// create a small hashtable that simulates a rowset with columns
Hashtable<String, Object> recipient = new Hashtable<String, Object>();
if (type.compareTo("if") == 0) {
recipient.put("nInf", (String) nodeService.getProperty(nodeRef,
QName.createQName(this.NAMESPACE + "codigo")));
recipient.put("nProc", ((Integer) nodeService.getProperty(nodeRef,
QName.createQName(this.NAMESPACE + "proc"))).toString());
} else if (type.compareTo("of") == 0) {
recipient.put("refInt", (String) nodeService.getProperty(nodeRef,
QName.createQName(this.NAMESPACE + "codigo")));
recipient.put("nProc", ((Integer) nodeService.getProperty(nodeRef,
QName.createQName(this.NAMESPACE + "proc"))).toString());
recipient.put("refExt", (String) nodeService.getProperty(nodeRef,
QName.createQName(this.NAMESPACE + "refExt")));
recipient.put("destinatario", (String) nodeService
.getProperty(nodeRef, QName.createQName(this.NAMESPACE
+ "destinatario")));
recipient.put("assunto", (String) nodeService.getProperty(nodeRef,
QName.createQName(this.NAMESPACE + "assunto")));
}
/*
* else if(type.compareTo("jt") == 0){ recipient.put("nInf",
* (String)nodeService.getProperty(nodeRef,
* QName.createQName(this.NAMESPACE+ "codigo"))); recipient.put("nProc",
* ((Integer)nodeService.getProperty(nodeRef,
* QName.createQName(this.NAMESPACE+ "proc"))).toString()); }
*/
System.out.println("Added Template needed Information");
// load template with User fields
XComponent xTemplateComponent = template;
XTextFieldsSupplier xTextFieldsSupplier = (XTextFieldsSupplier) UnoRuntime
.queryInterface(XTextFieldsSupplier.class, xTemplateComponent);
// access the TextFields and the TextFieldMasters collections
XNameAccess xNamedFieldMasters = xTextFieldsSupplier
.getTextFieldMasters();
XEnumerationAccess xEnumeratedFields = xTextFieldsSupplier
.getTextFields();
// iterate over hashtable and insert values into field masters
java.util.Enumeration<String> keys = recipient.keys();
while (keys.hasMoreElements()) {
// get column name
String key = (String) keys.nextElement();
System.out.println("Adding " + key);
// access corresponding field master
Object fieldMaster = xNamedFieldMasters
.getByName("com.sun.star.text.FieldMaster.User." + key);
// query the XPropertySet interface, we need to set the Content
// property
XPropertySet xPropertySet = (XPropertySet) UnoRuntime
.queryInterface(XPropertySet.class, fieldMaster);
System.out.println("Before Add");
// insert the column value into field master
xPropertySet.setPropertyValue("Content", recipient.get(key));
// System.out.println("After Add " + recipient.get(key).toString());
}
// afterwards we must refresh the textfields collection
XRefreshable xRefreshable = (XRefreshable) UnoRuntime.queryInterface(
XRefreshable.class, xEnumeratedFields);
xRefreshable.refresh();
}
private void documentWrite(XComponent document, NodeRef nodeRef)
throws IOException, com.sun.star.io.IOException, CloseVetoException {
XStorable xStorable = (XStorable) UnoRuntime.queryInterface(
XStorable.class, document);
PropertyValue[] storeProps = new PropertyValue[0];
tempFromFile = TempFileProvider.createTempFile("result", ".odt");
xStorable.storeAsURL(this.toUrl(tempFromFile, connection), storeProps);
XCloseable xcloseable = (XCloseable) UnoRuntime.queryInterface(
XCloseable.class, document);
xcloseable.close(false);
ContentService cs = serviceRegistry.getContentService();
ContentWriter cw = cs.getWriter(nodeRef, ContentModel.PROP_CONTENT,
true);
cw.putContent(tempFromFile);
//TODO: Add file extension to the name property
nodeService.setProperty(nodeRef,
ContentModel.PROP_NAME, nodeService.getProperty(nodeRef,ContentModel.PROP_NAME) + ".odt");
}
private String toUrl(File file, OpenOfficeConnection connection)
throws ConnectException {
Object fcp = connection.getFileContentProvider();
XFileIdentifierConverter fic = (XFileIdentifierConverter) UnoRuntime
.queryInterface(XFileIdentifierConverter.class, fcp);
return fic.getFileURLFromSystemPath("", file.getAbsolutePath());
}
04-01-2009 09:59 AM
04-06-2009 09:35 AM
04-06-2009 12:09 PM
<aspects>
<aspect name="me:processo">
<title>Processo</title>
<properties>
<property name="me:proc">
<type>d:int</type>
</property>
</properties>
<associations>
<association name="me:relatedDocs">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>me:doc</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
</aspect>
</aspects>
04-23-2009 07:10 AM
12:00:41,359 ERROR [org.alfresco.web.ui.common.Utils] A system error happened during the operation: Failed to execute transaction-level behaviour public abstract void org.alfresco.repo.node.NodeServicePolicies$OnUpdatePropertiesPolicy.onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef,java.util.Map,java.util.Map) in transaction df488f74-73a3-4aaa-8ca6-1a702bdac2ca
org.alfresco.error.AlfrescoRuntimeException: Failed to execute transaction-level behaviour public abstract void org.alfresco.repo.node.NodeServicePolicies$OnUpdatePropertiesPolicy.onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef,java.util.Map,java.util.Map) in transaction df488f74-73a3-4aaa-8ca6-1a702bdac2ca
at org.alfresco.repo.policy.TransactionBehaviourQueue.execute(TransactionBehaviourQueue.java:201)
…
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.