01: /**********************************************************************************
02: * $URL:https://source.sakaiproject.org/svn/osp/trunk/presentation/api-impl/src/java/org/theospi/portfolio/presentation/model/impl/PresentationAuthzMap.java $
03: * $Id:PresentationAuthzMap.java 9134 2006-05-08 20:28:42Z chmaurer@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.theospi.portfolio.presentation.model.impl;
21:
22: import java.util.HashMap;
23:
24: import org.apache.commons.logging.Log;
25: import org.apache.commons.logging.LogFactory;
26: import org.sakaiproject.metaobj.shared.model.Agent;
27: import org.theospi.portfolio.presentation.PresentationFunctionConstants;
28: import org.theospi.portfolio.presentation.model.Presentation;
29:
30: public class PresentationAuthzMap extends HashMap {
31: protected final transient Log logger = LogFactory
32: .getLog(getClass());
33:
34: private Agent currentAgent;
35: private Presentation presentation;
36: private boolean owner = false;
37:
38: /**
39: * Constructs a new, empty hashtable with a default initial capacity (11)
40: * and load factor, which is <tt>0.75</tt>.
41: */
42: public PresentationAuthzMap(Agent currentAgent,
43: Presentation presentation) {
44: this .currentAgent = currentAgent;
45: this .presentation = presentation;
46: owner = presentation.getOwner().getId().equals(
47: currentAgent.getId());
48: }
49:
50: /**
51: * Returns the value to which the specified key is mapped in this hashtable.
52: *
53: * @param key a key in the hashtable.
54: * @return the value to which the key is mapped in this hashtable;
55: * <code>null</code> if the key is not mapped to any value in
56: * this hashtable.
57: * @throws NullPointerException if the key is <code>null</code>.
58: * @see #put(Object, Object)
59: */
60: public Object get(Object key) {
61: if (owner) {
62: return new Boolean(true); // owner can do anything
63: }
64:
65: String func = PresentationFunctionConstants.PRESENTATION_PREFIX
66: + key.toString();
67:
68: if (func
69: .equals(PresentationFunctionConstants.VIEW_PRESENTATION)) {
70: return new Boolean(true);
71: } else {
72: return new Boolean(false);
73: }
74: }
75: }
|