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

org.openlca.collaboration.client.BrowseInvocation Maven / Gradle / Ivy

package org.openlca.collaboration.client;

import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.List;

import org.openlca.collaboration.client.WebRequests.Type;
import org.openlca.collaboration.model.Entry;
import org.openlca.collaboration.model.SearchResult;

import com.google.gson.reflect.TypeToken;

final class BrowseInvocation extends Invocation, List> {

	private final String repositoryId;
	private final String path;

	BrowseInvocation(String repositoryId, String path) {
		super(Type.GET, "public/browse", new TypeToken>() {
		});
		this.repositoryId = repositoryId;
		this.path = path;
	}

	@Override
	protected void checkValidity() {
		checkNotEmpty(repositoryId, "repository id");
	}

	@Override
	protected String query() {
		var query = "/" + repositoryId;
		if (path != null && !path.isEmpty()) {
            query += "?categoryPath=" + URLEncoder.encode(path, StandardCharsets.UTF_8);
        }
		return query;
	}

	protected List process(SearchResult response) {
		return response.data();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy