public static Gson gson() {
    return builder.create();
} public static final Charset OIO_CHARSET = Charset.forName("UTF-8"); public class AliasDeletedException extends OioException {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public AliasDeletedException(String message) {
        super(message);
    }

} public class BadRequestException extends OioException {


    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public BadRequestException(String message) {
        super(message);
    }
} public class ChunkNotFoundException extends OioException {


    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public ChunkNotFoundException(String message) {
        super(message);
    }
} public class ContainerExistException extends OioException {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public ContainerExistException(String message) {
        super(message);
    }
} public class ContainerNotEmptyException extends OioException {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public ContainerNotEmptyException(String message) {
        super(message);
    }

} public class ContainerNotFoundException extends OioException {

    /**
     * 
     */
    private static final long serialVersionUID = -4662162990209727136L;
    
    public ContainerNotFoundException() {
        super(null);
    }
    public ContainerNotFoundException(String message) {
        super(message);
    }
} public class ObjectExistException extends OioException {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public ObjectExistException(String message) {
        super(message);
    }

} public class ObjectNotFoundException extends OioException {

    /**
     * 
     */
    private static final long serialVersionUID = -2995680181164449256L;

    public ObjectNotFoundException() {
        super(null);
    }

    public ObjectNotFoundException(String message) {
        super(message);
    }
} @SuppressWarnings("deprecation")
public class OioException extends SdsException {

    /**
     * 
     */
    private static final long serialVersionUID = 3270900242235005338L;

    public OioException(String message) {
        super(message);
    }

    public OioException(String message, Throwable t) {
        super(message, t);
    }
} public class OioSystemException extends OioException {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public OioSystemException(String message) {
        super(message);
    }

    public OioSystemException(String message, Throwable t) {
        super(message, t);
    }
} public class ReferenceNotFoundException extends OioException {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public ReferenceNotFoundException(String message) {
        super(message);
    }

} public class ProxyError {

    private Integer status;
    private String message;

    public ProxyError() {
    }

    public Integer status() {
        return status;
    }

    public ProxyError status(Integer status) {
        this.status = status;
        return this;
    }

    public String message() {
        return message;
    }

    public ProxyError message(String message) {
        this.message = message;
        return this;
    }

    @Override
    public String toString() {
        return format(PROXY_ERROR_FORMAT, status, message);
    }
}
import static io.openio.sds.common.JsonUtils.gson;
import static io.openio.sds.common.OioConstants.OIO_CHARSET;
import static java.lang.String.format;
import java.io.IOException;
import java.io.InputStreamReader;
import com.google.gson.stream.JsonReader;
import io.openio.sds.exceptions.AliasDeletedException;
import io.openio.sds.exceptions.BadRequestException;
import io.openio.sds.exceptions.ChunkNotFoundException;
import io.openio.sds.exceptions.ContainerExistException;
import io.openio.sds.exceptions.ContainerNotEmptyException;
import io.openio.sds.exceptions.ContainerNotFoundException;
import io.openio.sds.exceptions.ObjectExistException;
import io.openio.sds.exceptions.ObjectNotFoundException;
import io.openio.sds.exceptions.OioException;
import io.openio.sds.exceptions.OioSystemException;
import io.openio.sds.exceptions.ReferenceNotFoundException;
import io.openio.sds.models.ProxyError;
package io.openio.sds.http;





/**
 * 
 * @author Christopher Dedeurwaerder
 *
 */
public class Verifiers {

    public static final OioHttpResponseVerifier REFERENCE_VERIFIER = new OioHttpResponseVerifier() {

        @Override
        public void verify(OioHttpResponse resp) throws OioException {
            if (200 == resp.code() || 201 == resp.code()
                    || 204 == resp.code())
                return;
            ProxyError err = extractError(resp);
            switch (err.status()) {
            case 406:
                throw new ReferenceNotFoundException(err.toString());
            case 400:
                throw new BadRequestException(err.toString());
            case 404:
                throw new ReferenceNotFoundException(err.toString());
            case 500:
                throw new OioSystemException(err.toString());
            default:
                throw new OioSystemException(err.toString());
            }
        }
    };

    public static final OioHttpResponseVerifier CONTAINER_VERIFIER = new OioHttpResponseVerifier() {

        @Override
        public void verify(OioHttpResponse resp) throws OioException {
            if (200 == resp.code() || 201 == resp.code()
                    || 204 == resp.code())
                return;
            ProxyError err = extractError(resp);
            switch (err.status()) {
            case 400:
                throw new BadRequestException(err.toString());
            case 406:
            case 431:
                throw new ContainerNotFoundException(err.toString());
            case 433:
                throw new ContainerExistException(err.toString());
            case 438:
                throw new ContainerNotEmptyException(err.toString());
            case 500:
                throw new OioSystemException(err.toString());
            default:
                throw new OioSystemException(err.toString());
            }
        }
    };

    public static final OioHttpResponseVerifier OBJECT_VERIFIER = new OioHttpResponseVerifier() {

        @Override
        public void verify(OioHttpResponse resp) throws OioException {
            if (200 == resp.code() || 201 == resp.code()
                    || 204 == resp.code())
                return;
            ProxyError err = extractError(resp);
            switch (err.status()) {
            case 400:
                throw new BadRequestException(err.toString());
            case 406:
            case 431:
                throw new ContainerNotFoundException(err.toString());
            case 420:
                throw new ObjectNotFoundException(err.toString());