All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.esbtools.eventhandler.lightblue.client.FailedLightblueResponse Maven / Gradle / Ivy

There is a newer version: 0.1.15
Show newest version
package org.esbtools.eventhandler.lightblue.client;

import com.redhat.lightblue.client.model.DataError;
import com.redhat.lightblue.client.model.Error;
import com.redhat.lightblue.client.response.LightblueDataResponse;
import com.redhat.lightblue.client.response.LightblueErrorResponse;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

class FailedLightblueResponse implements LightblueResponse {
    private final LightblueErrorResponse response;
    private final List errors = new ArrayList<>();

    FailedLightblueResponse(LightblueErrorResponse response,
            DataError[] dataErrors, Error[] lightblueErrors) {
        this.response = response;

        Arrays.stream(dataErrors)
                .flatMap(e -> e.getErrors().stream())
                .forEach(errors::add);
        Collections.addAll(errors, lightblueErrors);
    }

    @Override
    public LightblueDataResponse getSuccess() {
        // TODO: maybe dif exception?
        throw new LightblueResponseException(errors);
    }

    @Override
    public boolean isSuccess() {
        return false;
    }

    @Override
    public LightblueErrorResponse getFailure() {
        return response;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy