use of com.google.api.ads.admanager.axis.v202205.User in project oxTrust by GluuFederation.
the class UserWebService method patchUser.
// PATCH WEBSERVICES
@Path("/patch/{id}")
@PUT
@Consumes({ Constants.MEDIA_TYPE_SCIM_JSON, MediaType.APPLICATION_JSON })
@Produces({ Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8", MediaType.APPLICATION_JSON + "; charset=utf-8" })
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
@ApiOperation(value = "patch user", notes = "Update user (https://tools.ietf.org/html/rfc7644#section-3.5.1)", response = User.class)
public Response patchUser(@HeaderParam("Authorization") String authorization, @QueryParam(OxTrustConstants.QUERY_PARAMETER_TEST_MODE_OAUTH2_TOKEN) final String token, @PathParam("id") String id, @ApiParam(value = "User", required = true) ScimPatchUser user, @QueryParam(OxTrustConstants.QUERY_PARAMETER_ATTRIBUTES) final String attributesArray) throws Exception {
Response authorizationResponse;
if (jsonConfigurationService.getOxTrustappConfiguration().isScimTestMode()) {
log.info(" ##### SCIM Test Mode is ACTIVE");
authorizationResponse = processTestModeAuthorization(token);
} else {
authorizationResponse = processAuthorization(authorization);
}
if (authorizationResponse != null) {
return authorizationResponse;
}
try {
User updatedUser = scim2UserService.patchUser(id, user);
// Serialize to JSON
String json = serializeToJson(updatedUser, attributesArray);
URI location = new URI(updatedUser.getMeta().getLocation());
return Response.ok(json).location(location).build();
} catch (EntryPersistenceException ex) {
log.error("Failed to update user", ex);
ex.printStackTrace();
return getErrorResponse(Response.Status.NOT_FOUND, ErrorScimType.INVALID_VALUE, "Resource " + id + " not found");
} catch (DuplicateEntryException ex) {
log.error("DuplicateEntryException", ex);
ex.printStackTrace();
return getErrorResponse(Response.Status.CONFLICT, ErrorScimType.UNIQUENESS, ex.getMessage());
} catch (Exception ex) {
log.error("Failed to update user", ex);
ex.printStackTrace();
return getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, INTERNAL_SERVER_ERROR_MESSAGE);
}
}
use of com.google.api.ads.admanager.axis.v202205.User in project oxTrust by GluuFederation.
the class UserWebService method updateUser.
@Path("{id}")
@PUT
@Consumes({ Constants.MEDIA_TYPE_SCIM_JSON, MediaType.APPLICATION_JSON })
@Produces({ Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8", MediaType.APPLICATION_JSON + "; charset=utf-8" })
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
@ApiOperation(value = "Update user", notes = "Update user (https://tools.ietf.org/html/rfc7644#section-3.5.1)", response = User.class)
public Response updateUser(@HeaderParam("Authorization") String authorization, @QueryParam(OxTrustConstants.QUERY_PARAMETER_TEST_MODE_OAUTH2_TOKEN) final String token, @PathParam("id") String id, @ApiParam(value = "User", required = true) User user, @QueryParam(OxTrustConstants.QUERY_PARAMETER_ATTRIBUTES) final String attributesArray) throws Exception {
Response authorizationResponse;
if (jsonConfigurationService.getOxTrustappConfiguration().isScimTestMode()) {
log.info(" ##### SCIM Test Mode is ACTIVE");
authorizationResponse = processTestModeAuthorization(token);
} else {
authorizationResponse = processAuthorization(authorization);
}
if (authorizationResponse != null) {
return authorizationResponse;
}
try {
User updatedUser = scim2UserService.updateUser(id, user);
// Serialize to JSON
String json = serializeToJson(updatedUser, attributesArray);
URI location = new URI(updatedUser.getMeta().getLocation());
return Response.ok(json).location(location).build();
} catch (EntryPersistenceException ex) {
log.error("Failed to update user", ex);
ex.printStackTrace();
return getErrorResponse(Response.Status.NOT_FOUND, ErrorScimType.INVALID_VALUE, "Resource " + id + " not found");
} catch (DuplicateEntryException ex) {
log.error("DuplicateEntryException", ex);
ex.printStackTrace();
return getErrorResponse(Response.Status.CONFLICT, ErrorScimType.UNIQUENESS, ex.getMessage());
} catch (Exception ex) {
log.error("Failed to update user", ex);
ex.printStackTrace();
return getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, INTERNAL_SERVER_ERROR_MESSAGE);
}
}
use of com.google.api.ads.admanager.axis.v202205.User in project oxTrust by GluuFederation.
the class Scim2UserService method removeUserPatch.
private void removeUserPatch(Operation operation, String id) throws Exception {
User user = operation.getValue();
GluuCustomPerson updatedGluuPerson = patchUtil.removePatch(user, validUsernameByInum(user, id));
log.info(" Setting meta: removeUserPatch update user ");
setMeta(updatedGluuPerson);
}
use of com.google.api.ads.admanager.axis.v202205.User in project oxTrust by GluuFederation.
the class UserDeserializer method deserialize.
@Override
public User deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
log.info(" deserialize() ");
try {
JsonNode rootNode = jsonParser.readValueAsTree();
ObjectMapper mapper = new ObjectMapper();
mapper.disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);
User user = mapper.readValue(rootNode.toString(), User.class);
if (user.getSchemas() == null) {
throw new IllegalArgumentException("Required field \"schemas\" is null or missing.");
} else if (!user.getSchemas().contains(Constants.USER_CORE_SCHEMA_ID)) {
throw new IllegalArgumentException("User Core schema is required.");
} else if (user.getSchemas().contains(Constants.USER_EXT_SCHEMA_ID)) {
JsonNode userExtensionNode = rootNode.get(Constants.USER_EXT_SCHEMA_ID);
if (userExtensionNode != null) {
ExtensionDeserializer deserializer = new ExtensionDeserializer();
deserializer.setId(Constants.USER_EXT_SCHEMA_ID);
SimpleModule deserializerModule = new SimpleModule("ExtensionDeserializerModule", new Version(1, 0, 0, ""));
deserializerModule.addDeserializer(Extension.class, deserializer);
mapper.registerModule(deserializerModule);
Extension extension = mapper.readValue(userExtensionNode.toString(), Extension.class);
user.addExtension(extension);
} else {
throw new IllegalArgumentException("User Extension schema is indicated, but value body is absent.");
}
}
return user;
} catch (Exception e) {
e.printStackTrace();
throw new IOException(INTERNAL_SERVER_ERROR_MESSAGE);
}
}
use of com.google.api.ads.admanager.axis.v202205.User in project oxTrust by GluuFederation.
the class Scim2UserService method replaceUserPatch.
private void replaceUserPatch(Operation operation, String id) throws Exception {
User user = operation.getValue();
GluuCustomPerson updatedGluuPerson = patchUtil.replacePatch(user, validUsernameByInum(user, id));
log.info(" Setting meta: replaceUserPatch update user ");
setMeta(updatedGluuPerson);
}
Aggregations