updated the constructor
This commit is contained in:
parent
c40877b589
commit
2ab3c58507
|
@ -15,16 +15,32 @@ import org.slf4j.LoggerFactory;
|
|||
/**
|
||||
* The Class GeoportalCommon.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 1, 2020
|
||||
* Aug 5, 2021
|
||||
*/
|
||||
public class GeoportalCommon {
|
||||
|
||||
|
||||
/** The Constant LOG. */
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GeoportalCommon.class);
|
||||
|
||||
private GeoNaDataViewerProfile geonaDataProfile;
|
||||
|
||||
/**
|
||||
* Instantiates a new geoportal common.
|
||||
*/
|
||||
public GeoportalCommon() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new geoportal common.
|
||||
*
|
||||
* @param geonaDataProfile the geona data profile
|
||||
*/
|
||||
public GeoportalCommon(GeoNaDataViewerProfile geonaDataProfile) {
|
||||
this.geonaDataProfile = geonaDataProfile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the public links for.
|
||||
*
|
||||
|
@ -46,7 +62,8 @@ public class GeoportalCommon {
|
|||
if (item.getItemType() == null)
|
||||
throw new Exception("Bad request, the item type is null");
|
||||
|
||||
GeoNaDataViewerProfile geonaDataProfile = getGeoNaDataViewProfile(GeoportalCommonConstants.GEOPORTAL_DATA_VIEWER_APP);
|
||||
if(this.geonaDataProfile==null)
|
||||
this.geonaDataProfile = getGeoNaDataViewProfile(GeoportalCommonConstants.GEOPORTAL_DATA_VIEWER_APP);
|
||||
|
||||
// Restricted Link
|
||||
String link = String.format("%s?%s=%s&%s=%s", geonaDataProfile.getRestrictedPortletURL(),
|
||||
|
@ -56,8 +73,8 @@ public class GeoportalCommon {
|
|||
String shortUrl = link;
|
||||
try {
|
||||
shortUrl = getShortUrl(link);
|
||||
}catch (Exception e) {
|
||||
LOG.warn("Error on shortening the URL: ",e);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Error on shortening the URL: ", e);
|
||||
}
|
||||
item.setRestrictedLink(new PublicLink(link, shortUrl));
|
||||
|
||||
|
@ -69,8 +86,8 @@ public class GeoportalCommon {
|
|||
shortUrl = link;
|
||||
try {
|
||||
shortUrl = getShortUrl(link);
|
||||
}catch (Exception e) {
|
||||
LOG.warn("Error on shortening the URL: ",e);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Error on shortening the URL: ", e);
|
||||
}
|
||||
item.setOpenLink(new PublicLink(link, shortUrl));
|
||||
|
||||
|
@ -85,26 +102,26 @@ public class GeoportalCommon {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the GeoNaData Viewer Profile
|
||||
* Gets the GeoNaData Viewer Profile.
|
||||
*
|
||||
* @param appID if null or empty uses the default appID that is {@link GeoportalCommonConstants#GEOPORTAL_DATA_VIEWER_APP}
|
||||
* @param appID if null or empty uses the default appID that is
|
||||
* {@link GeoportalCommonConstants#GEOPORTAL_DATA_VIEWER_APP}
|
||||
* @return the GeoNaData Viewer Profile
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public GeoNaDataViewerProfile getGeoNaDataViewProfile(String appID) throws Exception {
|
||||
LOG.info("getGeoNaDataViewProfile called for: "+appID);
|
||||
|
||||
if(appID==null || appID.isEmpty())
|
||||
LOG.info("getGeoNaDataViewProfile called for: " + appID);
|
||||
|
||||
if (appID == null || appID.isEmpty())
|
||||
appID = GeoportalCommonConstants.GEOPORTAL_DATA_VIEWER_APP;
|
||||
|
||||
LOG.info("using AppId: "+appID);
|
||||
|
||||
LOG.info("using AppId: " + appID);
|
||||
GeoNaDataViewerProfileReader gdvp = new GeoNaDataViewerProfileReader(appID);
|
||||
GeoNaDataViewerProfile profile = gdvp.readProfileFromInfrastrucure();
|
||||
LOG.info("Returning profile: " + profile);
|
||||
return profile;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the short url.
|
||||
*
|
||||
|
@ -119,9 +136,9 @@ public class GeoportalCommon {
|
|||
return longUrl;
|
||||
|
||||
try {
|
||||
|
||||
|
||||
UrlShortener shortener = new UrlShortener();
|
||||
|
||||
|
||||
if (shortener != null && shortener.isAvailable()) {
|
||||
String toShort = longUrl;
|
||||
String[] splitted = toShort.split("\\?");
|
||||
|
@ -148,4 +165,14 @@ public class GeoportalCommon {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the geona data profile.
|
||||
*
|
||||
* @return the geona data profile
|
||||
*/
|
||||
public GeoNaDataViewerProfile getGeonaDataProfile() {
|
||||
return geonaDataProfile;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue