Search in sources :

Example 21 with IdentityDetails

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();
    }
}
Also used : JsonValue(org.forgerock.json.JsonValue) IdentityDetails(com.sun.identity.idsvcs.IdentityDetails) BadRequestException(org.forgerock.json.resource.BadRequestException) NotFoundException(org.forgerock.json.resource.NotFoundException) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException) MessagingException(javax.mail.MessagingException) ConflictException(org.forgerock.json.resource.ConflictException) PermanentException(org.forgerock.json.resource.PermanentException) InternalServerErrorException(org.forgerock.json.resource.InternalServerErrorException) ForbiddenException(org.forgerock.json.resource.ForbiddenException) DeleteFailedException(org.forgerock.openam.cts.exceptions.DeleteFailedException) SSOException(com.iplanet.sso.SSOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NotFoundException(org.forgerock.json.resource.NotFoundException) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException) NotSupportedException(org.forgerock.json.resource.NotSupportedException) BadRequestException(org.forgerock.json.resource.BadRequestException) IdRepoException(com.sun.identity.idm.IdRepoException) SMSException(com.sun.identity.sm.SMSException) ResourceException(org.forgerock.json.resource.ResourceException) CoreTokenException(org.forgerock.openam.cts.exceptions.CoreTokenException)

Aggregations

IdentityDetails (com.sun.identity.idsvcs.IdentityDetails)21 NotFoundException (org.forgerock.json.resource.NotFoundException)18 BadRequestException (org.forgerock.json.resource.BadRequestException)17 ResourceException (org.forgerock.json.resource.ResourceException)17 SSOException (com.iplanet.sso.SSOException)15 ServiceNotFoundException (com.sun.identity.sm.ServiceNotFoundException)14 IdRepoException (com.sun.identity.idm.IdRepoException)13 ForbiddenException (org.forgerock.json.resource.ForbiddenException)13 InternalServerErrorException (org.forgerock.json.resource.InternalServerErrorException)13 PermanentException (org.forgerock.json.resource.PermanentException)13 JsonValue (org.forgerock.json.JsonValue)12 SSOToken (com.iplanet.sso.SSOToken)10 SMSException (com.sun.identity.sm.SMSException)10 UnsupportedEncodingException (java.io.UnsupportedEncodingException)10 MessagingException (javax.mail.MessagingException)10 ConflictException (org.forgerock.json.resource.ConflictException)10 NotSupportedException (org.forgerock.json.resource.NotSupportedException)10 CoreTokenException (org.forgerock.openam.cts.exceptions.CoreTokenException)10 DeleteFailedException (org.forgerock.openam.cts.exceptions.DeleteFailedException)10 ObjectNotFound (com.sun.identity.idsvcs.ObjectNotFound)9