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.content.ContentType;
025: import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
026: import org.jboss.portal.core.model.portal.Page;
027: import org.jboss.portal.core.model.portal.Portal;
028: import org.jboss.portal.core.model.portal.PortalObject;
029: import org.jboss.portal.core.model.portal.Window;
030:
031: import java.util.HashMap;
032:
033: /**
034: * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
035: * @version $Revision: 9134 $
036: */
037: public class PageImpl extends PortalObjectImpl implements Page {
038:
039: public PageImpl() {
040: this (true);
041: }
042:
043: public PageImpl(boolean hibernate) {
044: super (hibernate);
045: }
046:
047: public Portal getPortal() {
048: PortalObject object = this ;
049: while (object != null && !(object instanceof Portal)) {
050: object = object.getParent();
051: }
052: return (Portal) object;
053: }
054:
055: public Page getPage(String name) {
056: PortalObject child = getChild(name);
057: if (child instanceof Page) {
058: return (Page) child;
059: }
060: return null;
061: }
062:
063: public Page createPage(String name)
064: throws DuplicatePortalObjectException {
065: PageImpl page = new PageImpl(false);
066: addChild(name, page);
067: return page;
068: }
069:
070: public Window getWindow(String name) {
071: PortalObject child = getChild(name);
072: if (child instanceof Window) {
073: return (Window) child;
074: }
075: return null;
076: }
077:
078: public Window createWindow(String name, ContentType contentType,
079: String contentURI) throws DuplicatePortalObjectException,
080: IllegalArgumentException {
081: WindowImpl window = new WindowImpl(contentType, contentURI);
082: addChild(name, window);
083: window.setDeclaredProperty(
084: WindowImpl.PORTAL_PROP_WINDOW_CONTENT_TYPE, contentType
085: .toString());
086: return window;
087: }
088:
089: public int getType() {
090: return PortalObject.TYPE_PAGE;
091: }
092:
093: protected PortalObjectImpl cloneObject() {
094: PageImpl clone = new PageImpl();
095: clone.setDeclaredPropertyMap(new HashMap(
096: getDeclaredPropertyMap()));
097: clone.setListener(getListener());
098: clone.setDisplayName(getDisplayName());
099: return clone;
100: }
101: }
|