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