Updated pom to allow maven deploy. Added try/catch into getItemURL

method
This commit is contained in:
Francesco Mangiacrapa 2019-12-05 11:12:31 +01:00
parent 02cacd0050
commit c45c7ab1f5
3 changed files with 32 additions and 21 deletions

View File

@ -1,9 +1,16 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets-widgets.catalogue-sharing-widget.1-0-1"
<Changeset
component="org.gcube.portlets-widgets.catalogue-sharing-widget.1-1-0"
date="2019-12-05">
<Change>Minor fix</Change>
</Changeset>
<Changeset
component="org.gcube.portlets-widgets.catalogue-sharing-widget.1-0-1"
date="2017-05-10">
<Change>Minor fix</Change>
</Changeset>
<Changeset component="org.gcube.portlets-widgets.catalogue-sharing-widget.1-0-0"
<Changeset
component="org.gcube.portlets-widgets.catalogue-sharing-widget.1-0-0"
date="2017-05-01">
<Change>First Release</Change>
</Changeset>

View File

@ -13,7 +13,7 @@
<groupId>org.gcube.portlets-widgets</groupId>
<artifactId>catalogue-sharing-widget</artifactId>
<version>1.0.1-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<name>catalogue-sharing-widget</name>
<description>
@ -194,7 +194,7 @@
<version>2.2</version>
<configuration>
<descriptors>
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
<descriptor>descriptor.xml</descriptor>
</descriptors>
</configuration>
<executions>

View File

@ -34,24 +34,28 @@ public class ShareServicesImpl extends RemoteServiceServlet implements ShareServ
@Override
public ItemUrls getPackageUrl(String uuid) throws Exception{
String scopePerCurrentUrl = ServerUtils.getScopeFromClientUrl(getThreadLocalRequest());
DataCatalogue catalogue = getCatalogue(scopePerCurrentUrl);
CkanDataset dataset = catalogue.getDataset(uuid, catalogue.getApiKeyFromUsername(ServerUtils.getUserInSession(getThreadLocalRequest())));
String longUrl = catalogue.getUnencryptedUrlFromDatasetIdOrName(uuid);
if(longUrl == null || longUrl.isEmpty())
throw new Exception("There was a problem while retrieving the item's url, retry later");
String shortUrl = null;
try{
UrlShortener shortener = new UrlShortener();
shortUrl = shortener.shorten(longUrl);
}catch(Exception e){
logger.warn("Short url not available");
try {
String scopePerCurrentUrl = ServerUtils.getScopeFromClientUrl(getThreadLocalRequest());
DataCatalogue catalogue = getCatalogue(scopePerCurrentUrl);
CkanDataset dataset = catalogue.getDataset(uuid, catalogue.getApiKeyFromUsername(ServerUtils.getUserInSession(getThreadLocalRequest())));
String longUrl = catalogue.getUnencryptedUrlFromDatasetIdOrName(uuid);
if(longUrl == null || longUrl.isEmpty())
throw new Exception("There was a problem while retrieving the item's url, retry later");
String shortUrl = null;
try{
UrlShortener shortener = new UrlShortener();
shortUrl = shortener.shorten(longUrl);
}catch(Exception e){
logger.warn("Short url not available");
}
return new ItemUrls(shortUrl, longUrl, uuid, dataset.getName(), dataset.getTitle());
}catch (Exception e) {
throw new Exception("Unable to get the ITEM URL for id: "+uuid, e);
}
return new ItemUrls(shortUrl, longUrl, uuid, dataset.getName(), dataset.getTitle());
}
}