Search in sources :

Example 6 with ProcessingException

use of com.homeaway.datapullclient.exception.ProcessingException in project datapull by homeaway.

the class DataPullRequestProcessor method validateAndEnrich.

private String validateAndEnrich(String json) throws ProcessingException {
    JSONObject jsonString = new JSONObject(new JSONTokener(new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8))));
    try {
        DataPullContext context = DataPullContextHolder.getContext();
        if (context != null) {
            String authenticatedUser = context.getAuthenticatedUser();
            if (authenticatedUser != null) {
                jsonString.put("authenticated_user", authenticatedUser);
            }
        }
        inputJsonSchema.validate(jsonString);
        return jsonString.toString();
    } catch (ValidationException exception) {
        throw new ProcessingException("Json Validation failed " + exception.getMessage(), exception);
    }
}
Also used : JSONTokener(org.json.JSONTokener) ValidationException(org.everit.json.schema.ValidationException) JSONObject(org.json.JSONObject) ByteArrayInputStream(java.io.ByteArrayInputStream) DataPullContext(com.homeaway.datapullclient.config.DataPullContext) ProcessingException(com.homeaway.datapullclient.exception.ProcessingException)

Example 7 with ProcessingException

use of com.homeaway.datapullclient.exception.ProcessingException in project datapull by homeaway.

the class DataPullRequestHandler method startSimpleDataPull.

@Override
public SimpleResponseEntity startSimpleDataPull(String pipelinename, String awsenv) {
    if (log.isDebugEnabled())
        log.debug("startSimpleDataPull -> data=" + awsenv);
    SimpleResponseEntity entity = null;
    try {
        service.runSimpleDataPull(awsenv, pipelinename);
        entity = new SimpleResponseEntity(HttpStatus.ACCEPTED.value(), "Request Succesfully registered : " + awsenv, "Request Succesfully registered : " + pipelinename);
    } catch (ProcessingException e) {
        throw new InputException("DataPull application failed for data : " + awsenv + " \n " + e.getMessage());
    }
    if (log.isDebugEnabled())
        log.debug("startSimpleDataPull <- return");
    return entity;
}
Also used : InputException(com.homeaway.datapullclient.exception.InputException) SimpleResponseEntity(com.homeaway.datapullclient.data.SimpleResponseEntity) ProcessingException(com.homeaway.datapullclient.exception.ProcessingException)

Aggregations

ProcessingException (com.homeaway.datapullclient.exception.ProcessingException)7 IOException (java.io.IOException)4 BufferedReader (java.io.BufferedReader)3 InputStreamReader (java.io.InputStreamReader)3 JSONObject (org.json.JSONObject)3 JSONTokener (org.json.JSONTokener)3 AmazonS3 (com.amazonaws.services.s3.AmazonS3)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 DataPullContext (com.homeaway.datapullclient.config.DataPullContext)2 SimpleResponseEntity (com.homeaway.datapullclient.data.SimpleResponseEntity)2 InputException (com.homeaway.datapullclient.exception.InputException)2 InvalidPointedJsonException (com.homeaway.datapullclient.exception.InvalidPointedJsonException)2 JsonInputFile (com.homeaway.datapullclient.input.JsonInputFile)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 PostConstruct (javax.annotation.PostConstruct)2 ValidationException (org.everit.json.schema.ValidationException)2 Resource (org.springframework.core.io.Resource)2 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)2 ResourcePatternResolver (org.springframework.core.io.support.ResourcePatternResolver)2