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.cocoon.portal.pluto.om;
018:
019: import java.util.HashMap;
020: import java.util.Iterator;
021: import java.util.Map;
022:
023: import org.apache.cocoon.portal.coplet.CopletInstanceData;
024: import org.apache.cocoon.portal.pluto.om.common.ObjectIDImpl;
025: import org.apache.pluto.om.common.ObjectID;
026: import org.apache.pluto.om.entity.PortletApplicationEntity;
027: import org.apache.pluto.om.entity.PortletEntity;
028: import org.apache.pluto.om.entity.PortletEntityList;
029: import org.apache.pluto.om.entity.PortletEntityListCtrl;
030: import org.apache.pluto.om.portlet.PortletDefinition;
031:
032: /**
033: *
034: *
035: * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
036: *
037: * @version CVS $Id: PortletEntityListImpl.java 433543 2006-08-22 06:22:54Z crossley $
038: */
039: public class PortletEntityListImpl implements PortletEntityList,
040: PortletEntityListCtrl {
041:
042: /** all portlet entities. */
043: protected Map portlets = new HashMap();
044:
045: /* (non-Javadoc)
046: * @see org.apache.pluto.om.entity.PortletEntityList#get(org.apache.pluto.om.common.ObjectID)
047: */
048: public PortletEntity get(ObjectID objectId) {
049: return (PortletEntity) this .portlets.get(objectId);
050: }
051:
052: /* (non-Javadoc)
053: * @see org.apache.pluto.om.entity.PortletEntityList#iterator()
054: */
055: public Iterator iterator() {
056: return this .portlets.values().iterator();
057: }
058:
059: /* (non-Javadoc)
060: * @see org.apache.pluto.om.entity.PortletEntityListCtrl#add(org.apache.pluto.om.entity.PortletApplicationEntity, java.lang.String)
061: */
062: public PortletEntity add(PortletApplicationEntity appEntity,
063: String definitionId) {
064: // FIXME
065: PortletDefinitionRegistry registry = null;
066: PortletDefinition pd = registry
067: .getPortletDefinition(ObjectIDImpl
068: .createFromString(definitionId));
069: PortletApplicationEntity pae = registry
070: .getPortletApplicationEntityList().get(
071: ObjectIDImpl.createFromString("cocoon"));
072: CopletInstanceData coplet = null;
073: PortletEntity portletEntity = new PortletEntityImpl(pae,
074: coplet, pd, registry.getPortalService());
075: this .portlets.put(portletEntity.getId(), portletEntity);
076:
077: return portletEntity;
078: }
079:
080: /* (non-Javadoc)
081: * @see org.apache.pluto.om.entity.PortletEntityListCtrl#add(org.apache.pluto.om.entity.PortletApplicationEntity, java.lang.String)
082: */
083: public PortletEntity add(PortletApplicationEntity appEntity,
084: String definitionId, CopletInstanceData coplet,
085: PortletDefinitionRegistry registry) {
086: PortletDefinition pd = registry
087: .getPortletDefinition(ObjectIDImpl
088: .createFromString(definitionId));
089: PortletEntity portletEntity = new PortletEntityImpl(appEntity,
090: coplet, pd, registry.getPortalService());
091: this .portlets.put(portletEntity.getId(), portletEntity);
092:
093: return portletEntity;
094: }
095:
096: /**
097: * Remove an entity
098: */
099: public void remove(PortletEntity entity) {
100: if (entity != null) {
101: this.portlets.remove(entity.getId());
102: }
103: }
104: }
|