41 lines
1.1 KiB
Java
41 lines
1.1 KiB
Java
package org.gcube.gcat.utils;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
import javax.ws.rs.WebApplicationException;
|
|
|
|
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
|
import org.gcube.portlets.user.uriresolvermanager.UriResolverManager;
|
|
|
|
/**
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
*/
|
|
public abstract class URIResolver {
|
|
|
|
private static final String CATALOGUE_CONTEXT = "gcube_scope";
|
|
private static final String ENTITY_TYPE = "entity_context";
|
|
private static final String ENTITY_NAME = "entity_name";
|
|
|
|
private static final String DATASET = "dataset";
|
|
|
|
|
|
public static String getCatalogueItemURL(String name) {
|
|
try {
|
|
String context = SecretManagerProvider.instance.get().getContext();
|
|
UriResolverManager uriResolverManager = new UriResolverManager("CTLG");
|
|
Map<String, String> params = new HashMap<>();
|
|
params.put(CATALOGUE_CONTEXT, context);
|
|
params.put(ENTITY_TYPE, DATASET);
|
|
params.put(ENTITY_NAME, name);
|
|
String url = uriResolverManager.getLink(params, false);
|
|
return url;
|
|
} catch(WebApplicationException e) {
|
|
throw e;
|
|
} catch(Exception e) {
|
|
throw new WebApplicationException(e);
|
|
}
|
|
}
|
|
|
|
}
|