001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.jetspeed.om.folder.psml;
018:
019: import java.security.AccessController;
020: import java.util.Iterator;
021: import java.util.List;
022: import java.util.Locale;
023:
024: import org.apache.commons.logging.Log;
025: import org.apache.commons.logging.LogFactory;
026: import org.apache.jetspeed.JetspeedActions;
027: import org.apache.jetspeed.om.common.GenericMetadata;
028: import org.apache.jetspeed.om.common.SecurityConstraints;
029: import org.apache.jetspeed.om.folder.Folder;
030: import org.apache.jetspeed.om.folder.FolderNotFoundException;
031: import org.apache.jetspeed.om.folder.MenuDefinition;
032: import org.apache.jetspeed.om.folder.MenuExcludeDefinition;
033: import org.apache.jetspeed.om.folder.MenuIncludeDefinition;
034: import org.apache.jetspeed.om.folder.MenuOptionsDefinition;
035: import org.apache.jetspeed.om.folder.MenuSeparatorDefinition;
036: import org.apache.jetspeed.om.folder.Reset;
037: import org.apache.jetspeed.om.page.Link;
038: import org.apache.jetspeed.om.page.Page;
039: import org.apache.jetspeed.om.page.PageSecurity;
040: import org.apache.jetspeed.page.PageManagerUtils;
041: import org.apache.jetspeed.page.PageNotFoundException;
042: import org.apache.jetspeed.page.document.DocumentException;
043: import org.apache.jetspeed.page.document.DocumentHandlerFactory;
044: import org.apache.jetspeed.page.document.DocumentNotFoundException;
045: import org.apache.jetspeed.page.document.FolderHandler;
046: import org.apache.jetspeed.page.document.Node;
047: import org.apache.jetspeed.page.document.NodeException;
048: import org.apache.jetspeed.page.document.NodeNotFoundException;
049: import org.apache.jetspeed.page.document.NodeSet;
050: import org.apache.jetspeed.page.document.UnsupportedDocumentTypeException;
051: import org.apache.jetspeed.page.document.psml.AbstractNode;
052: import org.apache.jetspeed.page.document.psml.NodeOrderCompartaor;
053: import org.apache.jetspeed.page.document.psml.NodeSetImpl;
054: import org.apache.jetspeed.security.FolderPermission;
055:
056: /**
057: * FolderImpl
058: *
059: * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
060: * @author <a href="mailto:jford@apache.org">Jeremy Ford </a>
061: * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
062: * @version $Id: FolderImpl.java 595429 2007-11-15 20:20:41Z smilek $
063: */
064: public class FolderImpl extends AbstractNode implements Folder, Reset {
065:
066: private NodeSet allNodes;
067: private FolderMetaDataImpl metadata;
068: private FolderHandler folderHandler;
069: private int reservedType = RESERVED_FOLDER_NONE;
070:
071: private static final Log log = LogFactory.getLog(FolderImpl.class);
072:
073: public FolderImpl(String path, FolderMetaDataImpl metadata,
074: DocumentHandlerFactory handlerFactory,
075: FolderHandler folderHandler) {
076: this .metadata = metadata;
077: this .metadata.setParent(this );
078: this .folderHandler = folderHandler;
079: setPath(path);
080: setReservedType();
081: setHandlerFactory(handlerFactory);
082: setPermissionsEnabled(handlerFactory.getPermissionsEnabled());
083: setConstraintsEnabled(handlerFactory.getConstraintsEnabled());
084: }
085:
086: public FolderImpl(String path,
087: DocumentHandlerFactory handlerFactory,
088: FolderHandler folderHandler) {
089: this .metadata = new FolderMetaDataImpl();
090: this .metadata.setParent(this );
091: this .folderHandler = folderHandler;
092: setPath(path);
093: setReservedType();
094: setHandlerFactory(handlerFactory);
095: setPermissionsEnabled(handlerFactory.getPermissionsEnabled());
096: setConstraintsEnabled(handlerFactory.getConstraintsEnabled());
097: }
098:
099: public FolderImpl() {
100: this .metadata = new FolderMetaDataImpl();
101: this .metadata.setParent(this );
102: setReservedType();
103: }
104:
105: /* (non-Javadoc)
106: * @see org.apache.jetspeed.om.folder.Folder#getSkin()
107: */
108: public String getSkin() {
109: return metadata.getSkin();
110: }
111:
112: /* (non-Javadoc)
113: * @see org.apache.jetspeed.om.folder.Folder#setSkin(java.lang.String)
114: */
115: public void setSkin(String skinName) {
116: metadata.setSkin(skinName);
117: }
118:
119: /* (non-Javadoc)
120: * @see org.apache.jetspeed.om.folder.Folder#getEffectiveDefaultDecorator(java.lang.String)
121: */
122: public String getEffectiveDefaultDecorator(String fragmentType) {
123: // get locally defined decorator
124: String decorator = getDefaultDecorator(fragmentType);
125: if (decorator == null) {
126: // delegate to parent folder
127: Folder parentFolder = (Folder) getParent();
128: if (parentFolder != null) {
129: return parentFolder
130: .getEffectiveDefaultDecorator(fragmentType);
131: }
132: }
133: return decorator;
134: }
135:
136: /* (non-Javadoc)
137: * @see org.apache.jetspeed.om.folder.Folder#getDefaultDecorator(java.lang.String)
138: */
139: public String getDefaultDecorator(String fragmentType) {
140: return metadata.getDefaultDecorator(fragmentType);
141: }
142:
143: /* (non-Javadoc)
144: * @see org.apache.jetspeed.om.folder.Folder#setDefaultDecorator(java.lang.String, java.lang.String)
145: */
146: public void setDefaultDecorator(String decoratorName,
147: String fragmentType) {
148: metadata.setDefaultDecorator(decoratorName, fragmentType);
149: }
150:
151: /* (non-Javadoc)
152: * @see org.apache.jetspeed.om.folder.Folder#getDocumentOrder()
153: */
154: public List getDocumentOrder() {
155: return metadata.getDocumentOrder();
156: }
157:
158: /* (non-Javadoc)
159: * @see org.apache.jetspeed.om.folder.Folder#setDocumentOrder(java.util.List)
160: */
161: public void setDocumentOrder(List docIndexes) {
162: metadata.setDocumentOrder(docIndexes);
163: }
164:
165: /* (non-Javadoc)
166: * @see org.apache.jetspeed.om.folder.Folder#getDefaultPage()
167: */
168: public String getDefaultPage() {
169: return metadata.getDefaultPage();
170: }
171:
172: /*
173: * (non-Javadoc)
174: *
175: * @see org.apache.jetspeed.om.folder.Folder#setDefaultPage()
176: */
177: public void setDefaultPage(String defaultPage) {
178: metadata.setDefaultPage(defaultPage);
179: }
180:
181: /**
182: * <p>
183: * getFolders
184: * </p>
185: *
186: * @param checkAccess flag
187: * @return folders node set
188: * @throws DocumentException
189: */
190: public NodeSet getFolders(boolean checkAccess)
191: throws DocumentException {
192: // get list of all folders
193: NodeSet folders = getAllNodes().subset(FOLDER_TYPE);
194:
195: // filter node set by access
196: if (checkAccess) {
197: folders = checkAccess(folders, JetspeedActions.VIEW);
198: }
199: return folders;
200: }
201:
202: /*
203: * (non-Javadoc)
204: *
205: * @see org.apache.jetspeed.om.folder.Folder#getFolders()
206: */
207: public NodeSet getFolders() throws DocumentException {
208: // by default enable access checks
209: return getFolders(true);
210: }
211:
212: /**
213: * <p>
214: * getFolder
215: * </p>
216: *
217: * @param name
218: * @param checkAccess flag
219: * @return folder
220: * @throws FolderNotFoundException
221: * @throws DocumentException
222: */
223: public Folder getFolder(String name, boolean checkAccess)
224: throws FolderNotFoundException, DocumentException {
225: // get folder
226: Folder folder = (Folder) getAllNodes().subset(FOLDER_TYPE).get(
227: name);
228: if (folder == null) {
229: throw new FolderNotFoundException(
230: "Jetspeed PSML folder not found: " + name);
231: }
232:
233: // check access
234: if (checkAccess) {
235: folder.checkAccess(JetspeedActions.VIEW);
236: }
237: return folder;
238: }
239:
240: /*
241: * (non-Javadoc)
242: *
243: * @see org.apache.jetspeed.om.folder.Folder#getFolder(java.lang.String)
244: */
245: public Folder getFolder(String name)
246: throws FolderNotFoundException, DocumentException {
247: // by default enable access checks
248: return getFolder(name, true);
249: }
250:
251: /**
252: * <p>
253: * getPages
254: * </p>
255: *
256: * @param checkAccess flag
257: * @return pages node set
258: * @throws NodeException
259: */
260: public NodeSet getPages(boolean checkAccess) throws NodeException {
261: // get list of all pages
262: NodeSet pages = getAllNodes().subset(Page.DOCUMENT_TYPE);
263:
264: // filter node set by access
265: if (checkAccess) {
266: pages = checkAccess(pages, JetspeedActions.VIEW);
267: }
268: return pages;
269: }
270:
271: /*
272: * (non-Javadoc)
273: *
274: * @see org.apache.jetspeed.om.folder.Folder#getPages()
275: */
276: public NodeSet getPages() throws NodeException {
277: // by default enable access checks
278: return getPages(true);
279: }
280:
281: /**
282: * <p>
283: * getPage
284: * </p>
285: *
286: * @param name
287: * @param checkAccess flag
288: * @return page
289: * @throws PageNotFoundException
290: * @throws NodeException
291: */
292: public Page getPage(String name, boolean checkAccess)
293: throws PageNotFoundException, NodeException {
294: // get page
295: Page page = (Page) getAllNodes().subset(Page.DOCUMENT_TYPE)
296: .get(name);
297: if (page == null) {
298: throw new PageNotFoundException(
299: "Jetspeed PSML page not found: " + name);
300: }
301:
302: // check access
303: if (checkAccess) {
304: page.checkAccess(JetspeedActions.VIEW);
305: }
306: return page;
307: }
308:
309: /*
310: * (non-Javadoc)
311: *
312: * @see org.apache.jetspeed.om.folder.Folder#getPage(java.lang.String)
313: */
314: public Page getPage(String name) throws PageNotFoundException,
315: NodeException {
316: // by default enable access checks
317: return getPage(name, true);
318: }
319:
320: /**
321: * <p>
322: * getLinks
323: * </p>
324: *
325: * @param checkAccess flag
326: * @return links node set
327: * @throws NodeException
328: */
329: public NodeSet getLinks(boolean checkAccess) throws NodeException {
330: // get list of all links
331: NodeSet links = getAllNodes().subset(Link.DOCUMENT_TYPE);
332:
333: // filter node set by access
334: if (checkAccess) {
335: links = checkAccess(links, JetspeedActions.VIEW);
336: }
337: return links;
338: }
339:
340: /*
341: * (non-Javadoc)
342: *
343: * @see org.apache.jetspeed.om.folder.Folder#getLinks()
344: */
345: public NodeSet getLinks() throws NodeException {
346: // by default enable access checks
347: return getLinks(true);
348: }
349:
350: /**
351: * <p>
352: * getLink
353: * </p>
354: *
355: * @param name
356: * @param checkAccess flag
357: * @return link
358: * @throws DocumentNotFoundException
359: * @throws NodeException
360: */
361: public Link getLink(String name, boolean checkAccess)
362: throws DocumentNotFoundException, NodeException {
363: // get link
364: Link link = (Link) getAllNodes().subset(Link.DOCUMENT_TYPE)
365: .get(name);
366: if (link == null) {
367: throw new DocumentNotFoundException(
368: "Jetspeed PSML link not found: " + name);
369: }
370:
371: // check access
372: if (checkAccess) {
373: link.checkAccess(JetspeedActions.VIEW);
374: }
375: return link;
376: }
377:
378: /*
379: * (non-Javadoc)
380: *
381: * @see org.apache.jetspeed.om.folder.Folder#getLink(java.lang.String)
382: */
383: public Link getLink(String name) throws DocumentNotFoundException,
384: NodeException {
385: // by default enable access checks
386: return getLink(name, true);
387: }
388:
389: /**
390: * <p>
391: * getPageSecurity
392: * </p>
393: *
394: * @param checkAccess flag
395: * @return page security
396: * @throws DocumentNotFoundException
397: * @throws NodeException
398: */
399: public PageSecurity getPageSecurity(boolean checkAccess)
400: throws DocumentNotFoundException, NodeException {
401: // check access to this folder in place
402: // of access to page security document
403: if (checkAccess) {
404: checkAccess(JetspeedActions.VIEW);
405: }
406:
407: // get pageSecurity
408: PageSecurity pageSecurity = (PageSecurity) getAllNodes(false)
409: .subset(PageSecurity.DOCUMENT_TYPE).get(
410: PageSecurity.DOCUMENT_TYPE);
411: if (pageSecurity == null) {
412: throw new DocumentNotFoundException(
413: "Jetspeed PSML page security not found: "
414: + PageSecurity.DOCUMENT_TYPE);
415: }
416: return pageSecurity;
417: }
418:
419: /*
420: * (non-Javadoc)
421: *
422: * @see org.apache.jetspeed.om.folder.Folder#getPageSecurity()
423: */
424: public PageSecurity getPageSecurity()
425: throws DocumentNotFoundException, NodeException {
426: // by default disable access checks
427: return getPageSecurity(false);
428: }
429:
430: /*
431: * (non-Javadoc)
432: *
433: * @see org.apache.jetspeed.om.folder.Folder#getAll()
434: */
435: public NodeSet getAll() throws DocumentException {
436: // return secure set of all nodes: enforce access checks
437: // on folders and documents while creating filtered nodes
438: NodeSet nodes = getAllNodes();
439: NodeSet filteredNodes = null;
440: Iterator checkAccessIter = nodes.iterator();
441: while (checkAccessIter.hasNext()) {
442: Node node = (Node) checkAccessIter.next();
443: try {
444: ((AbstractNode) node).checkAccess(JetspeedActions.VIEW);
445: if (filteredNodes != null) {
446: filteredNodes.add(node);
447: }
448: } catch (SecurityException se) {
449: if (filteredNodes == null) {
450: filteredNodes = new NodeSetImpl(getPath(),
451: ((NodeSetImpl) nodes).getComparator());
452: Iterator copyIter = nodes.iterator();
453: while (copyIter.hasNext()) {
454: Node copyNode = (Node) copyIter.next();
455: if (copyNode != node) {
456: filteredNodes.add(copyNode);
457: } else {
458: break;
459: }
460: }
461: }
462: }
463: }
464: if (filteredNodes != null) {
465: return filteredNodes;
466: }
467: return nodes;
468: }
469:
470: /**
471: * <p>
472: * getAllNodes
473: * </p>
474: *
475: * @return all nodes immediatley under this
476: * @throws DocumentException
477: */
478: public NodeSet getAllNodes() throws DocumentException {
479: return getAllNodes(true);
480: }
481:
482: protected synchronized NodeSet getAllNodes(
483: boolean folderExistenceRequired) throws DocumentException {
484: if ((allNodes == null) && (folderHandler != null)) {
485: if (metadata.getDocumentOrder() != null) {
486: if (getPath().endsWith(PATH_SEPARATOR)) {
487: allNodes = new NodeSetImpl(getPath(),
488: new NodeOrderCompartaor(metadata
489: .getDocumentOrder(), getPath()));
490: } else {
491: allNodes = new NodeSetImpl(getPath(),
492: new NodeOrderCompartaor(metadata
493: .getDocumentOrder(), getPath()
494: + PATH_SEPARATOR));
495: }
496: } else {
497: allNodes = new NodeSetImpl(getPath());
498: }
499:
500: try {
501: String[] nodeNames = folderHandler.listAll(getPath());
502: for (int i = 0; i < nodeNames.length; i++) {
503: if (!nodeNames[i]
504: .equals(FolderMetaDataImpl.DOCUMENT_TYPE)) {
505: Node node = null;
506: try {
507: if (getPath().endsWith(PATH_SEPARATOR)) {
508: String full = PageManagerUtils
509: .concatenatePaths(getPath(),
510: nodeNames[i]);
511: if (!folderHandler.isFolder(full)) {
512: node = getHandlerFactory()
513: .getDocumentHandlerForPath(
514: nodeNames[i])
515: .getDocument(
516: getPath()
517: + nodeNames[i]);
518: } else {
519: node = folderHandler
520: .getFolder(getPath()
521: + nodeNames[i]);
522: }
523: } else {
524: String full = PageManagerUtils
525: .concatenatePaths(getPath(),
526: nodeNames[i]);
527: if (!folderHandler.isFolder(full))
528: //if(nodeNames[i].indexOf(".") > -1)
529: {
530: node = getHandlerFactory()
531: .getDocumentHandlerForPath(
532: nodeNames[i])
533: .getDocument(
534: getPath()
535: + PATH_SEPARATOR
536: + nodeNames[i]);
537: } else {
538: node = folderHandler
539: .getFolder(getPath()
540: + PATH_SEPARATOR
541: + nodeNames[i]);
542: }
543: }
544: node.setParent(this );
545: allNodes.add(node);
546: } catch (UnsupportedDocumentTypeException e) {
547: // Skip unsupported documents
548: log
549: .info("getAllNodes() Skipping unsupported document: "
550: + nodeNames[i]);
551: } catch (Exception e) {
552: log.warn(
553: "getAllNodes() failed to create Node: "
554: + nodeNames[i] + ":"
555: + e.toString(), e);
556: }
557: }
558: }
559: } catch (FolderNotFoundException fnfe) {
560: if (folderExistenceRequired) {
561: log.error(
562: "getAllNodes() unexpected missing folder: "
563: + getPath(), fnfe);
564: }
565: }
566: }
567:
568: return allNodes;
569: }
570:
571: /**
572: * <p>
573: * getFolderMetaData
574: * </p>
575: *
576: * @return implementation specific folder metadata
577: */
578: public FolderMetaDataImpl getFolderMetaData() {
579: return metadata;
580: }
581:
582: /**
583: * <p>
584: * setFolderHandler
585: * </p>
586: *
587: * @param handler folder handler
588: */
589: public void setFolderHandler(FolderHandler handler) {
590: this .folderHandler = handler;
591: }
592:
593: /**
594: * <p>
595: * getMetadata
596: * </p>
597: *
598: * @see org.apache.jetspeed.page.document.AbstractNode#getMetadata()
599: * @return metadata
600: */
601: public GenericMetadata getMetadata() {
602: return metadata.getMetadata();
603: }
604:
605: /**
606: * <p>
607: * getSecurityConstraints
608: * </p>
609: *
610: * @see org.apache.jetspeed.om.common.SecureResource#getSecurityConstraints()
611: * @return
612: */
613: public SecurityConstraints getSecurityConstraints() {
614: return metadata.getSecurityConstraints();
615: }
616:
617: /**
618: * <p>
619: * setSecurityConstraints
620: * </p>
621: *
622: * @see org.apache.jetspeed.om.common.SecureResource#setSecurityConstraints(org.apache.jetspeed.om.common.SecurityConstraints)
623: * @param constraints
624: */
625: public void setSecurityConstraints(SecurityConstraints constraints) {
626: metadata.setSecurityConstraints(constraints);
627: }
628:
629: /**
630: * getEffectivePageSecurity
631: *
632: * @see org.apache.jetspeed.om.page.psml.AbstractElementImpl#getEffectivePageSecurity()
633: */
634: public PageSecurity getEffectivePageSecurity() {
635: // return single page security if available
636: PageSecurity pageSecurity = null;
637: try {
638: pageSecurity = getPageSecurity(false);
639: if (pageSecurity != null) {
640: return pageSecurity;
641: }
642: } catch (NodeException ne) {
643: } catch (NodeNotFoundException nnfe) {
644: }
645:
646: // delegate to parent folder implementation
647: FolderImpl parentFolderImpl = (FolderImpl) getParent();
648: if (parentFolderImpl != null) {
649: return parentFolderImpl.getEffectivePageSecurity();
650: }
651: return null;
652: }
653:
654: /**
655: * <p>
656: * checkPermissions
657: * </p>
658: *
659: * @param path
660: * @param mask
661: * @param checkNodeOnly
662: * @param checkParentsOnly
663: * @throws SecurityException
664: */
665: public void checkPermissions(String path, int mask,
666: boolean checkNodeOnly, boolean checkParentsOnly)
667: throws SecurityException {
668: // check granted folder permissions unless the check is
669: // to be skipped due to explicity granted access
670: if (!checkParentsOnly) {
671: FolderPermission permission = new FolderPermission(path,
672: mask);
673: AccessController.checkPermission(permission);
674: }
675:
676: // if not checking node only, recursively check
677: // all parent permissions in hierarchy
678: if (!checkNodeOnly && (getParent() != null)) {
679: ((AbstractNode) getParent()).checkPermissions(mask, false,
680: false);
681: }
682: }
683:
684: /**
685: * <p>
686: * getTitle
687: * </p>
688: *
689: * @see org.apache.jetspeed.page.document.Node#getTitle(java.util.Locale)
690: * @param locale
691: * @return title in specified locale
692: */
693: public String getTitle(Locale locale) {
694: return metadata.getTitle(locale);
695: }
696:
697: /**
698: * <p>
699: * getTitle
700: * </p>
701: *
702: * @see org.apache.jetspeed.om.page.BaseElement#getTitle()
703: * @return title
704: */
705: public String getTitle() {
706: return metadata.getTitle();
707: }
708:
709: /**
710: * <p>
711: * setTitle
712: * </p>
713: *
714: * @see org.apache.jetspeed.om.page.BaseElement#setTitle(java.lang.String)
715: * @param title
716: */
717: public void setTitle(String title) {
718: metadata.setTitle(title);
719: }
720:
721: /**
722: * <p>
723: * getShortTitle
724: * </p>
725: *
726: * @see org.apache.jetspeed.page.document.Node#getShortTitle(java.util.Locale)
727: * @param locale
728: * @return short title in supplied locate
729: */
730: public String getShortTitle(Locale locale) {
731: return metadata.getShortTitle(locale);
732: }
733:
734: /**
735: * <p>
736: * getShortTitle
737: * </p>
738: *
739: * @see org.apache.jetspeed.om.page.BaseElement#getShortTitle()
740: * @return short title
741: */
742: public String getShortTitle() {
743: return metadata.getShortTitle();
744: }
745:
746: /**
747: * <p>
748: * setShortTitle
749: * </p>
750: *
751: * @see org.apache.jetspeed.om.page.BaseElement#setShortTitle(java.lang.String)
752: * @param title
753: */
754: public void setShortTitle(String title) {
755: metadata.setShortTitle(title);
756: }
757:
758: /**
759: * <p>
760: * getType
761: * </p>
762: *
763: * @see org.apache.jetspeed.page.document.Node#getType()
764: * @return type string
765: */
766: public String getType() {
767: return FOLDER_TYPE;
768: }
769:
770: /**
771: * <p>
772: * isHidden
773: * </p>
774: *
775: * @see org.apache.jetspeed.page.document.Node#isHidden()
776: * @return whether folder is hidden
777: */
778: public boolean isHidden() {
779: return metadata.isHidden();
780: }
781:
782: /**
783: * <p>
784: * setHidden
785: * </p>
786: *
787: * @see org.apache.jetspeed.page.document.AbstractNode#setHidden(boolean)
788: * @param hidden
789: */
790: public void setHidden(boolean hidden) {
791: ((AbstractNode) metadata).setHidden(hidden);
792: }
793:
794: /* (non-Javadoc)
795: * @see org.apache.jetspeed.om.folder.Reset#reset()
796: */
797: public void reset() {
798: allNodes = null;
799:
800: }
801:
802: /**
803: * getMenuDefinitions - get list of menu definitions
804: *
805: * @return definition list
806: */
807: public List getMenuDefinitions() {
808: return metadata.getMenuDefinitions();
809: }
810:
811: /**
812: * newMenuDefinition - creates a new empty menu definition
813: *
814: * @return a newly created MenuDefinition object for use in Folder
815: */
816: public MenuDefinition newMenuDefinition() {
817: return new MenuDefinitionImpl();
818: }
819:
820: /**
821: * newMenuExcludeDefinition - creates a new empty menu exclude definition
822: *
823: * @return a newly created MenuExcludeDefinition object for use in Folder
824: */
825: public MenuExcludeDefinition newMenuExcludeDefinition() {
826: return new MenuExcludeDefinitionImpl();
827: }
828:
829: /**
830: * newMenuIncludeDefinition - creates a new empty menu include definition
831: *
832: * @return a newly created MenuIncludeDefinition object for use in Folder
833: */
834: public MenuIncludeDefinition newMenuIncludeDefinition() {
835: return new MenuIncludeDefinitionImpl();
836: }
837:
838: /**
839: * newMenuOptionsDefinition - creates a new empty menu options definition
840: *
841: * @return a newly created MenuOptionsDefinition object for use in Folder
842: */
843: public MenuOptionsDefinition newMenuOptionsDefinition() {
844: return new MenuOptionsDefinitionImpl();
845: }
846:
847: /**
848: * newMenuSeparatorDefinition - creates a new empty menu separator definition
849: *
850: * @return a newly created MenuSeparatorDefinition object for use in Folder
851: */
852: public MenuSeparatorDefinition newMenuSeparatorDefinition() {
853: return new MenuSeparatorDefinitionImpl();
854: }
855:
856: /**
857: * setMenuDefinitions - set list of menu definitions
858: *
859: * @param definitions definition list
860: */
861: public void setMenuDefinitions(List definitions) {
862: metadata.setMenuDefinitions(definitions);
863: }
864:
865: /**
866: * unmarshalled - notification that this instance has been
867: * loaded from the persistent store
868: */
869: public void unmarshalled() {
870: // notify super class implementation
871: super .unmarshalled();
872:
873: // default title of pages to name
874: if (getTitle() == null) {
875: setTitle(getTitleName());
876: }
877: }
878:
879: public boolean isReserved() {
880: return (reservedType > RESERVED_FOLDER_NONE);
881: }
882:
883: public int getReservedType() {
884: return reservedType;
885: }
886:
887: private void setReservedType() {
888: String name = getName();
889: if (name != null) {
890: if (name.startsWith(RESERVED_SUBSITE_FOLDER_PREFIX)) {
891: reservedType = RESERVED_FOLDER_SUBSITES;
892: } else if (name.startsWith(RESERVED_FOLDER_PREFIX)) {
893: if (name.equals(RESERVED_USER_FOLDER_NAME))
894: reservedType = RESERVED_FOLDER_USERS;
895: else if (name.equals(RESERVED_ROLE_FOLDER_NAME))
896: reservedType = RESERVED_FOLDER_ROLES;
897: else if (name.equals(RESERVED_GROUP_FOLDER_NAME))
898: reservedType = RESERVED_FOLDER_GROUPS;
899: else if (name.equals(RESERVED_MEDIATYPE_FOLDER_NAME))
900: reservedType = RESERVED_FOLDER_MEDIATYPE;
901: else if (name.equals(RESERVED_LANGUAGE_FOLDER_NAME))
902: reservedType = RESERVED_FOLDER_LANGUAGE;
903: else if (name.equals(RESERVED_COUNTRY_FOLDER_NAME))
904: reservedType = RESERVED_FOLDER_COUNTRY;
905: else
906: reservedType = RESERVED_FOLDER_OTHER;
907: }
908: }
909: }
910:
911: }
|