*/
public void doImport(RunData rundata, Context context)
throws Exception
{
Profile profile = null;
ProfileLocator locator = null;
String categoryName = null;
String categoryValue = null;
String copyFrom = null;
String name = null;
try
{
categoryName = rundata.getParameters().getString("CategoryName");
categoryValue = rundata.getParameters().getString("CategoryValue");
copyFrom = rundata.getParameters().getString("CopyFrom");
name = rundata.getParameters().getString("name");
//
//create a new locator and set its values according to users input
//
locator = Profiler.createLocator();
if (categoryName.equalsIgnoreCase(Profiler.PARAM_GROUP))
{
locator.setGroupByName(categoryValue);
}
else if (categoryName.equalsIgnoreCase(Profiler.PARAM_ROLE))
{
locator.setRoleByName(categoryValue);
}
else if (categoryName.equalsIgnoreCase(Profiler.PARAM_USER))
{
locator.setUser(JetspeedSecurity.getUser(categoryValue));
}
else
{
locator.setAnonymous(true);
}
String tempVar = rundata.getParameters().getString("MediaType");
if (tempVar != null && tempVar.trim().length() > 0)
{
locator.setMediaType(tempVar);
}
tempVar = rundata.getParameters().getString("Language");
if (tempVar != null && tempVar.trim().length() > 0)
{
locator.setLanguage(tempVar);
}
tempVar = rundata.getParameters().getString("Country");
if (tempVar != null && tempVar.trim().length() > 0)
{
locator.setCountry(tempVar);
}
locator.setName(name);
//
// validate that its not an 'blank' profile -- not allowed
//
if (name == null || name.trim().length() == 0)
{
JetspeedLink link = JetspeedLinkFactory.getInstance(rundata);
DynamicURI duri = link.addPathInfo(SecurityConstants.PARAM_MODE,
"import")
.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 document to import
//
PSMLDocument doc = this.loadDocument(copyFrom);
//
// create a new profile
//
if (doc != null)
{
Portlets portlets = doc.getPortlets();
//
// Profiler does not provide update capability - must remove before replacing
//
if (PsmlManager.getDocument(locator) != null)
{
Profiler.removeProfile(locator);
}
profile = Profiler.createProfile(locator, portlets);
}
else
{
throw new Exception("Failed to load PSML document from disk");
}
rundata.addMessage("Profile for [" + locator.getPath() + "] has been imported from file [" + copyFrom + "]<br>");
setRefreshPsmlFlag(rundata, TRUE);
goBackToBrowser(rundata);
}