diff --git a/changelog.xml b/changelog.xml index ce754df..bd0f193 100644 --- a/changelog.xml +++ b/changelog.xml @@ -1,9 +1,16 @@ - + Minor fix + + Minor fix - First Release diff --git a/pom.xml b/pom.xml index 5827dab..ccd6b0d 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.gcube.portlets-widgets catalogue-sharing-widget - 1.0.1-SNAPSHOT + 1.1.0-SNAPSHOT catalogue-sharing-widget @@ -194,7 +194,7 @@ 2.2 - ${distroDirectory}/descriptor.xml + descriptor.xml diff --git a/src/main/java/org/gcube/portlets_widgets/catalogue_sharing_widget/server/ShareServicesImpl.java b/src/main/java/org/gcube/portlets_widgets/catalogue_sharing_widget/server/ShareServicesImpl.java index 6ac805e..f9a579f 100644 --- a/src/main/java/org/gcube/portlets_widgets/catalogue_sharing_widget/server/ShareServicesImpl.java +++ b/src/main/java/org/gcube/portlets_widgets/catalogue_sharing_widget/server/ShareServicesImpl.java @@ -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()); } }