Updated to new storage hub exception handling
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/workspace-widget-portlet@178931 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7bb0dd576a
commit
e3e2b9a332
|
@ -15,6 +15,7 @@
|
|||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
|
|
|
@ -5,4 +5,5 @@ org.eclipse.jdt.core.compiler.compliance=1.8
|
|||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
<wb-module deploy-name="workspace-widget-portlet-portlet">
|
||||
<wb-module deploy-name="workspace-widget-portlet">
|
||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.workspace-widget-portlet.1-3-0"
|
||||
date="2019-03-04">
|
||||
<Change>Updated to new storage hub exception handling</Change>
|
||||
<Change>Feature #12796 Workspace widget: recent documents has a different behaviour on URL items</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.workspace-widget-portlet.1-1-0"
|
||||
|
|
1
pom.xml
1
pom.xml
|
@ -1,5 +1,4 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
|
|
@ -38,6 +38,7 @@ public class StorageHubServiceUtil {
|
|||
SecurityTokenProvider.instance.set(authUser.getSecurityToken());
|
||||
ItemManagerClient client = AbstractPlugin.item().build();
|
||||
List<? extends Item> theChildren = null;
|
||||
try {
|
||||
if (offset >= 0) {
|
||||
int limit = offset;
|
||||
theChildren = client.getChildren(itemId, from, limit, false, "hl:accounting");
|
||||
|
@ -45,6 +46,10 @@ public class StorageHubServiceUtil {
|
|||
else { //all the items
|
||||
theChildren = client.getChildren(itemId, false, "hl:accounting");
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (theChildren == null || theChildren.isEmpty()) {
|
||||
toReturn.setChildren(children);
|
||||
_log.debug("*** Returning empty ");
|
||||
|
@ -68,7 +73,14 @@ public class StorageHubServiceUtil {
|
|||
String authorizationToken = Utils.getCurrentUserToken(scope, userName);
|
||||
SecurityTokenProvider.instance.set(authorizationToken);
|
||||
ItemManagerClient client = AbstractPlugin.item().build();
|
||||
return client.childrenCount(itemId, false);
|
||||
int toReturn = -1;
|
||||
try {
|
||||
client.childrenCount(itemId, false);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.gcube.common.storagehub.client.dsl.FileContainer;
|
|||
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
||||
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
||||
import org.gcube.common.storagehub.client.proxies.WorkspaceManagerClient;
|
||||
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
||||
import org.gcube.common.storagehub.model.items.Item;
|
||||
import org.gcube.portlets.user.wswidget.shared.AuthorizedUser;
|
||||
import org.gcube.portlets.user.wswidget.shared.Breadcrumb;
|
||||
|
@ -56,8 +57,14 @@ public class WorkspaceWidget extends MVCPortlet {
|
|||
setAuthorizationToken(resourceRequest);
|
||||
String selectedItemId = fileToDownloadId.split("=")[1];
|
||||
StorageHubClient client = new StorageHubClient();
|
||||
FileContainer fileContainer = client.open(selectedItemId).asFile();
|
||||
StreamDescriptor streamDescr = fileContainer.download(selectedItemId);
|
||||
FileContainer fileContainer = null;
|
||||
StreamDescriptor streamDescr = null;
|
||||
try {
|
||||
fileContainer = client.open(selectedItemId).asFile();
|
||||
streamDescr = fileContainer.download(selectedItemId);
|
||||
} catch (StorageHubException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
HttpServletResponse httpRes = PortalUtil.getHttpServletResponse(resourceResponse);
|
||||
if (ITEM_URL_TYPE.compareTo(fileContainer.get().getPrimaryType()) == 0) { //if is a type URL we open drectly the link
|
||||
Scanner sc = new Scanner( streamDescr.getStream());
|
||||
|
|
Loading…
Reference in New Issue