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.folder.psml;
18  
19  import java.util.ArrayList;
20  import java.util.Iterator;
21  import java.util.List;
22  
23  import org.apache.jetspeed.om.page.Document;
24  import org.apache.jetspeed.om.page.psml.DefaultsImpl;
25  import org.apache.jetspeed.om.page.psml.DocumentImpl;
26  
27  /***
28   * <p>
29   * FolderMetaDataImpl
30   * </p>
31   * <p>
32   * 
33   * </p>
34   * 
35   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver </a>
36   * @version $Id: FolderMetaDataImpl.java 553014 2007-07-03 23:10:53Z ate $
37   *  
38   */
39  public class FolderMetaDataImpl extends DocumentImpl implements Document
40  {
41      public static final String DOCUMENT_TYPE = "folder.metadata";
42  
43      private DefaultsImpl defaults = new DefaultsImpl();
44      private List docOrder;
45      private String defaultPage;
46  
47      /***
48       * menuDefinitions - menu definitions for folder
49       */
50      private List menuDefinitions;
51      
52      public FolderMetaDataImpl()
53      {
54          docOrder = new ArrayList(4);
55      }
56         
57      /***
58       * <p>
59       * getType
60       * </p>
61       *
62       * @return document type
63       */
64      public String getType()
65      {
66          return DOCUMENT_TYPE;
67      }
68  
69      /***
70       * <p>
71       * getUrl
72       * </p>
73       *
74       * @return url of folder
75       */
76      public String getUrl()
77      {
78          return getParent(false).getPath() + PATH_SEPARATOR + getType();
79      }
80  
81      /***
82       * <p>
83       * getSkin
84       * </p>
85       *
86       * @return skin for folder
87       */
88      public String getSkin()
89      {
90          // delegate to defaults implementation
91          return defaults.getSkin();
92      }
93  
94      /***
95       * <p>
96       * setSkin
97       * </p>
98       *
99       * @param skinName skin for folder
100      */
101     public void setSkin( String skinName )
102     {
103         // delegate to defaults implementation
104         defaults.setSkin(skinName);
105     }
106 
107     /***
108      * <p>
109      * getDefaultDecorator
110      * </p>
111      *
112      * @param fragmentType portlet or layout fragment type
113      * @return decorator name
114      */
115     public String getDefaultDecorator( String fragmentType )
116     {
117         // delegate to defaults implementation
118         return defaults.getDecorator(fragmentType);
119     }
120 
121     /***
122      * <p>
123      * setDefaultDecorator
124      * </p>
125      *
126      * @param decoratorName decorator name
127      * @param fragmentType portlet or layout fragment type
128      */
129     public void setDefaultDecorator( String decoratorName, String fragmentType )
130     {
131         // delegate to defaults implementation
132         defaults.setDecorator(fragmentType, decoratorName);
133     }
134 
135     /***
136      * <p>
137      * getDocumentOrder
138      * </p>
139      *
140      * @return document order
141      */
142     public List getDocumentOrder()
143     {
144         return docOrder;
145     }
146 
147     /***
148      * <p>
149      * setDocumentOrder
150      * </p>
151      *
152      * @param docIndexes
153      */
154     public void setDocumentOrder(List docIndexes)
155     {
156         docOrder = docIndexes;
157     }
158 
159     /***
160      * @return Returns the defaultPage.
161      */
162     public String getDefaultPage()
163     {
164         return defaultPage;
165     }
166 
167     /***
168      * @param defaultPage The defaultPage to set.
169      */
170     public void setDefaultPage( String defaultPage )
171     {
172         this.defaultPage = defaultPage;
173     }
174 
175     /***
176      * getMenuDefinitions - get list of menu definitions
177      *
178      * @return definition list
179      */
180     public List getMenuDefinitions()
181     {
182         return menuDefinitions;
183     }
184 
185     /***
186      * setMenuDefinitions - set list of menu definitions
187      *
188      * @param definitions definition list
189      */
190     public void setMenuDefinitions(List definitions)
191     {
192         menuDefinitions = definitions;
193     }
194 
195     /***
196      * getDefaults - Castor access method for Defaults.
197      *
198      * @return defaults instance
199      */
200     public DefaultsImpl getDefaults()
201     {
202         return this.defaults;
203     }
204 
205     /***
206      * setDefaults - Castor access method for Defaults.
207      *
208      * @param defaults defaults instance
209      */
210     public void setDefaults( DefaultsImpl defaults )
211     {
212         this.defaults = defaults;
213     }
214 
215     /***
216      * unmarshalled - notification that this instance has been
217      *                loaded from the persistent store
218      */
219     public void unmarshalled()
220     {
221         // notify super class implementation
222         super.unmarshalled();
223 
224         // propagate unmarshalled notification
225         // to all menu definitions
226         if (menuDefinitions != null)
227         {
228             Iterator menuIter = menuDefinitions.iterator();
229             while (menuIter.hasNext())
230             {
231                 ((MenuDefinitionImpl)menuIter.next()).unmarshalled();
232             }
233         }
234     }
235 
236     /***
237      * marshalling - notification that this instance is to
238      *               be saved to the persistent store
239      */
240     public void marshalling()
241     {
242         // propagate marshalling notification
243         // to all menu definitions
244         if (menuDefinitions != null)
245         {
246             Iterator menuIter = menuDefinitions.iterator();
247             while (menuIter.hasNext())
248             {
249                 ((MenuDefinitionImpl)menuIter.next()).marshalling();
250             }
251         }
252 
253         // notify super class implementation
254         super.marshalling();
255     }
256 }