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

com.hp.autonomy.hod.client.api.HavenOnDemandServiceImpl Maven / Gradle / Ivy

There is a newer version: 0.25.3
Show newest version
/*
 * Copyright 2015-2016 Hewlett-Packard Development Company, L.P.
 * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
 */

package com.hp.autonomy.hod.client.api;

import com.hp.autonomy.hod.client.api.authentication.AuthenticationToken;
import com.hp.autonomy.hod.client.api.authentication.EntityType;
import com.hp.autonomy.hod.client.api.authentication.TokenType;
import com.hp.autonomy.hod.client.config.HodServiceConfig;
import com.hp.autonomy.hod.client.config.Requester;
import com.hp.autonomy.hod.client.error.HodErrorException;
import com.hp.autonomy.hod.client.job.JobId;
import com.hp.autonomy.hod.client.token.TokenProxy;
import retrofit.client.Response;

import java.util.Map;

public class HavenOnDemandServiceImpl implements HavenOnDemandService {

    private final HavenOnDemandBackend havenOnDemandBackend;
    private final Requester requester;

    public HavenOnDemandServiceImpl(final HodServiceConfig hodServiceConfig) {
        this.havenOnDemandBackend = hodServiceConfig.getRestAdapter().create(HavenOnDemandBackend.class);
        this.requester = hodServiceConfig.getRequester();
    }

    @Override
    public  T get(final TokenProxy tokenProxy, final String api, final int version, final Map params, final Class returnType) throws HodErrorException {
        return requester.makeRequest(tokenProxy, returnType, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.get(authenticationToken, api, version, params);
            }
        });
    }

    @Override
    public  T get(final TokenProxy tokenProxy, final String first, final String second, final int version, final Map params, final Class returnType) throws HodErrorException {
        return requester.makeRequest(tokenProxy, returnType, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.get(authenticationToken, first, second, version, params);
            }
        });
    }

    @Override
    public  T get(final TokenProxy tokenProxy, final String first, final String second, final String third, final int version, final Map params, final Class returnType) throws HodErrorException {
        return requester.makeRequest(tokenProxy, returnType, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.get(authenticationToken, first, second, third, version, params);
            }
        });
    }

    @Override
    public JobId getAsync(final TokenProxy tokenProxy, final String api, final int version, final Map params) throws HodErrorException {
        return requester.makeRequest(tokenProxy, JobId.class, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.getAsync(authenticationToken, api, version, params);
            }
        });
    }

    @Override
    public JobId getAsync(final TokenProxy tokenProxy, final String first, final String second, final int version, final Map params) throws HodErrorException {
        return requester.makeRequest(tokenProxy, JobId.class, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.getAsync(authenticationToken, first, second, version, params);
            }
        });
    }

    @Override
    public JobId getAsync(final TokenProxy tokenProxy, final String first, final String second, final String third, final int version, final Map params) throws HodErrorException {
        return requester.makeRequest(tokenProxy, JobId.class, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.getAsync(authenticationToken, first, second, third, version, params);
            }
        });
    }

    @Override
    public  T post(final TokenProxy tokenProxy, final String api, final int version, final Map params, final Class returnType) throws HodErrorException {
        return requester.makeRequest(tokenProxy, returnType, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.post(authenticationToken, api, version, params);
            }
        });
    }

    @Override
    public  T post(final TokenProxy tokenProxy, final String first, final String second, final int version, final Map params, final Class returnType) throws HodErrorException {
        return requester.makeRequest(tokenProxy, returnType, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.post(authenticationToken, first, second, version, params);
            }
        });
    }

    @Override
    public  T post(final TokenProxy tokenProxy, final String first, final String second, final String third, final int version, final Map params, final Class returnType) throws HodErrorException {
        return requester.makeRequest(tokenProxy, returnType, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.post(authenticationToken, first, second, third, version, params);
            }
        });
    }

    @Override
    public JobId postAsync(final TokenProxy tokenProxy, final String api, final int version, final Map params) throws HodErrorException {
        return requester.makeRequest(tokenProxy, JobId.class, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.postAsync(authenticationToken, api, version, params);
            }
        });
    }

    @Override
    public JobId postAsync(final TokenProxy tokenProxy, final String first, final String second, final int version, final Map params) throws HodErrorException {
        return requester.makeRequest(tokenProxy, JobId.class, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.postAsync(authenticationToken, first, second, version, params);
            }
        });
    }

    @Override
    public JobId postAsync(final TokenProxy tokenProxy, final String first, final String second, final String third, final int version, final Map params) throws HodErrorException {
        return requester.makeRequest(tokenProxy, JobId.class, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.postAsync(authenticationToken, first, second, third, version, params);
            }
        });
    }

    @Override
    public  T put(final TokenProxy tokenProxy, final String api, final int version, final Map params, final Class returnType) throws HodErrorException {
        return requester.makeRequest(tokenProxy, returnType, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.put(authenticationToken, api, version, params);
            }
        });
    }

    @Override
    public  T put(final TokenProxy tokenProxy, final String first, final String second, final int version, final Map params, final Class returnType) throws HodErrorException {
        return requester.makeRequest(tokenProxy, returnType, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.put(authenticationToken, first, second, version, params);
            }
        });
    }

    @Override
    public  T put(final TokenProxy tokenProxy, final String first, final String second, final String third, final int version, final Map params, final Class returnType) throws HodErrorException {
        return requester.makeRequest(tokenProxy, returnType, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.put(authenticationToken, first, second, third, version, params);
            }
        });
    }

    @Override
    public JobId putAsync(final TokenProxy tokenProxy, final String api, final int version, final Map params) throws HodErrorException {
        return requester.makeRequest(tokenProxy, JobId.class, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.putAsync(authenticationToken, api, version, params);
            }
        });
    }

    @Override
    public JobId putAsync(final TokenProxy tokenProxy, final String first, final String second, final int version, final Map params) throws HodErrorException {
        return requester.makeRequest(tokenProxy, JobId.class, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.putAsync(authenticationToken, first, second, version, params);
            }
        });
    }

    @Override
    public JobId putAsync(final TokenProxy tokenProxy, final String first, final String second, final String third, final int version, final Map params) throws HodErrorException {
        return requester.makeRequest(tokenProxy, JobId.class, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.putAsync(authenticationToken, first, second, third, version, params);
            }
        });
    }

    @Override
    public  T delete(final TokenProxy tokenProxy, final String api, final int version, final Map params, final Class returnType) throws HodErrorException {
        return requester.makeRequest(tokenProxy, returnType, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.delete(authenticationToken, api, version, params);
            }
        });
    }

    @Override
    public  T delete(final TokenProxy tokenProxy, final String first, final String second, final int version, final Map params, final Class returnType) throws HodErrorException {
        return requester.makeRequest(tokenProxy, returnType, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.delete(authenticationToken, first, second, version, params);
            }
        });
    }

    @Override
    public  T delete(final TokenProxy tokenProxy, final String first, final String second, final String third, final int version, final Map params, final Class returnType) throws HodErrorException {
        return requester.makeRequest(tokenProxy, returnType, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.delete(authenticationToken, first, second, third, version, params);
            }
        });
    }

    @Override
    public JobId deleteAsync(final TokenProxy tokenProxy, final String api, final int version, final Map params) throws HodErrorException {
        return requester.makeRequest(tokenProxy, JobId.class, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.deleteAsync(authenticationToken, api, version, params);
            }
        });
    }

    @Override
    public JobId deleteAsync(final TokenProxy tokenProxy, final String first, final String second, final int version, final Map params) throws HodErrorException {
        return requester.makeRequest(tokenProxy, JobId.class, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.deleteAsync(authenticationToken, first, second, version, params);
            }
        });
    }

    @Override
    public JobId deleteAsync(final TokenProxy tokenProxy, final String first, final String second, final String third, final int version, final Map params) throws HodErrorException {
        return requester.makeRequest(tokenProxy, JobId.class, new Requester.BackendCaller() {
            @Override
            public Response makeRequest(final AuthenticationToken authenticationToken) throws HodErrorException {
                return havenOnDemandBackend.deleteAsync(authenticationToken, first, second, third, version, params);
            }
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy