1
14
15 package com.liferay.portal.workflow;
16
17 import com.liferay.portal.kernel.workflow.RequiredWorkflowDefinitionException;
18 import com.liferay.portal.service.WorkflowDefinitionLinkLocalServiceUtil;
19
20 import org.aspectj.lang.ProceedingJoinPoint;
21
22
27 public class WorkflowLinkAdvice {
28
29 public Object invoke(ProceedingJoinPoint proceedingJoinPoint)
30 throws Throwable {
31
32 String methodName = proceedingJoinPoint.getSignature().getName();
33 Object[] arguments = proceedingJoinPoint.getArgs();
34
35 if (methodName.equals(_UPDATE_ACTIVE)) {
36 long companyId = (Long)arguments[0];
37 String name = (String)arguments[2];
38 int version = (Integer)arguments[3];
39 boolean active = (Boolean)arguments[4];
40
41 if (!active) {
42 int workflowDefinitionLinksCount =
43 WorkflowDefinitionLinkLocalServiceUtil.
44 getWorkflowDefinitionLinksCount(
45 companyId, name, version);
46
47 if (workflowDefinitionLinksCount >= 1) {
48 throw new RequiredWorkflowDefinitionException();
49 }
50 }
51 }
52
53 return proceedingJoinPoint.proceed();
54 }
55
56 private static final String _UPDATE_ACTIVE = "updateActive";
57
58 }