01: /**
02: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
03: *
04: * Permission is hereby granted, free of charge, to any person obtaining a copy
05: * of this software and associated documentation files (the "Software"), to deal
06: * in the Software without restriction, including without limitation the rights
07: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
08: * copies of the Software, and to permit persons to whom the Software is
09: * furnished to do so, subject to the following conditions:
10: *
11: * The above copyright notice and this permission notice shall be included in
12: * all copies or substantial portions of the Software.
13: *
14: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20: * SOFTWARE.
21: */package com.liferay.jbpm.handler;
22:
23: import com.liferay.client.portal.model.UserSoap;
24: import com.liferay.portal.kernel.log.Log;
25: import com.liferay.portal.kernel.log.LogFactoryUtil;
26: import com.liferay.portal.kernel.util.GetterUtil;
27: import com.liferay.portal.kernel.util.StringUtil;
28:
29: import org.jbpm.graph.def.ActionHandler;
30: import org.jbpm.graph.def.ProcessDefinition;
31: import org.jbpm.graph.exe.ExecutionContext;
32: import org.jbpm.taskmgmt.def.Swimlane;
33: import org.jbpm.taskmgmt.def.TaskMgmtDefinition;
34: import org.jbpm.taskmgmt.exe.SwimlaneInstance;
35: import org.jbpm.taskmgmt.exe.TaskMgmtInstance;
36:
37: /**
38: * <a href="NotifyRequestorActionHandler.java.html"><b><i>View Source</i></b>
39: * </a>
40: *
41: * @author Charles May
42: *
43: */
44: public class NotifyRequestorActionHandler extends DefaultHandler
45: implements ActionHandler {
46:
47: public void execute(ExecutionContext executionContext) {
48: ProcessDefinition definition = executionContext
49: .getProcessDefinition();
50:
51: TaskMgmtDefinition taskMgmtDefinition = definition
52: .getTaskMgmtDefinition();
53: TaskMgmtInstance taskMgmtInstance = executionContext
54: .getTaskMgmtInstance();
55:
56: Swimlane requestorSwimlane = taskMgmtDefinition
57: .getSwimlane("requestor");
58: SwimlaneInstance requestorSwimlaneInstance = taskMgmtInstance
59: .getInitializedSwimlaneInstance(executionContext,
60: requestorSwimlane);
61:
62: String userId = requestorSwimlaneInstance.getActorId();
63:
64: String displayMsg = null;
65:
66: try {
67: UserSoap user = getUserService().getUserById(
68: GetterUtil.getLong(userId));
69:
70: displayMsg = StringUtil.replace(msg, "${id}", user
71: .getEmailAddress());
72: } catch (Exception e) {
73: displayMsg = StringUtil.replace(msg, "${id}", userId);
74: }
75:
76: if (_log.isInfoEnabled()) {
77: _log.info(displayMsg);
78: }
79:
80: executionContext.leaveNode();
81: }
82:
83: private static Log _log = LogFactoryUtil
84: .getLog(NotifyRequestorActionHandler.class);
85:
86: }
|