02-27-2015 12:42 AM
02-27-2015 04:23 AM
public WorkflowDeployment deployDefinition(String engineId, InputStream workflowDefinition, String mimetype);
public void undeployDefinition(String workflowDefinitionId);
03-03-2015 01:00 AM
03-03-2015 10:46 AM
public void undeployUnUsedDefinitions(boolean deleteFlag){
WorkflowService wfService = getServiceRegistry().getWorkflowService();
List<WorkflowDefinition> workFlowDefinitions = wfService.getAllDefinitions();
for(WorkflowDefinition wfd : workFlowDefinitions){
String wfId = wfd.getId();
List<String> excludeList = new ArrayList<String>();
excludeList.add("activiti$activitiAdhoc:1:4");
excludeList.add("activiti$activitiInvitationModerated:1:23");
excludeList.add("activiti$activitiInvitationNominated:1:26");
excludeList.add("activiti$activitiParallelGroupReview:1:20");
excludeList.add("activiti$activitiParallelReview:1:16");
excludeList.add("activiti$activitiReview:1:8");
excludeList.add("activiti$activitiReviewPooled:1:12");
logger.debug("WorkFlowDefinition IDs :"+wfId);
if(deleteFlag){
if(excludeList.contains(wfId)){
logger.info("WorkFlowDefinitionID belongs to the sample and should not be deleted wfID: "+wfId);
}
else{
wfService.undeployDefinition(wfId);
logger.info("WorkFlowDefinitionID deleted successfully wfID: "+wfId);
}
}
}
}
03-04-2015 12:17 AM
03-03-2015 03:47 AM
03-03-2015 04:48 AM
03-03-2015 07:44 AM
03-09-2015 08:10 AM
package org.hc.utils;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.apache.log4j.Logger;
public class HCWorkFlowUtility {
protected static Logger logger = Logger.getLogger(HCWorkFlowUtility.class);
private static ServiceRegistry serviceRegistry;
public static void undeployUnUsedDefinitions(boolean deleteFlag) {
WorkflowService wfService = getServiceRegistry().getWorkflowService();
List<WorkflowDefinition> workFlowDefinitions = wfService
.getAllDefinitions();
for (WorkflowDefinition wfd : workFlowDefinitions) {
String wfId = wfd.getId();
List<String> excludeList = new ArrayList<String>();
excludeList.add("activiti$activitiAdhoc:1:4");
excludeList.add("activiti$activitiInvitationModerated:1:23");
excludeList.add("activiti$activitiInvitationNominated:1:26");
excludeList.add("activiti$activitiParallelGroupReview:1:20");
excludeList.add("activiti$activitiParallelReview:1:16");
excludeList.add("activiti$activitiReview:1:8");
excludeList.add("activiti$activitiReviewPooled:1:12");
logger.debug("WorkFlowDefinition IDs :" + wfId);
if (excludeList.contains(wfId)) {
logger.info("WorkFlowDefinitionID belongs to the sample and will not be deleted wfID: "
+ wfId);
} else {
if (deleteFlag) {
wfService.undeployDefinition(wfId);
logger.warn("WorkFlowDefinitionID deleted successfully wfID: "
+ wfId);
} else {
logger.warn("WorkFlowDefinitionID can be deleted, wfID: "
+ wfId);
}
}
}
}
public static ServiceRegistry getServiceRegistry() {
return serviceRegistry;
}
public static void setServiceRegistry(ServiceRegistry serviceRegistry) {
HCWorkFlowUtility.serviceRegistry = serviceRegistry;
}
}
package org.hc.javabackedwebscripts.content;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.apache.log4j.Logger;
import org.hc.utils.HCWorkFlowUtility;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
public class UnDeployWorkflows extends DeclarativeWebScript {
protected Logger logger = Logger.getLogger(UnDeployWorkflows.class);
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req,
Status status, Cache cache) {
String deleteStr = req.getParameter("delete");
boolean deleteFlag = Boolean.valueOf(deleteStr);
try {
HCWorkFlowUtility.undeployUnUsedDefinitions(deleteFlag);
} catch (Exception e) {
logger.error("Error occured while deleting the old workflows. Please see the log for more details!");
throw new AlfrescoRuntimeException(e.getMessage());
}
Map<String, Object> model = new HashMap<>();
String resultMessage = null;
if (deleteFlag) {
resultMessage = "All the old workflows have been successfully deleted, please see the log for the list of worklflows deleted.";
} else {
resultMessage = "All the old workflows have been successfully printed in the log, please see the log for the list.";
}
model.put("resultMessage", resultMessage);
return model;
}
}
<bean id="${project.artifactId}_hcWorkFlowUtility" class="org.hc.utils.HCWorkFlowUtility">
<property name="serviceRegistry" ref="ServiceRegistry"/>
</bean>
<bean id="webscript.workflow.undeploy-workflow.get" class="org.hc.javabackedwebscripts.content.UnDeployWorkflows" parent="webscript"/>
/** undeploy-workflow.get.desc.xml **/
<webscript>
<shortname>Undeploys the deployed workflows</shortname>
<description>This undeploys the deployed workflows based the flag set in it.</description>
<url>/undeploy-workflow?delete={deleteFlag}</url>
<format default="json">extension</format>
<authentication>admin</authentication>
</webscript>
/** undeploy-workflow.get.json.ftl **/
{
result:
[
{
undeployResult: "${resultMessage!'Result Message Not Found'}"
}
]
}
03-11-2015 01:34 AM
{
"status" :
{
"code" : 500,
"name" : "Internal Error",
"description" : "An error inside the HTTP server which prevented it from fulfilling the request."
},
"message" : "02110001 Wrapped Exception (with status template): 02110011 \r\n### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table \"act_re_procdef\" violates foreign key constraint \"act_fk_exe_procdef\" on table \"act_ru_execution\"\n Detail: Key (id_)=(activitiInvitationNominated:1:26) is still referenced from table \"act_ru_execution\".\r\n### The error may involve org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity.deleteProcessDefinitionsByDeploymentId-Inline\r\n### The error occurred while setting parameters\r\n### SQL: delete from ACT_RE_PROCDEF where DEPLOYMENT_ID_ = ?\r\n### Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table \"act_re_procdef\" violates foreign key constraint \"act_fk_exe_procdef\" on table \"act_ru_execution\"\n Detail: Key (id_)=(activitiInvitationNominated:1:26) is still referenced from table \"act_ru_execution\".",
"exception" : "org.springframework.extensions.webscripts.WebScriptException - 02110001 Wrapped Exception (with status template): 02110011 \r\n### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table \"act_re_procdef\" violates foreign key constraint \"act_fk_exe_procdef\" on table \"act_ru_execution\"\n Detail: Key (id_)=(activitiInvitationNominated:1:26) is still referenced from table \"act_ru_execution\".\r\n### The error may involve org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity.deleteProcessDefinitionsByDeploymentId-Inline\r\n### The error occurred while setting parameters\r\n### SQL: delete from ACT_RE_PROCDEF where DEPLOYMENT_ID_ = ?\r\n### Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table \"act_re_procdef\" violates foreign key constraint \"act_fk_exe_procdef\" on table \"act_ru_execution\"\n Detail: Key (id_)=(activitiInvitationNominated:1:26) is still referenced from table \"act_ru_execution\".",
"callstack" :
[
"" ,"org.alfresco.error.AlfrescoRuntimeException: 02110011 \r\n### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table \"act_re_procdef\" violates foreign key constraint \"act_fk_exe_procdef\" on table \"act_ru_execution\"\n Detail: Key (id_)=(activitiInvitationNominated:1:26) is still referenced from table \"act_ru_execution\".\r\n### The error may involve org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity.deleteProcessDefinitionsByDeploymentId-Inline\r\n### The error occurred while setting parameters\r\n### SQL: delete from ACT_RE_PROCDEF where DEPLOYMENT_ID_ = ?\r\n### Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table \"act_re_procdef\" violates foreign key constraint \"act_fk_exe_procdef\" on table \"act_ru_execution\"\n Detail: Key (id_)=(activitiInvitationNominated:1:26) is still referenced from table \"act_ru_execution\"."
,"org.hc.javabackedwebscripts.content.UnDeployWorkflows.executeImpl(UnDeployWorkflows.java:29)"
,"org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:64)"
,"org.alfresco.repo.web.scripts.RepositoryContainer$3.execute(RepositoryContainer.java:470)"
,"org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:454)"
,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:532)"
,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:600)"
,"org.alfresco.repo.web.scripts.RepositoryContainer.executeScriptInternal(RepositoryContainer.java:380)"
,"org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:261)"
,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:378)"
,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)"
,"org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132)"
,"javax.servlet.http.HttpServlet.service(HttpServlet.java:727)"
,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)"
,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)"
,"org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)"
,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)"
,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)"
,"org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)"
,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)"
,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)"
,"org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)"
,"org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)"
,"org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)"
,"org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)"
,"org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)"
,"org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)"
,"org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)"
,"org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)"
,"org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)"
,"org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)"
,"org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2441)"
,"org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2430)"
,"java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)"
,"java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)"
,"java.lang.Thread.run(Unknown Source)"
,"org.springframework.extensions.webscripts.WebScriptException: 02110001 Wrapped Exception (with status template): 02110011 \r\n### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table \"act_re_procdef\" violates foreign key constraint \"act_fk_exe_procdef\" on table \"act_ru_execution\"\n Detail: Key (id_)=(activitiInvitationNominated:1:26) is still referenced from table \"act_ru_execution\".\r\n### The error may involve org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity.deleteProcessDefinitionsByDeploymentId-Inline\r\n### The error occurred while setting parameters\r\n### SQL: delete from ACT_RE_PROCDEF where DEPLOYMENT_ID_ = ?\r\n### Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table \"act_re_procdef\" violates foreign key constraint \"act_fk_exe_procdef\" on table \"act_ru_execution\"\n Detail: Key (id_)=(activitiInvitationNominated:1:26) is still referenced from table \"act_ru_execution\"."
,"org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:1126)"
],
"server" : "Community v5.0.0 (c r91299-b145) schema 8,009",
"time" : "Mar 11, 2015 10:55:54 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.