duri.addPathInfo(SecurityConstants.PANE_NAME, SecurityConstants.PANEID_ROLEPERMISSION_UPDATE);
duri.addPathInfo(SecurityConstants.PARAM_MSGID, SecurityConstants.MID_MISSING_PARAMETER);
rundata.setRedirectURI(duri.toString());
return;
}
Role role = JetspeedSecurity.getRole(entityid);
if (null == role)
{
logger.error("RolePermissionBrowser: Failed to get role: " + entityid );
DynamicURI duri = new DynamicURI (rundata);
duri.addPathInfo(SecurityConstants.PANE_NAME, SecurityConstants.PANEID_ROLEPERMISSION_UPDATE);
duri.addPathInfo(SecurityConstants.PARAM_MSGID, SecurityConstants.MID_MISSING_PARAMETER);
rundata.setRedirectURI(duri.toString());
return;
}
try
{
List permissions = (List)rundata.getUser().getTemp(SecurityConstants.CONTEXT_PERMISSIONS);
List selected = (List)rundata.getUser().getTemp(SecurityConstants.CONTEXT_SELECTED);
if (permissions == null || selected == null)
{
DynamicURI duri = new DynamicURI (rundata);
duri.addPathInfo(SecurityConstants.PANE_NAME, SecurityConstants.PANEID_ROLEPERMISSION_UPDATE);
duri.addPathInfo(SecurityConstants.PARAM_MSGID, SecurityConstants.MID_MISSING_PARAMETER);
rundata.setRedirectURI(duri.toString());
return;
}
//
// walk thru all the permissions, see if anything changed
// if changed, update the database
//
for (int ix = 0; ix < permissions.size(); ix++)
{
String permissionName = ((Permission)permissions.get(ix)).getName();
boolean newValue = rundata.getParameters().getBoolean("box_" + permissionName, false);
boolean oldValue = ((Boolean)selected.get(ix + 1)).booleanValue();
if (newValue != oldValue)
{
if (newValue == true)
{
// grant a permission to a role
JetspeedSecurity.grantPermission(role.getName(), permissionName);
}
else
{
// revoke a permission from a role
JetspeedSecurity.revokePermission(role.getName(), permissionName);
}
}
}
// clear the temp values
rundata.getUser().setTemp(SecurityConstants.CONTEXT_PERMISSIONS, null);
rundata.getUser().setTemp(SecurityConstants.CONTEXT_SELECTED, null);
}
catch (Exception e)
{
// log the error msg
logger.error("Failed update role+permission", e);
//
// error on update - display error message
//
DynamicURI duri = new DynamicURI (rundata);
duri.addPathInfo(SecurityConstants.PANE_NAME, SecurityConstants.PANEID_ROLEPERMISSION_UPDATE);
duri.addPathInfo(SecurityConstants.PARAM_MSGID, SecurityConstants.MID_UPDATE_FAILED);
if (role != null)
duri.addPathInfo(SecurityConstants.PARAM_ENTITY_ID, role.getName());
rundata.setRedirectURI(duri.toString());
}
}