KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > deliver > portal > om > PortletEntityImpl


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23 package org.infoglue.deliver.portal.om;
24
25 import java.util.ArrayList JavaDoc;
26 import java.util.Iterator JavaDoc;
27 import java.util.Locale JavaDoc;
28
29 import org.apache.commons.logging.Log;
30 import org.apache.commons.logging.LogFactory;
31 import org.apache.pluto.om.common.Description;
32 import org.apache.pluto.om.common.ObjectID;
33 import org.apache.pluto.om.common.PreferenceSet;
34 import org.apache.pluto.om.entity.PortletApplicationEntity;
35 import org.apache.pluto.om.entity.PortletEntity;
36 import org.apache.pluto.om.portlet.PortletApplicationDefinition;
37 import org.apache.pluto.om.portlet.PortletDefinition;
38 import org.apache.pluto.om.window.PortletWindowList;
39 import org.apache.pluto.portalImpl.services.portletdefinitionregistry.PortletDefinitionRegistry;
40
41 /**
42  * @author jand
43  *
44  */

45 public class PortletEntityImpl implements PortletEntity {
46     private static final Log log = LogFactory.getLog(PortletEntityImpl.class);
47
48     private String JavaDoc portletName;
49     private PortletApplicationEntity applicationEntity;
50     private ArrayList JavaDoc preferences = new ArrayList JavaDoc();
51
52     /*
53      * (non-Javadoc)
54      *
55      * @see org.apache.pluto.om.entity.PortletEntity#getId()
56      */

57     public ObjectID getId() {
58         return org.apache.pluto.portalImpl.util.ObjectID.createFromString(portletName);
59     }
60
61     /*
62      * (non-Javadoc)
63      *
64      * @see org.apache.pluto.om.entity.PortletEntity#getPreferenceSet()
65      */

66     public PreferenceSet getPreferenceSet() {
67         return new PreferenceSetImpl(preferences);
68     }
69
70     public void setPreferenceSet(PreferenceSet p) {
71         this.preferences = new ArrayList JavaDoc();
72         for (Iterator JavaDoc it = p.iterator(); it.hasNext();) {
73             preferences.add(it.next());
74         }
75     }
76
77     /*
78      * (non-Javadoc)
79      *
80      * @see org.apache.pluto.om.entity.PortletEntity#getPortletDefinition()
81      */

82     public PortletDefinition getPortletDefinition() {
83         PortletDefinition def = PortletDefinitionRegistry.getPortletDefinition(getId());
84         if (def == null) {
85             log.error("Failed to lookup portlet-definition: " + portletName);
86             log.debug("Available portlet-definitions: ");
87             Iterator JavaDoc iterator =
88                 PortletDefinitionRegistry.getPortletApplicationDefinitionList().iterator();
89             while (iterator.hasNext()) {
90                 PortletApplicationDefinition papp = (PortletApplicationDefinition) iterator.next();
91
92                 // fill portletsKeyObjectId
93
Iterator JavaDoc portlets = papp.getPortletDefinitionList().iterator();
94                 while (portlets.hasNext()) {
95                     PortletDefinition portlet = (PortletDefinition) portlets.next();
96                     log.debug("Ok: " + portlet.getId());
97                 }
98
99             }
100         }
101         return def;
102     }
103
104     /*
105      * (non-Javadoc)
106      *
107      * @see org.apache.pluto.om.entity.PortletEntity#getPortletApplicationEntity()
108      */

109     public PortletApplicationEntity getPortletApplicationEntity() {
110         return applicationEntity;
111     }
112
113     /*
114      * (non-Javadoc)
115      *
116      * @see org.apache.pluto.om.entity.PortletEntity#getPortletWindowList()
117      */

118     public PortletWindowList getPortletWindowList() {
119         return new PortletWindowListImpl();
120     }
121
122     /*
123      * (non-Javadoc)
124      *
125      * @see org.apache.pluto.om.entity.PortletEntity#getDescription(java.util.Locale)
126      */

127     public Description getDescription(Locale JavaDoc locale) {
128         return getPortletDefinition().getDescription(locale);
129     }
130
131     /**
132      * @param portletApplicationEntity
133      * The portletApplicationEntity to set.
134      */

135     public void setPortletApplicationEntity(PortletApplicationEntity applicationEntity) {
136         this.applicationEntity = applicationEntity;
137     }
138
139     /**
140      * @param id The id to set.
141      */

142     public void setId(String JavaDoc id) {
143         this.portletName = id;
144     }
145
146     public String JavaDoc toString() {
147         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
148         buffer.append("PortletEntityImpl[ id:");
149         buffer.append(this.portletName.toString());
150         buffer.append(" preferences:");
151         buffer.append(this.preferences);
152         buffer.append("]");
153
154         return buffer.toString();
155     }
156 }
Popular Tags