1/*2 * Copyright 2000-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 at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * 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 and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.om.profile;
1819import org.apache.jetspeed.portal.PortletSet;
20import org.apache.jetspeed.services.PortalToolkit;
21import org.apache.jetspeed.services.PsmlManager;
2223/***24Provides base functionality within a Registry.2526@author <a href="mailto:taylor@apache.org">David Sean Taylor</a>27@version $Id: BaseProfile.java,v 1.19 2004/02/23 03:05:01 jford Exp $28*/2930publicclassBaseProfileextends BaseProfileLocator implements Profile
31 {
3233protectedPSMLDocument document = null;
3435publicBaseProfile()
36 {}
3738publicBaseProfile(ProfileLocator locator)
39 {
40 init(locator);
41 }
4243publicvoid init(ProfileLocator locator)
44 {
45this.setAnonymous(locator.getAnonymous());
46this.setCountry(locator.getCountry());
47this.setGroup(locator.getGroup());
48this.setLanguage(locator.getLanguage());
49this.setMediaType(locator.getMediaType());
50this.setName(locator.getName());
51this.setRole(locator.getRole());
52this.setUser(locator.getUser());
53 }
5455/***56 * @see Object#clone57 * @return an instance copy of this object58 */59public Object clone() throws java.lang.CloneNotSupportedException
60 {
61 Object cloned = super.clone();
6263// clone the document64 ((BaseProfile)cloned).document = ((this.document == null) ? null : (PSMLDocument) this.document.clone());
6566return cloned;
67 }
6869/***70 Gets the root set of portlets for this profile object.7172 @return The root portlet set for this profile.73 */74publicPortletSet getRootSet()
75 {
76return PortalToolkit.getSet( getDocument().getPortlets() );
77 }
7879/***80 Gets the root set of portlets for this profile object.8182 @return The root portlet set for this profile.83 */84publicPSMLDocument getDocument()
85 {
86synchronized (this)
87 {
88if ((this.document == null) || (this.document.getPortlets() == null))
89 {
90this.document = PsmlManager.getDocument(this);
91 }
92 }
9394returnthis.document;
95 }
9697/*98 * Sets the psml document attached to this profile99 *100 * @param The PSML document for this profile.101 */102publicvoid setDocument(PSMLDocument document)
103 {
104this.document = document;
105 }
106107/***108 stores the resource by merging and rewriting the psml file109110 @throws ProfileException if an error occurs storing the profile111 */112publicvoid store() throws ProfileException
113 {
114if (document != null)
115 {
116 PsmlManager.store(this);
117 }
118 }
119120/***121 provide useful info for ease of debugging122 */123public String toString()
124 {
125return"BaseProfile["+ getId() + "]"; /*126 getUser().getUserName()+","+127 getGroup().getName()+","+128 getRole().getName()+","+129 (getAnonymous() ? "anon,":"")+130 getMediaType()+","+131 getCountry()+","+132 getLanguage()+","+133 getName()+"]"; */134 }
135136137 }