Implementing
Feature #5873: Remove ASL Session from the Workspace and its components git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@134769 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
90eda1a95b
commit
a4621f6223
20
pom.xml
20
pom.xml
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>workspace-tree-widget</artifactId>
|
<artifactId>workspace-tree-widget</artifactId>
|
||||||
<version>6.14.0-SNAPSHOT</version>
|
<version>6.15.0-SNAPSHOT</version>
|
||||||
<name>gCube Workspace Tree Widget</name>
|
<name>gCube Workspace Tree Widget</name>
|
||||||
<description>
|
<description>
|
||||||
gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace
|
gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace
|
||||||
|
@ -88,6 +88,14 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common.portal</groupId>
|
<groupId>org.gcube.common.portal</groupId>
|
||||||
<artifactId>portal-manager</artifactId>
|
<artifactId>portal-manager</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- User Management Core -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.dvos</groupId>
|
||||||
|
<artifactId>usermanagement-core</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- FWS -->
|
<!-- FWS -->
|
||||||
|
@ -114,21 +122,11 @@
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.portal</groupId>
|
|
||||||
<artifactId>custom-portal-handler</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>gcube-widgets</artifactId>
|
<artifactId>gcube-widgets</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
|
||||||
<artifactId>aslcore</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
|
|
|
@ -17,8 +17,8 @@ public enum WorkspaceOperation {
|
||||||
LINK("LNK", "LNK"),
|
LINK("LNK", "LNK"),
|
||||||
SHOW("SHW", "SHW"), // SHOW
|
SHOW("SHW", "SHW"), // SHOW
|
||||||
ADD_URL("CLK", "CLK"), // Add Url
|
ADD_URL("CLK", "CLK"), // Add Url
|
||||||
OPEN_REPORT_TEMPLATE("ORT", "ORT"), // Open report template
|
// OPEN_REPORT_TEMPLATE("ORT", "ORT"), // Open report template
|
||||||
OPEN_REPORT("ORP", "ORP"), // Open report
|
// OPEN_REPORT("ORP", "ORP"), // Open report
|
||||||
SENDTO("SDT", "SDT"), // Send to
|
SENDTO("SDT", "SDT"), // Send to
|
||||||
GET_NEW_MESSAGES("DWM", "DWM"), // Get all new messages
|
GET_NEW_MESSAGES("DWM", "DWM"), // Get all new messages
|
||||||
CREATE_NEW_MESSAGE("CNM", "CNM"), // Create new message
|
CREATE_NEW_MESSAGE("CNM", "CNM"), // Create new message
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.gcube.portlets.user.workspace.client.event.GetInfoEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.GetPublicLinkEvent;
|
import org.gcube.portlets.user.workspace.client.event.GetPublicLinkEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.GetShareLinkEvent;
|
import org.gcube.portlets.user.workspace.client.event.GetShareLinkEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEvent;
|
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.OpenReportsEvent;
|
|
||||||
import org.gcube.portlets.user.workspace.client.event.OpenUrlEvent;
|
import org.gcube.portlets.user.workspace.client.event.OpenUrlEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.PasteItemEvent;
|
import org.gcube.portlets.user.workspace.client.event.PasteItemEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.PublishOnDataCatalogueEvent;
|
import org.gcube.portlets.user.workspace.client.event.PublishOnDataCatalogueEvent;
|
||||||
|
@ -127,43 +126,45 @@ public class ContextMenuTree {
|
||||||
contextMenu.add(openUrl);
|
contextMenu.add(openUrl);
|
||||||
|
|
||||||
//Open Report Template
|
//Open Report Template
|
||||||
MenuItem openReportTemplate = new MenuItem();
|
//TODO REMOVE
|
||||||
openReportTemplate.setId(WorkspaceOperation.OPEN_REPORT_TEMPLATE.getId());
|
// MenuItem openReportTemplate = new MenuItem();
|
||||||
openReportTemplate.setText(ConstantsExplorer.MESSAGE_OPEN_REPORT_TEMPLATE);
|
// openReportTemplate.setId(WorkspaceOperation.OPEN_REPORT_TEMPLATE.getId());
|
||||||
openReportTemplate.setIcon(Resources.getIconShow());
|
// openReportTemplate.setText(ConstantsExplorer.MESSAGE_OPEN_REPORT_TEMPLATE);
|
||||||
|
// openReportTemplate.setIcon(Resources.getIconShow());
|
||||||
|
//
|
||||||
|
// openReportTemplate.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
|
// public void componentSelected(MenuEvent ce) {
|
||||||
|
//
|
||||||
|
// FileModel selected = listSelectedItems.get(0);
|
||||||
|
//
|
||||||
|
// if(selected!=null){
|
||||||
|
// eventBus.fireEvent(new OpenReportsEvent(selected));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
openReportTemplate.addSelectionListener(new SelectionListener<MenuEvent>() {
|
//contextMenu.add(openReportTemplate);
|
||||||
public void componentSelected(MenuEvent ce) {
|
|
||||||
|
|
||||||
FileModel selected = listSelectedItems.get(0);
|
|
||||||
|
|
||||||
if(selected!=null){
|
|
||||||
eventBus.fireEvent(new OpenReportsEvent(selected));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
contextMenu.add(openReportTemplate);
|
|
||||||
|
|
||||||
//Open Report Template
|
//Open Report Template
|
||||||
MenuItem openReport = new MenuItem();
|
//TODO REMOVE
|
||||||
openReport.setId(WorkspaceOperation.OPEN_REPORT.getId());
|
// MenuItem openReport = new MenuItem();
|
||||||
openReport.setText(ConstantsExplorer.MESSAGE_OPEN_REPORT);
|
// openReport.setId(WorkspaceOperation.OPEN_REPORT.getId());
|
||||||
openReport.setIcon(Resources.getIconShow());
|
// openReport.setText(ConstantsExplorer.MESSAGE_OPEN_REPORT);
|
||||||
|
// openReport.setIcon(Resources.getIconShow());
|
||||||
|
//
|
||||||
|
// openReport.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
|
// public void componentSelected(MenuEvent ce) {
|
||||||
|
//
|
||||||
|
// FileModel selected = listSelectedItems.get(0);
|
||||||
|
//
|
||||||
|
// if (selected != null){
|
||||||
|
// eventBus.fireEvent(new OpenReportsEvent(selected));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
openReport.addSelectionListener(new SelectionListener<MenuEvent>() {
|
//contextMenu.add(openReport);
|
||||||
public void componentSelected(MenuEvent ce) {
|
|
||||||
|
|
||||||
FileModel selected = listSelectedItems.get(0);
|
|
||||||
|
|
||||||
if (selected != null){
|
|
||||||
eventBus.fireEvent(new OpenReportsEvent(selected));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
contextMenu.add(openReport);
|
|
||||||
contextMenu.add(new SeparatorMenuItem());
|
contextMenu.add(new SeparatorMenuItem());
|
||||||
//END SPECIFIC OPERATION
|
//END SPECIFIC OPERATION
|
||||||
|
|
||||||
|
@ -539,7 +540,7 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
|
|
||||||
for (final FileModel sel : listSelectedItems) {
|
for (final FileModel sel : listSelectedItems) {
|
||||||
eventBus.fireEvent(new FileDownloadEvent(sel.getIdentifier(), sel.getName(), DownloadType.SHOW, (sel.isDirectory() || sel.isVreFolder())));
|
eventBus.fireEvent(new FileDownloadEvent(sel.getIdentifier(), sel.getName(), DownloadType.SHOW, sel.isDirectory() || sel.isVreFolder()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -637,7 +638,7 @@ public class ContextMenuTree {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
for (FileModel sel : listSelectedItems) {
|
for (FileModel sel : listSelectedItems) {
|
||||||
eventBus.fireEvent(new FileDownloadEvent(sel.getIdentifier(), sel.getName(), DownloadType.DOWNLOAD, (sel.isDirectory() || sel.isVreFolder())));
|
eventBus.fireEvent(new FileDownloadEvent(sel.getIdentifier(), sel.getName(), DownloadType.DOWNLOAD, sel.isDirectory() || sel.isVreFolder()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -821,8 +822,8 @@ public class ContextMenuTree {
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PREVIEW.getId()).setVisible(false); //preview image
|
contextMenu.getItemByItemId(WorkspaceOperation.PREVIEW.getId()).setVisible(false); //preview image
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.LINK.getId()).setVisible(false); //open link
|
contextMenu.getItemByItemId(WorkspaceOperation.LINK.getId()).setVisible(false); //open link
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SHOW.getId()).setVisible(false); //show
|
contextMenu.getItemByItemId(WorkspaceOperation.SHOW.getId()).setVisible(false); //show
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.OPEN_REPORT.getId()).setVisible(false); //open report
|
//contextMenu.getItemByItemId(WorkspaceOperation.OPEN_REPORT.getId()).setVisible(false); //open report
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.OPEN_REPORT_TEMPLATE.getId()).setVisible(false); //open report template
|
//contextMenu.getItemByItemId(WorkspaceOperation.OPEN_REPORT_TEMPLATE.getId()).setVisible(false); //open report template
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(false); //paste
|
contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(false); //paste
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(false); //refresh
|
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(false); //refresh
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(false); //public link
|
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(false); //public link
|
||||||
|
@ -933,10 +934,10 @@ public class ContextMenuTree {
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.LINK.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.LINK.getId()).setVisible(true);
|
||||||
break;
|
break;
|
||||||
case REPORT_TEMPLATE:
|
case REPORT_TEMPLATE:
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.OPEN_REPORT_TEMPLATE.getId()).setVisible(true);
|
//contextMenu.getItemByItemId(WorkspaceOperation.OPEN_REPORT_TEMPLATE.getId()).setVisible(true);
|
||||||
break;
|
break;
|
||||||
case REPORT:
|
case REPORT:
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.OPEN_REPORT.getId()).setVisible(true);
|
//contextMenu.getItemByItemId(WorkspaceOperation.OPEN_REPORT.getId()).setVisible(true);
|
||||||
break;
|
break;
|
||||||
case QUERY:
|
case QUERY:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -13,7 +13,6 @@ import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
@ -43,10 +42,9 @@ public class DownloadFolderServlet extends HttpServlet{
|
||||||
|
|
||||||
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
|
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
|
||||||
boolean urlRedirectOnError = req.getParameter(ConstantsExplorer.REDIRECTONERROR)==null?false:req.getParameter(ConstantsExplorer.REDIRECTONERROR).equals("true");
|
boolean urlRedirectOnError = req.getParameter(ConstantsExplorer.REDIRECTONERROR)==null?false:req.getParameter(ConstantsExplorer.REDIRECTONERROR).equals("true");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
HttpSession session = req.getSession();
|
if(WsUtil.isSessionExpired(req))
|
||||||
if(WsUtil.isSessionExpired(session))
|
|
||||||
throw new SessionExpiredException();
|
throw new SessionExpiredException();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
@ -55,7 +53,7 @@ public class DownloadFolderServlet extends HttpServlet{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String fileRelativePath = req.getParameter("filepath");
|
String fileRelativePath = req.getParameter("filepath");
|
||||||
String tmpDir = System.getProperty("java.io.tmpdir");
|
String tmpDir = System.getProperty("java.io.tmpdir");
|
||||||
String pathToFile = tmpDir + File.separator + fileRelativePath;
|
String pathToFile = tmpDir + File.separator + fileRelativePath;
|
||||||
|
@ -63,7 +61,7 @@ public class DownloadFolderServlet extends HttpServlet{
|
||||||
logger.debug("looking for File in " + pathToFile);
|
logger.debug("looking for File in " + pathToFile);
|
||||||
File tmpZip = new File(pathToFile);
|
File tmpZip = new File(pathToFile);
|
||||||
logger.debug("File instanciated " + pathToFile);
|
logger.debug("File instanciated " + pathToFile);
|
||||||
|
|
||||||
resp.setHeader( "Content-Disposition", "attachment; filename=\"" + tmpZip.getName() + ".zip\"" );
|
resp.setHeader( "Content-Disposition", "attachment; filename=\"" + tmpZip.getName() + ".zip\"" );
|
||||||
resp.setContentType("application/zip");
|
resp.setContentType("application/zip");
|
||||||
resp = setContentLength(resp, tmpZip.length());
|
resp = setContentLength(resp, tmpZip.length());
|
||||||
|
|
|
@ -14,7 +14,6 @@ import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
@ -78,11 +77,10 @@ public class DownloadServlet extends HttpServlet{
|
||||||
Workspace wa = null;
|
Workspace wa = null;
|
||||||
try {
|
try {
|
||||||
//ADDED 13-01-2014 SESSION VALIDATION
|
//ADDED 13-01-2014 SESSION VALIDATION
|
||||||
HttpSession session = req.getSession();
|
if(WsUtil.isSessionExpired(req))
|
||||||
if(WsUtil.isSessionExpired(session))
|
|
||||||
throw new SessionExpiredException();
|
throw new SessionExpiredException();
|
||||||
|
|
||||||
wa = WsUtil.getWorkspace(session);
|
wa = WsUtil.getWorkspace(req);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
if (e instanceof SessionExpiredException){
|
if (e instanceof SessionExpiredException){
|
||||||
|
|
|
@ -16,7 +16,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
|
||||||
import org.gcube.common.encryption.StringEncrypter;
|
import org.gcube.common.encryption.StringEncrypter;
|
||||||
import org.gcube.common.homelibary.model.items.type.FolderItemType;
|
import org.gcube.common.homelibary.model.items.type.FolderItemType;
|
||||||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||||
|
@ -70,6 +69,7 @@ import org.gcube.portlets.user.workspace.server.reader.ApplicationProfileReader;
|
||||||
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex;
|
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex;
|
||||||
import org.gcube.portlets.user.workspace.server.util.AclTypeComparator;
|
import org.gcube.portlets.user.workspace.server.util.AclTypeComparator;
|
||||||
import org.gcube.portlets.user.workspace.server.util.DifferenceBetweenInfoContactModel;
|
import org.gcube.portlets.user.workspace.server.util.DifferenceBetweenInfoContactModel;
|
||||||
|
import org.gcube.portlets.user.workspace.server.util.PortalContextInfo;
|
||||||
import org.gcube.portlets.user.workspace.server.util.StringUtil;
|
import org.gcube.portlets.user.workspace.server.util.StringUtil;
|
||||||
import org.gcube.portlets.user.workspace.server.util.UserUtil;
|
import org.gcube.portlets.user.workspace.server.util.UserUtil;
|
||||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||||
|
@ -126,7 +126,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
*/
|
*/
|
||||||
protected GWTWorkspaceBuilder getGWTWorkspaceBuilder()
|
protected GWTWorkspaceBuilder getGWTWorkspaceBuilder()
|
||||||
{
|
{
|
||||||
return WsUtil.getGWTWorkspaceBuilder(this.getThreadLocalRequest().getSession());
|
return WsUtil.getGWTWorkspaceBuilder(this.getThreadLocalRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,7 +139,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
*/
|
*/
|
||||||
protected Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
|
protected Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
|
||||||
{
|
{
|
||||||
return WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
|
return WsUtil.getWorkspace(this.getThreadLocalRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,7 +149,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
*/
|
*/
|
||||||
protected NotificationsProducer getNotificationProducer(){
|
protected NotificationsProducer getNotificationProducer(){
|
||||||
|
|
||||||
return WsUtil.getNotificationProducer(WsUtil.getAslSession(this.getThreadLocalRequest().getSession()), this.getThreadLocalRequest());
|
return WsUtil.getNotificationProducer(this.getThreadLocalRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -159,7 +159,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
*/
|
*/
|
||||||
protected ScopeUtilFilter getScopeUtilFilter(){
|
protected ScopeUtilFilter getScopeUtilFilter(){
|
||||||
|
|
||||||
return WsUtil.getScopeUtilFilter(this.getThreadLocalRequest().getSession());
|
return WsUtil.getScopeUtilFilter(this.getThreadLocalRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,7 +177,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
* @return the url shortener
|
* @return the url shortener
|
||||||
*/
|
*/
|
||||||
protected UrlShortener getUrlShortener() {
|
protected UrlShortener getUrlShortener() {
|
||||||
return WsUtil.getUrlShortener(this.getThreadLocalRequest().getSession());
|
return WsUtil.getUrlShortener(this.getThreadLocalRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -186,7 +186,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
* @return the uri resolver
|
* @return the uri resolver
|
||||||
*/
|
*/
|
||||||
protected UriResolverReaderParameterForResolverIndex getUriResolver() {
|
protected UriResolverReaderParameterForResolverIndex getUriResolver() {
|
||||||
return WsUtil.getUriResolver(this.getThreadLocalRequest().getSession());
|
return WsUtil.getUriResolver(this.getThreadLocalRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -196,7 +196,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
*/
|
*/
|
||||||
protected PropertySpecialFolderReader getPropertySpecialFolderReader() {
|
protected PropertySpecialFolderReader getPropertySpecialFolderReader() {
|
||||||
String absolutePathProperty = getSpecialFolderPath();
|
String absolutePathProperty = getSpecialFolderPath();
|
||||||
return WsUtil.getPropertySpecialFolderReader(this.getThreadLocalRequest().getSession(),absolutePathProperty);
|
return WsUtil.getPropertySpecialFolderReader(this.getThreadLocalRequest(),absolutePathProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -878,7 +878,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
workspace.removeItem(itemId);
|
workspace.removeItem(itemId);
|
||||||
//IF SOURCE SHARED FOLDER IS NOT NULL
|
//IF SOURCE SHARED FOLDER IS NOT NULL
|
||||||
if(sourceFolderSharedId!=null)
|
if(sourceFolderSharedId!=null)
|
||||||
NotificationsUtil.checkSendNotifyRemoveItemToShare(this.getThreadLocalRequest(), this.getThreadLocalRequest().getSession(), sourceItemIsShared, itemName, itemId, sourceFolderSharedId);
|
NotificationsUtil.checkSendNotifyRemoveItemToShare(this.getThreadLocalRequest(), sourceItemIsShared, itemName, itemId, sourceFolderSharedId);
|
||||||
|
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
|
|
||||||
|
@ -1361,15 +1361,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
throw new Exception("Parent item is null");
|
throw new Exception("Parent item is null");
|
||||||
|
|
||||||
workspaceLogger.trace("create url in parent id: "+parentFileModel.getIdentifier());
|
workspaceLogger.trace("create url in parent id: "+parentFileModel.getIdentifier());
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
// workspaceLogger.trace("Name " + name);
|
|
||||||
// workspaceLogger.trace("description " + description);
|
|
||||||
// workspaceLogger.trace("url " + url);
|
|
||||||
// workspaceLogger.trace("parentFileModel " + parentFileModel.getIdentifier() + " " + parentFileModel.getName());
|
|
||||||
// if(description == null)
|
|
||||||
// description = "";
|
|
||||||
|
|
||||||
ExternalUrl ext = workspace.createExternalUrl(name, description, url, parentFileModel.getIdentifier());
|
ExternalUrl ext = workspace.createExternalUrl(name, description, url, parentFileModel.getIdentifier());
|
||||||
WorkspaceItem parent = workspace.getItem(parentFileModel.getIdentifier()); //get item from workspace
|
WorkspaceItem parent = workspace.getItem(parentFileModel.getIdentifier()); //get item from workspace
|
||||||
workspaceLogger.trace("parent name " + parent.getName());
|
workspaceLogger.trace("parent name " + parent.getName());
|
||||||
|
@ -1399,13 +1390,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
if(oid==null)
|
if(oid==null)
|
||||||
throw new Exception(IDENTIFIER_IS_NULL);
|
throw new Exception(IDENTIFIER_IS_NULL);
|
||||||
|
|
||||||
ASLSession session = WsUtil.getAslSession(this.getThreadLocalRequest().getSession());
|
PortalContextInfo info = WsUtil.getPortalContext(this.getThreadLocalRequest());
|
||||||
|
|
||||||
if(WsUtil.isVRE(session)){
|
if(WsUtil.isVRE(info.getCurrentScope())){
|
||||||
|
|
||||||
ScopeProvider.instance.set(session.getScope());
|
ScopeProvider.instance.set(info.getCurrentScope());
|
||||||
// GET WORKSPACE
|
// GET WORKSPACE
|
||||||
Workspace workspace = HomeLibrary.getUserWorkspace(session.getUsername());
|
Workspace workspace = HomeLibrary.getUserWorkspace(info.getUsername());
|
||||||
// GET ITEM FROM WORKSPACE
|
// GET ITEM FROM WORKSPACE
|
||||||
WorkspaceItem item = workspace.getItem(oid);
|
WorkspaceItem item = workspace.getItem(oid);
|
||||||
|
|
||||||
|
@ -1422,8 +1413,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else{
|
||||||
urlPortlet = app.getURLFromApplicationProfile(oid, WsUtil.getAslSession(this.getThreadLocalRequest().getSession()),this.getThreadLocalRequest().getSession());
|
//TODO DISMISSED
|
||||||
|
//urlPortlet = app.getURLFromApplicationProfile(oid, WsUtil.getPortalContext(this.getThreadLocalRequest().getSession()),this.getThreadLocalRequest().getSession());
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
workspaceLogger.error("getURLFromApplicationProfile", e);
|
workspaceLogger.error("getURLFromApplicationProfile", e);
|
||||||
|
@ -1440,9 +1433,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
public void setValueInSession(String name, String value) throws Exception {
|
public void setValueInSession(String name, String value) throws Exception {
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
this.getThreadLocalRequest().getSession().setAttribute(name, value);
|
||||||
ASLSession session = WsUtil.getAslSession(this.getThreadLocalRequest().getSession());
|
|
||||||
session.setAttribute(name, value);
|
|
||||||
workspaceLogger.trace("set value in session with name: "+name+", value: "+value);
|
workspaceLogger.trace("set value in session with name: "+name+", value: "+value);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
workspaceLogger.error("setValueInSession", e);
|
workspaceLogger.error("setValueInSession", e);
|
||||||
|
@ -2403,7 +2394,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isSessionExpired() throws Exception {
|
public boolean isSessionExpired() throws Exception {
|
||||||
return WsUtil.isSessionExpired(this.getThreadLocalRequest().getSession());
|
return WsUtil.isSessionExpired(this.getThreadLocalRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -2466,7 +2457,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
workspaceLogger.trace("Check notification for "+item);
|
workspaceLogger.trace("Check notification for "+item);
|
||||||
//IF SOURCE SHARED FOLDER IS NOT NULL
|
//IF SOURCE SHARED FOLDER IS NOT NULL
|
||||||
if(item.getSourceFolderSharedId()!=null)
|
if(item.getSourceFolderSharedId()!=null)
|
||||||
NotificationsUtil.checkSendNotifyRemoveItemToShare(this.getThreadLocalRequest(), this.getThreadLocalRequest().getSession(), item.isSourceItemIsShared(), item.getOldItemName(), item.getOldItemName(), item.getSourceFolderSharedId());
|
NotificationsUtil.checkSendNotifyRemoveItemToShare(this.getThreadLocalRequest(), item.isSourceItemIsShared(), item.getOldItemName(), item.getOldItemName(), item.getSourceFolderSharedId());
|
||||||
}
|
}
|
||||||
|
|
||||||
return frontEndError;
|
return frontEndError;
|
||||||
|
@ -2684,9 +2675,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public UserBean getMyLogin(String currentPortletUrl){
|
public UserBean getMyLogin(String currentPortletUrl){
|
||||||
ASLSession asl = WsUtil.getAslSession(this.getThreadLocalRequest().getSession());
|
PortalContextInfo info = WsUtil.getPortalContext(this.getThreadLocalRequest());
|
||||||
String username = asl.getUsername();
|
String username = info.getUsername();
|
||||||
String email = username+"@isti.cnr.it";
|
String email = info.getUserEmail();
|
||||||
String firstName = "Testing";
|
String firstName = "Testing";
|
||||||
String lastName = "User";
|
String lastName = "User";
|
||||||
boolean publishRights = false;
|
boolean publishRights = false;
|
||||||
|
@ -2724,8 +2715,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getMyFirstName(){
|
public String getMyFirstName(){
|
||||||
ASLSession asl = WsUtil.getAslSession(this.getThreadLocalRequest().getSession());
|
PortalContextInfo info = WsUtil.getPortalContext(this.getThreadLocalRequest());
|
||||||
String username = asl.getUsername();
|
String username = info.getUsername();
|
||||||
String firstName = "";
|
String firstName = "";
|
||||||
if (isWithinPortal() && username.compareTo(WsUtil.TEST_USER) != 0) {
|
if (isWithinPortal() && username.compareTo(WsUtil.TEST_USER) != 0) {
|
||||||
try {
|
try {
|
||||||
|
@ -3463,11 +3454,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
* @return the ckan utils obj
|
* @return the ckan utils obj
|
||||||
*/
|
*/
|
||||||
public DataCatalogue getCatalogue(String scope){
|
public DataCatalogue getCatalogue(String scope){
|
||||||
HttpSession httpSession = this.getThreadLocalRequest().getSession();
|
PortalContextInfo info = WsUtil.getPortalContext(this.getThreadLocalRequest());
|
||||||
ASLSession asl = WsUtil.getAslSession(httpSession);
|
|
||||||
DataCatalogue instance = null;
|
DataCatalogue instance = null;
|
||||||
try{
|
try{
|
||||||
String scopeInWhichDiscover = scope != null && !scope.isEmpty() ? scope : asl.getScope();
|
String scopeInWhichDiscover = scope != null && !scope.isEmpty() ? scope : info.getCurrentScope();
|
||||||
workspaceLogger.debug("Discovering ckan instance into scope " + scopeInWhichDiscover);
|
workspaceLogger.debug("Discovering ckan instance into scope " + scopeInWhichDiscover);
|
||||||
instance = DataCatalogueFactory.getFactory().getUtilsPerScope(scopeInWhichDiscover);
|
instance = DataCatalogueFactory.getFactory().getUtilsPerScope(scopeInWhichDiscover);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
|
@ -3484,9 +3474,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
*/
|
*/
|
||||||
private boolean enablePublishOnCatalogue(String currentPortletUrl) {
|
private boolean enablePublishOnCatalogue(String currentPortletUrl) {
|
||||||
|
|
||||||
|
PortalContextInfo info = WsUtil.getPortalContext(this.getThreadLocalRequest());
|
||||||
|
String username = info.getUsername();
|
||||||
HttpSession httpSession = this.getThreadLocalRequest().getSession();
|
HttpSession httpSession = this.getThreadLocalRequest().getSession();
|
||||||
ASLSession asl = WsUtil.getAslSession(httpSession);
|
|
||||||
String username = asl.getUsername();
|
|
||||||
|
|
||||||
if(!isWithinPortal()){
|
if(!isWithinPortal()){
|
||||||
workspaceLogger.warn("OUT FROM PORTAL DETECTED RETURNING TRUE");
|
workspaceLogger.warn("OUT FROM PORTAL DETECTED RETURNING TRUE");
|
||||||
|
@ -3509,7 +3499,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
|
|
||||||
// check if this information was already into the ASL Session (true means the user has at least in one org
|
// check if this information was already into the ASL Session (true means the user has at least in one org
|
||||||
// the role editor), false that he is just a member so he cannot publish
|
// the role editor), false that he is just a member so he cannot publish
|
||||||
Boolean role = (Boolean)httpSession.getAttribute(keyPerScopeRole);
|
Boolean role = (Boolean) httpSession.getAttribute(keyPerScopeRole);
|
||||||
|
|
||||||
// if the attribute was already set..
|
// if the attribute was already set..
|
||||||
if(role != null)
|
if(role != null)
|
||||||
|
@ -3546,10 +3536,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
// return false
|
// return false
|
||||||
return role;
|
return role;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the list of ckan groups for which the user is member
|
* Fetch the list of ckan groups for which the user is member
|
||||||
* @param context
|
* @param context
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private List<GroupBean> fetchUserGroups(String context, String username) {
|
private List<GroupBean> fetchUserGroups(String context, String username) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.user.workspace.server;
|
package org.gcube.portlets.user.workspace.server;
|
||||||
|
|
||||||
|
@ -25,16 +25,19 @@ import org.gcube.common.homelibrary.home.workspace.folder.items.Image;
|
||||||
import org.gcube.portlets.user.workspace.client.util.ImageRequestType;
|
import org.gcube.portlets.user.workspace.client.util.ImageRequestType;
|
||||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Federico De Faveri defaveri@isti.cnr.it
|
* The Class ImageServlet.
|
||||||
*
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* Nov 25, 2016
|
||||||
*/
|
*/
|
||||||
public class ImageServlet extends HttpServlet{
|
public class ImageServlet extends HttpServlet{
|
||||||
|
|
||||||
private static final long serialVersionUID = -8423345575690165644L;
|
private static final long serialVersionUID = -8423345575690165644L;
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(ImageServlet.class);
|
protected static Logger logger = Logger.getLogger(ImageServlet.class);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
@ -47,6 +50,9 @@ public class ImageServlet extends HttpServlet{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
|
||||||
|
*/
|
||||||
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
|
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
|
||||||
|
|
||||||
String imageId = req.getParameter("id");
|
String imageId = req.getParameter("id");
|
||||||
|
@ -64,7 +70,7 @@ public class ImageServlet extends HttpServlet{
|
||||||
|
|
||||||
Workspace wa = null;
|
Workspace wa = null;
|
||||||
try {
|
try {
|
||||||
wa = WsUtil.getWorkspace(req.getSession());
|
wa = WsUtil.getWorkspace(req);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error during workspace retrieving", e);
|
logger.error("Error during workspace retrieving", e);
|
||||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"Error during workspace retrieving");
|
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"Error during workspace retrieving");
|
||||||
|
@ -95,7 +101,7 @@ public class ImageServlet extends HttpServlet{
|
||||||
FolderItem folderItem = (FolderItem) item;
|
FolderItem folderItem = (FolderItem) item;
|
||||||
FolderItemType itemType = folderItem.getFolderItemType();
|
FolderItemType itemType = folderItem.getFolderItemType();
|
||||||
|
|
||||||
if (itemType != FolderItemType.EXTERNAL_IMAGE
|
if (itemType != FolderItemType.EXTERNAL_IMAGE
|
||||||
&& itemType != FolderItemType.IMAGE_DOCUMENT) {
|
&& itemType != FolderItemType.IMAGE_DOCUMENT) {
|
||||||
logger.error("Error wrong folder item type, expected EXTERNAL_IMAGE or IMAGE_DOCUMENT, found "+itemType);
|
logger.error("Error wrong folder item type, expected EXTERNAL_IMAGE or IMAGE_DOCUMENT, found "+itemType);
|
||||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error wrong folder item type, expected EXTERNAL_IMAGE or IMAGE_DOCUMENT, found "+itemType);
|
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error wrong folder item type, expected EXTERNAL_IMAGE or IMAGE_DOCUMENT, found "+itemType);
|
||||||
|
@ -117,7 +123,7 @@ public class ImageServlet extends HttpServlet{
|
||||||
long size = (requestType==ImageRequestType.IMAGE)?image.getLength():image.getThumbnailLength();
|
long size = (requestType==ImageRequestType.IMAGE)?image.getLength():image.getThumbnailLength();
|
||||||
resp.setContentLength((int)size);
|
resp.setContentLength((int)size);
|
||||||
*/
|
*/
|
||||||
long size = (requestType==ImageRequestType.IMAGE)?image.getLength():0;
|
long size = requestType==ImageRequestType.IMAGE?image.getLength():0;
|
||||||
if(size == 0){
|
if(size == 0){
|
||||||
logger.warn("Image or Thumbnail size is 0, skipping set content lenght");
|
logger.warn("Image or Thumbnail size is 0, skipping set content lenght");
|
||||||
}else
|
}else
|
||||||
|
@ -130,7 +136,7 @@ public class ImageServlet extends HttpServlet{
|
||||||
// Send the content
|
// Send the content
|
||||||
try {
|
try {
|
||||||
OutputStream out = resp.getOutputStream();
|
OutputStream out = resp.getOutputStream();
|
||||||
InputStream in = (requestType==ImageRequestType.IMAGE)?image.getData():image.getThumbnail();
|
InputStream in = requestType==ImageRequestType.IMAGE?image.getData():image.getThumbnail();
|
||||||
IOUtils.copy(in, out);
|
IOUtils.copy(in, out);
|
||||||
in.close();
|
in.close();
|
||||||
out.close();
|
out.close();
|
||||||
|
|
|
@ -7,9 +7,9 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
|
||||||
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
|
@ -17,6 +17,7 @@ import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
import org.gcube.common.scope.impl.ScopeBean;
|
||||||
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||||
import org.gcube.portlets.user.workspace.server.util.DifferenceBetweenInfoContactModel;
|
import org.gcube.portlets.user.workspace.server.util.DifferenceBetweenInfoContactModel;
|
||||||
|
import org.gcube.portlets.user.workspace.server.util.PortalContextInfo;
|
||||||
import org.gcube.portlets.user.workspace.server.util.UserUtil;
|
import org.gcube.portlets.user.workspace.server.util.UserUtil;
|
||||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||||
|
|
||||||
|
@ -32,20 +33,19 @@ public class NotificationsProducer {
|
||||||
protected static Logger logger = Logger.getLogger(NotificationsProducer.class);
|
protected static Logger logger = Logger.getLogger(NotificationsProducer.class);
|
||||||
|
|
||||||
protected NotificationsManager notificationsMng;
|
protected NotificationsManager notificationsMng;
|
||||||
protected ASLSession aslSession;
|
protected HttpSession httpSession;
|
||||||
protected String userId;
|
protected String userId;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new notifications producer.
|
* Instantiates a new notifications producer.
|
||||||
*
|
*
|
||||||
* @param aslSession the asl session
|
* @param httpServletRequest the http servlet request
|
||||||
* @param request the request
|
|
||||||
*/
|
*/
|
||||||
public NotificationsProducer(ASLSession aslSession, HttpServletRequest request) {
|
public NotificationsProducer(HttpServletRequest httpServletRequest) {
|
||||||
this.notificationsMng = WsUtil.getNotificationManager(aslSession, request);
|
PortalContextInfo info = WsUtil.getPortalContext(httpServletRequest);
|
||||||
this.aslSession = aslSession;
|
this.notificationsMng = WsUtil.getNotificationManager(httpServletRequest);
|
||||||
this.userId = aslSession.getUsername();
|
this.userId = info.getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,16 +66,6 @@ public class NotificationsProducer {
|
||||||
this.notificationsMng = notificationMng;
|
this.notificationsMng = notificationMng;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the asl session.
|
|
||||||
*
|
|
||||||
* @return the asl session
|
|
||||||
*/
|
|
||||||
public ASLSession getAslSession() {
|
|
||||||
return aslSession;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs a new thread to notify the contacts passed in input.
|
* Runs a new thread to notify the contacts passed in input.
|
||||||
*
|
*
|
||||||
|
@ -823,7 +813,6 @@ public class NotificationsProducer {
|
||||||
String fullName = "Francesco Mangiacrapa";
|
String fullName = "Francesco Mangiacrapa";
|
||||||
|
|
||||||
ScopeBean scope;
|
ScopeBean scope;
|
||||||
ASLSession session;
|
|
||||||
|
|
||||||
session = SessionManager.getInstance().getASLSession(sessionID, user);
|
session = SessionManager.getInstance().getASLSession(sessionID, user);
|
||||||
scope = new ScopeBean(scopeString);
|
scope = new ScopeBean(scopeString);
|
||||||
|
|
|
@ -19,9 +19,10 @@ import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
||||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The Class NotificationsUtil.
|
||||||
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* @May 27, 2013
|
* @May 27, 2013
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class NotificationsUtil {
|
public class NotificationsUtil {
|
||||||
|
|
||||||
|
@ -56,10 +57,10 @@ public class NotificationsUtil {
|
||||||
//if shareChangeCondition is true.. notifies added item to sharing
|
//if shareChangeCondition is true.. notifies added item to sharing
|
||||||
if(shareChangeCondition){
|
if(shareChangeCondition){
|
||||||
|
|
||||||
Workspace workspace = WsUtil.getWorkspace(httpSession);
|
Workspace workspace = WsUtil.getWorkspace(request);
|
||||||
List<InfoContactModel> listContacts = getListUsersSharedByFolderSharedId(workspace, folderDestinationItem.getIdSharedFolder());
|
List<InfoContactModel> listContacts = getListUsersSharedByFolderSharedId(workspace, folderDestinationItem.getIdSharedFolder());
|
||||||
WorkspaceItem destinationSharedFolder = workspace.getItem(folderDestinationItem.getIdSharedFolder());
|
WorkspaceItem destinationSharedFolder = workspace.getItem(folderDestinationItem.getIdSharedFolder());
|
||||||
NotificationsProducer np = new NotificationsProducer(WsUtil.getAslSession(httpSession), request);
|
NotificationsProducer np = new NotificationsProducer(request);
|
||||||
|
|
||||||
if(destinationSharedFolder instanceof WorkspaceSharedFolder){
|
if(destinationSharedFolder instanceof WorkspaceSharedFolder){
|
||||||
|
|
||||||
|
@ -87,11 +88,12 @@ public class NotificationsUtil {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Gets the list users shared by folder shared id.
|
||||||
*
|
*
|
||||||
* @param workspace
|
* @param workspace the workspace
|
||||||
* @param idSharedFolder
|
* @param idSharedFolder the id shared folder
|
||||||
* @return
|
* @return the list users shared by folder shared id
|
||||||
* @throws Exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public static List<InfoContactModel> getListUsersSharedByFolderSharedId(Workspace workspace, String idSharedFolder) throws Exception {
|
public static List<InfoContactModel> getListUsersSharedByFolderSharedId(Workspace workspace, String idSharedFolder) throws Exception {
|
||||||
|
|
||||||
|
@ -123,17 +125,17 @@ public class NotificationsUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check send notify remove item to share.
|
* Check send notify remove item to share.
|
||||||
*
|
*
|
||||||
* @param request the request
|
* @param request the request
|
||||||
* @param httpSession the http session
|
|
||||||
* @param sourceItemIsShared the source item is shared
|
* @param sourceItemIsShared the source item is shared
|
||||||
* @param oldItemName the old item name
|
* @param oldItemName the old item name
|
||||||
* @param oldItemId the old item id
|
* @param oldItemId the old item id
|
||||||
* @param sourceFolderSharedId the source folder shared id
|
* @param sourceFolderSharedId the source folder shared id
|
||||||
*/
|
*/
|
||||||
public static void checkSendNotifyRemoveItemToShare(HttpServletRequest request, HttpSession httpSession, final boolean sourceItemIsShared, final String oldItemName, String oldItemId, final String sourceFolderSharedId) {
|
public static void checkSendNotifyRemoveItemToShare(HttpServletRequest request, final boolean sourceItemIsShared, final String oldItemName, String oldItemId, final String sourceFolderSharedId) {
|
||||||
|
|
||||||
logger.trace("checkNotifyRemoveItemToShare:");
|
logger.trace("checkNotifyRemoveItemToShare:");
|
||||||
|
|
||||||
|
@ -152,16 +154,16 @@ public class NotificationsUtil {
|
||||||
logger.trace("Notification doesn't sent because the event is on root shared folder");
|
logger.trace("Notification doesn't sent because the event is on root shared folder");
|
||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
boolean isSharedFolder = isASharedFolderForId(httpSession,idSharedFolder);
|
boolean isSharedFolder = isASharedFolderForId(request,idSharedFolder);
|
||||||
if(isSharedFolder){
|
if(isSharedFolder){
|
||||||
|
|
||||||
logger.trace("idSharedFolder is: "+ idSharedFolder +" is shared folder: "+isSharedFolder);
|
logger.trace("idSharedFolder is: "+ idSharedFolder +" is shared folder: "+isSharedFolder);
|
||||||
Workspace workspace = WsUtil.getWorkspace(httpSession);
|
Workspace workspace = WsUtil.getWorkspace(request);
|
||||||
//get contacts
|
//get contacts
|
||||||
List<InfoContactModel> listContacts = getListUsersSharedByFolderSharedId(workspace, idSharedFolder);
|
List<InfoContactModel> listContacts = getListUsersSharedByFolderSharedId(workspace, idSharedFolder);
|
||||||
WorkspaceItem sourceSharedFolder = workspace.getItem(idSharedFolder);
|
WorkspaceItem sourceSharedFolder = workspace.getItem(idSharedFolder);
|
||||||
//System.out.println(" name sourceSharedFolder: "+ sourceSharedFolder.getName());
|
//System.out.println(" name sourceSharedFolder: "+ sourceSharedFolder.getName());
|
||||||
NotificationsProducer np = new NotificationsProducer(WsUtil.getAslSession(httpSession), request);
|
NotificationsProducer np = new NotificationsProducer(request);
|
||||||
|
|
||||||
//Notify Removed Item To Sharing?
|
//Notify Removed Item To Sharing?
|
||||||
if(!isRootFolderShared){
|
if(!isRootFolderShared){
|
||||||
|
@ -185,9 +187,10 @@ public class NotificationsUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Checks if is a shared folder.
|
||||||
*
|
*
|
||||||
* @param wsItem
|
* @param wsItem the ws item
|
||||||
* @return
|
* @return true, if is a shared folder
|
||||||
*/
|
*/
|
||||||
public static boolean isASharedFolder(WorkspaceItem wsItem){
|
public static boolean isASharedFolder(WorkspaceItem wsItem){
|
||||||
if(wsItem!=null)
|
if(wsItem!=null)
|
||||||
|
@ -195,19 +198,22 @@ public class NotificationsUtil {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Checks if is a shared folder for id.
|
||||||
*
|
*
|
||||||
* @param wsItem
|
* @param request the request
|
||||||
* @return
|
* @param itemId the item id
|
||||||
|
* @return true, if is a shared folder for id
|
||||||
*/
|
*/
|
||||||
public static boolean isASharedFolderForId(HttpSession httpSession, String itemId){
|
public static boolean isASharedFolderForId(HttpServletRequest request, String itemId){
|
||||||
|
|
||||||
if(itemId==null || itemId.isEmpty())
|
if(itemId==null || itemId.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Workspace workspace = WsUtil.getWorkspace(httpSession);
|
Workspace workspace = WsUtil.getWorkspace(request);
|
||||||
|
|
||||||
WorkspaceItem wsItem = workspace.getItem(itemId);
|
WorkspaceItem wsItem = workspace.getItem(itemId);
|
||||||
|
|
||||||
|
@ -223,10 +229,11 @@ public class NotificationsUtil {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Check is root folder shared.
|
||||||
*
|
*
|
||||||
* @param itemId
|
* @param itemId the item id
|
||||||
* @param rootFolderSharedId
|
* @param rootFolderSharedId the root folder shared id
|
||||||
* @return
|
* @return true, if successful
|
||||||
*/
|
*/
|
||||||
public static boolean checkIsRootFolderShared(String itemId, String rootFolderSharedId) {
|
public static boolean checkIsRootFolderShared(String itemId, String rootFolderSharedId) {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,244 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.workspace.server.util;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class PortalContextInfo.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* Nov 25, 2016
|
||||||
|
*/
|
||||||
|
public class PortalContextInfo implements Serializable{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 5003662885627052222L;
|
||||||
|
private String username;
|
||||||
|
private String userFullName;
|
||||||
|
private String userEmail;
|
||||||
|
private String userAvatarID;
|
||||||
|
private String userAvatarURL;
|
||||||
|
private String currentScope;
|
||||||
|
private String userToken;
|
||||||
|
private long currGroupId;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new portal context info.
|
||||||
|
*
|
||||||
|
* @param username the username
|
||||||
|
* @param userFullName the user full name
|
||||||
|
* @param userEmail the user email
|
||||||
|
* @param userAvatarID the user avatar id
|
||||||
|
* @param userAvatarURL the user avatar url
|
||||||
|
* @param currentScope the current scope
|
||||||
|
* @param userToken the user token
|
||||||
|
* @param currGroupId the curr group id
|
||||||
|
*/
|
||||||
|
public PortalContextInfo(String username, String userFullName, String userEmail, String userAvatarID, String userAvatarURL, String currentScope, String userToken, long currGroupId) {
|
||||||
|
this.username = username;
|
||||||
|
this.userFullName = userFullName;
|
||||||
|
this.userEmail = userEmail;
|
||||||
|
this.userAvatarID = userAvatarID;
|
||||||
|
this.userAvatarURL = userAvatarURL;
|
||||||
|
this.currentScope = currentScope;
|
||||||
|
this.userToken = userToken;
|
||||||
|
this.currGroupId = currGroupId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the username
|
||||||
|
*/
|
||||||
|
public String getUsername() {
|
||||||
|
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the userFullName
|
||||||
|
*/
|
||||||
|
public String getUserFullName() {
|
||||||
|
|
||||||
|
return userFullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the userEmail
|
||||||
|
*/
|
||||||
|
public String getUserEmail() {
|
||||||
|
|
||||||
|
return userEmail;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the userAvatarID
|
||||||
|
*/
|
||||||
|
public String getUserAvatarID() {
|
||||||
|
|
||||||
|
return userAvatarID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the userAvatarURL
|
||||||
|
*/
|
||||||
|
public String getUserAvatarURL() {
|
||||||
|
|
||||||
|
return userAvatarURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the currentScope
|
||||||
|
*/
|
||||||
|
public String getCurrentScope() {
|
||||||
|
|
||||||
|
return currentScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the userToken
|
||||||
|
*/
|
||||||
|
public String getUserToken() {
|
||||||
|
|
||||||
|
return userToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the currGroupId
|
||||||
|
*/
|
||||||
|
public long getCurrGroupId() {
|
||||||
|
|
||||||
|
return currGroupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param username the username to set
|
||||||
|
*/
|
||||||
|
public void setUsername(String username) {
|
||||||
|
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param userFullName the userFullName to set
|
||||||
|
*/
|
||||||
|
public void setUserFullName(String userFullName) {
|
||||||
|
|
||||||
|
this.userFullName = userFullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param userEmail the userEmail to set
|
||||||
|
*/
|
||||||
|
public void setUserEmail(String userEmail) {
|
||||||
|
|
||||||
|
this.userEmail = userEmail;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param userAvatarID the userAvatarID to set
|
||||||
|
*/
|
||||||
|
public void setUserAvatarID(String userAvatarID) {
|
||||||
|
|
||||||
|
this.userAvatarID = userAvatarID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param userAvatarURL the userAvatarURL to set
|
||||||
|
*/
|
||||||
|
public void setUserAvatarURL(String userAvatarURL) {
|
||||||
|
|
||||||
|
this.userAvatarURL = userAvatarURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param currentScope the currentScope to set
|
||||||
|
*/
|
||||||
|
public void setCurrentScope(String currentScope) {
|
||||||
|
|
||||||
|
this.currentScope = currentScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param userToken the userToken to set
|
||||||
|
*/
|
||||||
|
public void setUserToken(String userToken) {
|
||||||
|
|
||||||
|
this.userToken = userToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param currGroupId the currGroupId to set
|
||||||
|
*/
|
||||||
|
public void setCurrGroupId(long currGroupId) {
|
||||||
|
|
||||||
|
this.currGroupId = currGroupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("PortalContextInfo [username=");
|
||||||
|
builder.append(username);
|
||||||
|
builder.append(", userFullName=");
|
||||||
|
builder.append(userFullName);
|
||||||
|
builder.append(", userEmail=");
|
||||||
|
builder.append(userEmail);
|
||||||
|
builder.append(", userAvatarID=");
|
||||||
|
builder.append(userAvatarID);
|
||||||
|
builder.append(", userAvatarURL=");
|
||||||
|
builder.append(userAvatarURL);
|
||||||
|
builder.append(", currentScope=");
|
||||||
|
builder.append(currentScope);
|
||||||
|
builder.append(", userToken=");
|
||||||
|
builder.append(userToken);
|
||||||
|
builder.append(", currGroupId=");
|
||||||
|
builder.append(currGroupId);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,8 +8,6 @@ import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
|
||||||
import org.gcube.application.framework.core.session.SessionManager;
|
|
||||||
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
|
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
|
||||||
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
||||||
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
|
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
|
||||||
|
@ -19,8 +17,8 @@ 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.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.portal.PortalContext;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
|
||||||
import org.gcube.portlets.user.urlshortener.UrlShortener;
|
import org.gcube.portlets.user.urlshortener.UrlShortener;
|
||||||
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
||||||
|
@ -29,6 +27,7 @@ import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParame
|
||||||
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex.RESOLVER_TYPE;
|
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex.RESOLVER_TYPE;
|
||||||
import org.gcube.portlets.user.workspace.server.util.resource.PropertySpecialFolderReader;
|
import org.gcube.portlets.user.workspace.server.util.resource.PropertySpecialFolderReader;
|
||||||
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
|
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
|
||||||
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
|
||||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||||
|
|
||||||
|
@ -37,11 +36,10 @@ import com.liferay.portal.service.UserLocalServiceUtil;
|
||||||
* The Class WsUtil.
|
* The Class WsUtil.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* @Feb 18, 2014
|
* Nov 25, 2016
|
||||||
*/
|
*/
|
||||||
public class WsUtil {
|
public class WsUtil {
|
||||||
|
|
||||||
public static final String USERNAME_ATTRIBUTE = ScopeHelper.USERNAME_ATTRIBUTE;
|
|
||||||
public static final String FOLDERIMPORTER_ATTRIBUTE = "FOLDER_IMPORTER";
|
public static final String FOLDERIMPORTER_ATTRIBUTE = "FOLDER_IMPORTER";
|
||||||
public static final String METADATACONVERTER_ATTRIBUTE = "METADATA_CONVERTER";
|
public static final String METADATACONVERTER_ATTRIBUTE = "METADATA_CONVERTER";
|
||||||
public static final String WORKSPACE_EVENT_COLLECTOR_ATTRIBUTE = "EVENT_COLLECTOR";
|
public static final String WORKSPACE_EVENT_COLLECTOR_ATTRIBUTE = "EVENT_COLLECTOR";
|
||||||
|
@ -55,20 +53,11 @@ public class WsUtil {
|
||||||
public static final String PROPERTY_SPECIAL_FOLDER = "PROPERTY_SPECIAL_FOLDER";
|
public static final String PROPERTY_SPECIAL_FOLDER = "PROPERTY_SPECIAL_FOLDER";
|
||||||
public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl"; //IN DEV
|
public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl"; //IN DEV
|
||||||
|
|
||||||
|
// public static final String TEST_SCOPE = "/d4science.research-infrastructures.eu";
|
||||||
|
// public static final String TEST_TOKEN = "57b42a99-6239-44c4-9a68-591c18363222-843339462"; //username Francesco Mangiacrapa scope: BiodiversityLab
|
||||||
public static final String TEST_SCOPE = "/gcube";
|
public static final String TEST_SCOPE = "/gcube";
|
||||||
public static final String TEST_TOKEN = "89257623-0570-4fbe-a15b-458bb84f4902-98187548"; //username Francesco Mangiacrapa scope: NextNext
|
public static final String TEST_TOKEN = "89257623-0570-4fbe-a15b-458bb84f4902-98187548"; //username Francesco Mangiacrapa scope: NextNext
|
||||||
|
|
||||||
// public static final String TEST_USER = "pasquale.pagano";
|
|
||||||
// public static final String TEST_USER = "federico.defaveri";
|
|
||||||
// public static final String TEST_USER = "massimiliano.assante";
|
|
||||||
// public static final String TEST_USER = "pasquale.pagano";
|
|
||||||
// public static final String TEST_USER = "aureliano.gentile";
|
|
||||||
// public static final String TEST_USER = "antonio.gioia";
|
|
||||||
|
|
||||||
//COMMENT THIS FOR RELEASE
|
|
||||||
// public static final String TEST_USER = "francesco.mangiacrapa";
|
|
||||||
// public static final String TEST_USER_FULL_NAME = "Francesco Mangiacrapa";
|
|
||||||
|
|
||||||
//UNCOMMENT THIS FOR RELEASE
|
//UNCOMMENT THIS FOR RELEASE
|
||||||
public static String TEST_USER = "test.user";
|
public static String TEST_USER = "test.user";
|
||||||
public static String TEST_USER_FULL_NAME = "Test User";
|
public static String TEST_USER_FULL_NAME = "Test User";
|
||||||
|
@ -94,103 +83,64 @@ public class WsUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the asl session.
|
* Gets the portal context.
|
||||||
*
|
*
|
||||||
* @param httpSession the http session
|
* @param httpServletRequest the http servlet request
|
||||||
* @return the asl session
|
* @return the portal context
|
||||||
*/
|
*/
|
||||||
public static ASLSession getAslSession(HttpSession httpSession)
|
public static PortalContextInfo getPortalContext(HttpServletRequest httpServletRequest){
|
||||||
{
|
PortalContext pContext = PortalContext.getConfiguration();
|
||||||
String sessionID = httpSession.getId();
|
//USER
|
||||||
String user = (String) httpSession.getAttribute(USERNAME_ATTRIBUTE);
|
GCubeUser user = pContext.getCurrentUser(httpServletRequest);
|
||||||
ASLSession session;
|
String username = user.getUsername();
|
||||||
|
String fullName = user.getFullname();
|
||||||
|
String email = user.getEmail();
|
||||||
|
String avatarID = user.getUserAvatarId();
|
||||||
|
String avatarURL = user.getUserAvatarURL();
|
||||||
|
//SESSION
|
||||||
|
String currentScope = pContext.getCurrentScope(httpServletRequest);
|
||||||
|
String userToken = pContext.getCurrentUserToken(httpServletRequest);
|
||||||
|
long currGroupId = pContext.getCurrentGroupId(httpServletRequest);
|
||||||
|
|
||||||
if (user == null) {
|
return new PortalContextInfo(username, fullName, email, avatarID, avatarURL, currentScope, userToken, currGroupId);
|
||||||
|
|
||||||
/*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING
|
|
||||||
* COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/
|
|
||||||
user=TEST_USER;
|
|
||||||
|
|
||||||
if (!isWithinPortal()) { //DEV MODE
|
|
||||||
user = "francesco.mangiacrapa";
|
|
||||||
TEST_USER_FULL_NAME = "Francesco Mangiacrapa";
|
|
||||||
//SecurityTokenProvider.instance.set(TEST_TOKEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:");
|
|
||||||
logger.warn("session id: "+sessionID);
|
|
||||||
logger.warn("TEST_USER: "+user);
|
|
||||||
logger.warn("TEST_SCOPE: "+TEST_SCOPE);
|
|
||||||
logger.warn("USERNAME_ATTRIBUTE: "+USERNAME_ATTRIBUTE);
|
|
||||||
session = SessionManager.getInstance().getASLSession(sessionID, user);
|
|
||||||
session.setScope(TEST_SCOPE);
|
|
||||||
session.setSecurityToken(TEST_TOKEN);
|
|
||||||
|
|
||||||
//MANDATORY FOR SOCIAL LIBRARY
|
|
||||||
session.setUserAvatarId(user + "Avatar");
|
|
||||||
session.setUserFullName(TEST_USER_FULL_NAME);
|
|
||||||
session.setUserEmailAddress(user + "@mail.test");
|
|
||||||
|
|
||||||
//SET HTTP SESSION ATTRIBUTE
|
|
||||||
httpSession.setAttribute(USERNAME_ATTRIBUTE, user);
|
|
||||||
|
|
||||||
// withoutPortal = true;
|
|
||||||
|
|
||||||
return session;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return SessionManager.getInstance().getASLSession(sessionID, user);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is session expired.
|
* Checks if is session expired.
|
||||||
*
|
*
|
||||||
* @param httpSession the http session
|
* @param httpServletRequest the http servlet request
|
||||||
* @return true if current username into ASL session is WsUtil.TEST_USER, false otherwise
|
* @return true, if is session expired
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public static boolean isSessionExpired(HttpSession httpSession) throws Exception {
|
public static boolean isSessionExpired(HttpServletRequest httpServletRequest) throws Exception {
|
||||||
logger.trace("workspace session validating...");
|
logger.trace("workspace session validating...");
|
||||||
//READING USERNAME FROM ASL SESSION
|
PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||||
String userUsername = getAslSession(httpSession).getUsername();
|
return info.getUsername()==null;
|
||||||
boolean isTestUser = userUsername.compareTo(WsUtil.TEST_USER)==0;
|
|
||||||
|
|
||||||
//TODO UNCOMMENT THIS FOR RELEASE
|
|
||||||
logger.trace("Is "+WsUtil.TEST_USER+" test user? "+isTestUser);
|
|
||||||
|
|
||||||
if(isTestUser){
|
|
||||||
logger.error("workspace session is expired! username is: "+WsUtil.TEST_USER);
|
|
||||||
return true; //is TEST_USER, session is expired
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("workspace session is valid! current username is: "+userUsername);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the workspace.
|
* Gets the workspace.
|
||||||
*
|
*
|
||||||
* @param httpSession the http session
|
* @param httpServletRequest the http servlet request
|
||||||
* @return the workspace
|
* @return the workspace
|
||||||
* @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
|
||||||
*/
|
*/
|
||||||
public static Workspace getWorkspace(final HttpSession httpSession) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
|
public static Workspace getWorkspace(HttpServletRequest httpServletRequest) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
|
||||||
{
|
{
|
||||||
logger.trace("Get Workspace");
|
logger.trace("Get Workspace");
|
||||||
final ASLSession session = getAslSession(httpSession);
|
PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||||
logger.trace("ASLSession scope: "+session.getScope() + " username: "+session.getUsername());
|
logger.trace("PortalContextInfo: "+info);
|
||||||
|
|
||||||
ScopeProvider.instance.set(session.getScope());
|
ScopeProvider.instance.set(info.getCurrentScope());
|
||||||
logger.trace("Scope provider instancied");
|
logger.trace("Scope provider instancied");
|
||||||
|
|
||||||
Workspace workspace = HomeLibrary.getUserWorkspace(session.getUsername());
|
Workspace workspace = HomeLibrary.getUserWorkspace(info.getUsername());
|
||||||
return workspace;
|
return workspace;
|
||||||
|
|
||||||
|
|
||||||
|
@ -199,72 +149,72 @@ public class WsUtil {
|
||||||
/**
|
/**
|
||||||
* Gets the GWT workspace builder.
|
* Gets the GWT workspace builder.
|
||||||
*
|
*
|
||||||
* @param httpSession the http session
|
* @param httpServletRequest the http servlet request
|
||||||
* @return the GWT workspace builder
|
* @return the GWT workspace builder
|
||||||
*/
|
*/
|
||||||
public static GWTWorkspaceBuilder getGWTWorkspaceBuilder(HttpSession httpSession)
|
public static GWTWorkspaceBuilder getGWTWorkspaceBuilder(HttpServletRequest httpServletRequest)
|
||||||
{
|
{
|
||||||
ASLSession session = getAslSession(httpSession);
|
PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||||
|
logger.trace("PortalContextInfo: "+info);
|
||||||
|
|
||||||
|
HttpSession session = httpServletRequest.getSession();
|
||||||
|
|
||||||
GWTWorkspaceBuilder builder = (GWTWorkspaceBuilder) session.getAttribute(WORKSPACEBUILDER_ATTRIBUTE);
|
GWTWorkspaceBuilder builder = (GWTWorkspaceBuilder) session.getAttribute(WORKSPACEBUILDER_ATTRIBUTE);
|
||||||
if (builder == null){
|
if (builder == null){
|
||||||
logger.info("Initializing the workspace area builder");
|
logger.info("Initializing the workspace area builder");
|
||||||
builder = new GWTWorkspaceBuilder();
|
builder = new GWTWorkspaceBuilder();
|
||||||
//ADDED 03/09/2013
|
//ADDED 03/09/2013
|
||||||
builder.setUserLogged(new InfoContactModel(session.getUsername(), session.getUsername(), session.getUserFullName(), false));
|
builder.setUserLogged(new InfoContactModel(info.getUsername(), info.getUsername(), info.getUserFullName(), false));
|
||||||
session.setAttribute(WORKSPACEBUILDER_ATTRIBUTE, builder);
|
session.setAttribute(WORKSPACEBUILDER_ATTRIBUTE, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the notification manager.
|
* Gets the notification manager.
|
||||||
*
|
*
|
||||||
* @param session the session
|
* @param httpServletRequest the http servlet request
|
||||||
* @param request the request
|
|
||||||
* @return the notification manager
|
* @return the notification manager
|
||||||
*/
|
*/
|
||||||
public static NotificationsManager getNotificationManager(ASLSession session, HttpServletRequest request)
|
public static NotificationsManager getNotificationManager(HttpServletRequest httpServletRequest)
|
||||||
{
|
{
|
||||||
|
PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||||
|
HttpSession session = httpServletRequest.getSession();
|
||||||
NotificationsManager notifMng = (NotificationsManager) session.getAttribute(NOTIFICATION_MANAGER);
|
NotificationsManager notifMng = (NotificationsManager) session.getAttribute(NOTIFICATION_MANAGER);
|
||||||
|
|
||||||
if (notifMng == null) {
|
if (notifMng == null) {
|
||||||
try{
|
try{
|
||||||
logger.trace("Create new NotificationsManager for user: "+session.getUsername());
|
logger.trace("Create new NotificationsManager for user: "+info.getUsername());
|
||||||
logger.trace("New ApplicationNotificationsManager with portlet class name: "+NOTIFICATION_PORTLET_CLASS_ID);
|
logger.trace("New ApplicationNotificationsManager with portlet class name: "+NOTIFICATION_PORTLET_CLASS_ID);
|
||||||
SocialNetworkingSite site = new SocialNetworkingSite(request);
|
SocialNetworkingSite site = new SocialNetworkingSite(httpServletRequest);
|
||||||
SocialNetworkingUser curser = new SocialNetworkingUser(session.getUsername(), session.getUserEmailAddress(), session.getUserFullName(), session.getUserAvatarId());
|
SocialNetworkingUser curser = new SocialNetworkingUser(info.getUsername(), info.getUserEmail(), info.getUserFullName(), info.getUserAvatarID());
|
||||||
notifMng = new ApplicationNotificationsManager(site, session.getScope(), curser, NOTIFICATION_PORTLET_CLASS_ID);
|
notifMng = new ApplicationNotificationsManager(site, info.getCurrentScope(), curser, NOTIFICATION_PORTLET_CLASS_ID);
|
||||||
session.setAttribute(NOTIFICATION_MANAGER, notifMng);
|
session.setAttribute(NOTIFICATION_MANAGER, notifMng);
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
logger.error("An error occurred instancing ApplicationNotificationsManager for user: "+session.getUsername(),e);
|
logger.error("An error occurred instancing ApplicationNotificationsManager for user: "+info.getUsername(),e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return notifMng;
|
return notifMng;
|
||||||
|
|
||||||
|
|
||||||
// SocialNetworkingSite site = new SocialNetworkingSite(request);
|
|
||||||
// SocialNetworkingUser curser = new SocialNetworkingUser(session.getUsername(), session.getUserEmailAddress(), session.getUserFullName(), session.getUserAvatarId());
|
|
||||||
// return new ApplicationNotificationsManager(site, session.getScope(), curser, NOTIFICATION_PORTLET_CLASS_ID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the notification producer.
|
* Gets the notification producer.
|
||||||
*
|
*
|
||||||
* @param session the session
|
* @param httpServletRequest the http servlet request
|
||||||
* @param request the request
|
|
||||||
* @return the notification producer
|
* @return the notification producer
|
||||||
*/
|
*/
|
||||||
public static NotificationsProducer getNotificationProducer(ASLSession session, HttpServletRequest request)
|
public static NotificationsProducer getNotificationProducer(HttpServletRequest httpServletRequest)
|
||||||
{
|
{
|
||||||
|
PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||||
|
HttpSession session = httpServletRequest.getSession();
|
||||||
NotificationsProducer notifProducer = (NotificationsProducer) session.getAttribute(NOTIFICATION_PRODUCER);
|
NotificationsProducer notifProducer = (NotificationsProducer) session.getAttribute(NOTIFICATION_PRODUCER);
|
||||||
|
|
||||||
if (notifProducer == null) {
|
if (notifProducer == null) {
|
||||||
logger.trace("Create new Notification Producer for user: "+session.getUsername());
|
logger.trace("Create new Notification Producer for user: "+info.getUsername());
|
||||||
notifProducer = new NotificationsProducer(session, request);
|
notifProducer = new NotificationsProducer(httpServletRequest);
|
||||||
session.setAttribute(NOTIFICATION_PRODUCER, notifProducer);
|
session.setAttribute(NOTIFICATION_PRODUCER, notifProducer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,30 +223,30 @@ public class WsUtil {
|
||||||
//return new NotificationsProducer(session, request);
|
//return new NotificationsProducer(session, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the user id.
|
* Gets the user id.
|
||||||
*
|
*
|
||||||
* @param httpSession the http session
|
* @param httpServletRequest the http servlet request
|
||||||
* @return the user id
|
* @return the user id
|
||||||
*/
|
*/
|
||||||
public static String getUserId(HttpSession httpSession) {
|
public static String getUserId(HttpServletRequest httpServletRequest) {
|
||||||
|
|
||||||
ASLSession session = getAslSession(httpSession);
|
PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||||
|
return info.getUsername();
|
||||||
return session.getUsername();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is vre.
|
* Checks if is vre.
|
||||||
*
|
*
|
||||||
* @param session the session
|
* @param scope the scope
|
||||||
* @return true, if is vre
|
* @return true, if is vre
|
||||||
*/
|
*/
|
||||||
public static boolean isVRE(ASLSession session){
|
public static boolean isVRE(String scope){
|
||||||
|
|
||||||
String currentScope = session.getScopeName();
|
int slashCount = StringUtils.countMatches(scope, "/");
|
||||||
|
|
||||||
int slashCount = StringUtils.countMatches(currentScope, "/");
|
|
||||||
|
|
||||||
if(slashCount < 3){
|
if(slashCount < 3){
|
||||||
logger.trace("currentScope is not VRE");
|
logger.trace("currentScope is not VRE");
|
||||||
|
@ -308,21 +258,23 @@ public class WsUtil {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the scope util filter.
|
* Gets the scope util filter.
|
||||||
*
|
*
|
||||||
* @param httpSession the http session
|
* @param httpServletRequest the http servlet request
|
||||||
* @return the scope util filter
|
* @return the scope util filter
|
||||||
*/
|
*/
|
||||||
public static ScopeUtilFilter getScopeUtilFilter(HttpSession httpSession){
|
public static ScopeUtilFilter getScopeUtilFilter(HttpServletRequest httpServletRequest){
|
||||||
|
|
||||||
ASLSession session = getAslSession(httpSession);
|
PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||||
|
HttpSession session = httpServletRequest.getSession();
|
||||||
ScopeUtilFilter scopeUtil = null;
|
ScopeUtilFilter scopeUtil = null;
|
||||||
try{
|
try{
|
||||||
scopeUtil = (ScopeUtilFilter) session.getAttribute(WsUtil.WORKSPACE_SCOPE_UTIL);
|
scopeUtil = (ScopeUtilFilter) session.getAttribute(WsUtil.WORKSPACE_SCOPE_UTIL);
|
||||||
|
|
||||||
if(scopeUtil==null){
|
if(scopeUtil==null){
|
||||||
scopeUtil = new ScopeUtilFilter(session.getScopeName(),true);
|
scopeUtil = new ScopeUtilFilter(info.getCurrentScope(),true);
|
||||||
|
|
||||||
}
|
}
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
|
@ -336,12 +288,13 @@ public class WsUtil {
|
||||||
/**
|
/**
|
||||||
* Gets the url shortener.
|
* Gets the url shortener.
|
||||||
*
|
*
|
||||||
* @param httpSession the http session
|
* @param httpServletRequest the http servlet request
|
||||||
* @return the url shortener
|
* @return the url shortener
|
||||||
*/
|
*/
|
||||||
public static UrlShortener getUrlShortener(HttpSession httpSession) {
|
public static UrlShortener getUrlShortener(HttpServletRequest httpServletRequest) {
|
||||||
|
|
||||||
ASLSession session = getAslSession(httpSession);
|
HttpSession session = httpServletRequest.getSession();
|
||||||
|
PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||||
UrlShortener shortener = null;
|
UrlShortener shortener = null;
|
||||||
try{
|
try{
|
||||||
shortener = (UrlShortener) session.getAttribute(WsUtil.URL_SHORTENER_SERVICE);
|
shortener = (UrlShortener) session.getAttribute(WsUtil.URL_SHORTENER_SERVICE);
|
||||||
|
@ -362,19 +315,19 @@ public class WsUtil {
|
||||||
/**
|
/**
|
||||||
* Gets the uri resolver.
|
* Gets the uri resolver.
|
||||||
*
|
*
|
||||||
* @param httpSession the http session
|
* @param httpServletRequest the http servlet request
|
||||||
* @return the uri resolver
|
* @return the uri resolver
|
||||||
*/
|
*/
|
||||||
public static UriResolverReaderParameterForResolverIndex getUriResolver(HttpSession httpSession) {
|
public static UriResolverReaderParameterForResolverIndex getUriResolver(HttpServletRequest httpServletRequest) {
|
||||||
|
|
||||||
ASLSession session = getAslSession(httpSession);
|
|
||||||
|
|
||||||
|
HttpSession session = httpServletRequest.getSession();
|
||||||
|
PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||||
UriResolverReaderParameterForResolverIndex uriResolver = null;
|
UriResolverReaderParameterForResolverIndex uriResolver = null;
|
||||||
try{
|
try{
|
||||||
uriResolver = (UriResolverReaderParameterForResolverIndex) session.getAttribute(WsUtil.URI_RESOLVER_SERVICE);
|
uriResolver = (UriResolverReaderParameterForResolverIndex) session.getAttribute(WsUtil.URI_RESOLVER_SERVICE);
|
||||||
|
|
||||||
if(uriResolver==null){
|
if(uriResolver==null){
|
||||||
uriResolver = new UriResolverReaderParameterForResolverIndex(session.getScope().toString(),RESOLVER_TYPE.SMP_ID);
|
uriResolver = new UriResolverReaderParameterForResolverIndex(info.getCurrentScope(),RESOLVER_TYPE.SMP_ID);
|
||||||
session.setAttribute(URI_RESOLVER_SERVICE, uriResolver);
|
session.setAttribute(URI_RESOLVER_SERVICE, uriResolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,12 +341,12 @@ public class WsUtil {
|
||||||
/**
|
/**
|
||||||
* Gets the property special folder reader.
|
* Gets the property special folder reader.
|
||||||
*
|
*
|
||||||
* @param httpSession the http session
|
* @param httpServletRequest the http servlet request
|
||||||
* @param pathProperty the path property
|
* @param pathProperty the path property
|
||||||
* @return the property special folder reader
|
* @return the property special folder reader
|
||||||
*/
|
*/
|
||||||
public static PropertySpecialFolderReader getPropertySpecialFolderReader(HttpSession httpSession, String pathProperty) {
|
public static PropertySpecialFolderReader getPropertySpecialFolderReader(HttpServletRequest httpServletRequest, String pathProperty) {
|
||||||
ASLSession session = getAslSession(httpSession);
|
HttpSession session = httpServletRequest.getSession();
|
||||||
|
|
||||||
PropertySpecialFolderReader psFolderReader = null;
|
PropertySpecialFolderReader psFolderReader = null;
|
||||||
try{
|
try{
|
||||||
|
|
Loading…
Reference in New Issue