Compare commits

...

36 Commits

Author SHA1 Message Date
Massimiliano Assante b6463ff598 ready to release 2021-10-04 16:08:48 +02:00
Massimiliano Assante c7c962414d Feature #22109 load VRE Folder without using JCR indices 2021-10-04 15:56:55 +02:00
Massimiliano Assante 80b24443e0 just remove da forgotten sysout used for debugging 2021-07-14 09:37:50 +02:00
Massimiliano Assante 3d4667d504 Bug #21794 fixed, added to release current 2021-07-13 11:50:37 +02:00
Massimiliano Assante 0acb08f4ba Bug #21794 fixed, folder names were not URI encoded 2021-07-13 11:32:48 +02:00
Massimiliano Assante fa373c0ff7 updated bom 2021-06-24 17:30:16 +02:00
Massimiliano Assante 90baf04995 ready to release 2021-06-24 11:44:57 +02:00
Massimiliano Assante 9890dfe01c updated use of wrong token provider 2021-05-25 18:24:17 +02:00
Massimiliano Assante b9e4aea1db pom fixed 2021-05-25 18:01:19 +02:00
Massimiliano Assante f87d7e85cf Feature #21507 support new UMATokensProvider class 2021-05-25 17:58:33 +02:00
Massimiliano Assante e9330f651e Feature #21507 support new UMATokensProvider class 2021-05-25 17:58:30 +02:00
Massimiliano Assante 7d43b96e11 another minor fix on getVREFoldersId when user is new 2021-04-22 15:34:43 +02:00
Massimiliano Assante 9b1c436756 fixed the issue on getWorkspaceFolderURL method 2021-04-22 14:57:38 +02:00
Massimiliano Assante b204c9f343 ready to release 2021-04-21 18:11:38 +02:00
Massimiliano Assante 04ab828143 fix bug avoiding the download of files 2021-04-21 18:09:41 +02:00
Roberto Cirillo b4cad2e995 Update 'pom.xml'
fix scm url
2021-04-16 17:05:47 +02:00
Massimiliano Assante 8b7ad4af51 updated pom for release 2021-04-12 16:14:29 +02:00
Massimiliano Assante 1ccb6f519f ready to release 2021-04-06 15:08:38 +02:00
Massimiliano Assante b776f1bbe7 boh 2021-04-06 12:58:13 +02:00
Massimiliano Assante 4e2ef87567 none 2021-04-06 12:54:32 +02:00
Massimiliano Assante ff6cd1f69c none 2021-04-06 12:51:25 +02:00
Massimiliano Assante e567750d6f none 2021-04-06 12:36:13 +02:00
Massimiliano Assante f0c5ca5574 none 2021-04-06 12:24:10 +02:00
Massimiliano Assante 23b109755c none 2021-04-06 12:18:19 +02:00
Massimiliano Assante 3927b75c67 none 2021-04-06 11:30:39 +02:00
Massimiliano Assante 7541e723a4 none 2021-04-06 11:28:05 +02:00
Massimiliano Assante aed9af164b none 2021-04-06 11:19:41 +02:00
Massimiliano Assante 182cc8a94c none 2021-04-06 10:39:35 +02:00
Massimiliano Assante a2d522d7e8 just lowered one log to DEBUG from INFO 2021-01-28 18:59:09 +01:00
Massimiliano Assante 754e599564 removed -snapshot from maven-portal-bom version 2021-01-27 09:53:39 +01:00
Massimiliano Assante 30fca73f1c typo fix 2021-01-26 17:40:56 +01:00
Massimiliano Assante a85af08838 Fix Bug #20552 Workspace widget item counter no longer works 2021-01-26 17:37:48 +01:00
Massimiliano Assante 2dd5e12d8c minor fixes in pom, updated minor version 2020-04-21 10:47:37 +02:00
Massimiliano Assante 1004068c8f Merge branch 'master' of
https://code-repo.d4science.org/gCubeSystem/workspace-widget-portlet.git

Conflicts:
	pom.xml
2020-02-27 15:16:27 +01:00
Massimiliano Assante 2ac20e020c Feature #17913 merged 2020-02-27 15:14:05 +01:00
Massimiliano Assante 909b0ccf81 Feature #17913 2020-02-27 15:08:24 +01:00
16 changed files with 248 additions and 158 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@ -1,5 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="src/main/java"> <classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
@ -13,16 +24,5 @@
<attribute name="test" value="true"/> <attribute name="test" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>

View File

@ -3,7 +3,9 @@ org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.compiler.source=1.8

View File

@ -1,10 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> <?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="workspace-widget-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="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<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="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<property name="context-root" value="workspace-widget-portlet"/> <property name="context-root" value="workspace-widget-portlet"/>
<property name="java-output-path" value="/workspace-widget-portlet/target/classes"/> <property name="java-output-path" value="/workspace-widget-portlet/target/classes"/>
</wb-module> </wb-module>
</project-modules> </project-modules>

37
CHANGELOG.md Normal file
View File

@ -0,0 +1,37 @@
# Changelog for Workspace Widget Portlet
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.5.2] - 2021-10-04
- Feature #22109 Workspace widget to load VRE Folders without using JCR indices
## [v1.5.1] - 2021-07-13
- Feature #21507 support new UMATokensProvider class
- Bug #21794 folder names were not URI encoded
## [v1.5.0] - 2021-04-06
- Removed legacy auth dependency
## [v1.4.1] - 2021-01-26
- Fix Bug #20552 Workspace widget item counter no longer works
## [v1.3.1] - 2019-10-09
- Updated to new storage hub api
## [v1.3.0] - 2019-03-04
- Updated to new storage hub exception handling<
- Feature #12796 Workspace widget: recent documents has a different behaviour on URL items
## [v1.0.0] - 2018-05-17
First release

26
FUNDING.md Normal file
View File

@ -0,0 +1,26 @@
# Acknowledgments
The projects leading to this software have received funding from a series of European Union programmes including:
- the Sixth Framework Programme for Research and Technological Development
- [DILIGENT](https://cordis.europa.eu/project/id/004260) (grant no. 004260).
- the Seventh Framework Programme for research, technological development and demonstration
- [D4Science](https://cordis.europa.eu/project/id/212488) (grant no. 212488);
- [D4Science-II](https://cordis.europa.eu/project/id/239019) (grant no.239019);
- [ENVRI](https://cordis.europa.eu/project/id/283465) (grant no. 283465);
- [iMarine](https://cordis.europa.eu/project/id/283644) (grant no. 283644);
- [EUBrazilOpenBio](https://cordis.europa.eu/project/id/288754) (grant no. 288754).
- the H2020 research and innovation programme
- [SoBigData](https://cordis.europa.eu/project/id/654024) (grant no. 654024);
- [PARTHENOS](https://cordis.europa.eu/project/id/654119) (grant no. 654119);
- [EGI-Engage](https://cordis.europa.eu/project/id/654142) (grant no. 654142);
- [ENVRI PLUS](https://cordis.europa.eu/project/id/654182) (grant no. 654182);
- [BlueBRIDGE](https://cordis.europa.eu/project/id/675680) (grant no. 675680);
- [PerformFISH](https://cordis.europa.eu/project/id/727610) (grant no. 727610);
- [AGINFRA PLUS](https://cordis.europa.eu/project/id/731001) (grant no. 731001);
- [DESIRA](https://cordis.europa.eu/project/id/818194) (grant no. 818194);
- [ARIADNEplus](https://cordis.europa.eu/project/id/823914) (grant no. 823914);
- [RISIS 2](https://cordis.europa.eu/project/id/824091) (grant no. 824091);
- [EOSC-Pillar](https://cordis.europa.eu/project/id/857650) (grant no. 857650);
- [Blue Cloud](https://cordis.europa.eu/project/id/862409) (grant no. 862409);
- [SoBigData-PlusPlus](https://cordis.europa.eu/project/id/871042) (grant no. 871042);

View File

@ -1,19 +0,0 @@
<ReleaseNotes>
<Changeset component="org.gcube.workspace-widget-portlet.1-3-1"
date="2019-10-09">
<Change>Updated to new storage hub api</Change>
</Changeset>
<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"
date="2018-06-12">
<Change>Added mazimise feature</Change>
</Changeset>
<Changeset component="org.gcube.workspace-widget-portlet.1-0-0"
date="2018-05-17">
<Change>First Release</Change>
</Changeset>
</ReleaseNotes>

View File

@ -1,31 +0,0 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>servicearchive</id>
<formats>
<format>tar.gz</format>
</formats>
<baseDirectory>/</baseDirectory>
<fileSets>
<fileSet>
<directory>${distroDirectory}</directory>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<includes>
<include>README</include>
<include>LICENSE</include>
<include>changelog.xml</include>
<include>profile.xml</include>
</includes>
<fileMode>755</fileMode>
<filtered>true</filtered>
</fileSet>
</fileSets>
<files>
<file>
<source>target/${build.finalName}.${project.packaging}</source>
<outputDirectory>/${artifactId}</outputDirectory>
</file>
</files>
</assembly>

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ID></ID>
<Type>Service</Type>
<Profile>
<Description>${description}</Description>
<Class>PortletUser</Class>
<Name>${artifactId}</Name>
<Version>${version}</Version>
<Packages>
<Software>
<Name>${artifactId}</Name>
<Version>${version}</Version>
<MavenCoordinates>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</MavenCoordinates>
<Files>
<File>target/${build.finalName}.war</File>
</Files>
</Software>
</Packages>
</Profile>
</Resource>

36
pom.xml
View File

@ -1,5 +1,6 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <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"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
@ -12,19 +13,17 @@
<artifactId>workspace-widget-portlet</artifactId> <artifactId>workspace-widget-portlet</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<name>workspace-widget-portlet Portlet</name> <name>workspace-widget-portlet Portlet</name>
<version>1.3.2</version> <version>1.5.2</version>
<description> <description>
Workspace Widget Workspace Widget Portlet is a small Front-end component looking like G Drive which exposes the content of the user's workspace or VRE Folders in read only mode.
</description> </description>
<scm> <scm>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/workspace-widget-portlet.git</connection> <connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/workspace-widget-portlet.git</developerConnection> <developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</developerConnection>
<url>https://code-repo.d4science.org/gCubeSystem/workspace-widget-portlet</url> <url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url>
</scm> </scm>
<properties> <properties>
<distroDirectory>distro</distroDirectory> <distroDirectory>distro</distroDirectory>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<liferay.version>6.2.5</liferay.version> <liferay.version>6.2.5</liferay.version>
<liferay.maven.plugin.version>6.2.10.12</liferay.maven.plugin.version> <liferay.maven.plugin.version>6.2.10.12</liferay.maven.plugin.version>
<liferay.auto.deploy.dir>/Users/massi/portal/liferay-portal-6.2-ce-ga6/deploy</liferay.auto.deploy.dir> <liferay.auto.deploy.dir>/Users/massi/portal/liferay-portal-6.2-ce-ga6/deploy</liferay.auto.deploy.dir>
@ -37,7 +36,7 @@
<dependency> <dependency>
<groupId>org.gcube.distribution</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId> <artifactId>maven-portal-bom</artifactId>
<version>3.5.0-4.16.0-181969</version> <version>3.6.3</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
@ -77,10 +76,19 @@
<artifactId>common-authorization</artifactId> <artifactId>common-authorization</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>oidc-library-portal</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>oidc-library</artifactId>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>com.liferay.portal</groupId> <groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId> <artifactId>portal-service</artifactId>
<version>${liferay.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -150,8 +158,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<configuration> <configuration>
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
<source>1.8</source> <source>${maven.compiler.source}</source>
<target>1.8</target> <target>${maven.compiler.target}</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
@ -161,7 +169,7 @@
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<configuration> <configuration>

View File

@ -25,6 +25,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@SuppressWarnings("deprecation")
public class ItemBuilder { public class ItemBuilder {
public static final Logger _log = LoggerFactory.getLogger(ItemBuilder.class); public static final Logger _log = LoggerFactory.getLogger(ItemBuilder.class);
@ -37,6 +38,7 @@ public class ItemBuilder {
* @param currentUserName * @param currentUserName
* @return * @return
*/ */
@SuppressWarnings("deprecation")
public static WSItem getItem(WSItem parent, Item workspaceItem, String workspaceItemPath, String currentUserName) { public static WSItem getItem(WSItem parent, Item workspaceItem, String workspaceItemPath, String currentUserName) {
ItemType type = getItemType(workspaceItem); ItemType type = getItemType(workspaceItem);
boolean isFolder = type.equals(ItemType.PRIVATE_FOLDER)?true:false; boolean isFolder = type.equals(ItemType.PRIVATE_FOLDER)?true:false;
@ -44,7 +46,7 @@ public class ItemBuilder {
String itemName = workspaceItem.getName(); String itemName = workspaceItem.getName();
if(isSharedFolder){ if(isSharedFolder){
_log.info("Is shared folder: "+workspaceItem.getTitle()); _log.debug("Is shared folder: "+workspaceItem.getTitle());
SharedFolder shared = (SharedFolder) workspaceItem; SharedFolder shared = (SharedFolder) workspaceItem;
itemName = shared.isVreFolder()?shared.getDisplayName():workspaceItem.getTitle(); itemName = shared.isVreFolder()?shared.getDisplayName():workspaceItem.getTitle();
} }

View File

@ -7,18 +7,28 @@ import java.util.List;
import javax.portlet.ResourceRequest; import javax.portlet.ResourceRequest;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.authorization.library.provider.AccessTokenProvider;
import org.gcube.common.portal.GCubePortalConstants; import org.gcube.common.portal.GCubePortalConstants;
import org.gcube.common.portal.PortalContext; import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.storagehub.client.plugins.AbstractPlugin; import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
import org.gcube.common.storagehub.client.proxies.ItemManagerClient; import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
import org.gcube.common.storagehub.client.proxies.WorkspaceManagerClient; import org.gcube.common.storagehub.client.proxies.WorkspaceManagerClient;
import org.gcube.common.storagehub.model.items.Item; import org.gcube.common.storagehub.model.items.Item;
import org.gcube.oidc.rest.JWTToken;
import org.gcube.portal.oidc.lr62.InvalidTokenException;
import org.gcube.portal.oidc.lr62.JWTTokenUtil;
import org.gcube.portal.oidc.lr62.MissingTokenException;
import org.gcube.portal.oidc.lr62.NotAuthorizedException;
import org.gcube.portal.oidc.lr62.OIDCUmaUtil;
import org.gcube.portal.oidc.lr62.RefreshException;
import org.gcube.portal.oidc.lr62.UMAException;
import org.gcube.portlets.user.wswidget.shared.AuthorizedUser; import org.gcube.portlets.user.wswidget.shared.AuthorizedUser;
import org.gcube.portlets.user.wswidget.shared.WSItem; import org.gcube.portlets.user.wswidget.shared.WSItem;
import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.util.PortalUtil;
public class StorageHubServiceUtil { public class StorageHubServiceUtil {
private static Log _log = LogFactoryUtil.getLog(StorageHubServiceUtil.class); private static Log _log = LogFactoryUtil.getLog(StorageHubServiceUtil.class);
@ -29,13 +39,12 @@ public class StorageHubServiceUtil {
* @param itemName * @param itemName
* @param from * @param from
* @param offset * @param offset
* @return * @return the list of items
*/ */
public static List<WSItem> getItemChildren(AuthorizedUser authUser, String itemId, String itemName, int from, int offset) { public static List<WSItem> getItemChildren(AuthorizedUser authUser, String itemId, String itemName, int from, int offset) {
WSItem toReturn = new WSItem(itemId, itemName, true); WSItem toReturn = new WSItem(itemId, itemName, true);
_log.debug("getItemChildren folder/item = " + itemId); _log.debug("getItemChildren folder/item = " + itemId);
ArrayList<WSItem> children = new ArrayList<>(); ArrayList<WSItem> children = new ArrayList<>();
SecurityTokenProvider.instance.set(authUser.getSecurityToken());
ItemManagerClient client = AbstractPlugin.item().build(); ItemManagerClient client = AbstractPlugin.item().build();
List<? extends Item> theChildren = null; List<? extends Item> theChildren = null;
try { try {
@ -61,21 +70,17 @@ public class StorageHubServiceUtil {
} }
toReturn.setChildren(children); toReturn.setChildren(children);
Collections.sort(toReturn.getChildren(), new ItemComparator()); Collections.sort(toReturn.getChildren(), new ItemComparator());
_log.debug("*** Returning children size: "+toReturn.getChildren().size()); _log.debug("Returning children size: "+toReturn.getChildren().size());
return children; return children;
} }
/** /**
* *
*/ */
public static int getItemChildrenCount(ResourceRequest request, String itemId) { public static int getItemChildrenCount(ResourceRequest request, String itemId) {
String userName = Utils.getCurrentUser(request).getUsername();
String scope = Utils.getCurrentContext(request);
String authorizationToken = Utils.getCurrentUserToken(scope, userName);
SecurityTokenProvider.instance.set(authorizationToken);
ItemManagerClient client = AbstractPlugin.item().build(); ItemManagerClient client = AbstractPlugin.item().build();
int toReturn = -1; int toReturn = -1;
try { try {
client.childrenCount(itemId, false); toReturn = client.childrenCount(itemId, false);
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -91,7 +96,6 @@ public class StorageHubServiceUtil {
*/ */
public static List<WSItem> getRootChildren(AuthorizedUser authUser, int from, int offset) { public static List<WSItem> getRootChildren(AuthorizedUser authUser, int from, int offset) {
try { try {
SecurityTokenProvider.instance.set(authUser.getSecurityToken());
WorkspaceManagerClient client = AbstractPlugin.workspace().build(); WorkspaceManagerClient client = AbstractPlugin.workspace().build();
Item itemRoot = client.getWorkspace("hl:accounting"); Item itemRoot = client.getWorkspace("hl:accounting");
WSItem root = new WSItem(itemRoot.getId(), Utils.HOME_LABEL, true); WSItem root = new WSItem(itemRoot.getId(), Utils.HOME_LABEL, true);
@ -112,7 +116,6 @@ public class StorageHubServiceUtil {
WSItem toReturn = new WSItem("recents", "Recent Documents", true); WSItem toReturn = new WSItem("recents", "Recent Documents", true);
_log.debug("getRecentItems "); _log.debug("getRecentItems ");
ArrayList<WSItem> children = new ArrayList<>(); ArrayList<WSItem> children = new ArrayList<>();
SecurityTokenProvider.instance.set(authUser.getSecurityToken());
WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build(); WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build();
List<? extends Item> theChildren = wsclient.getRecentModifiedFilePerVre(); List<? extends Item> theChildren = wsclient.getRecentModifiedFilePerVre();
@ -136,14 +139,19 @@ public class StorageHubServiceUtil {
* @return the id of the VRE Folder associated to the given context * @return the id of the VRE Folder associated to the given context
*/ */
public static String getWorkspaceFolderURL(HttpServletRequest request) { public static String getWorkspaceFolderURL(HttpServletRequest request) {
String userName = Utils.getCurrentUser(request).getUsername();
String scope = Utils.getCurrentContext(request);
String authorizationToken = Utils.getCurrentUserToken(scope, userName);
SecurityTokenProvider.instance.set(authorizationToken);
String siteLandingPagePath = PortalContext.getConfiguration().getSiteLandingPagePath(request); String siteLandingPagePath = PortalContext.getConfiguration().getSiteLandingPagePath(request);
String toReturn = siteLandingPagePath; String toReturn = siteLandingPagePath;
try { try {
String currentContext = Utils.getCurrentContext(request);
try {
long userId = PortalUtil.getUser(request).getUserId();
JWTToken umaToken = OIDCUmaUtil.getUMAToken(request, userId, currentContext);
AccessTokenProvider.instance.set(JWTTokenUtil.getAccessTokenString(umaToken));
} catch (Exception e1) {
e1.printStackTrace();
}
ScopeProvider.instance.set(currentContext);
WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build(); WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build();
String itemId = wsclient.getVreFolder("hl:accounting").getId(); String itemId = wsclient.getVreFolder("hl:accounting").getId();
toReturn = new String(new StringBuffer(siteLandingPagePath) toReturn = new String(new StringBuffer(siteLandingPagePath)
@ -160,23 +168,31 @@ public class StorageHubServiceUtil {
* @param request * @param request
* @return the VRE Folders Id * @return the VRE Folders Id
*/ */
public static String getVREFoldersId(HttpServletRequest request) { public static String getVREFoldersId(long groupId, HttpServletRequest request, String currentUsername) {
String userName = Utils.getCurrentUser(request).getUsername();
String scope = Utils.getCurrentContext(request);
String authorizationToken = Utils.getCurrentUserToken(scope, userName);
SecurityTokenProvider.instance.set(authorizationToken);
String toReturn = ""; String toReturn = "";
String currentContext = PortalContext.getConfiguration().getCurrentScope(""+groupId);
String username = currentUsername;
try {
JWTToken umaToken = OIDCUmaUtil.getUMAToken(request, username, currentContext);
AccessTokenProvider.instance.set(JWTTokenUtil.getAccessTokenString(umaToken));
} catch (InvalidTokenException | MissingTokenException | RefreshException | NotAuthorizedException
| UMAException e1) {
_log.warn("could not get UMA Token for context="+currentContext);
e1.printStackTrace();
}
_log.debug("getVREFoldersId, context="+currentContext);
ScopeProvider.instance.set(currentContext);
try { try {
WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build(); WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build();
try { try {
List<? extends Item> list = wsclient.getVreFolders("hl:accounting"); List<? extends Item> list = wsclient.getVreFolders("hl:accounting");
toReturn =list.iterator().next().getParentId(); toReturn =list.iterator().next().getParentId();
} catch (Exception e) { } catch (java.util.NoSuchElementException ex) {
_log.info("This user has no VRE Folders", e); _log.info("This user has no VRE Folders");
return null; return null;
} }
}catch (Exception e) { }catch (Exception e) {
e.printStackTrace(); _log.warn("Could not load VREFolders id" + e.getMessage());
} }
return toReturn; return toReturn;
} }

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.wswidget;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.Scanner; import java.util.Scanner;
import javax.portlet.PortletException; import javax.portlet.PortletException;
@ -12,7 +13,8 @@ import javax.portlet.ResourceResponse;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.authorization.library.provider.AccessTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.storagehub.client.StreamDescriptor; import org.gcube.common.storagehub.client.StreamDescriptor;
import org.gcube.common.storagehub.client.dsl.FileContainer; import org.gcube.common.storagehub.client.dsl.FileContainer;
import org.gcube.common.storagehub.client.dsl.ItemContainer; import org.gcube.common.storagehub.client.dsl.ItemContainer;
@ -23,6 +25,9 @@ import org.gcube.common.storagehub.model.exceptions.StorageHubException;
import org.gcube.common.storagehub.model.items.ExternalLink; import org.gcube.common.storagehub.model.items.ExternalLink;
import org.gcube.common.storagehub.model.items.ExternalURL; import org.gcube.common.storagehub.model.items.ExternalURL;
import org.gcube.common.storagehub.model.items.Item; import org.gcube.common.storagehub.model.items.Item;
import org.gcube.oidc.rest.JWTToken;
import org.gcube.portal.oidc.lr62.JWTTokenUtil;
import org.gcube.portal.oidc.lr62.OIDCUmaUtil;
import org.gcube.portlets.user.wswidget.shared.AuthorizedUser; import org.gcube.portlets.user.wswidget.shared.AuthorizedUser;
import org.gcube.portlets.user.wswidget.shared.Breadcrumb; import org.gcube.portlets.user.wswidget.shared.Breadcrumb;
import org.gcube.portlets.user.wswidget.shared.WSItem; import org.gcube.portlets.user.wswidget.shared.WSItem;
@ -58,6 +63,17 @@ public class WorkspaceWidget extends MVCPortlet {
//check if is a file download //check if is a file download
if (fileToDownloadId != null) { if (fileToDownloadId != null) {
setAuthorizationToken(resourceRequest); setAuthorizationToken(resourceRequest);
String currentContext = Utils.getCurrentContext(resourceRequest);
ScopeProvider.instance.set(currentContext);
HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(resourceRequest);
long userId;
try {
userId = PortalUtil.getUser(resourceRequest).getUserId();
JWTToken umaToken = OIDCUmaUtil.getUMAToken(httpReq, userId, currentContext);
AccessTokenProvider.instance.set(JWTTokenUtil.getAccessTokenString(umaToken));
} catch (Exception e1) {
e1.printStackTrace();
}
String selectedItemId = fileToDownloadId.split("=")[1]; String selectedItemId = fileToDownloadId.split("=")[1];
StorageHubClient client = new StorageHubClient(); StorageHubClient client = new StorageHubClient();
FileContainer fileContainer = null; FileContainer fileContainer = null;
@ -73,6 +89,7 @@ public class WorkspaceWidget extends MVCPortlet {
} else { } else {
fileContainer = client.open(selectedItemId).asFile(); fileContainer = client.open(selectedItemId).asFile();
streamDescr = fileContainer.download(selectedItemId); streamDescr = fileContainer.download(selectedItemId);
_log.info("*** DONE fileContainer.download for itemid=" +selectedItemId);
} }
if (item instanceof ExternalURL) { //if is a type URL we open directly the link (HL Created it) if (item instanceof ExternalURL) { //if is a type URL we open directly the link (HL Created it)
Scanner sc = new Scanner( streamDescr.getStream()); Scanner sc = new Scanner( streamDescr.getStream());
@ -86,7 +103,6 @@ public class WorkspaceWidget extends MVCPortlet {
e.printStackTrace(); e.printStackTrace();
} }
if (! (item instanceof ExternalURL || item instanceof ExternalLink)) { if (! (item instanceof ExternalURL || item instanceof ExternalLink)) {
HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(resourceRequest);
ServletResponseUtil.sendFile(httpReq,httpRes, streamDescr.getFileName(), streamDescr.getStream(), "application/download"); ServletResponseUtil.sendFile(httpReq,httpRes, streamDescr.getFileName(), streamDescr.getStream(), "application/download");
streamDescr.getStream().close(); streamDescr.getStream().close();
} }
@ -125,8 +141,13 @@ public class WorkspaceWidget extends MVCPortlet {
toSet = new Breadcrumb(itemId, Utils.getCurrentUser(request).getFirstName()+"\'s home"); toSet = new Breadcrumb(itemId, Utils.getCurrentUser(request).getFirstName()+"\'s home");
request.getPortletSession().setAttribute(BREADCRUMB_ATTR, toSet, PortletSession.APPLICATION_SCOPE); request.getPortletSession().setAttribute(BREADCRUMB_ATTR, toSet, PortletSession.APPLICATION_SCOPE);
} else { //is in a VRE } else { //is in a VRE
WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build(); _log.debug("looking for vre context");
itemId = wsclient.getVreFolder("hl:accounting").getId(); String context = Utils.getCurrentContext(request);
final String vreContext = context.replace("/", "-").substring(1); //shub expects this name, e.g. gcube-devsec-devVRE
_log.debug("shub vre name to look for: "+vreContext);
StorageHubClient shc = new StorageHubClient();
Optional<ItemContainer<? extends Item>> vreContainer = shc.getVREFolders().getContainers().stream().filter(v -> v.get().getTitle().equals(vreContext)).findFirst();
itemId = vreContainer.get().getId();
itemsList = StorageHubServiceUtil.getItemChildren(authUser, itemId, itemId, start, offset); itemsList = StorageHubServiceUtil.getItemChildren(authUser, itemId, itemId, start, offset);
String groupName = GroupLocalServiceUtil.getGroup(groupId).getName(); String groupName = GroupLocalServiceUtil.getGroup(groupId).getName();
groupName = groupName.replace("_", " "); groupName = groupName.replace("_", " ");
@ -257,10 +278,6 @@ public class WorkspaceWidget extends MVCPortlet {
} }
private static WSItem getRootItem(ResourceRequest request) { private static WSItem getRootItem(ResourceRequest request) {
String userName = Utils.getCurrentUser(request).getUsername();
String scope = Utils.getCurrentContext(request);
String authorizationToken = Utils.getCurrentUserToken(scope, userName);
SecurityTokenProvider.instance.set(authorizationToken);
WorkspaceManagerClient client = AbstractPlugin.workspace().build(); WorkspaceManagerClient client = AbstractPlugin.workspace().build();
Item itemRoot = client.getWorkspace("hl:accounting"); Item itemRoot = client.getWorkspace("hl:accounting");
WSItem root = new WSItem(itemRoot.getId(), Utils.HOME_LABEL, true); WSItem root = new WSItem(itemRoot.getId(), Utils.HOME_LABEL, true);
@ -276,9 +293,6 @@ public class WorkspaceWidget extends MVCPortlet {
*/ */
private AuthorizedUser setAuthorizationToken(ResourceRequest request) { private AuthorizedUser setAuthorizationToken(ResourceRequest request) {
GCubeUser currentUser = Utils.getCurrentUser(request); GCubeUser currentUser = Utils.getCurrentUser(request);
String scope = Utils.getCurrentContext(request); return new AuthorizedUser(currentUser);
String authorizationToken = Utils.getCurrentUserToken(scope, currentUser.getUsername());
SecurityTokenProvider.instance.set(authorizationToken);
return new AuthorizedUser(currentUser, authorizationToken, scope);
} }
} }

View File

@ -6,11 +6,10 @@ public class AuthorizedUser {
private GCubeUser user; private GCubeUser user;
private String token; private String token;
private String context; private String context;
public AuthorizedUser(GCubeUser user, String token, String context) { public AuthorizedUser(GCubeUser user) {
super(); super();
this.user = user; this.user = user;
this.token = token;
this.context = context;
} }
public GCubeUser getUser() { public GCubeUser getUser() {
return user; return user;
@ -18,18 +17,7 @@ public class AuthorizedUser {
public void setUser(GCubeUser user) { public void setUser(GCubeUser user) {
this.user = user; this.user = user;
} }
public String getSecurityToken() {
return token;
}
public void setSecurityToken(String token) {
this.token = token;
}
public String getContext() {
return context;
}
public void setContext(String context) {
this.context = context;
}
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();

View File

@ -130,7 +130,8 @@
.workspace-widget-portlet .dataTables_wrapper { .workspace-widget-portlet .dataTables_wrapper {
margin-left: -5px; margin-left: -5px;
} overflow-x: hidden;
}
/* .dataTables_wrapper .dataTables_paginate .paginate_button.current, .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover */ /* .dataTables_wrapper .dataTables_paginate .paginate_button.current, .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover */

View File

@ -3,7 +3,10 @@
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" <link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet"> rel="stylesheet">
<% pageContext.setAttribute("currentGroup", GroupLocalServiceUtil.getGroup(PortalUtil.getScopeGroupId(request))); <%
pageContext.setAttribute("currentGroup", GroupLocalServiceUtil.getGroup(PortalUtil.getScopeGroupId(request)));
String currentUsername = PortalUtil.getUser(request).getScreenName();
pageContext.setAttribute("currentUsername", PortalUtil.getUser(request).getScreenName());
%> %>
<script src="<%=renderRequest.getContextPath()%>/js/datatables.min.js"></script> <script src="<%=renderRequest.getContextPath()%>/js/datatables.min.js"></script>
@ -21,7 +24,7 @@
<c:set var="maximised" scope="session" <c:set var="maximised" scope="session"
value="${renderRequest.getWindowState().toString().equalsIgnoreCase('maximized')}" /> value="${renderRequest.getWindowState().toString().equalsIgnoreCase('maximized')}" />
<table width="100%" style="border: none; border-collapse: inherit;"> <table width="100%" style="border: none; border-collapse: inherit; overflow-x: hidden;">
<tr> <tr>
<td><div class="ws-breadcrumb-container"></div></td> <td><div class="ws-breadcrumb-container"></div></td>
<c:choose> <c:choose>
@ -42,7 +45,7 @@
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<td> <td>
<%pageContext.setAttribute("vreFoldersId", StorageHubServiceUtil.getVREFoldersId(request));%> <%pageContext.setAttribute("vreFoldersId", StorageHubServiceUtil.getVREFoldersId(PortalUtil.getScopeGroupId(request), request, currentUsername));%>
<c:if test="${not empty vreFoldersId}"> <c:if test="${not empty vreFoldersId}">
<div id="vreFoldersDiv" class="ws-recents"> <div id="vreFoldersDiv" class="ws-recents">
<a <a
@ -88,7 +91,7 @@ $.fn.dataTable.ext.errMode = 'none';
function loadItemsListIntoTable(itemId, itemName, hideVreFolders) { function loadItemsListIntoTable(itemId, itemName, hideVreFolders) {
var table = $('#userTable').DataTable(); var table = $('#userTable').DataTable();
table.ajax.url('<%=usersCustomDataSourceURL%>'+itemId+'_selectedName='+itemName).load(); table.ajax.url('<%=usersCustomDataSourceURL%>'+itemId+'_selectedName='+encodeURIComponent(itemName)).load();
if (hideVreFolders) { if (hideVreFolders) {
$('#vreFoldersDiv').hide(); $('#vreFoldersDiv').hide();
} else { } else {
@ -100,7 +103,7 @@ function loadItemsListIntoTable(itemId, itemName, hideVreFolders) {
function loadRecentItemsListIntoTable(itemId, itemName) { function loadRecentItemsListIntoTable(itemId, itemName) {
var table = $('#userTable').DataTable(); var table = $('#userTable').DataTable();
table.ajax.url('<%=usersCustomDataSourceURL%>'+itemId+'_selectedName='+itemName).load(); table.ajax.url('<%=usersCustomDataSourceURL%>'+itemId+'_selectedName='+encodeURIComponent(itemName)).load();
$('#userTable_info').hide(); $('#userTable_info').hide();
$('#userTable_length').hide(); $('#userTable_length').hide();
} }