use of org.orcid.jaxb.model.message.ErrorDesc in project ORCID-Source by ORCID.
the class GroupAdministratorController method createClient.
@RequestMapping(value = "/add-client.json", method = RequestMethod.POST)
@Produces(value = { MediaType.APPLICATION_JSON })
@ResponseBody
public Client createClient(@RequestBody Client client) {
// Clean the error list
client.setErrors(new ArrayList<String>());
// Validate fields
validateDisplayName(client);
validateWebsite(client);
validateShortDescription(client);
validateRedirectUris(client);
copyErrors(client.getDisplayName(), client);
copyErrors(client.getWebsite(), client);
copyErrors(client.getShortDescription(), client);
for (RedirectUri redirectUri : client.getRedirectUris()) {
copyErrors(redirectUri, client);
}
if (client.getErrors().size() == 0) {
OrcidProfile profile = getEffectiveProfile();
String groupOrcid = profile.getOrcidIdentifier().getPath();
if (profile.getType() == null || !profile.getType().equals(OrcidType.GROUP)) {
LOGGER.warn("Trying to create client with non group user {}", profile.getOrcidIdentifier().getPath());
throw new OrcidClientGroupManagementException(getMessage("web.orcid.privilege.exception"));
}
OrcidClient result = null;
try {
result = orcidClientGroupManager.createAndPersistClientProfile(groupOrcid, client.toOrcidClient());
} catch (OrcidClientGroupManagementException e) {
LOGGER.error(e.getMessage());
result = new OrcidClient();
result.setErrors(new ErrorDesc(getMessage("manage.developer_tools.group.cannot_create_client")));
}
client = Client.valueOf(result);
}
return client;
}
use of org.orcid.jaxb.model.message.ErrorDesc in project ORCID-Source by ORCID.
the class OrcidMarshallerContextResolver method getResponse.
private Response getResponse(Throwable e) {
OrcidMessage entity = new OrcidMessage();
entity.setErrorDesc(new ErrorDesc(e.getMessage()));
return Response.serverError().entity(entity).build();
}
Aggregations