Updated in order to use the method:
Workspace ws = HomeLibrary.getHomeManagerFactory().getHomeManager().getGuestLogin().getWorkspace(); see: #3782 git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/workspace-explorer-app@131325 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7619df4ca8
commit
8337e7b912
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" output="target/workspace-explorer-app-0.0.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
<classpathentry kind="src" output="target/workspace-explorer-app-0.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry excluding="**" kind="src" output="target/workspace-explorer-app-0.0.1-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
<classpathentry excluding="**" kind="src" output="target/workspace-explorer-app-0.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
@ -33,5 +33,5 @@
|
||||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="target/workspace-explorer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
|
<classpathentry kind="output" path="target/workspace-explorer-app-0.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
activeProfiles=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
resolveWorkspaceProjects=true
|
||||||
|
version=1
|
35
pom.xml
35
pom.xml
|
@ -9,7 +9,7 @@
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>workspace-explorer-app</artifactId>
|
<artifactId>workspace-explorer-app</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
|
@ -70,17 +70,16 @@
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- <dependency> -->
|
<!-- <dependency> -->
|
||||||
<!-- <groupId>com.google.gwt</groupId> -->
|
<!-- <groupId>com.google.gwt</groupId> -->
|
||||||
<!-- <artifactId>gwt-servlet</artifactId> -->
|
<!-- <artifactId>gwt-servlet</artifactId> -->
|
||||||
<!-- <version>${gwtVersion}</version> -->
|
<!-- <version>${gwtVersion}</version> -->
|
||||||
<!-- <scope>provided</scope> -->
|
<!-- <scope>provided</scope> -->
|
||||||
<!-- </dependency> -->
|
<!-- </dependency> -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.gwtbootstrap</groupId>
|
<groupId>com.github.gwtbootstrap</groupId>
|
||||||
<artifactId>gwt-bootstrap</artifactId>
|
<artifactId>gwt-bootstrap</artifactId>
|
||||||
<version>2.3.2.0</version>
|
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -113,36 +112,33 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.resources.discovery</groupId>
|
<groupId>org.gcube.resources.discovery</groupId>
|
||||||
<artifactId>ic-client</artifactId>
|
<artifactId>ic-client</artifactId>
|
||||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.core</groupId>
|
<groupId>org.gcube.core</groupId>
|
||||||
<artifactId>common-scope-maps</artifactId>
|
<artifactId>common-scope-maps</artifactId>
|
||||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- END FWS -->
|
<!-- END FWS -->
|
||||||
|
|
||||||
<dependency>
|
<!-- <dependency> -->
|
||||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
<!-- <groupId>org.gcube.applicationsupportlayer</groupId> -->
|
||||||
<artifactId>aslcore</artifactId>
|
<!-- <artifactId>aslcore</artifactId> -->
|
||||||
<version>[4.0.0-SNAPSHOT, 5.0.0-SNAPSHOT)</version>
|
<!-- <scope>provided</scope> -->
|
||||||
<scope>provided</scope>
|
<!-- </dependency> -->
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- HOME LIBRARY -->
|
<!-- HOME LIBRARY -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>home-library-model</artifactId>
|
<artifactId>home-library-model</artifactId>
|
||||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>home-library-jcr</artifactId>
|
<artifactId>home-library-jcr</artifactId>
|
||||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
<version>[2.5.0-SNAPSHOT,3.5.0-SNAPSHOT)</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
|
@ -154,8 +150,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>home-library</artifactId>
|
<artifactId>home-library</artifactId>
|
||||||
<!-- <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> -->
|
<version>[2.5.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
|
|
|
@ -6,9 +6,7 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
|
||||||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
|
@ -140,37 +138,37 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
|
||||||
@Override
|
@Override
|
||||||
public Item getItemByCategory(ItemCategory category) throws WorkspaceNavigatorServiceException{
|
public Item getItemByCategory(ItemCategory category) throws WorkspaceNavigatorServiceException{
|
||||||
logger.trace("GetItemByCategory category: "+category);
|
logger.trace("GetItemByCategory category: "+category);
|
||||||
try {
|
return null; //TODO
|
||||||
Workspace workspace = WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
|
// try {
|
||||||
Item item = null;
|
// Workspace workspace = WsUtil.getWorkspace();
|
||||||
|
// Item item = null;
|
||||||
switch(category){
|
//
|
||||||
case HOME:{
|
// switch(category){
|
||||||
WorkspaceItem root = workspace.getRoot();
|
// case HOME:{
|
||||||
ASLSession session = WsUtil.getASLSession(this.getThreadLocalRequest().getSession());
|
// WorkspaceItem root = workspace.getRoot();
|
||||||
// String fullName = UserUtil.getUserFullName(session.getUsername());
|
//// String fullName = UserUtil.getUserFullName(session.getUsername());
|
||||||
String fullName = session.getUsername();
|
// String fullName = session.getUsername();
|
||||||
if(fullName.indexOf(" ")>0){
|
// if(fullName.indexOf(" ")>0){
|
||||||
fullName = fullName.substring(0, fullName.indexOf(" "));
|
// fullName = fullName.substring(0, fullName.indexOf(" "));
|
||||||
}else if(fullName.indexOf(".")>0){
|
// }else if(fullName.indexOf(".")>0){
|
||||||
fullName = fullName.substring(0, fullName.indexOf("."));
|
// fullName = fullName.substring(0, fullName.indexOf("."));
|
||||||
}
|
// }
|
||||||
item = new Item(null, root.getId(), fullName+"'s", ItemType.FOLDER, root.getPath(), root.getOwner().getPortalLogin(), null, true, true);
|
// item = new Item(null, root.getId(), fullName+"'s", ItemType.FOLDER, root.getPath(), root.getOwner().getPortalLogin(), null, true, true);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case VRE_FOLDER:{
|
// case VRE_FOLDER:{
|
||||||
WorkspaceItem folder = workspace.getMySpecialFolders();
|
// WorkspaceItem folder = workspace.getMySpecialFolders();
|
||||||
item = new Item(null, folder.getId(), WorkspaceExplorerAppConstants.VRE_FOLDERS_LABEL, ItemType.FOLDER, folder.getPath(), folder.getOwner().getPortalLogin(), null, true, false);
|
// item = new Item(null, folder.getId(), WorkspaceExplorerAppConstants.VRE_FOLDERS_LABEL, ItemType.FOLDER, folder.getPath(), folder.getOwner().getPortalLogin(), null, true, false);
|
||||||
//SET SPECIAL FOLDER /Workspace/MySpecialFolders
|
// //SET SPECIAL FOLDER /Workspace/MySpecialFolders
|
||||||
item.setSpecialFolder(true);
|
// item.setSpecialFolder(true);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return item;
|
// return item;
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
logger.error("Error during get item by category", e);
|
// logger.error("Error during get item by category", e);
|
||||||
throw new WorkspaceNavigatorServiceException("Sorry, an error occurred when performing get item by category");
|
// throw new WorkspaceNavigatorServiceException("Sorry, an error occurred when performing get item by category");
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -228,8 +226,7 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
|
||||||
public boolean checkName(String name) throws WorkspaceNavigatorServiceException {
|
public boolean checkName(String name) throws WorkspaceNavigatorServiceException {
|
||||||
logger.trace("checkName name: "+name);
|
logger.trace("checkName name: "+name);
|
||||||
try {
|
try {
|
||||||
ASLSession session = WsUtil.getASLSession(this.getThreadLocalRequest().getSession());
|
Workspace workspace = WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
|
||||||
Workspace workspace = HomeLibrary.getUserWorkspace(session.getUsername());
|
|
||||||
return workspace.isValidName(name);
|
return workspace.isValidName(name);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error during folder retrieving", e);
|
logger.error("Error during folder retrieving", e);
|
||||||
|
|
|
@ -5,11 +5,10 @@ package org.gcube.portlets.user.workspaceexplorerapp.server;
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
|
||||||
import org.gcube.application.framework.core.session.SessionManager;
|
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||||
|
import org.gcube.common.homelibrary.home.exceptions.UserNotFoundException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
@ -21,49 +20,12 @@ import org.slf4j.LoggerFactory;
|
||||||
* The Class WsUtil.
|
* The Class WsUtil.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* Mar 7, 2016
|
* Sep 13, 2016
|
||||||
*/
|
*/
|
||||||
public class WsUtil {
|
public class WsUtil {
|
||||||
|
|
||||||
public static final String USERNAME_ATTRIBUTE = "username";
|
|
||||||
public static final String TEST_USER = "francesco.mangiacrapa";
|
|
||||||
public static final String TEST_SCOPE = "/gcube/devsec/devVRE";
|
|
||||||
|
|
||||||
public static final Logger logger = LoggerFactory.getLogger(WsUtil.class);
|
public static final Logger logger = LoggerFactory.getLogger(WsUtil.class);
|
||||||
|
private static final String SCOPE = "scope";
|
||||||
/**
|
|
||||||
* Gets the ASL session.
|
|
||||||
*
|
|
||||||
* @param httpSession the http session
|
|
||||||
* @return the ASL session
|
|
||||||
*/
|
|
||||||
public static ASLSession getASLSession(HttpSession httpSession) {
|
|
||||||
String sessionID = httpSession.getId();
|
|
||||||
String user = (String) httpSession.getAttribute(USERNAME_ATTRIBUTE);
|
|
||||||
|
|
||||||
//TODO we check for the older attribute name
|
|
||||||
if (user == null) {
|
|
||||||
user = (String) httpSession.getAttribute("user");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user == null) {
|
|
||||||
|
|
||||||
logger.error("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND");
|
|
||||||
|
|
||||||
//for test only
|
|
||||||
// user = "test.user";
|
|
||||||
user = TEST_USER;
|
|
||||||
httpSession.setAttribute(USERNAME_ATTRIBUTE, user);
|
|
||||||
ASLSession session = SessionManager.getInstance().getASLSession(sessionID, user);
|
|
||||||
session.setScope(TEST_SCOPE);
|
|
||||||
|
|
||||||
return session;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logger.trace("user found in session "+user);
|
|
||||||
}
|
|
||||||
return SessionManager.getInstance().getASLSession(sessionID, user);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the workspace.
|
* Gets the workspace.
|
||||||
|
@ -73,17 +35,21 @@ public class WsUtil {
|
||||||
* @throws InternalErrorException the internal error exception
|
* @throws InternalErrorException the internal error exception
|
||||||
* @throws HomeNotFoundException the home not found exception
|
* @throws HomeNotFoundException the home not found exception
|
||||||
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
|
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
|
||||||
|
* @throws UserNotFoundException
|
||||||
*/
|
*/
|
||||||
public static Workspace getWorkspace(HttpSession httpSession) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException {
|
public static Workspace getWorkspace(HttpSession httpSession) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException, UserNotFoundException {
|
||||||
ASLSession session = getASLSession(httpSession);
|
// ASLSession session = getASLSession(httpSession);
|
||||||
logger.trace("Scope : "+session.getScope() + " username: "+session.getUsername());
|
|
||||||
String scope = session.getScope();
|
String scope = (String) httpSession.getAttribute(SCOPE);
|
||||||
if(scope==null)
|
|
||||||
scope= WsUtil.TEST_SCOPE;
|
if(scope==null){
|
||||||
System.out.println("Scope : "+scope + " username: "+session.getUsername());
|
logger.info(SCOPE + "read from context is: "+scope);
|
||||||
|
scope = httpSession.getServletContext().getInitParameter(SCOPE);
|
||||||
|
}
|
||||||
|
//GET CONTEXT
|
||||||
|
logger.info("Setting scope: "+scope);
|
||||||
ScopeProvider.instance.set(scope);
|
ScopeProvider.instance.set(scope);
|
||||||
Workspace workspace = HomeLibrary.getUserWorkspace(session.getUsername());
|
return HomeLibrary.getHomeManagerFactory().getHomeManager().getGuestLogin().getWorkspace();
|
||||||
return workspace;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
<welcome-file-list>
|
<welcome-file-list>
|
||||||
<welcome-file>WorkspaceExplorerApp.html</welcome-file>
|
<welcome-file>WorkspaceExplorerApp.html</welcome-file>
|
||||||
</welcome-file-list>
|
</welcome-file-list>
|
||||||
|
<context-param>
|
||||||
|
<description>scope for using HL</description>
|
||||||
|
<param-name>scope</param-name>
|
||||||
|
<param-value>/d4science.research-infrastructures.eu</param-value>
|
||||||
|
</context-param>
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>workspaceExplorerAppServlet</servlet-name>
|
<servlet-name>workspaceExplorerAppServlet</servlet-name>
|
||||||
<servlet-class>org.gcube.portlets.user.workspaceexplorerapp.server.WorkspaceExplorerAppServiceImpl</servlet-class>
|
<servlet-class>org.gcube.portlets.user.workspaceexplorerapp.server.WorkspaceExplorerAppServiceImpl</servlet-class>
|
||||||
|
|
Loading…
Reference in New Issue