Incident #17778, Messages: direct download attachment does not work

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/message-conversations@182066 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2019-10-17 15:53:43 +00:00
parent 23e097035b
commit d5aad130be
2 changed files with 4 additions and 8 deletions

View File

@ -5,9 +5,6 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<dependent-module archiveName="client-context-library-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/client-context-library/client-context-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/message-conversations/target/message-conversations-0.0.1-SNAPSHOT/WEB-INF/classes"/>
<property name="context-root" value="messages"/>
</wb-module>

View File

@ -25,6 +25,7 @@ import org.gcube.common.homelibrary.home.workspace.sharing.WorkspaceMessage;
import org.gcube.common.homelibrary.home.workspace.sharing.WorkspaceMessageManager;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
import org.gcube.portal.notifications.bean.GenericItemBean;
import org.gcube.portal.notifications.thread.MessageNotificationsThread;
import org.gcube.portets.user.message_conversations.client.MessageService;
@ -280,12 +281,10 @@ public class ConvServiceImpl extends RemoteServiceServlet implements MessageServ
GCubeUser user = getCurrentUser(getThreadLocalRequest());
String scope = pContext.getCurrentScope(getThreadLocalRequest());
SecurityTokenProvider.instance.set(pContext.getCurrentUserToken(scope, user.getUserId()));
_log.info("getAttachmentDownloadURL for user "+user.getUsername() + " file id="+itemId);
try {
HomeManagerFactory factory = HomeLibrary.getHomeManagerFactory();
HomeManager manager = factory.getHomeManager();
Workspace workspace = manager.getHome().getWorkspace();
WorkspaceItem item = workspace.getItem(itemId);
String downladURL = item.getPublicLink(false);
StorageHubClient shc = new StorageHubClient();
String downladURL = shc.open(itemId).asFile().getPublicLink().toString();
downladURL = (downladURL.startsWith("https")) ? downladURL : downladURL.replace("http", "https");
return downladURL;
} catch (Exception e) {