fixed breadcrumb on move item
updated notification git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@77048 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d12ac3193c
commit
52e6dfd548
4
pom.xml
4
pom.xml
|
@ -87,13 +87,13 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>home-library</artifactId>
|
||||
<version>[4.3.0-SNAPSHOT, 5.0.0-SNAPSHOT)</version>
|
||||
<version>[4.3.0-SNAPSHOT, 4.6.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>home-library-jcr</artifactId>
|
||||
<version>[1.3.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<version>[1.3.0-SNAPSHOT, 1.6.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -18,7 +18,9 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.portlets.user.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder;
|
||||
|
@ -42,7 +44,7 @@ import org.gcube.portlets.user.homelibrary.jcr.repository.external.GCUBEStorage;
|
|||
import org.gcube.portlets.user.homelibrary.util.Extensions;
|
||||
import org.gcube.portlets.user.homelibrary.util.MimeTypeUtil;
|
||||
import org.gcube.portlets.user.homelibrary.util.zip.ZipUtil;
|
||||
import org.gcube.portlets.user.workspace.server.util.Util;
|
||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||
|
||||
/**
|
||||
* @author Federico De Faveri defaveri@isti.cnr.it
|
||||
|
@ -76,7 +78,7 @@ public class DownloadServlet extends HttpServlet{
|
|||
|
||||
Workspace wa = null;
|
||||
try {
|
||||
wa = Util.getWorkspace(req.getSession());
|
||||
wa = WsUtil.getWorkspace(req.getSession());
|
||||
} catch (Exception e) {
|
||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"Error during workspace retrieving");
|
||||
return;
|
||||
|
@ -87,7 +89,7 @@ public class DownloadServlet extends HttpServlet{
|
|||
return;
|
||||
}
|
||||
|
||||
GCUBELog logger = Util.getLogger(wa);
|
||||
GCUBELog logger = WsUtil.getLogger(wa);
|
||||
|
||||
WorkspaceItem item;
|
||||
try {
|
||||
|
@ -515,7 +517,7 @@ public class DownloadServlet extends HttpServlet{
|
|||
|
||||
try{
|
||||
|
||||
// Workspace ws = HomeLibrary.getHomeManagerFactory().getHomeManager().getHome("test.user", GCUBEScope.getScope("/gcube/devsec")).getWorkspace();
|
||||
Workspace ws = HomeLibrary.getHomeManagerFactory().getHomeManager().getHome("test.user", GCUBEScope.getScope("/gcube/devsec")).getWorkspace();
|
||||
//
|
||||
// ExternalFile f = (ExternalFile) ws.getItem("61c6d01c-72f3-44b6-88da-6b9b486ef391");
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTM
|
|||
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTPDFDocument;
|
||||
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTUrlDocument;
|
||||
import org.gcube.portlets.user.workspace.server.util.UserUtil;
|
||||
import org.gcube.portlets.user.workspace.server.util.Util;
|
||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingEntryType;
|
||||
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
|
||||
|
||||
|
@ -127,7 +127,7 @@ public class GWTWorkspaceBuilder {
|
|||
hashTestUser.put("antonio.gioia", new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia"));
|
||||
hashTestUser.put("fabio.sinibaldi", new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi"));
|
||||
hashTestUser.put("pasquale.pagano", new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano"));
|
||||
hashTestUser.put(Util.TEST_USER.toString(), new InfoContactModel(Util.TEST_USER, Util.TEST_USER, Util.TEST_USER_FULL_NAME));
|
||||
hashTestUser.put(WsUtil.TEST_USER.toString(), new InfoContactModel(WsUtil.TEST_USER, WsUtil.TEST_USER, WsUtil.TEST_USER_FULL_NAME));
|
||||
hashTestUser.put("francesco.mangiacrapa", new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa"));
|
||||
hashTestUser.put("massimiliano.assante", new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante"));
|
||||
|
||||
|
|
|
@ -49,8 +49,9 @@ import org.gcube.portlets.user.workspace.client.model.SubTree;
|
|||
import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService;
|
||||
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
||||
import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer;
|
||||
import org.gcube.portlets.user.workspace.server.notifications.NotificationsUtil;
|
||||
import org.gcube.portlets.user.workspace.server.util.UserUtil;
|
||||
import org.gcube.portlets.user.workspace.server.util.Util;
|
||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
|
||||
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingEntryType;
|
||||
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
|
||||
|
@ -77,26 +78,26 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
|
||||
protected GWTWorkspaceBuilder getGWTWorkspaceBuilder()
|
||||
{
|
||||
return Util.getGWTWorkspaceBuilder(this.getThreadLocalRequest().getSession());
|
||||
return WsUtil.getGWTWorkspaceBuilder(this.getThreadLocalRequest().getSession());
|
||||
}
|
||||
|
||||
protected Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
|
||||
{
|
||||
return Util.getWorkspace(this.getThreadLocalRequest().getSession());
|
||||
return WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
|
||||
}
|
||||
|
||||
protected NotificationsProducer getNotificationProducer(){
|
||||
|
||||
return Util.getNotificationProducer(Util.getAslSession(this.getThreadLocalRequest().getSession()));
|
||||
return WsUtil.getNotificationProducer(WsUtil.getAslSession(this.getThreadLocalRequest().getSession()));
|
||||
}
|
||||
|
||||
protected ScopeUtilFilter getScopeUtilFilter(){
|
||||
|
||||
return Util.getScopeUtilFilter(this.getThreadLocalRequest().getSession());
|
||||
return WsUtil.getScopeUtilFilter(this.getThreadLocalRequest().getSession());
|
||||
}
|
||||
|
||||
protected boolean isTestMode(){
|
||||
return Util.withoutPortal;
|
||||
return WsUtil.withoutPortal;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -363,7 +364,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
try{
|
||||
checkNotifyAddItemToShare(sourceItem, sourceSharedId, folderDestinationItem);
|
||||
|
||||
checkNotifyRemoveItemToShare(sourceItemIsShared, sourceItem, sourceSharedId, folderDestinationItem);
|
||||
checkNotifyMoveItemFromShare(sourceItemIsShared, sourceItem, sourceSharedId, folderDestinationItem);
|
||||
|
||||
}catch (Exception e) {
|
||||
workspaceLogger.error("An error occurred in checkNotify ", e);
|
||||
|
@ -435,9 +436,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
}
|
||||
|
||||
|
||||
private void checkNotifyRemoveItemToShare(final boolean sourceItemIsShared, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem) {
|
||||
private void checkNotifyMoveItemFromShare(final boolean sourceItemIsShared, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem) {
|
||||
|
||||
workspaceLogger.trace("checkNotifyRemoveItemToShare:");
|
||||
workspaceLogger.trace("checkNotifyMoveItemFromShare:");
|
||||
|
||||
try{
|
||||
|
||||
|
@ -448,7 +449,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
//share condition is true if source shared folder is not equal to destination shared folder
|
||||
boolean shareChangeCondition = sourceSharedId==null?false:(sourceSharedId.compareTo(idSharedFolder)!=0);
|
||||
|
||||
workspaceLogger.trace("checkNotifyRemoveItemToShare source item: "+sourceItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName() +" sourceItemIsShared: "+sourceItemIsShared);
|
||||
workspaceLogger.trace("checkNotifyMoveItemFromShare source item: "+sourceItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName() +" sourceItemIsShared: "+sourceItemIsShared);
|
||||
|
||||
// System.out.println("shareChangeCondition remove item: "+ shareChangeCondition);
|
||||
|
||||
|
@ -472,17 +473,17 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
|
||||
NotificationsProducer np = getNotificationProducer();
|
||||
|
||||
np.notifyRemovedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) sourceSharedFolder);
|
||||
np.notifyMovedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) sourceSharedFolder);
|
||||
|
||||
workspaceLogger.trace("The notifies was sent correctly");
|
||||
|
||||
}
|
||||
|
||||
}else
|
||||
workspaceLogger.warn("The notifies is failure in verifyNotifyRemoveItemToShare because folder destination item is null");
|
||||
workspaceLogger.warn("The notifies is failure in checkNotifyMoveItemFromShare because folder destination item is null");
|
||||
|
||||
}catch (Exception e) {
|
||||
workspaceLogger.error("An error occurred in checkNotifyRemoveItemToShare ",e);
|
||||
workspaceLogger.error("An error occurred in checkNotifyMoveItemFromShare ",e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -513,8 +514,28 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
||||
logger.trace("removeItem item: "+itemId);
|
||||
|
||||
|
||||
//NOTIFICATION
|
||||
WorkspaceItem wsItem = workspace.getItem(itemId);
|
||||
|
||||
//SAVING ATTRIBUTE FOR NOTIFICATION
|
||||
boolean sourceItemIsShared = wsItem.isShared();
|
||||
String itemName = wsItem.getName();
|
||||
String sourceFolderSharedId = null;
|
||||
|
||||
|
||||
if(sourceItemIsShared){
|
||||
sourceFolderSharedId = wsItem.getIdSharedFolder();
|
||||
}
|
||||
|
||||
//REMOVE ITEM
|
||||
workspace.removeItem(itemId);
|
||||
|
||||
//IF SOURCE SHARED FOLDER IS NOT NULL
|
||||
if(sourceFolderSharedId!=null)
|
||||
NotificationsUtil.checkSendNotifyRemoveItemToShare(this.getThreadLocalRequest().getSession(), sourceItemIsShared, itemName, itemId, sourceFolderSharedId);
|
||||
|
||||
|
||||
return Boolean.TRUE;
|
||||
|
||||
} catch (InsufficientPrivilegesException e) {
|
||||
|
@ -553,8 +574,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
List<InfoContactModel> listSharedContact = new ArrayList<InfoContactModel>();
|
||||
NotificationsProducer notification = getNotificationProducer();
|
||||
listSharedContact = getListUserSharedByFolderSharedId(wsItem.getIdSharedFolder());
|
||||
if(Util.isASharedFolder(wsItem)){
|
||||
notification.notifyFolderRenamed(listSharedContact, previousName, newName, wsItem.getIdSharedFolder());
|
||||
if(NotificationsUtil.isASharedFolder(wsItem)){
|
||||
notification.notifyFolderRenamed(listSharedContact, wsItem, previousName, newName, wsItem.getIdSharedFolder());
|
||||
}else{
|
||||
WorkspaceFolder sharedFolder = (WorkspaceFolder) workspace.getItem(wsItem.getIdSharedFolder());
|
||||
notification.notifyItemRenamed(listSharedContact, previousName, wsItem, sharedFolder);
|
||||
|
@ -1003,9 +1024,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
|
||||
try{
|
||||
|
||||
ASLSession session = Util.getAslSession(this.getThreadLocalRequest().getSession());
|
||||
ASLSession session = WsUtil.getAslSession(this.getThreadLocalRequest().getSession());
|
||||
|
||||
if(Util.isVRE(session)){
|
||||
if(WsUtil.isVRE(session)){
|
||||
|
||||
// GET WORKSPACE
|
||||
Workspace workspace = HomeLibrary.getUserWorkspace(session);
|
||||
|
@ -1029,7 +1050,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
}
|
||||
}
|
||||
else
|
||||
urlPortlet = app.getURLFromApplicationProfile(oid, Util.getAslSession(this.getThreadLocalRequest().getSession()),this.getThreadLocalRequest().getSession());
|
||||
urlPortlet = app.getURLFromApplicationProfile(oid, WsUtil.getAslSession(this.getThreadLocalRequest().getSession()),this.getThreadLocalRequest().getSession());
|
||||
|
||||
} catch (Exception e) {
|
||||
workspaceLogger.error("getURLFromApplicationProfile", e);
|
||||
|
@ -1044,7 +1065,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
|
||||
try{
|
||||
|
||||
ASLSession session = Util.getAslSession(this.getThreadLocalRequest().getSession());
|
||||
ASLSession session = WsUtil.getAslSession(this.getThreadLocalRequest().getSession());
|
||||
session.setAttribute(name, value);
|
||||
workspaceLogger.trace("set value in session with name: "+name+", value: "+value);
|
||||
workspaceLogger.debug("WS Session Id = " + session.getExternalSessionID());
|
||||
|
@ -1112,7 +1133,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
listContactsModel.add(new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia"));
|
||||
listContactsModel.add(new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi"));
|
||||
listContactsModel.add(new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano"));
|
||||
listContactsModel.add(new InfoContactModel(Util.TEST_USER, Util.TEST_USER, Util.TEST_USER_FULL_NAME));
|
||||
listContactsModel.add(new InfoContactModel(WsUtil.TEST_USER, WsUtil.TEST_USER, WsUtil.TEST_USER_FULL_NAME));
|
||||
listContactsModel.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa"));
|
||||
listContactsModel.add(new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante"));
|
||||
return listContactsModel;
|
||||
|
@ -1697,7 +1718,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
|
||||
WorkspaceItem wsItem = workspace.getItem(folderSharedId);
|
||||
|
||||
if(Util.isASharedFolder(wsItem)){
|
||||
if(NotificationsUtil.isASharedFolder(wsItem)){
|
||||
|
||||
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) wsItem;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItem;
|
|||
import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItemType;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.Image;
|
||||
import org.gcube.portlets.user.workspace.client.util.ImageRequestType;
|
||||
import org.gcube.portlets.user.workspace.server.util.Util;
|
||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||
|
||||
/**
|
||||
* @author Federico De Faveri defaveri@isti.cnr.it
|
||||
|
@ -61,7 +61,7 @@ public class ImageServlet extends HttpServlet{
|
|||
|
||||
Workspace wa = null;
|
||||
try {
|
||||
wa = Util.getWorkspace(req.getSession());
|
||||
wa = WsUtil.getWorkspace(req.getSession());
|
||||
} catch (Exception e) {
|
||||
logger.error("Error during workspace retrieving", e);
|
||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"Error during workspace retrieving");
|
||||
|
|
|
@ -42,7 +42,7 @@ import org.gcube.portlets.user.homelibrary.util.WorkspaceUtil;
|
|||
import org.gcube.portlets.user.homelibrary.util.zip.UnzipUtil;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.UploadResultMessage;
|
||||
import org.gcube.portlets.user.workspace.server.notifications.NotificationsUtil;
|
||||
import org.gcube.portlets.user.workspace.server.util.Util;
|
||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||
|
||||
/**
|
||||
* @author Federico De Faveri defaveri@isti.cnr.it
|
||||
|
@ -148,7 +148,7 @@ public class UploadServlet extends HttpServlet {
|
|||
|
||||
Workspace wa = null;
|
||||
try {
|
||||
wa = Util.getWorkspace(request.getSession());
|
||||
wa = WsUtil.getWorkspace(request.getSession());
|
||||
} catch (Exception e) {
|
||||
logger.error("Error during workspace retrieving", e);
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error processing request in upload servlet");
|
||||
|
@ -265,7 +265,7 @@ public class UploadServlet extends HttpServlet {
|
|||
sourceItem = workspace.getItem(itemId);
|
||||
String sourceSharedId = sourceItem.getIdSharedFolder();
|
||||
WorkspaceItem folderDestinationItem = workspace.getItem(destinationFolderId);
|
||||
NotificationsUtil.checkNotifyAddItemToShare(httpSession, sourceItem, sourceSharedId, folderDestinationItem);
|
||||
NotificationsUtil.checkSendNotifyAddItemToShare(httpSession, sourceItem, sourceSharedId, folderDestinationItem);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error in notifyUploadInSharedFolder", e);
|
||||
|
||||
|
|
|
@ -11,13 +11,14 @@ import org.gcube.application.framework.core.session.SessionManager;
|
|||
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gcube.common.core.utils.logging.GCUBEClientLog;
|
||||
import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceSharedFolder;
|
||||
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||
import org.gcube.portlets.user.workspace.server.util.DiffereceBeetweenInfoContactModel;
|
||||
import org.gcube.portlets.user.workspace.server.util.UserUtil;
|
||||
import org.gcube.portlets.user.workspace.server.util.Util;
|
||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -39,7 +40,7 @@ public class NotificationsProducer {
|
|||
* @param aslSession
|
||||
*/
|
||||
public NotificationsProducer(ASLSession aslSession) {
|
||||
this.notificationsMng = Util.getNotificationManager(aslSession);
|
||||
this.notificationsMng = WsUtil.getNotificationManager(aslSession);
|
||||
this.aslSession = aslSession;
|
||||
this.userId = aslSession.getUsername();
|
||||
}
|
||||
|
@ -103,17 +104,30 @@ public class NotificationsProducer {
|
|||
|
||||
/**
|
||||
* Runs a new thread to notify the contacts passed in input
|
||||
* @param folderItem
|
||||
* @param listContacts
|
||||
* @param sharedFolder
|
||||
*/
|
||||
public void notifyFolderRenamed(final List<InfoContactModel> listSharedContact, final String itemOldName, final String itemNewName, final String idsharedFolder) {
|
||||
public void notifyFolderRenamed(final List<InfoContactModel> listSharedContact, final WorkspaceItem folderItem, final String itemOldName, final String itemNewName, final String idsharedFolder) {
|
||||
|
||||
new Thread(){
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
gcubeLogger.trace("Send notifies shared folder was renamed is running...");
|
||||
|
||||
|
||||
try {
|
||||
|
||||
if(NotificationsUtil.checkIsRootFolderShared(folderItem.getId(), idsharedFolder)){
|
||||
gcubeLogger.trace("Notification isn't sent because the event is on root shared folder");
|
||||
return;
|
||||
}
|
||||
|
||||
} catch (InternalErrorException e1) {
|
||||
gcubeLogger.error("An error occurred in checkIsRootFolderShared ", e1);
|
||||
return;
|
||||
}
|
||||
|
||||
for (InfoContactModel infoContactModel : listSharedContact) {
|
||||
try{
|
||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||
|
@ -390,17 +404,31 @@ public class NotificationsProducer {
|
|||
* @param listContacts
|
||||
* @param sharedFolder
|
||||
*/
|
||||
public void notifyRemovedItemToSharing(final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceFolder sharedFolder) {
|
||||
public void notifyMovedItemToSharing(final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceFolder sharedFolder) {
|
||||
|
||||
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
gcubeLogger.trace("Sending notification remove item in shared folder is running...");
|
||||
// printContacts(listContacts);
|
||||
gcubeLogger.trace("Sending notificationremove item in shared folder is running...");
|
||||
|
||||
System.out.println("Sending notification remove item in shared folder is running...");
|
||||
try {
|
||||
|
||||
if(NotificationsUtil.checkIsRootFolderShared(workspaceItem.getId(), sharedFolder.getId())){
|
||||
gcubeLogger.trace("Notification isn't sent because the event is on root shared folder");
|
||||
return;
|
||||
}
|
||||
|
||||
} catch (InternalErrorException e1) {
|
||||
gcubeLogger.error("An error occurred in checkIsRootFolderShared ", e1);
|
||||
return;
|
||||
}
|
||||
|
||||
gcubeLogger.trace("Sending notification moved item in shared folder is running...");
|
||||
|
||||
System.out.println("Sending notification moved item in shared folder is running...");
|
||||
|
||||
for (InfoContactModel infoContactModel : listContacts) {
|
||||
try{
|
||||
|
@ -408,13 +436,13 @@ public class NotificationsProducer {
|
|||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||
|
||||
gcubeLogger.trace("Sending notification to user "+infoContactModel.getLogin() +" removed item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
||||
gcubeLogger.trace("Sending notification to user "+infoContactModel.getLogin() +" moved item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
||||
|
||||
//DEBUG
|
||||
System.out.println("Sending notification to user "+infoContactModel.getLogin() +" removed item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
||||
System.out.println("Sending notification to user "+infoContactModel.getLogin() +" moved item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
||||
|
||||
boolean notify = notificationsMng.notifyRemovedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder);
|
||||
|
||||
|
||||
if(!notify){
|
||||
gcubeLogger.error("An error occured when notify user: "+infoContactModel.getLogin());
|
||||
|
||||
|
@ -423,20 +451,93 @@ public class NotificationsProducer {
|
|||
}
|
||||
}
|
||||
}catch (Exception e) {
|
||||
gcubeLogger.error("An error occured in notifyRemovedItemToSharing ", e);
|
||||
gcubeLogger.error("An error occurred in notifyMovedItemToSharing ", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
gcubeLogger.trace("notifies of removed item in shared folder is completed");
|
||||
gcubeLogger.trace("notifies of moved item in shared folder is completed");
|
||||
|
||||
//DEBUG
|
||||
System.out.println("notifies of removed item in shared folder is completed");
|
||||
System.out.println("notifies of moved item in shared folder is completed");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}.start();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runs a new thread to notify the contacts passed in input
|
||||
* @param listContacts
|
||||
* @param sharedFolder
|
||||
*/
|
||||
public void notifyRemovedItemToSharing(final List<InfoContactModel> listContacts, final String itemName, final WorkspaceFolder sharedFolder) {
|
||||
|
||||
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
gcubeLogger.trace("Sending notification remove item in shared folder is running...");
|
||||
// printContacts(listContacts);
|
||||
|
||||
if(itemName==null || itemName.isEmpty()){
|
||||
gcubeLogger.trace("Notification isn't sent - itemName is null or empty");
|
||||
return;
|
||||
}
|
||||
|
||||
if(sharedFolder==null){
|
||||
gcubeLogger.trace("Notification isn't sent - sharedFolder is null");
|
||||
}
|
||||
|
||||
gcubeLogger.trace("Sending notification removed item in shared folder is running...");
|
||||
|
||||
System.out.println("Sending notification removed item in shared folder is running...");
|
||||
|
||||
for (InfoContactModel infoContactModel : listContacts) {
|
||||
try{
|
||||
|
||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||
|
||||
gcubeLogger.trace("Sending notification to user "+infoContactModel.getLogin() +" removed item "+itemName+" in shared folder "+sharedFolder.getName());
|
||||
|
||||
//DEBUG
|
||||
System.out.println("Sending notification to user "+infoContactModel.getLogin() +" removed item "+itemName+" in shared folder "+sharedFolder.getName());
|
||||
|
||||
|
||||
|
||||
// boolean notify = notificationsMng.notifyRemovedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder);
|
||||
|
||||
|
||||
// if(!notify){
|
||||
// gcubeLogger.error("An error occured when notify user: "+infoContactModel.getLogin());
|
||||
|
||||
//DEBUG
|
||||
// System.out.println("An error occured when notify user: "+infoContactModel.getLogin());
|
||||
// }
|
||||
}
|
||||
}catch (Exception e) {
|
||||
gcubeLogger.error("An error occurred in notifyRemovedItemToSharing ", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
gcubeLogger.trace("notifies of moved item in shared folder is completed");
|
||||
|
||||
//DEBUG
|
||||
System.out.println("notifies of moved item in shared folder is completed");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}.start();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//DEBUG
|
||||
private void printContacts(List<InfoContactModel> listContacts){
|
||||
|
|
|
@ -9,14 +9,17 @@ import java.util.List;
|
|||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.gcube.portlets.user.homelibrary.home.exceptions.HomeNotFoundException;
|
||||
import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceFolder;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItemType;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceSharedFolder;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
||||
import org.gcube.portlets.user.workspace.server.util.Util;
|
||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
|
@ -35,9 +38,9 @@ public class NotificationsUtil {
|
|||
* @param sourceSharedId
|
||||
* @param folderDestinationItem
|
||||
*/
|
||||
public static void checkNotifyAddItemToShare(HttpSession httpSession, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem) {
|
||||
public static void checkSendNotifyAddItemToShare(HttpSession httpSession, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem) {
|
||||
|
||||
logger.trace("checkNotifyAddItemToShare");
|
||||
logger.trace("checkSendNotifyAddItemToShare");
|
||||
|
||||
if(folderDestinationItem!=null){
|
||||
|
||||
|
@ -57,13 +60,13 @@ public class NotificationsUtil {
|
|||
//if shareChangeCondition is true.. notifies added item to sharing
|
||||
if(shareChangeCondition){
|
||||
|
||||
Workspace workspace = Util.getWorkspace(httpSession);
|
||||
Workspace workspace = WsUtil.getWorkspace(httpSession);
|
||||
|
||||
List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(workspace, folderDestinationItem.getIdSharedFolder());
|
||||
|
||||
WorkspaceItem destinationSharedFolder = workspace.getItem(folderDestinationItem.getIdSharedFolder());
|
||||
|
||||
NotificationsProducer np = new NotificationsProducer(Util.getAslSession(httpSession));
|
||||
NotificationsProducer np = new NotificationsProducer(WsUtil.getAslSession(httpSession));
|
||||
|
||||
np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) destinationSharedFolder);
|
||||
|
||||
|
@ -75,10 +78,10 @@ public class NotificationsUtil {
|
|||
logger.trace("folder destination is not shared");
|
||||
|
||||
}catch (Exception e) {
|
||||
logger.error("An error occurred in verifyNotifyAddItemToShare ",e);
|
||||
logger.error("An error occurred in checkSendNotifyAddItemToShare ",e);
|
||||
}
|
||||
}else
|
||||
logger.warn("The notifies is failure in verifyNotifyAddItemToShare because folder destination item is null");
|
||||
logger.warn("The notifies is failure in checkSendNotifyAddItemToShare because folder destination item is null");
|
||||
}
|
||||
|
||||
|
||||
|
@ -97,7 +100,7 @@ public class NotificationsUtil {
|
|||
|
||||
WorkspaceItem wsItem = workspace.getItem(idSharedFolder);
|
||||
|
||||
if(Util.isASharedFolder(wsItem)){
|
||||
if(isASharedFolder(wsItem)){
|
||||
|
||||
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) wsItem;
|
||||
|
||||
|
@ -126,65 +129,129 @@ public class NotificationsUtil {
|
|||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param httpSession
|
||||
* @param sourceItemIsShared
|
||||
* @param sourceItem
|
||||
* @param sourceSharedId
|
||||
* @param folderDestinationItem
|
||||
* @param oldItemName
|
||||
* @param oldItemId
|
||||
* @param sourceFolderSharedId
|
||||
*/
|
||||
|
||||
public static void checkNotifyRemoveItemToShare(HttpSession httpSession, final boolean sourceItemIsShared, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem) {
|
||||
public static void checkSendNotifyRemoveItemToShare(HttpSession httpSession, final boolean sourceItemIsShared, final String oldItemName, String oldItemId, final String sourceFolderSharedId) {
|
||||
|
||||
|
||||
logger.trace("checkNotifyRemoveItemToShare:");
|
||||
|
||||
try{
|
||||
|
||||
if(folderDestinationItem!=null){
|
||||
|
||||
String idSharedFolder = folderDestinationItem.getIdSharedFolder()!=null?folderDestinationItem.getIdSharedFolder():"";
|
||||
|
||||
//share condition is true if source shared folder is not equal to destination shared folder
|
||||
boolean shareChangeCondition = sourceSharedId==null?false:(sourceSharedId.compareTo(idSharedFolder)!=0);
|
||||
|
||||
logger.trace("checkNotifyRemoveItemToShare source item: "+sourceItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName() +" sourceItemIsShared: "+sourceItemIsShared);
|
||||
if(!sourceItemIsShared){
|
||||
|
||||
logger.trace("checkSendNotifyRemoveItemToShare returned, source item is not shared");
|
||||
return;
|
||||
}
|
||||
|
||||
String idSharedFolder = sourceFolderSharedId!=null?sourceFolderSharedId:"";
|
||||
|
||||
// System.out.println("shareChangeCondition remove item: "+ shareChangeCondition);
|
||||
|
||||
logger.trace("shareChangeCondition remove item: "+ shareChangeCondition);
|
||||
|
||||
//Notify Removed Item To Sharing?
|
||||
//if source Item is shared and folder destination is not shared or shareChangeCondition is true.. notifies removed item to sharing
|
||||
if(sourceItemIsShared && (!folderDestinationItem.isShared() || shareChangeCondition)){
|
||||
|
||||
Workspace workspace = Util.getWorkspace(httpSession);
|
||||
|
||||
|
||||
boolean isRootFolderShared = checkIsRootFolderShared(oldItemId, idSharedFolder);
|
||||
logger.trace("isRootFolderShared is: "+ isRootFolderShared);
|
||||
|
||||
if(isRootFolderShared){
|
||||
logger.trace("Notification doesn't send because the event is on root shared folder");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
boolean isSharedFolder = isASharedFolderForId(httpSession,idSharedFolder);
|
||||
|
||||
logger.trace("idSharedFolder is: "+ idSharedFolder +" is shared folder: "+isSharedFolder);
|
||||
|
||||
|
||||
//Notify Removed Item To Sharing?
|
||||
if(isSharedFolder && !isRootFolderShared){
|
||||
|
||||
//get contacts
|
||||
List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(workspace, sourceSharedId);
|
||||
|
||||
|
||||
WorkspaceItem sourceSharedFolder = workspace.getItem(sourceSharedId);
|
||||
|
||||
//System.out.println(" name sourceSharedFolder: "+ sourceSharedFolder.getName());
|
||||
|
||||
NotificationsProducer np = new NotificationsProducer(Util.getAslSession(httpSession));
|
||||
|
||||
np.notifyRemovedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) sourceSharedFolder);
|
||||
|
||||
logger.trace("The notifies was sent correctly");
|
||||
|
||||
}
|
||||
|
||||
}else
|
||||
logger.warn("The notifies is failure in verifyNotifyRemoveItemToShare because folder destination item is null");
|
||||
Workspace workspace = WsUtil.getWorkspace(httpSession);
|
||||
|
||||
//get contacts
|
||||
List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(workspace, idSharedFolder);
|
||||
|
||||
WorkspaceItem sourceSharedFolder = workspace.getItem(idSharedFolder);
|
||||
|
||||
//System.out.println(" name sourceSharedFolder: "+ sourceSharedFolder.getName());
|
||||
|
||||
NotificationsProducer np = new NotificationsProducer(WsUtil.getAslSession(httpSession));
|
||||
|
||||
np.notifyRemovedItemToSharing(listContacts, oldItemName, (WorkspaceFolder) sourceSharedFolder);
|
||||
|
||||
logger.trace("The notifies was sent correctly");
|
||||
|
||||
}
|
||||
|
||||
}catch (Exception e) {
|
||||
logger.error("An error occurred in checkNotifyRemoveItemToShare ",e);
|
||||
logger.error("An error occurred in checkSendNotifyRemoveItemToShare ",e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param wsItem
|
||||
* @return
|
||||
*/
|
||||
public static boolean isASharedFolder(WorkspaceItem wsItem){
|
||||
if(wsItem!=null)
|
||||
return wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param wsItem
|
||||
* @return
|
||||
*/
|
||||
public static boolean isASharedFolderForId(HttpSession httpSession, String itemId){
|
||||
|
||||
if(itemId==null || itemId.isEmpty())
|
||||
return false;
|
||||
|
||||
try {
|
||||
|
||||
Workspace workspace = WsUtil.getWorkspace(httpSession);
|
||||
|
||||
WorkspaceItem wsItem = workspace.getItem(itemId);
|
||||
|
||||
if(wsItem!=null)
|
||||
return wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER);
|
||||
return false;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("An errror occurred in isASharedFolderForId", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param itemId
|
||||
* @param rootFolderSharedId
|
||||
* @return
|
||||
*/
|
||||
public static boolean checkIsRootFolderShared(String itemId, String rootFolderSharedId) {
|
||||
|
||||
logger.trace("checkIsRootFolderShared between [itemid: "+itemId +", rootFolderSharedId: "+rootFolderSharedId+"]");
|
||||
if(itemId==null)
|
||||
return false;
|
||||
|
||||
if(rootFolderSharedId==null)
|
||||
return false;
|
||||
|
||||
if(itemId.compareTo(rootFolderSharedId)==0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class UserUtil {
|
|||
public static String getUserFullName(String portalLogin){
|
||||
// return user.getPortalLogin(); //for testing in eclipse
|
||||
|
||||
if (portalLogin.compareTo(Util.TEST_USER) != 0) { //skip test.user
|
||||
if (portalLogin.compareTo(WsUtil.TEST_USER) != 0) { //skip test.user
|
||||
|
||||
UserModel curr = null;
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class UserUtil {
|
|||
return curr.getFullname();
|
||||
}else{
|
||||
|
||||
return Util.TEST_USER_FULL_NAME;
|
||||
return WsUtil.TEST_USER_FULL_NAME;
|
||||
}
|
||||
|
||||
return "";
|
||||
|
|
|
@ -17,8 +17,6 @@ import org.gcube.portlets.user.homelibrary.home.HomeLibrary;
|
|||
import org.gcube.portlets.user.homelibrary.home.exceptions.HomeNotFoundException;
|
||||
import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.WorkspaceItemType;
|
||||
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
||||
import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer;
|
||||
|
@ -29,7 +27,7 @@ import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
|
|||
* @author Federico De Faveri defaveri@isti.cnr.it
|
||||
*
|
||||
*/
|
||||
public class Util {
|
||||
public class WsUtil {
|
||||
|
||||
public static final String USERNAME_ATTRIBUTE = ScopeHelper.USERNAME_ATTRIBUTE;
|
||||
public static final String FOLDERIMPORTER_ATTRIBUTE = "FOLDER_IMPORTER";
|
||||
|
@ -57,7 +55,7 @@ public class Util {
|
|||
public static final String TEST_USER_FULL_NAME = "Test User";
|
||||
|
||||
|
||||
public static GCUBEClientLog defaultLogger = new GCUBEClientLog(Util.class);
|
||||
public static GCUBEClientLog defaultLogger = new GCUBEClientLog(WsUtil.class);
|
||||
|
||||
public static boolean withoutPortal = false;
|
||||
|
||||
|
@ -190,13 +188,13 @@ public class Util {
|
|||
public static WorkspaceEventCollector getEventCollector(HttpSession httpSession)
|
||||
{
|
||||
ASLSession session = getAslSession(httpSession);
|
||||
return (WorkspaceEventCollector) session.getAttribute(Util.WORKSPACE_EVENT_COLLECTOR_ATTRIBUTE);
|
||||
return (WorkspaceEventCollector) session.getAttribute(WsUtil.WORKSPACE_EVENT_COLLECTOR_ATTRIBUTE);
|
||||
}
|
||||
|
||||
public static GWTWorkspaceBuilder getGWTWorkspaceBuilder(HttpSession httpSession)
|
||||
{
|
||||
ASLSession session = getAslSession(httpSession);
|
||||
return (GWTWorkspaceBuilder) session.getAttribute(Util.WORKSPACEBUILDER_ATTRIBUTE);
|
||||
return (GWTWorkspaceBuilder) session.getAttribute(WsUtil.WORKSPACEBUILDER_ATTRIBUTE);
|
||||
}
|
||||
|
||||
public static NotificationsManager getNotificationManager(ASLSession session)
|
||||
|
@ -250,18 +248,12 @@ public class Util {
|
|||
|
||||
}
|
||||
|
||||
public static boolean isASharedFolder(WorkspaceItem wsItem){
|
||||
if(wsItem!=null)
|
||||
return wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ScopeUtilFilter getScopeUtilFilter(HttpSession httpSession){
|
||||
|
||||
ASLSession session = getAslSession(httpSession);
|
||||
ScopeUtilFilter scopeUtil = null;
|
||||
try{
|
||||
scopeUtil = (ScopeUtilFilter) session.getAttribute(Util.WORKSPACE_SCOPE_UTIL);
|
||||
scopeUtil = (ScopeUtilFilter) session.getAttribute(WsUtil.WORKSPACE_SCOPE_UTIL);
|
||||
|
||||
if(scopeUtil==null){
|
||||
scopeUtil = new ScopeUtilFilter(session.getScopeName());
|
Loading…
Reference in New Issue