1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.om.profile;
18
19 import org.apache.jetspeed.portal.PortletSet;
20 import org.apache.jetspeed.services.PortalToolkit;
21 import org.apache.jetspeed.services.PsmlManager;
22
23 /***
24 Provides base functionality within a Registry.
25
26 @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 */
29
30 public class BaseProfile extends BaseProfileLocator implements Profile
31 {
32
33 protected PSMLDocument document = null;
34
35 public BaseProfile()
36 {}
37
38 public BaseProfile(ProfileLocator locator)
39 {
40 init(locator);
41 }
42
43 public void init(ProfileLocator locator)
44 {
45 this.setAnonymous(locator.getAnonymous());
46 this.setCountry(locator.getCountry());
47 this.setGroup(locator.getGroup());
48 this.setLanguage(locator.getLanguage());
49 this.setMediaType(locator.getMediaType());
50 this.setName(locator.getName());
51 this.setRole(locator.getRole());
52 this.setUser(locator.getUser());
53 }
54
55 /***
56 * @see Object#clone
57 * @return an instance copy of this object
58 */
59 public Object clone() throws java.lang.CloneNotSupportedException
60 {
61 Object cloned = super.clone();
62
63
64 ((BaseProfile)cloned).document = ((this.document == null) ? null : (PSMLDocument) this.document.clone());
65
66 return cloned;
67 }
68
69 /***
70 Gets the root set of portlets for this profile object.
71
72 @return The root portlet set for this profile.
73 */
74 public PortletSet getRootSet()
75 {
76 return PortalToolkit.getSet( getDocument().getPortlets() );
77 }
78
79 /***
80 Gets the root set of portlets for this profile object.
81
82 @return The root portlet set for this profile.
83 */
84 public PSMLDocument getDocument()
85 {
86 synchronized (this)
87 {
88 if ((this.document == null) || (this.document.getPortlets() == null))
89 {
90 this.document = PsmlManager.getDocument(this);
91 }
92 }
93
94 return this.document;
95 }
96
97
98
99
100
101
102 public void setDocument(PSMLDocument document)
103 {
104 this.document = document;
105 }
106
107 /***
108 stores the resource by merging and rewriting the psml file
109
110 @throws ProfileException if an error occurs storing the profile
111 */
112 public void store() throws ProfileException
113 {
114 if (document != null)
115 {
116 PsmlManager.store(this);
117 }
118 }
119
120 /***
121 provide useful info for ease of debugging
122 */
123 public String toString()
124 {
125 return "BaseProfile["+ getId() + "]";
126
127
128
129
130
131
132
133
134 }
135
136
137 }