Search in sources :

Example 1 with ValidationError

use of com.emc.vipr.model.catalog.ValidationError in project coprhd-controller by CoprHD.

the class ExecutionWindowsApi method update.

public static void update(String executionWindowId, ExecutionWindowInfo info) {
    ExecutionWindowRestRep window = ExecutionWindowUtils.getExecutionWindow(uri(executionWindowId));
    if (window != null) {
        copyExecutionWindowInfoToExecutionWindow(info, window);
        window.setId(URI.create(executionWindowId));
        createForm(window).validate("executionWindowForm");
        if (validation.hasErrors()) {
            response.status = HttpStatus.SC_BAD_REQUEST;
            ValidationError validationError = null;
            renderApi(getValidationErrors());
        } else {
            ExecutionWindowUpdateParam updateParam = new ExecutionWindowUpdateParam();
            map(updateParam, info);
            ExecutionWindowUtils.updateExecutionWindow(uri(executionWindowId), updateParam);
            info.setId(window.getId().toString());
            renderApi(info);
        }
    } else {
        notFound(Messages.get("ExecutionWindowsApi.windowWithId", executionWindowId));
    }
}
Also used : ExecutionWindowUpdateParam(com.emc.vipr.model.catalog.ExecutionWindowUpdateParam) ExecutionWindowRestRep(com.emc.vipr.model.catalog.ExecutionWindowRestRep) ValidationError(com.emc.vipr.model.catalog.ValidationError)

Example 2 with ValidationError

use of com.emc.vipr.model.catalog.ValidationError in project coprhd-controller by CoprHD.

the class ValidationErrorFilter method handle.

@Override
public ClientResponse handle(ClientRequest request) throws ClientHandlerException {
    ClientResponse response = getNext().handle(request);
    int status = response.getStatus();
    if (supportsPortalValidation(request) && status == 400) {
        List<ValidationError> errorsList = ApiListUtils.getEntityList(config, new GenericType<List<ValidationError>>() {
        }, response);
        ValidationException exception = new ValidationException(response.getStatus(), errorsList);
        LOG.error(exception.getMessage());
        throw exception;
    }
    return response;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ValidationException(com.emc.vipr.client.exceptions.ValidationException) List(java.util.List) ValidationError(com.emc.vipr.model.catalog.ValidationError)

Example 3 with ValidationError

use of com.emc.vipr.model.catalog.ValidationError in project coprhd-controller by CoprHD.

the class SetupApi method skip.

// This API is intended to allow skipping the initial setup. It requires the system properties to be set
// manually through the proper APIs.
public static void skip() {
    if (SetupUtils.isSetupComplete()) {
        ok();
    }
    Map<String, String> properties = ConfigPropertyUtils.getProperties();
    String proxyPassword = properties.get(ConfigProperty.PROXYUSER_PASSWORD);
    if (StringUtils.isEmpty(proxyPassword)) {
        response.status = HttpStatus.SC_BAD_REQUEST;
        renderApi(new ValidationError(ConfigProperty.PROXYUSER_PASSWORD, MessagesUtils.get("setup.no.proxy.password")));
    }
    SetupUtils.markSetupComplete();
    ok();
}
Also used : ValidationError(com.emc.vipr.model.catalog.ValidationError)

Aggregations

ValidationError (com.emc.vipr.model.catalog.ValidationError)3 ValidationException (com.emc.vipr.client.exceptions.ValidationException)1 ExecutionWindowRestRep (com.emc.vipr.model.catalog.ExecutionWindowRestRep)1 ExecutionWindowUpdateParam (com.emc.vipr.model.catalog.ExecutionWindowUpdateParam)1 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 List (java.util.List)1