01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.core.document.authorization;
17:
18: import org.apache.commons.lang.StringUtils;
19: import org.kuali.core.bo.Parameter;
20: import org.kuali.core.bo.user.UniversalUser;
21: import org.kuali.core.document.Document;
22: import org.kuali.core.document.MaintenanceDocument;
23:
24: /**
25: * This is a description of what this class does - kellerj don't forget to fill this in.
26: *
27: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
28: *
29: */
30: public class ParameterMaintenanceDocumentAuthorizer extends
31: MaintenanceDocumentAuthorizerBase {
32:
33: /**
34: * This overridden method ...
35: *
36: * @see org.kuali.core.document.authorization.DocumentAuthorizerBase#hasInitiateAuthorization(org.kuali.core.document.Document, org.kuali.core.bo.user.UniversalUser)
37: */
38: @Override
39: public boolean hasInitiateAuthorization(Document document,
40: UniversalUser user) {
41: boolean hasInitiateAuth = super .hasInitiateAuthorization(
42: document, user);
43:
44: // user can not initiate if they are not in the workgroup
45: if (hasInitiateAuth) {
46: Parameter oldParm = (Parameter) ((MaintenanceDocument) document)
47: .getOldMaintainableObject().getBusinessObject();
48: // don't enforce the workgroup limitation when creating a new parameter
49: if (oldParm != null && oldParm.getParameterName() != null) {
50: Parameter parm = (Parameter) ((MaintenanceDocument) document)
51: .getNewMaintainableObject().getBusinessObject();
52: if (parm != null
53: && StringUtils.isNotBlank(parm
54: .getParameterWorkgroupName())
55: && !user.isMember(parm
56: .getParameterWorkgroupName())) {
57: hasInitiateAuth = false;
58: }
59: }
60: }
61:
62: return hasInitiateAuth;
63: }
64:
65: }
|