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.Context;
025: import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
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:
031: /**
032: * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
033: * @version $Revision: 9134 $
034: */
035: public class ContextImpl extends PortalObjectImpl implements Context {
036:
037: public ContextImpl() {
038: this (true);
039: }
040:
041: public ContextImpl(boolean hibernate) {
042: super (hibernate);
043: }
044:
045: public Portal getPortal(String name) {
046: PortalObject child = getChild(name);
047: if (child instanceof Portal) {
048: return (Portal) child;
049: }
050: return null;
051: }
052:
053: public Portal createPortal(String name)
054: throws DuplicatePortalObjectException {
055: PortalImpl portal = new PortalImpl(false);
056: addChild(name, portal);
057: return portal;
058: }
059:
060: public Portal getDefaultPortal() {
061: PortalObject child = getDefaultChild();
062: if (child instanceof Portal) {
063: return (Portal) child;
064: }
065: if (child != null) {
066: log.warn("Default child is not a portal " + child);
067: }
068: return null;
069: }
070:
071: // public PortalContainer createPortalContainer(String name) throws DuplicatePortalObjectException
072: // {
073: // ContextImpl portalContainer = new ContextImpl(false);
074: // addChild(name, portalContainer);
075: // return portalContainer;
076: // }
077:
078: // public PortalContainer getPortalContainer(String name) throws IllegalArgumentException
079: // {
080: // PortalObject child = getChild(name);
081: // if (child instanceof PortalContainer)
082: // {
083: // return (PortalContainer)child;
084: // }
085: // return null;
086: // }
087:
088: public int getType() {
089: return PortalObject.TYPE_CONTEXT;
090: }
091:
092: protected PortalObjectImpl cloneObject() {
093: ContextImpl clone = new ContextImpl();
094: clone.setDeclaredPropertyMap(new HashMap(
095: getDeclaredPropertyMap()));
096: clone.setListener(getListener());
097: clone.setDisplayName(getDisplayName());
098: return clone;
099: }
100: }
|