// validate that its not an 'blank' profile -- not allowed
//
if (name == null || name.trim().length() == 0)
{
JetspeedLink link = JetspeedLinkFactory.getInstance(rundata);
DynamicURI duri = link.getPaneByName(PSML_UPDATE_PANE)
.addPathInfo(SecurityConstants.PARAM_MODE,
SecurityConstants.PARAM_MODE_INSERT)
.addPathInfo(SecurityConstants.PARAM_MSGID,
SecurityConstants.MID_INVALID_ENTITY_NAME);
JetspeedLinkFactory.putInstance(link);
rundata.setRedirectURI(duri.toString());
//save user entered values
if (locator != null)
rundata.getUser().setTemp(TEMP_LOCATOR, locator);
if (categoryName != null)
rundata.getUser().setTemp(CATEGORY_NAME, categoryName);
if (categoryValue != null)
rundata.getUser().setTemp(CATEGORY_VALUE, categoryValue);
if (copyFrom != null)
rundata.getUser().setTemp(COPY_FROM, copyFrom);
return;
}
//
// retrieve the profile to clone
//
ProfileLocator baseLocator = Profiler.createLocator();
baseLocator.createFromPath(copyFrom);
Profile baseProfile = Profiler.getProfile(baseLocator);
//
// create a new profile
//
if(baseProfile != null)
{
PSMLDocument doc = baseProfile.getDocument();
if(doc != null)
{
Portlets portlets = doc.getPortlets();
Portlets clonedPortlets = (Portlets) SerializationUtils.clone(portlets);
org.apache.jetspeed.util.PortletUtils.regenerateIds(clonedPortlets);
profile = Profiler.createProfile(locator, clonedPortlets);
}
else
{
profile = Profiler.createProfile(locator, null);
}
setRefreshPsmlFlag(rundata, TRUE);
}
else
{
logger.error("Profile listed in Copy From Not Found!");
}
}
catch (EntityExistsException e)
{
// log the error msg
logger.error("Exception", e);
//
// dup key found - display error message - bring back to same screen
//
JetspeedLink link = JetspeedLinkFactory.getInstance(rundata);
DynamicURI duri = link.getPaneByName(PSML_UPDATE_PANE)
.addPathInfo(SecurityConstants.PARAM_MODE,
SecurityConstants.PARAM_MODE_INSERT)
.addPathInfo(SecurityConstants.PARAM_MSGID,
SecurityConstants.MID_ENTITY_ALREADY_EXISTS);
JetspeedLinkFactory.putInstance(link);
rundata.setRedirectURI(duri.toString());
}
catch (Exception e)
{
// log the error msg
logger.error("Exception", e);
//
// dup key found - display error message - bring back to same screen
//
JetspeedLink link = JetspeedLinkFactory.getInstance(rundata);
DynamicURI duri = link.getPaneByName(PSML_UPDATE_PANE)
.addPathInfo(SecurityConstants.PARAM_MODE,
SecurityConstants.PARAM_MODE_INSERT)
.addPathInfo(SecurityConstants.PARAM_MSGID,
SecurityConstants.MID_UPDATE_FAILED);
JetspeedLinkFactory.putInstance(link);
rundata.setRedirectURI(duri.toString());
}
// save values that user just entered so they don't have to re-enter
if (locator != null)
rundata.getUser().setTemp(TEMP_LOCATOR, locator);
if (categoryName != null)