Added RESOLVE_AS parameter
This commit is contained in:
parent
a6ba441015
commit
771fc98e19
|
@ -12,6 +12,7 @@ public class GeoportalResolverQueryString {
|
||||||
private final String itemType;
|
private final String itemType;
|
||||||
private String itemId;
|
private String itemId;
|
||||||
private String gcubeScope;
|
private String gcubeScope;
|
||||||
|
private String resolveAs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new geoportal resolver query string.
|
* Instantiates a new geoportal resolver query string.
|
||||||
|
@ -22,6 +23,7 @@ public class GeoportalResolverQueryString {
|
||||||
this.itemType = builder.getItemType();
|
this.itemType = builder.getItemType();
|
||||||
this.itemId = builder.getItemId();
|
this.itemId = builder.getItemId();
|
||||||
this.gcubeScope = builder.getGcubeScope();
|
this.gcubeScope = builder.getGcubeScope();
|
||||||
|
this.resolveAs = builder.getResolveAs() != null ? builder.getResolveAs().getParamValue() : null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,10 +55,14 @@ public class GeoportalResolverQueryString {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To string.
|
* Gets the resolver as.
|
||||||
*
|
*
|
||||||
* @return the string
|
* @return the resolver as
|
||||||
*/
|
*/
|
||||||
|
public String getResolveAs() {
|
||||||
|
return resolveAs;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
@ -66,6 +72,8 @@ public class GeoportalResolverQueryString {
|
||||||
builder.append(itemId);
|
builder.append(itemId);
|
||||||
builder.append(", gcubeScope=");
|
builder.append(", gcubeScope=");
|
||||||
builder.append(gcubeScope);
|
builder.append(gcubeScope);
|
||||||
|
builder.append(", resolveAs=");
|
||||||
|
builder.append(resolveAs);
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,43 @@ public final class GeoportalResolverQueryStringBuilder {
|
||||||
public static final String ITEM_TYPE_PARAMETER = "item_type";
|
public static final String ITEM_TYPE_PARAMETER = "item_type";
|
||||||
public static final String ITEM_ID_PARAMETER = "item_id";
|
public static final String ITEM_ID_PARAMETER = "item_id";
|
||||||
public static final String GCUBE_SCOPE_PARAMETER = "gcube_scope";
|
public static final String GCUBE_SCOPE_PARAMETER = "gcube_scope";
|
||||||
|
public static final String RESOLVE_AS_PARAMETER = "res";
|
||||||
|
|
||||||
private String itemType;
|
private String itemType;
|
||||||
private String itemId;
|
private String itemId;
|
||||||
private String gcubeScope;
|
private String gcubeScope;
|
||||||
|
private RESOLVE_AS resolveAs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Enum RESOLVE_AS_PARAMETER.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Mar 28, 2023
|
||||||
|
*/
|
||||||
|
public static enum RESOLVE_AS {
|
||||||
|
PUBLIC("public"), PRIVATE("private");
|
||||||
|
|
||||||
|
String paramValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new resolve as.
|
||||||
|
*
|
||||||
|
* @param paramValue the param value
|
||||||
|
*/
|
||||||
|
RESOLVE_AS(String paramValue) {
|
||||||
|
this.paramValue = paramValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the param value.
|
||||||
|
*
|
||||||
|
* @return the param value
|
||||||
|
*/
|
||||||
|
public String getParamValue() {
|
||||||
|
return paramValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new geoportal resolver query string builder.
|
* Instantiates a new geoportal resolver query string builder.
|
||||||
|
@ -49,6 +82,17 @@ public final class GeoportalResolverQueryStringBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolver as.
|
||||||
|
*
|
||||||
|
* @param resolveAs the resolve as
|
||||||
|
* @return the geoportal resolver query string builder
|
||||||
|
*/
|
||||||
|
public GeoportalResolverQueryStringBuilder resolverAs(RESOLVE_AS resolveAs) {
|
||||||
|
this.resolveAs = resolveAs;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the item type.
|
* Gets the item type.
|
||||||
*
|
*
|
||||||
|
@ -76,6 +120,10 @@ public final class GeoportalResolverQueryStringBuilder {
|
||||||
return gcubeScope;
|
return gcubeScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RESOLVE_AS getResolveAs() {
|
||||||
|
return resolveAs;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the query parameters.
|
* Builds the query parameters.
|
||||||
*
|
*
|
||||||
|
@ -101,6 +149,9 @@ public final class GeoportalResolverQueryStringBuilder {
|
||||||
query.put(ITEM_TYPE_PARAMETER, crQS.getItemType());
|
query.put(ITEM_TYPE_PARAMETER, crQS.getItemType());
|
||||||
query.put(ITEM_ID_PARAMETER, crQS.getItemId());
|
query.put(ITEM_ID_PARAMETER, crQS.getItemId());
|
||||||
query.put(GCUBE_SCOPE_PARAMETER, crQS.getGcubeScope());
|
query.put(GCUBE_SCOPE_PARAMETER, crQS.getGcubeScope());
|
||||||
|
if (crQS.getResolveAs() != null) {
|
||||||
|
query.put(RESOLVE_AS_PARAMETER, crQS.getResolveAs());
|
||||||
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,8 @@ import org.gcube.portlets.user.uriresolvermanager.exception.IllegalArgumentExcep
|
||||||
import org.gcube.portlets.user.uriresolvermanager.exception.UriResolverMapException;
|
import org.gcube.portlets.user.uriresolvermanager.exception.UriResolverMapException;
|
||||||
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.CatalogueResolverQueryStringBuilder;
|
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.CatalogueResolverQueryStringBuilder;
|
||||||
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder;
|
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder;
|
||||||
|
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder.RESOLVE_AS;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
@ -144,13 +146,16 @@ public class UriResolverManagerTest {
|
||||||
// params.put(GeoportalResolverQueryStringBuilder.GCUBE_SCOPE_PARAMETER, gcubeScope);
|
// params.put(GeoportalResolverQueryStringBuilder.GCUBE_SCOPE_PARAMETER, gcubeScope);
|
||||||
// params.put(GeoportalResolverQueryStringBuilder.ITEM_ID_PARAMETER, itemId);
|
// params.put(GeoportalResolverQueryStringBuilder.ITEM_ID_PARAMETER, itemId);
|
||||||
// params.put(GeoportalResolverQueryStringBuilder.ITEM_TYPE_PARAMETER, itemType);
|
// params.put(GeoportalResolverQueryStringBuilder.ITEM_TYPE_PARAMETER, itemType);
|
||||||
|
// params.put(GeoportalResolverQueryStringBuilder.RESOLVE_AS_PARAMETER, GeoportalResolverQueryStringBuilder.RESOLVE_AS.PUBLIC.getParamValue());
|
||||||
|
|
||||||
//Method 2
|
//Method 2
|
||||||
GeoportalResolverQueryStringBuilder builder = new GeoportalResolverQueryStringBuilder(itemType,itemId);
|
GeoportalResolverQueryStringBuilder builder = new GeoportalResolverQueryStringBuilder(itemType,itemId);
|
||||||
builder.scope(gcubeScope);
|
builder.scope(gcubeScope);
|
||||||
|
builder.resolverAs(RESOLVE_AS.PUBLIC);
|
||||||
|
//builder.resolverAs(RESOLVE_AS.PRIVATE);
|
||||||
Map<String, String> params = builder.buildQueryParameters();
|
Map<String, String> params = builder.buildQueryParameters();
|
||||||
|
|
||||||
String shortLink = resolver.getLink(params, false);
|
String shortLink = resolver.getLink(params, true);
|
||||||
System.out.println(shortLink);
|
System.out.println(shortLink);
|
||||||
} catch (UriResolverMapException e) {
|
} catch (UriResolverMapException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
Loading…
Reference in New Issue