KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > pluto > om > PortletEntityListImpl


1 /*
2  * Copyright 2004,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.portal.pluto.om;
17
18 import java.util.HashMap JavaDoc;
19 import java.util.Iterator JavaDoc;
20 import java.util.Map JavaDoc;
21
22 import org.apache.cocoon.portal.coplet.CopletInstanceData;
23 import org.apache.cocoon.portal.pluto.om.common.ObjectIDImpl;
24 import org.apache.pluto.om.common.ObjectID;
25 import org.apache.pluto.om.entity.PortletApplicationEntity;
26 import org.apache.pluto.om.entity.PortletEntity;
27 import org.apache.pluto.om.entity.PortletEntityList;
28 import org.apache.pluto.om.entity.PortletEntityListCtrl;
29 import org.apache.pluto.om.portlet.PortletDefinition;
30
31 /**
32  *
33  *
34  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
35  *
36  * @version CVS $Id: PortletEntityListImpl.java 280331 2005-09-12 12:46:40Z cziegeler $
37  */

38 public class PortletEntityListImpl
39     implements PortletEntityList, PortletEntityListCtrl {
40
41     /** all portlet entities. */
42     protected Map JavaDoc portlets = new HashMap JavaDoc();
43     
44     /* (non-Javadoc)
45      * @see org.apache.pluto.om.entity.PortletEntityList#get(org.apache.pluto.om.common.ObjectID)
46      */

47     public PortletEntity get(ObjectID objectId) {
48         return (PortletEntity)this.portlets.get(objectId);
49     }
50
51
52     /* (non-Javadoc)
53      * @see org.apache.pluto.om.entity.PortletEntityList#iterator()
54      */

55     public Iterator JavaDoc iterator() {
56         return this.portlets.values().iterator();
57     }
58
59     /* (non-Javadoc)
60      * @see org.apache.pluto.om.entity.PortletEntityListCtrl#add(org.apache.pluto.om.entity.PortletApplicationEntity, java.lang.String)
61      */

62     public PortletEntity add(PortletApplicationEntity appEntity, String JavaDoc definitionId) {
63         // FIXME
64
PortletDefinitionRegistry registry = null;
65         PortletDefinition pd = registry.getPortletDefinition(ObjectIDImpl.createFromString(definitionId));
66         PortletApplicationEntity pae = registry.getPortletApplicationEntityList().get(ObjectIDImpl.createFromString("cocoon"));
67         CopletInstanceData coplet = null;
68         PortletEntity portletEntity = new PortletEntityImpl(pae, coplet, pd, registry.getPortalService());
69         this.portlets.put(portletEntity.getId(), portletEntity);
70         
71         return portletEntity;
72     }
73
74     /* (non-Javadoc)
75      * @see org.apache.pluto.om.entity.PortletEntityListCtrl#add(org.apache.pluto.om.entity.PortletApplicationEntity, java.lang.String)
76      */

77     public PortletEntity add(PortletApplicationEntity appEntity,
78                              String JavaDoc definitionId,
79                              CopletInstanceData coplet,
80                              PortletDefinitionRegistry registry) {
81         PortletDefinition pd = registry.getPortletDefinition(ObjectIDImpl.createFromString(definitionId));
82         PortletEntity portletEntity = new PortletEntityImpl(appEntity, coplet, pd, registry.getPortalService());
83         this.portlets.put(portletEntity.getId(), portletEntity);
84         
85         return portletEntity;
86     }
87     
88     /**
89      * Remove an entity
90      */

91     public void remove(PortletEntity entity) {
92         if ( entity != null ) {
93             this.portlets.remove(entity.getId());
94         }
95     }
96 }
97
Popular Tags