Francesco Mangiacrapa 11 years ago
parent daaf1d6990
commit dd0a419209

@ -147,7 +147,7 @@
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>opengcubeapplication</artifactId>
<artifactId>workspaceapplicationhandler</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>

@ -28,7 +28,6 @@ import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalU
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ts.TimeSeries;
import org.gcube.portlets.user.homelibrary.home.workspace.search.SearchItem;
import org.gcube.portlets.user.homelibrary.home.workspace.sharing.WorkspaceMessage;
import org.gcube.portlets.user.opengcubeapplication.ApplicationReaderFromGenericResource;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategoryItemInterface;
import org.gcube.portlets.user.workspace.client.model.BulkCreatorModel;
@ -46,6 +45,7 @@ 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.util.AllScope;
import org.gcube.portlets.user.workspace.server.util.Util;
import org.gcube.portlets.user.workspaceapplicationhandler.ApplicationReaderFromGenericResource;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
@ -293,82 +293,27 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
sourceSharedId = sourceItem.getIdSharedFolder(); //GET SHARED ID BEFORE OF MOVE
System.out.println("moveItem item: "+itemId+" sourceItem name "+sourceItem.getName() + " shared: "+sourceItemIsShared+ " destination: "+destinationId);
//System.out.println("moveItem item: "+itemId+" sourceItem name "+sourceItem.getName() + " shared: "+sourceItemIsShared+ " destination: "+destinationId);
workspace.moveItem(itemId, destinationId); //move item
WorkspaceItem folderDestinationItem = workspace.getItem(destinationId); //retrieve folder destination
System.out.println("sourceItem.isShared() "+sourceItemIsShared );
System.out.println("folderDestinationItem item: "+destinationId+" folderDestinationItem name "+folderDestinationItem.getName() + " folderDestinationItem shared: "+folderDestinationItem.isShared());
//System.out.println("sourceItem.isShared() "+sourceItemIsShared );
//System.out.println("folderDestinationItem item: "+destinationId+" folderDestinationItem name "+folderDestinationItem.getName() + " folderDestinationItem shared: "+folderDestinationItem.isShared());
if(folderDestinationItem!=null){
// //if folder destination is shared folder
// if(folderDestinationItem.isShared()){ //Notify Added Item To Sharing?
//
// //share condition is true if source shared folder is null or not equal to destination shared folder
// shareChangeCondition = (sourceSharedId==null) || (sourceSharedId.compareTo(folderDestinationItem.getIdSharedFolder())!=0);
//
// System.out.println("shareChangeCondition add item: "+ shareChangeCondition);
//
//
// //if shareChangeCondition is true.. notifies added item to sharing
// if(shareChangeCondition){
//
// List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(folderDestinationItem.getIdSharedFolder());
//
// //DEBUG
// printContacts(listContacts);
//
// WorkspaceItem destinationSharedFolder = workspace.getItem(folderDestinationItem.getIdSharedFolder());
//
// np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) destinationSharedFolder);
//
//// np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem);
// }
// }
try{
checkNotifyAddItemToShare(sourceItem, sourceSharedId, folderDestinationItem);
checkNotifyRemoveItemToShare(sourceItemIsShared, sourceItem, sourceSharedId, folderDestinationItem);
checkNotifyAddItemToShare(sourceItem, sourceSharedId, folderDestinationItem);
checkNotifyRemoveItemToShare(sourceItemIsShared, sourceItem, sourceSharedId, folderDestinationItem);
}catch (Exception e) {
workspaceLogger.error("An error occurred in checkNotify ", e);
}
// System.out.println("folderDestinationItem.isShared() "+ folderDestinationItem.getName() + ": "+ folderDestinationItem.isShared());
//
//
// String idSharedFolder = folderDestinationItem.getIdSharedFolder()!=null?folderDestinationItem.getIdSharedFolder():"";
//
// //share condition is true if source shared folder is not equal to destination shared folder
// shareChangeCondition = sourceSharedId==null?false:(sourceSharedId.compareTo(idSharedFolder)!=0);
//
// System.out.println("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)){
//
// //get contacts
// List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(sourceSharedId);
//
// //DEBUG
// printContacts(listContacts);
//
// WorkspaceItem sourceSharedFolder = workspace.getItem(sourceSharedId);
//
// System.out.println(" name sourceSharedFolder: "+ sourceSharedFolder.getName());
//
// np.notifyRemovedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) sourceSharedFolder);
//
// }
}
return Boolean.TRUE;
}catch (InsufficientPrivilegesException e) {
@ -384,158 +329,122 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
}
private void checkNotifyAddItemToShare(WorkspaceItem sourceItem, String sourceSharedId, WorkspaceItem folderDestinationItem) throws WorkspaceFolderNotFoundException, ItemNotFoundException, InternalErrorException, HomeNotFoundException, Exception{
private void checkNotifyAddItemToShare(final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem) {
workspaceLogger.trace("checkNotifyAddItemToShare");
if(folderDestinationItem!=null){
//if folder destination is shared folder
if(folderDestinationItem.isShared()){ //Notify Added Item To Sharing?
//share condition is true if source shared folder is null or not equal to destination shared folder
boolean shareChangeCondition = (sourceSharedId==null) || (sourceSharedId.compareTo(folderDestinationItem.getIdSharedFolder())!=0);
System.out.println("shareChangeCondition add item: "+ shareChangeCondition);
//if shareChangeCondition is true.. notifies added item to sharing
if(shareChangeCondition){
List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(folderDestinationItem.getIdSharedFolder());
//DEBUG
printContacts(listContacts);
Workspace workspace = getWorkspace();
try{
//if folder destination is shared folder
if(folderDestinationItem.isShared()){ //Notify Added Item To Sharing?
WorkspaceItem destinationSharedFolder = workspace.getItem(folderDestinationItem.getIdSharedFolder());
workspaceLogger.trace("checkNotifyAddItemToShare source item: "+sourceItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName());
NotificationsProducer np = getNotificationProducer();
np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) destinationSharedFolder);
//share condition is true if source shared folder is null or not equal to destination shared folder
boolean shareChangeCondition = (sourceSharedId==null) || (sourceSharedId.compareTo(folderDestinationItem.getIdSharedFolder())!=0);
//System.out.println("shareChangeCondition add item: "+ shareChangeCondition);
workspaceLogger.trace("shareChangeCondition add item: "+shareChangeCondition);
// np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem);
}
//if shareChangeCondition is true.. notifies added item to sharing
if(shareChangeCondition){
List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(folderDestinationItem.getIdSharedFolder());
//DEBUG
printContacts(listContacts);
Workspace workspace = getWorkspace();
WorkspaceItem destinationSharedFolder = workspace.getItem(folderDestinationItem.getIdSharedFolder());
NotificationsProducer np = getNotificationProducer();
np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) destinationSharedFolder);
workspaceLogger.trace("The notifies was sent correctly");
// np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem);
}
}
else
workspaceLogger.trace("folder destination is not shared");
}catch (Exception e) {
workspaceLogger.error("An error occurred in verifyNotifyAddItemToShare ",e);
}
}else
workspaceLogger.error("verifyNotifyAddItemToShare folder destination item is null");
workspaceLogger.warn("The notifies is failure in verifyNotifyAddItemToShare because folder destination item is null");
}
// private void checkNotifyAddItemToShare(final String itemId, final String destinationId) throws WorkspaceFolderNotFoundException, ItemNotFoundException, InternalErrorException, HomeNotFoundException, Exception{
//
// new Thread(){
// @Override
// public void run() {
//
// try{
//
// Workspace workspace = getWorkspace();
// GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
// logger.trace("moveItem item: "+itemId+" destination: "+destinationId);
//
// WorkspaceItem sourceItem = workspace.getItem(itemId);
//
// if(sourceItem==null)
// return;
//
// String sourceSharedId = null;
// boolean sourceItemIsShared = sourceItem.isShared();
//
// if(sourceItemIsShared)
// sourceSharedId = sourceItem.getIdSharedFolder(); //GET SHARED ID BEFORE OF MOVE
//
//
// System.out.println("moveItem item: "+itemId+" sourceItem name "+sourceItem.getName() + " shared: "+sourceItemIsShared+ " destination: "+destinationId);
//
//
// WorkspaceItem folderDestinationItem = workspace.getItem(destinationId); //retrieve folder destination
//
// if(folderDestinationItem!=null){
//
// //if folder destination is shared folder
// if(folderDestinationItem.isShared()){ //Notify Added Item To Sharing?
//
// //share condition is true if source shared folder is null or not equal to destination shared folder
// boolean shareChangeCondition = (sourceSharedId==null) || (sourceSharedId.compareTo(folderDestinationItem.getIdSharedFolder())!=0);
//
// System.out.println("shareChangeCondition add item: "+ shareChangeCondition);
//
// //if shareChangeCondition is true.. notifies added item to sharing
// if(shareChangeCondition){
//
// List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(folderDestinationItem.getIdSharedFolder());
//
// //DEBUG
// printContacts(listContacts);
//
// WorkspaceItem destinationSharedFolder = workspace.getItem(folderDestinationItem.getIdSharedFolder());
//
// NotificationsProducer np = getNotificationProducer();
//
// np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) destinationSharedFolder);
//
//// np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem);
// }
// }
// }else
// workspaceLogger.error("verifyNotifyAddItemToShare folder destination item is null");
//
//
// }catch (Exception e) {
// // TODO: handle exception
// }
//
//
// }
// }.start();
//
// }
private void checkNotifyRemoveItemToShare(boolean sourceItemIsShared, WorkspaceItem sourceItem, String sourceSharedId, WorkspaceItem folderDestinationItem) throws WorkspaceFolderNotFoundException, ItemNotFoundException, InternalErrorException, HomeNotFoundException, Exception{
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);
System.out.println("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)){
//get contacts
List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(sourceSharedId);
//DEBUG
printContacts(listContacts);
Workspace workspace = getWorkspace();
WorkspaceItem sourceSharedFolder = workspace.getItem(sourceSharedId);
System.out.println(" name sourceSharedFolder: "+ sourceSharedFolder.getName());
NotificationsProducer np = getNotificationProducer();
np.notifyRemovedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) sourceSharedFolder);
}
private void checkNotifyRemoveItemToShare(final boolean sourceItemIsShared, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem) {
workspaceLogger.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);
workspaceLogger.trace("checkNotifyRemoveItemToShare source item: "+sourceItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName() +" sourceItemIsShared: "+sourceItemIsShared);
// System.out.println("shareChangeCondition remove item: "+ shareChangeCondition);
workspaceLogger.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)){
//get contacts
List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(sourceSharedId);
//DEBUG
printContacts(listContacts);
Workspace workspace = getWorkspace();
WorkspaceItem sourceSharedFolder = workspace.getItem(sourceSharedId);
//System.out.println(" name sourceSharedFolder: "+ sourceSharedFolder.getName());
NotificationsProducer np = getNotificationProducer();
np.notifyRemovedItemToSharing(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");
}else
workspaceLogger.error("verifyNotifyRemoveItemToShare folder destination item is null");
}catch (Exception e) {
workspaceLogger.error("An error occurred in checkNotifyRemoveItemToShare ",e);
}
}
//DEBUG
private void printContacts(List<InfoContactModel> listContacts){
System.out.println("PRINT CONTACTS: ");
boolean testMode = isTestMode();
if(testMode)
System.out.println("Contacts: ");
else
workspaceLogger.trace("Contacts:");
for (InfoContactModel infoContactModel : listContacts) {
System.out.println("User: "+infoContactModel);
if(testMode)
System.out.println("User: "+infoContactModel);
else
workspaceLogger.trace("User: "+infoContactModel);
}
}
@ -1594,14 +1503,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
+ " listContacts size: " + listContacts.size());
// //DEBUG
System.out.println("shareFolder "+ folder.getIdentifier()
+ " name: "+ folder.getName()
+ " parent name: " + folder.getParentFileModel().getName()
+ " listContacts size: " + listContacts.size());
//System.out.println("shareFolder "+ folder.getIdentifier() + " name: "+ folder.getName() + " parent name: " + folder.getParentFileModel().getName() + " listContacts size: " + listContacts.size());
for (InfoContactModel infoContactModel : listContacts) {
System.out.println("share with "+ infoContactModel.getLogin());
}
// for (InfoContactModel infoContactModel : listContacts) {
// System.out.println("share with "+ infoContactModel.getLogin());
// }
printContacts(listContacts);
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
@ -1687,7 +1595,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
workspaceLogger.trace("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER);
//DEBUG
System.out.println("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER);
//System.out.println("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER);
}
return new ArrayList<InfoContactModel>();
@ -1716,7 +1624,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
unShared = unSharedFolder==null?false:true;
System.out.println("unShared is "+unShared);
// System.out.println("unShared is "+unShared);
workspaceLogger.trace("unShared is "+ unShared);
if(unShared){
NotificationsProducer np = getNotificationProducer();

Loading…
Cancel
Save