110 lines
2.6 KiB
Java
110 lines
2.6 KiB
Java
/*
|
|
*
|
|
*/
|
|
package org.gcube.portlets.user.uriresolvermanager.resolvers.query;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
/**
|
|
* The Class GeoportalResolverQueryStringBuilder.
|
|
*
|
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
|
*
|
|
* Mar 27, 2023
|
|
*/
|
|
public final class GeoportalResolverQueryStringBuilder {
|
|
|
|
public static final Logger LOG = LoggerFactory.getLogger(GeoportalResolverQueryStringBuilder.class);
|
|
public static final String ITEM_TYPE_PARAMETER = "item_type";
|
|
public static final String ITEM_ID_PARAMETER = "item_id";
|
|
public static final String GCUBE_SCOPE_PARAMETER = "gcube_scope";
|
|
|
|
private String itemType;
|
|
private String itemId;
|
|
private String gcubeScope;
|
|
|
|
/**
|
|
* Instantiates a new geoportal resolver query string builder.
|
|
*
|
|
* @param itemType the item type
|
|
* @param itemId the item id
|
|
*/
|
|
public GeoportalResolverQueryStringBuilder(String itemType, String itemId) {
|
|
this.itemType = itemType;
|
|
this.itemId = itemId;
|
|
}
|
|
|
|
/**
|
|
* Scope.
|
|
*
|
|
* @param gcubeScope the gcube scope
|
|
* @return the geoportal resolver query string builder
|
|
*/
|
|
public GeoportalResolverQueryStringBuilder scope(String gcubeScope) {
|
|
this.gcubeScope = gcubeScope;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Gets the item type.
|
|
*
|
|
* @return the item type
|
|
*/
|
|
public String getItemType() {
|
|
return itemType;
|
|
}
|
|
|
|
/**
|
|
* Gets the item id.
|
|
*
|
|
* @return the item id
|
|
*/
|
|
public String getItemId() {
|
|
return itemId;
|
|
}
|
|
|
|
/**
|
|
* Gets the gcube scope.
|
|
*
|
|
* @return the gcube scope
|
|
*/
|
|
public String getGcubeScope() {
|
|
return gcubeScope;
|
|
}
|
|
|
|
/**
|
|
* Builds the query parameters.
|
|
*
|
|
* @return the map
|
|
*/
|
|
public Map<String, String> buildQueryParameters() {
|
|
|
|
GeoportalResolverQueryString crQS = new GeoportalResolverQueryString(this);
|
|
|
|
if (crQS.getItemType() == null || crQS.getItemType().isEmpty()) {
|
|
throw new IllegalArgumentException("The " + ITEM_TYPE_PARAMETER + " cannot be null or empty");
|
|
}
|
|
|
|
if (crQS.getItemId() == null || crQS.getItemId().isEmpty()) {
|
|
throw new IllegalArgumentException("The " + ITEM_ID_PARAMETER + " cannot be null or empty");
|
|
}
|
|
|
|
if (crQS.getGcubeScope() == null || crQS.getGcubeScope().isEmpty()) {
|
|
throw new IllegalArgumentException("The " + GCUBE_SCOPE_PARAMETER + " cannot be null or empty");
|
|
}
|
|
|
|
Map<String, String> query = new HashMap<String, String>();
|
|
query.put(ITEM_TYPE_PARAMETER, crQS.getItemType());
|
|
query.put(ITEM_ID_PARAMETER, crQS.getItemId());
|
|
query.put(GCUBE_SCOPE_PARAMETER, crQS.getGcubeScope());
|
|
|
|
return query;
|
|
|
|
}
|
|
|
|
}
|