01: /*
02: * Copyright 2006-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.module.chart.document;
17:
18: import org.apache.log4j.Logger;
19: import org.kuali.core.bo.user.UniversalUser;
20: import org.kuali.core.document.MaintenanceDocument;
21: import org.kuali.core.document.authorization.MaintenanceDocumentAuthorizations;
22: import org.kuali.core.document.authorization.MaintenanceDocumentAuthorizerBase;
23: import org.kuali.kfs.KFSConstants;
24: import org.kuali.kfs.context.SpringContext;
25: import org.kuali.kfs.service.ParameterService;
26: import org.kuali.module.chart.bo.Org;
27:
28: /**
29: * Org/Organization specific authorization rules.
30: */
31: public class OrgDocumentAuthorizer extends
32: MaintenanceDocumentAuthorizerBase {
33:
34: private static final Logger LOG = Logger
35: .getLogger(OrgDocumentAuthorizer.class);
36:
37: /**
38: * Constructs a OrgDocumentAuthorizer.java.
39: */
40: public OrgDocumentAuthorizer() {
41: super ();
42: }
43:
44: /**
45: * This method returns the set of authorization restrictions (if any) that apply to this Org in this context.
46: *
47: * @param document
48: * @param user
49: * @return a new set of {@link MaintenanceDocumentAuthorizations} that marks certain fields read-only if necessary
50: */
51: public MaintenanceDocumentAuthorizations getFieldAuthorizations(
52: MaintenanceDocument document, UniversalUser user) {
53:
54: MaintenanceDocumentAuthorizations auths = new MaintenanceDocumentAuthorizations();
55:
56: // if the user is the system supervisor, then do nothing, dont apply
57: // any restrictions
58: if (user.isSupervisorUser()) {
59: return auths;
60: }
61:
62: String groupName = SpringContext
63: .getBean(ParameterService.class)
64: .getParameterValue(
65: Org.class,
66: KFSConstants.ChartApcParms.ORG_PLANT_WORKGROUP_PARM_NAME);
67:
68: // if the user is NOT a member of the special group, then mark all the
69: // ICR & CS fields read-only.
70: if (!user.isMember(groupName)) {
71: auths.addReadonlyAuthField("organizationPlantChartCode");
72: auths
73: .addReadonlyAuthField("organizationPlantAccountNumber");
74: auths.addReadonlyAuthField("campusPlantChartCode");
75: auths.addReadonlyAuthField("campusPlantAccountNumber");
76: }
77: return auths;
78: }
79: }
|