Search in sources :

Example 1 with ErrorDesc

use of org.orcid.jaxb.model.message.ErrorDesc in project ORCID-Source by ORCID.

the class OrcidExceptionMapper method getLegacyOrcidEntity.

private OrcidMessage getLegacyOrcidEntity(String prefix, Throwable e) {
    OrcidMessage entity = new OrcidMessage();
    entity.setMessageVersion(OrcidMessage.DEFAULT_VERSION);
    if (e != null && !PojoUtil.isEmpty(e.getMessage()))
        entity.setErrorDesc(new ErrorDesc(prefix + e.getMessage()));
    else
        entity.setErrorDesc(new ErrorDesc(prefix));
    return entity;
}
Also used : ErrorDesc(org.orcid.jaxb.model.message.ErrorDesc) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage)

Example 2 with ErrorDesc

use of org.orcid.jaxb.model.message.ErrorDesc in project ORCID-Source by ORCID.

the class OrcidExceptionMapper method getLegacy500OrcidEntity.

private OrcidMessage getLegacy500OrcidEntity(Throwable e) {
    OrcidMessage entity = new OrcidMessage();
    entity.setMessageVersion(OrcidMessage.DEFAULT_VERSION);
    entity.setErrorDesc(new ErrorDesc(StringUtils.isNotBlank(e.getMessage()) ? e.getMessage() : messageSource.getMessage("apiError.unknown.exception", null, localeManager.getLocale())));
    return entity;
}
Also used : ErrorDesc(org.orcid.jaxb.model.message.ErrorDesc) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage)

Example 3 with ErrorDesc

use of org.orcid.jaxb.model.message.ErrorDesc in project ORCID-Source by ORCID.

the class OrcidValidationJaxbContextResolver method getResponse.

private Response getResponse(Throwable e) {
    OrcidMessage entity = new OrcidMessage();
    entity.setErrorDesc(new ErrorDesc(e.getMessage()));
    return Response.serverError().entity(entity).build();
}
Also used : ErrorDesc(org.orcid.jaxb.model.message.ErrorDesc) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage)

Example 4 with ErrorDesc

use of org.orcid.jaxb.model.message.ErrorDesc in project ORCID-Source by ORCID.

the class MembersManagerImpl method updateClient.

@Override
public Client updateClient(Client client) {
    OrcidClient result = null;
    try {
        result = orcidClientGroupManager.updateClient(client.toOrcidClient());
        clearCache();
    } catch (OrcidClientGroupManagementException e) {
        LOGGER.error(e.getMessage());
        result = new OrcidClient();
        result.setErrors(new ErrorDesc(getMessage("manage.developer_tools.group.unable_to_update")));
    }
    return Client.valueOf(result);
}
Also used : OrcidClient(org.orcid.jaxb.model.clientgroup.OrcidClient) OrcidClientGroupManagementException(org.orcid.core.exception.OrcidClientGroupManagementException) ErrorDesc(org.orcid.jaxb.model.message.ErrorDesc)

Example 5 with ErrorDesc

use of org.orcid.jaxb.model.message.ErrorDesc in project ORCID-Source by ORCID.

the class GroupAdministratorController method editClient.

@RequestMapping(value = "/edit-client.json", method = RequestMethod.POST)
@Produces(value = { MediaType.APPLICATION_JSON })
@ResponseBody
public Client editClient(@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 edit client with non group user {}", profile.getOrcidIdentifier().getPath());
            throw new OrcidClientGroupManagementException(getMessage("web.orcid.privilege.exception"));
        }
        OrcidClient result = null;
        try {
            result = orcidClientGroupManager.updateClient(groupOrcid, client.toOrcidClient());
            clearCache();
        } catch (OrcidClientGroupManagementException e) {
            LOGGER.error(e.getMessage());
            result = new OrcidClient();
            result.setErrors(new ErrorDesc(getMessage("manage.developer_tools.group.unable_to_update")));
        }
        client = Client.valueOf(result);
    }
    return client;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidClientGroupManagementException(org.orcid.core.exception.OrcidClientGroupManagementException) OrcidClient(org.orcid.jaxb.model.clientgroup.OrcidClient) ErrorDesc(org.orcid.jaxb.model.message.ErrorDesc) RedirectUri(org.orcid.pojo.ajaxForm.RedirectUri) Produces(javax.ws.rs.Produces) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ErrorDesc (org.orcid.jaxb.model.message.ErrorDesc)7 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)4 OrcidClientGroupManagementException (org.orcid.core.exception.OrcidClientGroupManagementException)3 OrcidClient (org.orcid.jaxb.model.clientgroup.OrcidClient)3 Produces (javax.ws.rs.Produces)2 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)2 RedirectUri (org.orcid.pojo.ajaxForm.RedirectUri)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2