01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.actions;
18:
19: import java.util.List;
20:
21: import org.apache.log4j.MDC;
22:
23: import edu.iu.uis.eden.EdenConstants;
24: import edu.iu.uis.eden.exception.EdenUserNotFoundException;
25: import edu.iu.uis.eden.exception.InvalidActionTakenException;
26: import edu.iu.uis.eden.exception.ResourceUnavailableException;
27: import edu.iu.uis.eden.routeheader.DocumentRouteHeaderValue;
28: import edu.iu.uis.eden.user.WorkflowUser;
29: import edu.iu.uis.eden.util.Utilities;
30:
31: /**
32: * Simply records an action taken with an annotation.
33: *
34: * @author rkirkend
35: */
36: public class LogDocumentActionAction extends ActionTakenEvent {
37:
38: private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
39: .getLogger(LogDocumentActionAction.class);
40:
41: /**
42: * @param rh RouteHeader for the document upon which the action is taken.
43: * @param user User taking the action.
44: */
45: public LogDocumentActionAction(DocumentRouteHeaderValue rh,
46: WorkflowUser user) {
47: super (rh, user);
48: setupAction();
49: }
50:
51: /**
52: * @param rh RouteHeader for the document upon which the action is taken.
53: * @param user User taking the action.
54: * @param annotation User comment on the action taken
55: */
56: public LogDocumentActionAction(DocumentRouteHeaderValue rh,
57: WorkflowUser user, String annotation) {
58: super (rh, user, annotation);
59: setupAction();
60: }
61:
62: private void setupAction() {
63: setActionTakenCode(EdenConstants.ACTION_TAKEN_LOG_DOCUMENT_ACTION_CD);
64: setCurrentInd(Boolean.FALSE);
65: }
66:
67: /* (non-Javadoc)
68: * @see edu.iu.uis.eden.actions.ActionTakenEvent#validateActionRules()
69: */
70: @Override
71: public String validateActionRules()
72: throws EdenUserNotFoundException {
73: // log action is always valid so return no error message
74: return "";
75: }
76:
77: /**
78: * Records the non-routed document action. - Checks to make sure the document status allows the action. Records the action.
79: *
80: * @throws InvalidActionTakenException
81: * @throws EdenUserNotFoundException
82: */
83: public void recordAction() throws InvalidActionTakenException,
84: EdenUserNotFoundException {
85: MDC.put("docId", getRouteHeader().getRouteHeaderId());
86:
87: String errorMessage = validateActionRules();
88: if (!Utilities.isEmpty(errorMessage)) {
89: throw new InvalidActionTakenException(errorMessage);
90: }
91:
92: LOG.debug("Logging document action");
93: saveActionTaken();
94: notifyActionTaken(this.actionTaken);
95:
96: }
97: }
|