1
22
23 package com.liferay.portal.mirage.aop;
24
25 import com.sun.saw.Workflow;
26 import com.sun.saw.WorkflowException;
27 import com.sun.saw.WorkflowFactory;
28
29 import java.util.Properties;
30
31 import org.aspectj.lang.ProceedingJoinPoint;
32
33
41 public class JournalArticleLocalServiceAdvice extends BaseMirageAdvice {
42
43 protected Object doInvoke(ProceedingJoinPoint proceedingJoinPoint)
44 throws Throwable {
45
46 String methodName = proceedingJoinPoint.getSignature().getName();
47 Object[] arguments = proceedingJoinPoint.getArgs();
48
49 if (methodName.equals("addArticle") ||
50 methodName.equals("deleteArticle") ||
51 methodName.equals("getArticle") ||
52 methodName.equals("getLatestArticle") ||
53 methodName.equals("updateArticle")||
54 methodName.equals("updateContent")) {
55
56 ContentInvoker contentInvoker = new ContentInvoker(
57 proceedingJoinPoint);
58
59 if (methodName.equals("addArticle")) {
60 contentService.createContent(contentInvoker);
61 }
62 else if (methodName.equals("deleteArticle")) {
63 contentService.deleteContent(contentInvoker);
64 }
65 else if (methodName.equals("getArticle") ||
66 methodName.equals("getLatestArticle")) {
67
68 contentService.getContent(contentInvoker, null);
69 }
70 else if (methodName.equals("updateArticle")) {
71 contentService.updateContent(contentInvoker);
72 }
73 else if (methodName.equals("updateContent")) {
74 contentService.updateContent(contentInvoker, null);
75 }
76
77 return contentInvoker.getReturnValue();
78 }
79 else if (methodName.equals("approveArticle") ||
80 methodName.equals("expireArticle")) {
81
82 WorkflowInvoker workflowInvoker = new WorkflowInvoker(
83 proceedingJoinPoint);
84
85 if (methodName.equals("approveArticle")) {
86 workflowService.updateWorkflowComplete(workflowInvoker);
87 }
88 else if (methodName.equals("expireArticle")) {
89 workflowService.updateWorkflowContentRejected(workflowInvoker);
90 }
91
92 return workflowInvoker.getReturnValue();
93 }
94 else if (methodName.equals("getArticles") ||
95 methodName.equals("getArticlesBySmallImageId")||
96 methodName.equals("getArticlesCount") ||
97 methodName.equals("getDisplayArticle") ||
98 methodName.equals("getStructureArticles") ||
99 methodName.equals("getStructureArticlesCount") ||
100 methodName.equals("getTemplateArticles") ||
101 methodName.equals("getTemplateArticlesCount") ||
102 methodName.equals("searchCount") ||
103 (methodName.equals("search") && (arguments.length > 6))) {
104
105 SearchCriteriaInvoker searchCriteriaInvoker =
106 new SearchCriteriaInvoker(proceedingJoinPoint);
107
108 if (methodName.equals("getArticles") ||
109 methodName.equals("getArticlesBySmallImageId") ||
110 methodName.equals("getDisplayArticle")||
111 methodName.equals("getTemplateArticles")||
112 methodName.equals("search")) {
113
114 contentService.searchContents(searchCriteriaInvoker);
115 }
116 else if (methodName.equals("getStructureArticles")) {
117 contentService.searchContentsByType(
118 null, searchCriteriaInvoker);
119 }
120 else if (methodName.equals("getArticlesCount") ||
121 methodName.equals("searchCount")||
122 methodName.equals("getTemplateArticlesCount")) {
123
124 contentService.contentSearchCount(searchCriteriaInvoker);
125 }
126 else if (methodName.equals("getStructureArticlesCount")) {
127 contentService.contentSearchCount(null,searchCriteriaInvoker);
128 }
129
130 return searchCriteriaInvoker.getReturnValue();
131 }
132 else {
133 return proceedingJoinPoint.proceed();
134 }
135 }
136
137 protected Workflow getWorkflow() throws WorkflowException {
138 Properties properties = new Properties();
139
140 properties.setProperty(
141 "sawworkflowimplclass", "com.sun.saw.impls.osworkflow.OSWorkflow");
142
143 WorkflowFactory workflowFactory = WorkflowFactory.getInstance();
144
145 return workflowFactory.getWorkflowInstance(properties);
146 }
147
148 }