When adding new users in Jetspeed (1.5), Jetspeed adds a new profile based on a
default user's profile (Jetspeed resource "newuser.template"). This works fine if the
default users has only one PSML document.
If there are several docs, Jetspeed don't load the right one because the resource
"resource.default" is not used when retriving the document. It's only used when
storing new profile.
For example :
- jetspeed resources : newuser.template = anon / resource.default = default
- user anon has 4 psml docs (profiles) :
anon/html/default.psml
anon/html/sub1.psml
anon/html/sub2.psml
anon/html/sub3.psml
Adding a user 'foo' will create for him a new profile foo/html/default.psml associated
with a clone of sub3.psml
I think this method has to be updated :
public Profile createProfile( RunData data, Profile profile, String contentType,
String from )
throws ProfileException
{
if ((contentType == null) || (contentType.length() < 2)) {
contentType = "html";
}
if ((from == null) || (from.length() < 2)) {
from = "turbine";
}
if ((null == profile.getDocument()) ||
(!profile.getMediaType().equalsIgnoreCase (contentType))) {
if (profile.getDocument() == null)
System.out.println("[JetspeedProfilerService] ... profile doc is null");
else System.out.println("[JetspeedProfilerService] ... profile media-type is
"+profile.getMediaType());
// locate the default resource
// TODO: make this configurable
try {
ProfileLocator locator = createLocator();
locator.setUser( JetspeedSecurity.getUser(from) );
locator.setMediaType(contentType);
+ // Try to get the doc as configured in jetspeed resources
+ locator.setName(resourceDefault + resourceExt);
PSMLDocument doc = fallback(locator);
+ if (doc == null) {
+
+ // Doc not found, try without default name
+ locator.setName(null);
+ doc = fallback(locator);
+ }
if (doc != null) {
PSMLDocument clonedDoc = (PSMLDocument) SerializationUtils.clone(doc);
org.apache.jetspeed.util.PortletUtils.regenerateIds(clonedDoc.getPortlets());
profile.setDocument(clonedDoc);
}
profile.setName( resourceDefault + resourceExt );
}
catch (Exception e) {
logger.error( "Error creating profile", e );
throw new ProfileException(e.toString());
}
}
try
{
profile.setMediaType(contentType);
PSMLDocument doc = PsmlManager.createDocument(profile);
Profile newProfile = (Profile)profile.clone();
newProfile.setDocument(doc);
return newProfile;
}
catch (CloneNotSupportedException e)
{
logger.error("Could not clone profile locator object: ", e);
}
return null;
}
Now it works for me.
Laurent GUY
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]