{
context.put(SecurityConstants.PARAM_MSG, SecurityConstants.MESSAGES[id]);
}
// get the bad entered data and put it back for convenient update
ProfileLocator locator = (ProfileLocator) rundata.getUser().getTemp(TEMP_LOCATOR);
if (locator != null)
{
context.put("profile", Profiler.createProfile(locator));
}
}
String mode = rundata.getParameters().getString(SecurityConstants.PARAM_MODE);
context.put(SecurityConstants.PARAM_MODE, mode);
String path = rundata.getParameters().getString(SecurityConstants.PARAM_ENTITY_ID);
if (mode != null && mode.equals(SecurityConstants.PARAM_MODE_DELETE))
{
ProfileLocator locator = Profiler.createLocator();
locator.createFromPath(path);
Profile profile = Profiler.getProfile(locator);
if (profile != null)
{
rundata.getUser().setTemp(TEMP_LOCATOR, locator);
context.put("profile", profile);
}
else
{
logger.error("Profile for Path:" + path + " Not Found!");
}
}
if (mode != null && mode.equals(SecurityConstants.PARAM_MODE_INSERT))
{
org.apache.jetspeed.om.registry.Registry mediaTypes = Registry.get(Registry.MEDIA_TYPE);
context.put("mediaTypes", mediaTypes.listEntryNames());
JetspeedRunData jdata = (JetspeedRunData) rundata;
context.put("defMediaType", jdata.getCapability().getPreferredMediaType());
if (msgid == null)
{
if (((String) context.get("can-clone")).equals("false"))
{
context.put(CATEGORY_NAME, "user");
context.put("categoryValue", rundata.getUser().getUserName());
context.put("copyFrom", "none");
context.put("title", "My Page");
}
else if (path == null)
{
context.put(CATEGORY_NAME, "user");
context.put("categoryValue", "anon");
context.put("copyFrom", "user/anon/media-type/html/page/default.psml");
}
else
{
ProfileLocator tmpLocator = Profiler.createLocator();
tmpLocator.createFromPath(path);
Profile profile = Profiler.getProfile(tmpLocator);
if (profile != null)
{
rundata.getUser().setTemp(TEMP_LOCATOR, tmpLocator);
context.put("profile", profile);
context.put("title", profile.getRootSet().getTitle());
}
String categoryName = "group";
String categoryValue = tmpLocator.getGroupName();
if (categoryValue == null)
{
categoryName = "role";
categoryValue = tmpLocator.getRoleName();
if (categoryValue == null)
{
categoryName = "user";
categoryValue = tmpLocator.getUserName();
if (categoryValue == null)
{
categoryName = "user";
categoryValue = "anon";
}
}
}
context.put(CATEGORY_NAME, categoryName);
context.put("categoryValue", categoryValue);
context.put("copyFrom", path);
}
}
else
{
context.put(CATEGORY_NAME, rundata.getUser().getTemp(CATEGORY_NAME));
context.put(CATEGORY_VALUE, rundata.getUser().getTemp(CATEGORY_VALUE));
context.put(COPY_FROM, rundata.getUser().getTemp(COPY_FROM));
}
}
if (mode != null && mode.equals("export"))
{
if (msgid == null)
{
String tmpPath = JetspeedResources.getString(JetspeedResources.TEMP_DIRECTORY_KEY, "/tmp");
String exportPath = JetspeedResources.getString("psml.export.default.path",
TurbineServlet.getRealPath(tmpPath));
if (path == null)
{
context.put(COPY_TO, exportPath);
context.put(COPY_FROM,
Profiler.PARAM_USER +
File.separator +
Profiler.PARAM_ANON +
File.separator +
Profiler.PARAM_MEDIA_TYPE +
File.separator +
"html" +
File.separator +
Profiler.PARAM_PAGE +
File.separator +
Profiler.FULL_DEFAULT_PROFILE);
}
else
{
ProfileLocator tmpLocator = Profiler.createLocator();
tmpLocator.createFromPath(path);
Profile profile = Profiler.getProfile(tmpLocator);
if (profile != null)
{
rundata.getUser().setTemp(TEMP_LOCATOR, tmpLocator);
context.put("profile", profile);
}
String categoryName = Profiler.PARAM_GROUP;
String categoryValue = tmpLocator.getGroupName();
if (categoryValue == null)
{
categoryName = Profiler.PARAM_ROLE;
categoryValue = tmpLocator.getRoleName();
if (categoryValue == null)
{
categoryName = Profiler.PARAM_USER;
categoryValue = tmpLocator.getUserName();
if (categoryValue == null)
{
categoryName = Profiler.PARAM_USER;
categoryValue = Profiler.PARAM_ANON;
}
}
}
context.put(COPY_TO, exportPath + File.separator + tmpLocator.getName());
context.put(COPY_FROM, path);
}
}
else
{
context.put(COPY_TO, rundata.getUser().getTemp(COPY_TO));
context.put(COPY_FROM, rundata.getUser().getTemp(COPY_FROM));
}
}
if (mode != null && mode.equals("export_all"))
{
if (msgid == null)
{
// get the PSML Root Directory
ResourceService serviceConf = ((TurbineServices) TurbineServices.getInstance())
.getResources(PsmlManagerService.SERVICE_NAME);
String root = serviceConf.getString("root", "/WEB-INF/psml");
context.put(COPY_TO, TurbineServlet.getRealPath(root));
}
else
{
context.put(COPY_TO, rundata.getUser().getTemp(COPY_TO));
}
}
if (mode != null && mode.equals("import"))
{
org.apache.jetspeed.om.registry.Registry mediaTypes = Registry.get(Registry.MEDIA_TYPE);
context.put("mediaTypes", mediaTypes.listEntryNames());
if (msgid == null)
{
// get the PSML Root Directory
ResourceService serviceConf = ((TurbineServices) TurbineServices.getInstance())
.getResources(PsmlManagerService.SERVICE_NAME);
String root = serviceConf.getString("root", "/WEB-INF/psml");
root = TurbineServlet.getRealPath(root);
if (path == null)
{
context.put(CATEGORY_NAME, Profiler.PARAM_USER);
context.put("categoryValue", Profiler.PARAM_ANON);
context.put("copyFrom",
root +
File.separator +
Profiler.PARAM_USER +
File.separator +
Profiler.PARAM_ANON +
File.separator +
Profiler.PARAM_MEDIA_TYPE +
File.separator +
"html" +
File.separator +
Profiler.PARAM_PAGE +
File.separator +
Profiler.FULL_DEFAULT_PROFILE);
}
else
{
ProfileLocator tmpLocator = Profiler.createLocator();
tmpLocator.createFromPath(path);
Profile profile = Profiler.getProfile(tmpLocator);
if (profile != null)
{
rundata.getUser().setTemp(TEMP_LOCATOR, tmpLocator);
context.put("profile", profile);
}
String categoryName = Profiler.PARAM_GROUP;
String categoryValue = tmpLocator.getGroupName();
if (categoryValue == null)
{
categoryName = Profiler.PARAM_ROLE;
categoryValue = tmpLocator.getRoleName();
if (categoryValue == null)
{
categoryName = Profiler.PARAM_USER;
categoryValue = tmpLocator.getUserName();
if (categoryValue == null)
{
categoryName = Profiler.PARAM_USER;
categoryValue = Profiler.PARAM_ANON;
}