001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2006, Red Hat Middleware, LLC, and individual *
004: * contributors as indicated by the @authors tag. See the *
005: * copyright.txt in the distribution for a full listing of *
006: * individual contributors. *
007: * *
008: * This is free software; you can redistribute it and/or modify it *
009: * under the terms of the GNU Lesser General Public License as *
010: * published by the Free Software Foundation; either version 2.1 of *
011: * the License, or (at your option) any later version. *
012: * *
013: * This software is distributed in the hope that it will be useful, *
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
016: * Lesser General Public License for more details. *
017: * *
018: * You should have received a copy of the GNU Lesser General Public *
019: * License along with this software; if not, write to the Free *
020: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
021: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
022: ******************************************************************************/package org.jboss.portal.core.impl.model.portal;
023:
024: import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
025: import org.jboss.portal.core.model.portal.Page;
026: import org.jboss.portal.core.model.portal.Portal;
027: import org.jboss.portal.core.model.portal.PortalObject;
028:
029: import java.util.HashMap;
030: import java.util.HashSet;
031: import java.util.Set;
032:
033: /**
034: * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
035: * @version $Revision: 9134 $
036: */
037: public class PortalImpl extends PortalObjectImpl implements Portal {
038:
039: // Persistent state
040: protected Set windowStates;
041: protected Set modes;
042:
043: public PortalImpl() {
044: this (true);
045: }
046:
047: public PortalImpl(boolean hibernate) {
048: super (hibernate);
049: windowStates = hibernate ? null : new HashSet();
050: modes = hibernate ? null : new HashSet();
051: }
052:
053: public Set getModes() {
054: return modes;
055: }
056:
057: public void setModes(Set modes) {
058: this .modes = modes;
059: }
060:
061: public Set getWindowStates() {
062: return windowStates;
063: }
064:
065: public void setWindowStates(Set windowStates) {
066: this .windowStates = windowStates;
067: }
068:
069: public Set getSupportedWindowStates() {
070: return windowStates;
071: }
072:
073: public Set getSupportedModes() {
074: return modes;
075: }
076:
077: public Page getPage(String name) {
078: PortalObject child = getChild(name);
079: if (child instanceof Page) {
080: return (Page) child;
081: }
082: return null;
083: }
084:
085: public Page createPage(String name)
086: throws DuplicatePortalObjectException {
087: PageImpl page = new PageImpl(false);
088: addChild(name, page);
089: return page;
090: }
091:
092: public int getType() {
093: return PortalObject.TYPE_PORTAL;
094: }
095:
096: public Page getDefaultPage() {
097: PortalObject child = getDefaultChild();
098: if (child instanceof Page) {
099: return (Page) child;
100: }
101: if (child != null) {
102: log.warn("Default child is not a page " + child);
103: }
104: return null;
105: }
106:
107: protected PortalObjectImpl cloneObject() {
108: PortalImpl clone = new PortalImpl();
109: clone.setWindowStates(new HashSet(getWindowStates()));
110: clone.setModes(new HashSet(getModes()));
111: clone.setDeclaredPropertyMap(new HashMap(
112: getDeclaredPropertyMap()));
113: clone.setListener(getListener());
114: clone.setDisplayName(getDisplayName());
115: return clone;
116: }
117: }
|