use of com.sun.identity.idsvcs.IdentityDetails in project OpenAM by OpenRock.
the class IdentityResourceV2 method updateInstance.
/**
* Updates an instance given a JSON object with User Attributes
* @param admin Token that has administrative privileges
* @param details Json Value containing details of user identity
* @return A successful promise if the update was successful
*/
private Promise<ActionResponse, ResourceException> updateInstance(SSOToken admin, final JsonValue details, final String realm) {
JsonValue jVal = details;
IdentityDetails newDtls;
String resourceId = jVal.get(USERNAME).asString();
try {
newDtls = jsonValueToIdentityDetails(objectType, jVal, realm);
if (newDtls.getAttributes() == null || newDtls.getAttributes().length < 1) {
throw new BadRequestException("Illegal arguments: One or more required arguments is null or empty");
}
newDtls.setName(resourceId);
// update resource with new details
identityServices.update(newDtls, admin);
debug.message("IdentityResource.updateInstance :: Anonymous UPDATE in realm={} for resourceId={}", realm, resourceId);
// read updated identity back to client
IdentityDetails checkIdent = identityServices.read(resourceId, getIdentityServicesAttributes(realm, objectType), admin);
// handle updated resource
return newResultPromise(newActionResponse(identityDetailsToJsonValue(checkIdent)));
} catch (final Exception e) {
debug.error("IdentityResource.updateInstance() :: Cannot UPDATE in realm={} for resourceId={}", realm, resourceId, e);
return new NotFoundException(e.getMessage(), e).asPromise();
}
}
Aggregations