SessionInfo info = this.getSessionInfo(request);
String name = (String) seq.getAttribute(AccessRightsDetailsForm.ATTR_RESOURCE_NAME, null);
String description = (String) seq.getAttribute(AccessRightsDetailsForm.ATTR_RESOURCE_DESCRIPTION, null);
PropertyList permissionList = (PropertyList) seq.getAttribute(AccessRightsPermissionsForm.ATTR_SELECTED_ACCESS_RIGHTS, null);
String permissionClass = (String) seq.getAttribute(AccessRightsDetailsForm.ATTR_RESOURCE_PERMISSION_CLASS, null);
AccessRights accessRights = null;
Calendar now = Calendar.getInstance();
try {
DefaultAccessRights defaultAccessRights = new DefaultAccessRights(info.getUser().getRealm().getRealmID(), 0, name, description, new ArrayList<AccessRight>(), permissionClass, now, now);
defaultAccessRights.setAllAccessRights(info.getHttpSession(), permissionList);
accessRights = PolicyDatabaseFactory.getInstance().createAccessRights(defaultAccessRights);
actionStatus.add(new WizardActionStatus(WizardActionStatus.COMPLETED_OK,
"accessRightsWizard.resourceFinish.status.resourceCreated"));
CoreEvent coreEvent = new CoreEvent(this, CoreEventConstants.CREATE_ACCESS_RIGHT, accessRights, info, CoreEvent.STATE_SUCCESSFUL)
.addAttribute(CoreAttributeConstants.EVENT_ATTR_RESOURCE_NAME, accessRights.getResourceName())
.addAttribute(CoreAttributeConstants.EVENT_ATTR_RESOURCE_DESCRIPTION, accessRights.getResourceDescription())
.addAttribute(CoreAttributeConstants.EVENT_ATTR_TYPE_ACCESS_RIGHT, getAccessRightType(request.getSession(), permissionClass));
List permissionsList = accessRights.getAccessRights();
if (permissionsList != null) {
int j =0;
for (Iterator i = permissionsList.iterator(); i.hasNext();) {
j++;
AccessRight permission = (AccessRight)i.next();
MessageResources mrPermission = CoreUtil.getMessageResources(request.getSession(), permission.getPermission().getBundle());
String permissionName = mrPermission.getMessage("permission."+permission.getPermission().getId()+".title").trim();
MessageResources mrResourceType = CoreUtil.getMessageResources(request.getSession(), permission.getResourceType().getBundle());
String resourceTypeName = mrResourceType.getMessage("resourceType."+permission.getResourceType().getResourceTypeId()+".title").trim();
coreEvent.addAttribute(CoreAttributeConstants.EVENT_ATTR_TYPE_PERMISSION + Integer.toString(j), permissionName + " " + resourceTypeName);
}
}
CoreServlet.getServlet().fireCoreEvent(coreEvent);
} catch (Exception e) {
log.error("Failed to create delegation resource.", e);
CoreServlet.getServlet().fireCoreEvent(new CoreEvent(this, CoreEventConstants.CREATE_ACCESS_RIGHT, accessRights, info, CoreEvent.STATE_UNSUCCESSFUL)
.addAttribute(CoreAttributeConstants.EVENT_ATTR_RESOURCE_NAME, accessRights.getResourceName())
.addAttribute(CoreAttributeConstants.EVENT_ATTR_RESOURCE_DESCRIPTION, accessRights.getResourceDescription())
.addAttribute(CoreAttributeConstants.EVENT_ATTR_TYPE_ACCESS_RIGHT, getAccessRightType(request.getSession(), permissionClass)));
actionStatus.add(new WizardActionStatus(WizardActionStatus.COMPLETED_WITH_ERRORS,
"accessRightsWizard.resourceFinish.status.failedToCreateResource", e.getMessage()));
}
if (accessRights != null) {