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> <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"> date="2017-05-10">
<Change>Minor fix</Change> <Change>Minor fix</Change>
</Changeset> </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"> date="2017-05-01">
<Change>First Release</Change> <Change>First Release</Change>
</Changeset> </Changeset>

View File

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

View File

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