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

com.hp.autonomy.hod.client.api.resource.ResourcesServiceImpl 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.resource;

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.token.TokenProxy;

import java.util.List;

/**
 * Default implementation of ResourcesService
 */
public class ResourcesServiceImpl implements ResourcesService {

    private final ResourcesBackend resourcesBackend;
    private final Requester requester;

    /**
     * Create a new ResourcesServiceImpl with the give configuration
     *
     * @param hodServiceConfig The configuration to use
     */
    public ResourcesServiceImpl(final HodServiceConfig hodServiceConfig) {
        resourcesBackend = hodServiceConfig.getRestAdapter().create(ResourcesBackend.class);
        requester = hodServiceConfig.getRequester();
    }

    @Override
    public List list(final ListResourcesRequestBuilder parameters) throws HodErrorException {
        return requester.makeRequest(Resources.class, getBackendCaller(parameters)).getResources();
    }

    @Override
    public List list(final TokenProxy tokenProxy, final ListResourcesRequestBuilder parameters) throws HodErrorException {
        return requester.makeRequest(tokenProxy, Resources.class, getBackendCaller(parameters)).getResources();
    }

    private Requester.BackendCaller getBackendCaller(final ListResourcesRequestBuilder parameters) {
        return authenticationToken -> resourcesBackend.list(authenticationToken, parameters.build());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy