use of org.gluu.persist.exception.mapping.BaseMappingException in project oxTrust by GluuFederation.
the class ManageCustomScriptAction method save.
public String save() {
try {
List<CustomScript> oldCustomScripts = customScriptService.findCustomScripts(Arrays.asList(this.applianceService.getCustomScriptTypes()), "dn", "inum");
List<String> updatedInums = new ArrayList<String>();
for (Entry<CustomScriptType, List<CustomScript>> customScriptsByType : this.customScriptsByTypes.entrySet()) {
List<CustomScript> customScripts = customScriptsByType.getValue();
for (CustomScript customScript : customScripts) {
String configId = customScript.getName();
if (StringHelper.equalsIgnoreCase(configId, OxConstants.SCRIPT_TYPE_INTERNAL_RESERVED_NAME)) {
facesMessages.add(FacesMessage.SEVERITY_ERROR, "'{0}' is reserved script name", configId);
return OxTrustConstants.RESULT_FAILURE;
}
customScript.setRevision(customScript.getRevision() + 1);
boolean update = true;
String dn = customScript.getDn();
String customScriptId = customScript.getInum();
if (StringHelper.isEmpty(dn)) {
String basedInum = organizationService.getOrganizationInum();
customScriptId = basedInum + "!" + INumGenerator.generate(2);
dn = customScriptService.buildDn(customScriptId);
customScript.setDn(dn);
customScript.setInum(customScriptId);
update = false;
}
;
customScript.setDn(dn);
customScript.setInum(customScriptId);
if (ScriptLocationType.LDAP == customScript.getLocationType()) {
customScript.removeModuleProperty(CustomScript.LOCATION_PATH_MODEL_PROPERTY);
}
if ((customScript.getConfigurationProperties() != null) && (customScript.getConfigurationProperties().size() == 0)) {
customScript.setConfigurationProperties(null);
}
if ((customScript.getConfigurationProperties() != null) && (customScript.getModuleProperties().size() == 0)) {
customScript.setModuleProperties(null);
}
updatedInums.add(customScriptId);
if (update) {
customScriptService.update(customScript);
} else {
customScriptService.add(customScript);
}
}
}
// Remove removed scripts
for (CustomScript oldCustomScript : oldCustomScripts) {
if (!updatedInums.contains(oldCustomScript.getInum())) {
customScriptService.remove(oldCustomScript);
}
}
} catch (BaseMappingException ex) {
log.error("Failed to update custom scripts", ex);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to update custom script configuration");
return OxTrustConstants.RESULT_FAILURE;
}
facesMessages.add(FacesMessage.SEVERITY_INFO, "Custom script configuration updated successfully");
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.gluu.persist.exception.mapping.BaseMappingException in project oxTrust by GluuFederation.
the class UpdateGroupAction method add.
public String add() throws Exception {
if (this.group != null) {
return OxTrustConstants.RESULT_SUCCESS;
}
this.update = false;
this.group = new GluuGroup();
this.group.setOwner(identity.getUser().getDn());
this.group.setOrganization(organizationService.getOrganization().getDn());
try {
this.members = getMemberDisplayNameEntiries();
} catch (BaseMappingException ex) {
log.error("Failed to prepare lists", ex);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to add new group");
conversationService.endConversation();
return OxTrustConstants.RESULT_FAILURE;
}
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.gluu.persist.exception.mapping.BaseMappingException in project oxTrust by GluuFederation.
the class UpdateOrganizationAction method initOxAuthSetting.
private void initOxAuthSetting() {
String configurationDn = configurationFactory.getConfigurationDn();
try {
ldapOxAuthConfiguration = organizationService.getOxAuthSetting(configurationDn);
this.webKeysSettings = ldapOxAuthConfiguration.getOxWebKeysSettings();
if (webKeysSettings == null) {
webKeysSettings = new WebKeysSettings();
}
} catch (BaseMappingException ex) {
log.error("Failed to load configuration from LDAP");
}
}
use of org.gluu.persist.exception.mapping.BaseMappingException in project oxTrust by GluuFederation.
the class UpdatePersonAction method save.
/**
* Saves person to ldap
*
* @return String describing success of the operation
*/
public String save() throws Exception {
if (!organizationService.isAllowPersonModification()) {
return OxTrustConstants.RESULT_FAILURE;
}
if (!update) {
if (!validatePerson(this.person)) {
return OxTrustConstants.RESULT_FAILURE;
}
}
updateCustomObjectClasses();
List<GluuCustomAttribute> removedAttributes = customAttributeAction.detectRemovedAttributes();
customAttributeAction.updateOriginCustomAttributes();
List<GluuCustomAttribute> customAttributes = customAttributeAction.getCustomAttributes();
for (GluuCustomAttribute customAttribute : customAttributes) {
if (customAttribute.getName().equalsIgnoreCase("gluuStatus")) {
customAttribute.setValue(gluuStatus.getValue());
}
}
this.person.setCustomAttributes(customAttributeAction.getCustomAttributes());
this.person.getCustomAttributes().addAll(removedAttributes);
// Sync email, in reverse ("oxTrustEmail" <- "mail")
this.person = ServiceUtil.syncEmailReverse(this.person, true);
boolean runScript = externalUpdateUserService.isEnabled();
if (update) {
try {
if (runScript) {
externalUpdateUserService.executeExternalUpdateUserMethods(this.person);
}
personService.updatePerson(this.person);
if (runScript) {
externalUpdateUserService.executeExternalPostUpdateUserMethods(this.person);
}
} catch (BaseMappingException ex) {
log.error("Failed to update person {}", inum, ex);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to update person '#{updatePersonAction.person.displayName}'");
return OxTrustConstants.RESULT_FAILURE;
}
facesMessages.add(FacesMessage.SEVERITY_INFO, "Person '#{updatePersonAction.person.displayName}' updated successfully");
} else {
if (personService.getPersonByUid(this.person.getUid()) != null) {
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Person with the uid '#{updatePersonAction.person.uid}' already exist'");
return OxTrustConstants.RESULT_DUPLICATE;
}
this.inum = personService.generateInumForNewPerson();
String iname = personService.generateInameForNewPerson(this.person.getUid());
String dn = personService.getDnForPerson(this.inum);
// Save person
this.person.setDn(dn);
this.person.setInum(this.inum);
this.person.setIname(iname);
this.person.setUserPassword(this.password);
List<GluuCustomAttribute> personAttributes = this.person.getCustomAttributes();
if (!personAttributes.contains(new GluuCustomAttribute("cn", ""))) {
List<GluuCustomAttribute> changedAttributes = new ArrayList<GluuCustomAttribute>();
changedAttributes.addAll(personAttributes);
changedAttributes.add(new GluuCustomAttribute("cn", this.person.getGivenName() + " " + this.person.getDisplayName()));
this.person.setCustomAttributes(changedAttributes);
} else {
this.person.setCommonName(this.person.getCommonName() + " " + this.person.getGivenName());
}
try {
if (runScript) {
externalUpdateUserService.executeExternalAddUserMethods(this.person);
}
personService.addPerson(this.person);
if (runScript) {
externalUpdateUserService.executeExternalPostAddUserMethods(this.person);
}
} catch (Exception ex) {
log.error("Failed to add new person {}", this.person.getInum(), ex);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to add new person'");
return OxTrustConstants.RESULT_FAILURE;
}
facesMessages.add(FacesMessage.SEVERITY_INFO, "New person '#{updatePersonAction.person.displayName}' added successfully");
conversationService.endConversation();
this.update = true;
}
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.gluu.persist.exception.mapping.BaseMappingException in project oxTrust by GluuFederation.
the class UpdateScopeAction method add.
public String add() throws Exception {
if (this.scope != null) {
return OxTrustConstants.RESULT_SUCCESS;
}
this.update = false;
this.scope = new OxAuthScope();
try {
if (this.scope.getOxAuthClaims() != null && this.scope.getOxAuthClaims().size() > 0) {
this.claims = getClaimDisplayNameEntiries();
} else {
this.claims = new ArrayList<DisplayNameEntry>();
}
} catch (BaseMappingException ex) {
log.error("Failed to load scopes", ex);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to add new scope");
conversationService.endConversation();
return OxTrustConstants.RESULT_FAILURE;
}
this.dynamicScripts = getInitialDynamicScripts();
return OxTrustConstants.RESULT_SUCCESS;
}
Aggregations