View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
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 org.apache.jetspeed.om.page.psml;
18  
19  import java.util.HashMap;
20  import java.util.Iterator;
21  import java.util.List;
22  import java.util.Map;
23  
24  import org.apache.jetspeed.om.page.PageSecurity;
25  import org.apache.jetspeed.om.page.SecurityConstraintsDef;
26  
27  /***
28   * <p>
29   * SecurityImpl
30   * </p>
31   * <p>
32   *
33   * </p>
34   * @author <a href="mailto:rwatler@finali.com">Randy Watler</a>
35   * @version $Id: PageSecurityImpl.java 516448 2007-03-09 16:25:47Z ate $
36   *
37   */
38  public class PageSecurityImpl extends DocumentImpl implements PageSecurity
39  {
40      private List constraintsDefsList;
41  
42      private Map constraintsDefsMap;
43  
44      private List globalConstraintsRefs;
45  
46      /***
47       * <p>
48       * getType
49       * </p>
50       *
51       * @see org.apache.jetspeed.om.page.Document#getType()
52       * @return
53       */
54      public String getType()
55      {       
56          return DOCUMENT_TYPE;
57      }
58  
59      /***
60       * <p>
61       * getSecurityConstraintsDefs
62       * </p>
63       *
64       * @see org.apache.jetspeed.om.page.PageSecurity#getSecurityConstraintsDefs()
65       * @return
66       */
67      public List getSecurityConstraintsDefs()
68      {
69          return constraintsDefsList;
70      }
71      
72      /***
73       * <p>
74       * setSecurityConstraintsDefs
75       * </p>
76       *
77       * @see org.apache.jetspeed.om.page.PageSecurity#setSecurityConstraintsDefs(java.util.List)
78       * @param defintions
79       */
80      public void setSecurityConstraintsDefs(List definitions)
81      {
82          constraintsDefsList = definitions;
83          constraintsDefsMap = null;
84      }
85  
86      /***
87       * <p>
88       * newSecurityConstraintsDef
89       * </p>
90       *
91       * @see org.apache.jetspeed.om.page.PageSecurity#newSecurityConstraintsDef()
92       * @return security constraints definition
93       */
94      public SecurityConstraintsDef newSecurityConstraintsDef()
95      {
96          return new SecurityConstraintsDefImpl();
97      }
98  
99      /***
100      * <p>
101      * getSecurityConstraintsDef
102      * </p>
103      *
104      * @see org.apache.jetspeed.om.page.PageSecurity#getSecurityConstraintsDef(java.lang.String)
105      * @param name
106      * @return
107      */
108     public SecurityConstraintsDef getSecurityConstraintsDef(String name)
109     {
110         if ((constraintsDefsList != null) && (constraintsDefsMap == null))
111         {
112             constraintsDefsMap = new HashMap((constraintsDefsList.size() * 2) + 1);
113             Iterator definitionsIter = constraintsDefsList.iterator();
114             while (definitionsIter.hasNext())
115             {
116                 SecurityConstraintsDef definition = (SecurityConstraintsDef)definitionsIter.next();
117                 constraintsDefsMap.put(definition.getName(), definition);
118             }
119         }
120         if (constraintsDefsMap != null)
121         {
122             return (SecurityConstraintsDef) constraintsDefsMap.get(name);
123         }
124         return null;
125     }
126 
127     /***
128      * <p>
129      * getGlobalSecurityConstraintsRefs
130      * </p>
131      *
132      * @see org.apache.jetspeed.om.page.PageSecurity#getGlobalSecurityConstraintsRefs()
133      * @return
134      */
135     public List getGlobalSecurityConstraintsRefs()
136     {
137         return globalConstraintsRefs;
138     }
139     
140     /***
141      * <p>
142      * setGlobalSecurityConstraintsRefs
143      * </p>
144      *
145      * @see org.apache.jetspeed.om.page.PageSecurity#setGlobalSecurityConstraintsRefs(java.util.List)
146      * @param constraintsRefs
147      */
148     public void setGlobalSecurityConstraintsRefs(List constraintsRefs)
149     {
150         globalConstraintsRefs = constraintsRefs;
151     }
152 }