*/
public ActionForward commit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
ActionMessages messages = new ActionMessages();
User user = LogonControllerFactory.getInstance().getUser(request);
PropertyProfileForm profileForm = (PropertyProfileForm) form;
PropertyProfile profile = (PropertyProfile) profileForm.getResource();
if (profileForm.getPropertyScope().equals(Constants.SCOPE_GLOBAL)) {
PolicyUtil.checkPermissions(PolicyConstants.PROFILE_RESOURCE_TYPE, new Permission[] {
PolicyConstants.PERM_CREATE_EDIT_AND_ASSIGN, PolicyConstants.PERM_EDIT_AND_ASSIGN,
PolicyConstants.PERM_ASSIGN }, request);
} else {
PolicyUtil.checkPermission(PolicyConstants.PERSONAL_PROFILE_RESOURCE_TYPE, PolicyConstants.PERM_MAINTAIN, request);
}
profileForm.apply();
if (profileForm.getEditing()) {
PolicyDatabaseFactory.getInstance().attachResourceToPolicyList(profile, profileForm.getSelectedPoliciesList(),
getSessionInfo(request));
profile.getResourceType().updateResource(profile, getSessionInfo(request));
} else {
int baseOn = profileForm.getSelectedPropertyProfile();
User owner = profileForm.getOwner();
int realmId = user.getRealm().getRealmID();
try {
PropertyProfile newProfile = ProfilesFactory.getInstance().createPropertyProfile(
owner == null ? null : owner.getPrincipalName(), profile.getResourceName(), profile.getResourceDescription(),
baseOn, realmId);
PolicyDatabaseFactory.getInstance().attachResourceToPolicyList(newProfile, profileForm.getSelectedPoliciesList(),
getSessionInfo(request));
CoreServlet.getServlet().fireCoreEvent(
new ResourceChangeEvent(this, CoreEventConstants.CREATE_PROPERTY_PROFILE, newProfile, getSessionInfo(request),
ResourceChangeEvent.STATE_SUCCESSFUL));
profileForm.setResource(newProfile);
} catch (Exception e) {
CoreServlet.getServlet().fireCoreEvent(
new ResourceChangeEvent(this, CoreEventConstants.CREATE_PROPERTY_PROFILE, getSessionInfo(request), e));
throw e;
}