KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > pluto > portalImpl > om > entity > impl > PortletApplicationEntityImpl


1 /*
2  * Copyright 2003,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 /*
17
18  */

19
20 package org.apache.pluto.portalImpl.om.entity.impl;
21
22 import java.util.Collection JavaDoc;
23 import java.util.Iterator JavaDoc;
24
25 import org.apache.pluto.om.common.ObjectID;
26 import org.apache.pluto.om.entity.PortletApplicationEntity;
27 import org.apache.pluto.om.entity.PortletEntityList;
28 import org.apache.pluto.om.portlet.PortletApplicationDefinition;
29 import org.apache.pluto.portalImpl.services.portletdefinitionregistry.PortletDefinitionRegistry;
30 import org.apache.pluto.util.StringUtils;
31
32 public class PortletApplicationEntityImpl
33 implements PortletApplicationEntity, java.io.Serializable JavaDoc,
34 org.apache.pluto.portalImpl.om.common.Support {
35
36     private String JavaDoc id = "";
37     private String JavaDoc definitionId = "";
38     private PortletEntityList portlets = new PortletEntityListImpl();
39
40     private ObjectID objectId = null;
41
42     // PortletApplicationEntity implementation.
43

44     public ObjectID getId()
45     {
46         if (objectId==null) {
47             objectId = org.apache.pluto.portalImpl.util.ObjectID.createFromString(id);
48         }
49         return objectId;
50     }
51
52     public PortletEntityList getPortletEntityList()
53     {
54         return portlets;
55     }
56
57     public PortletApplicationDefinition getPortletApplicationDefinition()
58     {
59         return PortletDefinitionRegistry.getPortletApplicationDefinitionList().get(
60                                                                                   org.apache.pluto.portalImpl.util.ObjectID.createFromString(definitionId));
61     }
62
63     // additional methods.
64

65     // additional internal methods
66

67     public void setId(String JavaDoc id)
68     {
69         this.id = id;
70         objectId= null;
71     }
72
73     public Collection JavaDoc getCastorPortlets()
74     {
75         return(PortletEntityListImpl)portlets;
76     }
77
78     public void postLoad(Object JavaDoc parameter) throws Exception JavaDoc
79     {
80     }
81
82     public void preBuild(Object JavaDoc parameter) throws Exception JavaDoc
83     {
84         Iterator JavaDoc iterator = portlets.iterator();
85         while (iterator.hasNext()) {
86             ((PortletEntityImpl)iterator.next()).preBuild(this);
87         }
88     }
89
90     public void postBuild(Object JavaDoc parameter) throws Exception JavaDoc
91     {
92     }
93
94     public void preStore(Object JavaDoc parameter) throws Exception JavaDoc
95     {
96     }
97
98     public void postStore(Object JavaDoc parameter) throws Exception JavaDoc
99     {
100     }
101
102     // internal methods used for castor only
103
public String JavaDoc getCastorId() {
104         return getId().toString();
105     }
106
107     public void setCastorId(String JavaDoc id) {
108         setId(id);
109     }
110
111     public String JavaDoc getDefinitionId()
112     {
113         return definitionId;
114     }
115
116     public void setDefinitionId(String JavaDoc definitionId)
117     {
118         this.definitionId = definitionId;
119     }
120
121     // internal methods used for debugging purposes only
122

123     public String JavaDoc toString()
124     {
125         return toString(0);
126     }
127
128     public String JavaDoc toString(int indent)
129     {
130         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(1000);
131         StringUtils.newLine(buffer,indent);
132         buffer.append(getClass().toString()); buffer.append(":");
133         StringUtils.newLine(buffer,indent);
134         buffer.append("{");
135         StringUtils.newLine(buffer,indent);
136         buffer.append("id='");
137         buffer.append(id);
138         buffer.append("'");
139         StringUtils.newLine(buffer,indent);
140         buffer.append("definition-id='");
141         buffer.append(definitionId);
142         buffer.append("'");
143
144         StringUtils.newLine(buffer,indent);
145         buffer.append(((org.apache.pluto.portalImpl.om.entity.impl.PortletEntityListImpl)portlets).toString(indent));
146
147         StringUtils.newLine(buffer,indent);
148         buffer.append("}");
149         return buffer.toString();
150     }
151
152 }
153
Popular Tags