1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.pluto.portalImpl.om.entity.impl;
21
22 import java.util.Collection;
23 import java.util.Locale;
24
25 import org.apache.pluto.om.common.Description;
26 import org.apache.pluto.om.common.DescriptionSet;
27 import org.apache.pluto.om.common.ObjectID;
28 import org.apache.pluto.om.common.PreferenceSet;
29 import org.apache.pluto.om.entity.PortletApplicationEntity;
30 import org.apache.pluto.om.entity.PortletEntity;
31 import org.apache.pluto.om.entity.PortletEntityCtrl;
32 import org.apache.pluto.om.portlet.PortletDefinition;
33 import org.apache.pluto.om.window.PortletWindowList;
34 import org.apache.pluto.portalImpl.om.common.impl.DescriptionSetImpl;
35 import org.apache.pluto.portalImpl.services.portletentityregistry.PortletEntityRegistry;
36 import org.apache.pluto.util.StringUtils;
37
38 public class PortletEntityImpl
39 implements PortletEntity, PortletEntityCtrl, java.io.Serializable,
40 org.apache.pluto.portalImpl.om.common.Support {
41
42 private String id;
43 private String definitionId;
44
45 protected PreferenceSet preferences;
46
47 private PreferenceSet origPreferences;
48 private PortletApplicationEntity applicationEntity;
49 private PortletWindowList portletWindows;
50 private ObjectID objectId;
51 private DescriptionSet descriptions;
52
53 public PortletEntityImpl()
54 {
55 id = "";
56 definitionId = "";
57 preferences = new org.apache.pluto.portalImpl.om.common.impl.PreferenceSetImpl();
58 origPreferences = new org.apache.pluto.portalImpl.om.common.impl.PreferenceSetImpl();
59 portletWindows = new org.apache.pluto.portalImpl.om.window.impl.PortletWindowListImpl();
60 descriptions = new org.apache.pluto.portalImpl.om.common.impl.DescriptionSetImpl();
61 }
62
63
64
65 public ObjectID getId()
66 {
67 if (objectId==null && applicationEntity != null) {
68 objectId = org.apache.pluto.portalImpl.util.ObjectID.createFromString(applicationEntity.getId().toString()
69 + "." + id);
70 }
71 return objectId;
72 }
73
74 public PreferenceSet getPreferenceSet()
75 {
76 return preferences;
77 }
78
79 public PortletDefinition getPortletDefinition()
80 {
81 return applicationEntity.getPortletApplicationDefinition().getPortletDefinitionList().get(org.apache.pluto.portalImpl.util.ObjectID.createFromString(definitionId));
82 }
83
84 public void setPortletDefinition(PortletDefinition portletDefinition)
85 {
86 this.definitionId = portletDefinition.getId().toString();
87 }
88
89 public PortletApplicationEntity getPortletApplicationEntity()
90 {
91 return applicationEntity;
92 }
93
94 public PortletWindowList getPortletWindowList() {
95 return portletWindows;
96 }
97
98
99
100
101 public Description getDescription(Locale locale) {
102 return descriptions.get(locale);
103 }
104
105
106
107 public void setId(String id)
108 {
109 this.id = id;
110 objectId = null;
111 }
112
113 public void store() throws java.io.IOException
114 {
115 PortletEntityRegistry.store();
116
117
118 origPreferences = new org.apache.pluto.portalImpl.om.common.impl.PreferenceSetImpl();
119 ((org.apache.pluto.portalImpl.om.common.impl.PreferenceSetImpl)origPreferences).addAll((Collection)preferences);
120 }
121
122 public void reset() throws java.io.IOException
123 {
124
125 preferences = new org.apache.pluto.portalImpl.om.common.impl.PreferenceSetImpl();
126 ((org.apache.pluto.portalImpl.om.common.impl.PreferenceSetImpl)preferences).clear();
127 ((org.apache.pluto.portalImpl.om.common.impl.PreferenceSetImpl)preferences).addAll((Collection)origPreferences);
128 }
129
130
131
132 public void postLoad(Object parameter) throws Exception
133 {
134 }
135
136 public void preBuild(Object parameter) throws Exception
137 {
138 ((org.apache.pluto.portalImpl.om.common.impl.PreferenceSetImpl)origPreferences).addAll((Collection)preferences);
139 setPortletApplicationEntity((PortletApplicationEntity)parameter);
140 }
141
142 public void postBuild(Object parameter) throws Exception
143 {
144 }
145
146 public void preStore(Object parameter) throws Exception
147 {
148 }
149
150 public void postStore(Object parameter) throws Exception
151 {
152 }
153
154
155
156
157
158 public Collection getCastorPreferences()
159 {
160 return(org.apache.pluto.portalImpl.om.common.impl.PreferenceSetImpl)preferences;
161 }
162
163 protected void setPortletApplicationEntity(PortletApplicationEntity applicationEntity)
164 {
165 this.applicationEntity = applicationEntity;
166 }
167
168 protected void setPortletWindowList(PortletWindowList portletWindows)
169 {
170 this.portletWindows = portletWindows;
171 }
172
173
174 public String getCastorId() {
175
176
177
178
179
180 return id.length() > 0 ? id : null;
181 }
182
183 public void setCastorId(String id) {
184 setId(id);
185 }
186
187 public String getDefinitionId()
188 {
189 return definitionId;
190 }
191
192 public void setDefinitionId(String definitionId)
193 {
194 this.definitionId = definitionId;
195 }
196
197
198
199 public String toString()
200 {
201 return toString(0);
202 }
203
204 public String toString(int indent)
205 {
206 StringBuffer buffer = new StringBuffer(1000);
207 StringUtils.newLine(buffer,indent);
208 buffer.append(getClass().toString()); buffer.append(":");
209 StringUtils.newLine(buffer,indent);
210 buffer.append("{");
211 StringUtils.newLine(buffer,indent);
212 buffer.append("id='");
213 buffer.append(id);
214 buffer.append("'");
215 StringUtils.newLine(buffer,indent);
216 buffer.append("definition-id='");
217 buffer.append(definitionId);
218 buffer.append("'");
219
220 StringUtils.newLine(buffer,indent);
221 buffer.append(((org.apache.pluto.portalImpl.om.common.impl.PreferenceSetImpl)preferences).toString(indent));
222 StringUtils.newLine(buffer,indent);
223 buffer.append(((DescriptionSetImpl) descriptions).toString(indent));
224
225 StringUtils.newLine(buffer,indent);
226 buffer.append("}");
227 return buffer.toString();
228 }
229 }