Just a bit of code optimization
This commit is contained in:
parent
7214f2e188
commit
f0fb363818
|
@ -24,6 +24,7 @@ public class ItemCatalogueURLs {
|
|||
private String itemName;
|
||||
private boolean isPublicItem;
|
||||
private String privateVRECataloguePortletURL;
|
||||
private String publicGatewayCataloguePortletURL;
|
||||
private String publicVRECataloguePortletURL;
|
||||
private String publicGatewayCataloguePortletURL;
|
||||
|
||||
}
|
||||
|
|
|
@ -51,7 +51,6 @@ public class CkanCatalogueConfigurationsReader {
|
|||
private static final String DATACATALOGUECONFIGURATION_PROPERTIES = "datacatalogueconfiguration.properties";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Load catalogue end points.
|
||||
*
|
||||
|
@ -64,16 +63,19 @@ public class CkanCatalogueConfigurationsReader {
|
|||
|
||||
DataCatalogueImpl catalogueImpl = CatalogueServiceEndpointReader.getDataCatalogueImpl();
|
||||
|
||||
//String privatePortletURL = catalogueImpl.getPortletUrl();
|
||||
|
||||
Map<ACCESS_LEVEL_TO_CATALOGUE_PORTLET, String> accessLevelMap = catalogueImpl.getMapAccessURLToCatalogue();
|
||||
links.setMapAccessURLToCatalogue(accessLevelMap);
|
||||
String privatePortletURL = accessLevelMap.get(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PRIVATE_VRE);
|
||||
links.setPrivateVREPortletURL(privatePortletURL);
|
||||
String publicVREPortletURL = accessLevelMap.get(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PUBLIC_VRE);
|
||||
links.setPublicVREPortletURL(publicVREPortletURL);
|
||||
String publicGatewayPortletURL = accessLevelMap.get(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PUBLIC_GATEWAY);
|
||||
links.setPublicGatewayPortletURL(publicGatewayPortletURL);
|
||||
|
||||
//Building public URL from private portlet URL
|
||||
try{
|
||||
|
||||
if(publicGatewayPortletURL==null || publicGatewayPortletURL.isEmpty()) {
|
||||
//Building the gateway catalogue public URL from private VRE Portlet URL
|
||||
URI toURL = new URI(privatePortletURL);
|
||||
String publicURL = privatePortletURL.startsWith("https://")?"https://"+toURL.getHost():"http://"+toURL.getHost();
|
||||
//It returns the string "catalogue"
|
||||
|
@ -81,6 +83,7 @@ public class CkanCatalogueConfigurationsReader {
|
|||
//Replacing for example "ckan-bb" with "catalogue-bb"
|
||||
String publicCatalogueName = extractCatalogueName(catalogueImpl.getCatalogueUrl(), prefixToPublicCtlg);
|
||||
links.setPublicGatewayPortletURL(publicURL+"/"+publicCatalogueName);
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.warn("Erron on generating public catalogue URL from private URL: "+privatePortletURL, e);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -27,6 +28,7 @@ import lombok.Setter;
|
|||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class GatewayCKANCatalogueReference implements Serializable{
|
||||
|
||||
/**
|
||||
|
|
|
@ -226,7 +226,7 @@ public class CatalogueResolver {
|
|||
String publicGatewayPorltetURL = String.format("%s?path=/%s/%s",ckanCatalogueReference.getPublicGatewayPortletURL(),entityContextValue, entityName);
|
||||
String privateVREPortletURL = String.format("%s?path=/%s/%s",ckanCatalogueReference.getPrivateVREPortletURL(),entityContextValue, entityName);
|
||||
String publicVREPortletURL = String.format("%s?path=/%s/%s",ckanCatalogueReference.getPublicVREPortletURL(),entityContextValue, entityName);
|
||||
return new ItemCatalogueURLs(entityName, isPublicItem, privateVREPortletURL, publicGatewayPorltetURL, publicVREPortletURL);
|
||||
return new ItemCatalogueURLs(entityName, isPublicItem, privateVREPortletURL, publicVREPortletURL, publicGatewayPorltetURL);
|
||||
}catch (Exception e) {
|
||||
logger.error("Error when resolving CatalogueURL:", e);
|
||||
throw e;
|
||||
|
|
Loading…
Reference in New Issue