Feature #12796 Workspace widget: recent documents has a different behaviour on URL items
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/workspace-widget-portlet@178446 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
fd1126105a
commit
7bb0dd576a
|
@ -1,4 +1,8 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.workspace-widget-portlet.1-3-0"
|
||||
date="2019-03-04">
|
||||
<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"
|
||||
date="2018-06-12">
|
||||
<Change>Added mazimise feature</Change>
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<artifactId>workspace-widget-portlet</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<name>workspace-widget-portlet Portlet</name>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>1.3.0-SNAPSHOT</version>
|
||||
<description>
|
||||
Workspace Widget
|
||||
</description>
|
||||
|
|
|
@ -68,7 +68,7 @@ public class StorageHubServiceUtil {
|
|||
String authorizationToken = Utils.getCurrentUserToken(scope, userName);
|
||||
SecurityTokenProvider.instance.set(authorizationToken);
|
||||
ItemManagerClient client = AbstractPlugin.item().build();
|
||||
return client.childrenCount(itemId);
|
||||
return client.childrenCount(itemId, false);
|
||||
}
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.gcube.portlets.user.wswidget;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
import javax.portlet.PortletException;
|
||||
import javax.portlet.PortletSession;
|
||||
|
@ -13,8 +14,9 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.storagehub.client.StreamDescriptor;
|
||||
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.ItemManagerClient;
|
||||
import org.gcube.common.storagehub.client.proxies.WorkspaceManagerClient;
|
||||
import org.gcube.common.storagehub.model.items.Item;
|
||||
import org.gcube.portlets.user.wswidget.shared.AuthorizedUser;
|
||||
|
@ -39,6 +41,7 @@ public class WorkspaceWidget extends MVCPortlet {
|
|||
private static com.liferay.portal.kernel.log.Log _log = LogFactoryUtil.getLog(WorkspaceWidget.class);
|
||||
public static String BREADCRUMB_ATTR = "BREADCRUMB_ATTR_name";
|
||||
public final static int LIMIT = 5;
|
||||
public final static String ITEM_URL_TYPE = "nthl:externalUrl";
|
||||
|
||||
/**
|
||||
* all the AJAX calls are served by this method, to discriminate the operation we use the parameters:
|
||||
|
@ -52,12 +55,22 @@ public class WorkspaceWidget extends MVCPortlet {
|
|||
if (fileToDownloadId != null) {
|
||||
setAuthorizationToken(resourceRequest);
|
||||
String selectedItemId = fileToDownloadId.split("=")[1];
|
||||
ItemManagerClient client = AbstractPlugin.item().build();
|
||||
StreamDescriptor streamDescr = client.download(selectedItemId);
|
||||
StorageHubClient client = new StorageHubClient();
|
||||
FileContainer fileContainer = client.open(selectedItemId).asFile();
|
||||
StreamDescriptor streamDescr = fileContainer.download(selectedItemId);
|
||||
HttpServletResponse httpRes = PortalUtil.getHttpServletResponse(resourceResponse);
|
||||
HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(resourceRequest);
|
||||
ServletResponseUtil.sendFile(httpReq,httpRes, streamDescr.getFileName(), streamDescr.getStream(), "application/download");
|
||||
streamDescr.getStream().close();
|
||||
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());
|
||||
String text = sc.useDelimiter("\\A").next();
|
||||
sc.close();
|
||||
streamDescr.getStream().close();
|
||||
httpRes.sendRedirect(text);
|
||||
}
|
||||
else {
|
||||
HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(resourceRequest);
|
||||
ServletResponseUtil.sendFile(httpReq,httpRes, streamDescr.getFileName(), streamDescr.getStream(), "application/download");
|
||||
streamDescr.getStream().close();
|
||||
}
|
||||
}
|
||||
//the user is browsing the workspace or asking for recents
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue