001: /*
002: * Copyright 2005-2006 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.opensource.org/licenses/ecl1.php
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package edu.iu.uis.eden.actions;
018:
019: import org.apache.commons.lang.StringUtils;
020:
021: import edu.iu.uis.eden.actionrequests.ActionRequestValue;
022: import edu.iu.uis.eden.exception.EdenUserNotFoundException;
023: import edu.iu.uis.eden.user.WorkflowUser;
024: import edu.iu.uis.eden.workgroup.Workgroup;
025:
026: /**
027: * Represents a revocation of an AdHoc request.<br><br>
028: *
029: * If the <code>nodeName</code> property on this object is set, then the system will only
030: * examine pending app-specific requests at nodes with that particular name. In addition to
031: * this, one of the following 3 parameters is required:<br><br>
032: *
033: * <ol>
034: * <li><b>actionRequestId</b> - the ID of the action request to revoke</li>
035: * <li><b>userId</b> - the ID of the user whose request(s) should be revoked</li>
036: * <li><b>workgroupId</b> - the ID of the workgroup whose requests(s) should be revoked</li>
037: * </ol>
038: *
039: * @author Eric Westfall
040: */
041: public class AdHocRevoke implements java.io.Serializable {
042:
043: private static final long serialVersionUID = 8536540010313763068L;
044:
045: private Long actionRequestId;
046: private String nodeName;
047: private WorkflowUser user;
048: private Workgroup workgroup;
049:
050: public AdHocRevoke() {
051: }
052:
053: public Long getActionRequestId() {
054: return actionRequestId;
055: }
056:
057: public void setActionRequestId(Long actionRequestId) {
058: this .actionRequestId = actionRequestId;
059: }
060:
061: public String getNodeName() {
062: return nodeName;
063: }
064:
065: public void setNodeName(String nodeName) {
066: this .nodeName = nodeName;
067: }
068:
069: public WorkflowUser getUser() {
070: return user;
071: }
072:
073: public void setUser(WorkflowUser user) {
074: this .user = user;
075: }
076:
077: public Workgroup getWorkgroup() {
078: return workgroup;
079: }
080:
081: public void setWorkgroup(Workgroup workgroup) {
082: this .workgroup = workgroup;
083: }
084:
085: /**
086: * Determines if the given action request is an ad hoc request which matches this set of criteria.
087: */
088: public boolean matchesActionRequest(ActionRequestValue actionRequest)
089: throws EdenUserNotFoundException {
090: if (!actionRequest.isAdHocRequest()) {
091: return false;
092: }
093: if (getActionRequestId() != null
094: && !getActionRequestId().equals(
095: actionRequest.getActionRequestId())) {
096: return false;
097: }
098: if (!StringUtils.isEmpty(getNodeName())
099: && !getNodeName().equals(
100: actionRequest.getNodeInstance().getName())) {
101: return false;
102: }
103: WorkflowUser user = getUser();
104: if (user != null
105: && (!actionRequest.isUserRequest() || !actionRequest
106: .getWorkflowId().equals(user.getWorkflowId()))) {
107: return false;
108: }
109: Workgroup workgroup = getWorkgroup();
110: if (workgroup != null
111: && (!actionRequest.isWorkgroupRequest() || !actionRequest
112: .getWorkgroupId().equals(
113: workgroup.getWorkflowGroupId()
114: .getGroupId()))) {
115: return false;
116: }
117: return true;
118: }
119:
120: }
|