2013-02-06 15:40:17 +01:00
|
|
|
package org.gcube.portlets.user.workspace.server;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2013-03-25 12:35:05 +01:00
|
|
|
import java.util.Calendar;
|
2013-02-06 15:40:17 +01:00
|
|
|
import java.util.Collections;
|
2013-03-25 12:35:05 +01:00
|
|
|
import java.util.Date;
|
2013-02-06 15:40:17 +01:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
2013-03-11 19:06:56 +01:00
|
|
|
import org.apache.log4j.Logger;
|
2013-02-06 15:40:17 +01:00
|
|
|
import org.gcube.application.framework.core.session.ASLSession;
|
|
|
|
import org.gcube.common.core.scope.GCUBEScope;
|
|
|
|
import org.gcube.common.core.utils.logging.GCUBEClientLog;
|
2013-03-27 17:30:37 +01:00
|
|
|
import org.gcube.portlets.user.homelibrary.home.Home;
|
2013-03-25 11:14:26 +01:00
|
|
|
import org.gcube.portlets.user.homelibrary.home.HomeLibrary;
|
2013-02-06 15:40:17 +01:00
|
|
|
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.WorkspaceSmartFolder;
|
2013-05-23 19:03:43 +02:00
|
|
|
import org.gcube.portlets.user.homelibrary.home.workspace.accounting.AccountingEntry;
|
2013-02-20 14:51:36 +01:00
|
|
|
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
|
|
|
|
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.ItemAlreadyExistException;
|
2013-02-06 15:40:17 +01:00
|
|
|
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.ItemNotFoundException;
|
|
|
|
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
2013-02-20 14:51:36 +01:00
|
|
|
import org.gcube.portlets.user.homelibrary.home.workspace.exceptions.WrongDestinationException;
|
2013-02-06 15:40:17 +01:00
|
|
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderBulkCreator;
|
2013-03-25 11:14:26 +01:00
|
|
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItem;
|
2013-02-06 15:40:17 +01:00
|
|
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.FolderItemType;
|
|
|
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalUrl;
|
|
|
|
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;
|
2013-02-20 14:51:36 +01:00
|
|
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
2013-02-06 15:40:17 +01:00
|
|
|
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategoryItemInterface;
|
|
|
|
import org.gcube.portlets.user.workspace.client.model.BulkCreatorModel;
|
|
|
|
import org.gcube.portlets.user.workspace.client.model.FileDetailsModel;
|
|
|
|
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
|
|
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
|
|
|
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
|
|
|
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
|
|
|
import org.gcube.portlets.user.workspace.client.model.MessageModel;
|
|
|
|
import org.gcube.portlets.user.workspace.client.model.ScopeModel;
|
|
|
|
import org.gcube.portlets.user.workspace.client.model.SmartFolderModel;
|
|
|
|
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;
|
2013-02-13 18:39:33 +01:00
|
|
|
import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer;
|
2013-03-25 17:35:27 +01:00
|
|
|
import org.gcube.portlets.user.workspace.server.util.UserUtil;
|
2013-02-06 15:40:17 +01:00
|
|
|
import org.gcube.portlets.user.workspace.server.util.Util;
|
2013-03-27 17:30:37 +01:00
|
|
|
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
|
2013-05-23 19:03:43 +02:00
|
|
|
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingEntryType;
|
|
|
|
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
|
2013-02-28 12:32:45 +01:00
|
|
|
import org.gcube.portlets.user.workspaceapplicationhandler.ApplicationReaderFromGenericResource;
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWTWorkspaceService{
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 2828885661214875589L;
|
|
|
|
|
|
|
|
public static final String LAST_OPEN_FOLDER_ATTRIBUTE = "WORKSPACE.LAST_OPEN_FOLDER";
|
|
|
|
public static final String SELECTION_STATE_ATTRIBUTE = "WORKSPACE.SELECTION_STATE";
|
|
|
|
|
2013-03-11 19:06:56 +01:00
|
|
|
// protected GCUBELog workspaceLogger = new GCUBELog(GWTWorkspaceServiceImpl.class);
|
|
|
|
|
|
|
|
protected Logger workspaceLogger = Logger.getLogger(GWTWorkspaceServiceImpl.class);
|
2013-02-13 18:39:33 +01:00
|
|
|
|
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
protected GWTWorkspaceBuilder getGWTWorkspaceBuilder()
|
|
|
|
{
|
|
|
|
return Util.getGWTWorkspaceBuilder(this.getThreadLocalRequest().getSession());
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Workspace getWorkspace() throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
|
|
|
|
{
|
|
|
|
return Util.getWorkspace(this.getThreadLocalRequest().getSession());
|
|
|
|
}
|
2013-02-13 18:39:33 +01:00
|
|
|
|
|
|
|
protected NotificationsProducer getNotificationProducer(){
|
|
|
|
|
|
|
|
return Util.getNotificationProducer(Util.getAslSession(this.getThreadLocalRequest().getSession()));
|
|
|
|
}
|
|
|
|
|
2013-03-27 17:30:37 +01:00
|
|
|
protected ScopeUtilFilter getScopeUtilFilter(){
|
|
|
|
|
|
|
|
return Util.getScopeUtilFilter(this.getThreadLocalRequest().getSession());
|
|
|
|
}
|
|
|
|
|
2013-02-14 15:06:34 +01:00
|
|
|
protected boolean isTestMode(){
|
2013-02-15 12:51:01 +01:00
|
|
|
return Util.withoutPortal;
|
2013-02-13 18:39:33 +01:00
|
|
|
}
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public FolderModel getRootForTree() throws Exception {
|
|
|
|
|
2013-02-27 19:17:22 +01:00
|
|
|
workspaceLogger.trace("getRoot");
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
workspaceLogger.trace("getting workspace");
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
|
|
|
|
|
|
|
logger.info("getRoot");
|
|
|
|
|
|
|
|
WorkspaceFolder root = workspace.getRoot();
|
|
|
|
|
|
|
|
if (root == null) {
|
|
|
|
logger.error("The root is null");
|
|
|
|
throw new Exception("The root is null");
|
|
|
|
}
|
|
|
|
|
|
|
|
logger.trace("Root loaded, gxt conversion");
|
|
|
|
workspaceLogger.trace("Root loaded, gxt conversion");
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
FolderModel gwtroot =builder.buildWorkspaceFileModelRoot(root);
|
|
|
|
|
|
|
|
logger.trace("Root converted, returnig...");
|
|
|
|
workspaceLogger.trace("Root converted, returnig...");
|
|
|
|
return gwtroot;
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server during root retrieving", e);
|
|
|
|
// workspaceLogger.trace("Error in server During root retrieving " + e);
|
|
|
|
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception("Error during workspace loading, please contact the support. Exception:" +e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FolderModel getRootForTree(String scopeId) throws Exception {
|
|
|
|
|
|
|
|
workspaceLogger.info("getRoot for scope " + scopeId);
|
|
|
|
workspaceLogger.trace("getting workspace");
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
|
|
|
logger.info("getRoot for scope " + scopeId);
|
|
|
|
|
|
|
|
workspaceLogger.trace("on server getRoot for scope: " + scopeId);
|
|
|
|
|
|
|
|
GCUBEScope gcubeScope = null;
|
|
|
|
|
2013-03-27 17:30:37 +01:00
|
|
|
if(scopeId.compareTo(ScopeUtilFilter.IDALLSCOPE)!=0){
|
2013-02-06 15:40:17 +01:00
|
|
|
gcubeScope = GCUBEScope.getScope(scopeId);
|
|
|
|
}
|
|
|
|
WorkspaceFolder root = workspace.getRoot(gcubeScope);
|
|
|
|
// WorkspaceFolder root = workspace.getRoot(); //TODO CHAGE METHOD
|
|
|
|
|
|
|
|
// WorkspaceFolder root = workspace.getRoot(scopeId);
|
|
|
|
|
|
|
|
if (root == null) {
|
|
|
|
logger.error("The root is null");
|
|
|
|
throw new Exception("The root is null");
|
|
|
|
}
|
|
|
|
|
|
|
|
logger.trace("Root loaded, gxt conversion");
|
|
|
|
workspaceLogger.trace("Root loaded, gxt conversion");
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
logger.trace("Root converted, returnig...");
|
|
|
|
workspaceLogger.trace("Root converted, returnig...");
|
|
|
|
return builder.buildWorkspaceFileModelRoot(root);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server during root retrieving", e);
|
|
|
|
// workspaceLogger.trace("Error in server During root retrieving " + e);
|
|
|
|
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception("Error during workspace loading, please contact the support. Exception:" +e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<FileGridModel> getItemsBySearchName(String text) throws Exception {
|
|
|
|
|
|
|
|
workspaceLogger.trace("getting search");
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
|
|
|
|
|
|
|
List<SearchItem> listSearchItems = workspace.searchByName(text);
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
List<FileGridModel> listFileGridModels = new ArrayList<FileGridModel>();
|
|
|
|
|
|
|
|
logger.trace("Call search HL..");
|
|
|
|
|
|
|
|
listFileGridModels = builder.buildGXTListFileGridModelItemForSearch(listSearchItems, null);
|
|
|
|
logger.trace("Search converted, completed...");
|
|
|
|
|
|
|
|
return listFileGridModels;
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server During search retrieving", e);
|
|
|
|
// workspaceLogger.trace("Error in server During search retrieving " + e);
|
|
|
|
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception("Error during searching, please contact the support.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<FileModel> getFolderChildren(FolderModel folder) throws Exception{
|
|
|
|
|
|
|
|
Workspace workspace;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
workspace = getWorkspace();
|
|
|
|
|
|
|
|
List<FileModel> listFileModels = new ArrayList<FileModel>();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
|
|
|
logger.info("get children");
|
|
|
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(folder.getIdentifier());
|
2013-05-23 19:03:43 +02:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
listFileModels = builder.buildGXTListFileModelItem(wsItem, folder);
|
|
|
|
|
|
|
|
return listFileModels;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server During item retrieving", e);
|
|
|
|
// workspaceLogger.trace("Error in server During item retrieving " + e);
|
|
|
|
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception("Error during item loading, please contact the support.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<FileGridModel> getFolderChildrenForFileGrid(FileModel folder) throws Exception {
|
|
|
|
Workspace workspace;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
workspace = getWorkspace();
|
|
|
|
|
|
|
|
List<FileGridModel> listFileGridModels = new ArrayList<FileGridModel>();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
2013-02-27 19:17:22 +01:00
|
|
|
logger.trace("get children for Grid");
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
workspaceLogger.trace("get children for Grid");
|
|
|
|
|
|
|
|
WorkspaceFolder wsFolder = (WorkspaceFolder) workspace.getItem(folder.getIdentifier());
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
Long startTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
List<WorkspaceItem> listItems = (List<WorkspaceItem>) wsFolder.getChildren();
|
|
|
|
|
|
|
|
Long endTime = System.currentTimeMillis() - startTime;
|
|
|
|
String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
|
2013-02-27 19:17:22 +01:00
|
|
|
logger.trace("grid getChildren() returning "+listItems.size()+" elements in " + time);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
listFileGridModels = builder.buildGXTListFileGridModelItem(listItems, folder);
|
|
|
|
|
|
|
|
return listFileGridModels;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server During items retrieving", e);
|
|
|
|
// workspaceLogger.trace("Error in server During items retrieving " + e);
|
2013-03-28 10:40:56 +01:00
|
|
|
e.printStackTrace();
|
2013-02-06 15:40:17 +01:00
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception("Error during item loading, please contact the support.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Boolean moveItem(String itemId, String destinationId) throws Exception {
|
2013-02-27 19:17:22 +01:00
|
|
|
workspaceLogger.trace("moveItem itemId: "+itemId+" destination: "+destinationId);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
2013-02-27 19:17:22 +01:00
|
|
|
logger.trace("moveItem item: "+itemId+" destination: "+destinationId);
|
|
|
|
|
|
|
|
WorkspaceItem sourceItem = workspace.getItem(itemId); //GET SOURCE ITEM BEFORE OF MOVE
|
|
|
|
|
|
|
|
if(sourceItem==null)
|
|
|
|
return Boolean.FALSE;
|
|
|
|
|
|
|
|
String sourceSharedId = null;
|
|
|
|
boolean sourceItemIsShared = sourceItem.isShared();
|
|
|
|
|
|
|
|
if(sourceItemIsShared)
|
|
|
|
sourceSharedId = sourceItem.getIdSharedFolder(); //GET SHARED ID BEFORE OF MOVE
|
|
|
|
|
|
|
|
|
2013-02-28 12:32:45 +01:00
|
|
|
//System.out.println("moveItem item: "+itemId+" sourceItem name "+sourceItem.getName() + " shared: "+sourceItemIsShared+ " destination: "+destinationId);
|
2013-02-27 19:17:22 +01:00
|
|
|
|
|
|
|
workspace.moveItem(itemId, destinationId); //move item
|
|
|
|
|
|
|
|
WorkspaceItem folderDestinationItem = workspace.getItem(destinationId); //retrieve folder destination
|
|
|
|
|
2013-02-28 12:32:45 +01:00
|
|
|
//System.out.println("sourceItem.isShared() "+sourceItemIsShared );
|
|
|
|
//System.out.println("folderDestinationItem item: "+destinationId+" folderDestinationItem name "+folderDestinationItem.getName() + " folderDestinationItem shared: "+folderDestinationItem.isShared());
|
2013-02-06 15:40:17 +01:00
|
|
|
|
2013-02-27 19:17:22 +01:00
|
|
|
if(folderDestinationItem!=null){
|
|
|
|
|
|
|
|
try{
|
2013-02-28 12:32:45 +01:00
|
|
|
checkNotifyAddItemToShare(sourceItem, sourceSharedId, folderDestinationItem);
|
|
|
|
|
|
|
|
checkNotifyRemoveItemToShare(sourceItemIsShared, sourceItem, sourceSharedId, folderDestinationItem);
|
2013-02-27 19:17:22 +01:00
|
|
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
workspaceLogger.error("An error occurred in checkNotify ", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
return Boolean.TRUE;
|
|
|
|
|
2013-02-20 14:51:36 +01:00
|
|
|
}catch (InsufficientPrivilegesException e) {
|
|
|
|
workspaceLogger.error("Error in server Item move", e);
|
|
|
|
String error = "An error occurred on moving item. "+e.getMessage();
|
|
|
|
throw new Exception(error);
|
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server Item move", e);
|
2013-02-20 14:51:36 +01:00
|
|
|
String error = ConstantsExplorer.SERVER_ERROR + " moving item. "+e.getMessage();
|
|
|
|
throw new Exception(error);
|
2013-02-06 15:40:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2013-02-27 19:17:22 +01:00
|
|
|
|
2013-02-28 12:32:45 +01:00
|
|
|
private void checkNotifyAddItemToShare(final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem) {
|
|
|
|
|
|
|
|
workspaceLogger.trace("checkNotifyAddItemToShare");
|
|
|
|
|
2013-02-27 19:17:22 +01:00
|
|
|
if(folderDestinationItem!=null){
|
|
|
|
|
2013-02-28 12:32:45 +01:00
|
|
|
try{
|
|
|
|
//if folder destination is shared folder
|
|
|
|
if(folderDestinationItem.isShared()){ //Notify Added Item To Sharing?
|
2013-02-27 19:17:22 +01:00
|
|
|
|
2013-02-28 12:32:45 +01:00
|
|
|
workspaceLogger.trace("checkNotifyAddItemToShare source item: "+sourceItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName());
|
2013-02-27 19:17:22 +01:00
|
|
|
|
2013-02-28 12:32:45 +01:00
|
|
|
//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);
|
2013-02-27 19:17:22 +01:00
|
|
|
|
2013-02-28 12:32:45 +01:00
|
|
|
//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);
|
2013-02-27 19:17:22 +01:00
|
|
|
}
|
|
|
|
}else
|
2013-02-28 12:32:45 +01:00
|
|
|
workspaceLogger.warn("The notifies is failure in verifyNotifyAddItemToShare because folder destination item is null");
|
2013-02-27 19:17:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-28 12:32:45 +01:00
|
|
|
private void checkNotifyRemoveItemToShare(final boolean sourceItemIsShared, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem) {
|
|
|
|
|
|
|
|
workspaceLogger.trace("checkNotifyRemoveItemToShare:");
|
|
|
|
|
|
|
|
try{
|
2013-02-27 19:17:22 +01:00
|
|
|
|
2013-02-28 12:32:45 +01:00
|
|
|
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");
|
2013-02-27 19:17:22 +01:00
|
|
|
|
2013-02-28 12:32:45 +01:00
|
|
|
}catch (Exception e) {
|
|
|
|
workspaceLogger.error("An error occurred in checkNotifyRemoveItemToShare ",e);
|
|
|
|
}
|
|
|
|
|
2013-02-27 19:17:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//DEBUG
|
|
|
|
private void printContacts(List<InfoContactModel> listContacts){
|
|
|
|
|
2013-02-28 12:32:45 +01:00
|
|
|
boolean testMode = isTestMode();
|
|
|
|
if(testMode)
|
|
|
|
System.out.println("Contacts: ");
|
|
|
|
else
|
|
|
|
workspaceLogger.trace("Contacts:");
|
|
|
|
|
2013-02-27 19:17:22 +01:00
|
|
|
for (InfoContactModel infoContactModel : listContacts) {
|
2013-02-28 12:32:45 +01:00
|
|
|
if(testMode)
|
|
|
|
System.out.println("User: "+infoContactModel);
|
|
|
|
else
|
|
|
|
workspaceLogger.trace("User: "+infoContactModel);
|
2013-02-27 19:17:22 +01:00
|
|
|
}
|
|
|
|
}
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public Boolean removeItem(String itemId) throws Exception {
|
2013-02-27 19:17:22 +01:00
|
|
|
workspaceLogger.trace("removeItem itemId: "+itemId);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
2013-02-27 19:17:22 +01:00
|
|
|
logger.trace("removeItem item: "+itemId);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
workspace.removeItem(itemId);
|
2013-03-25 11:14:26 +01:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
return Boolean.TRUE;
|
2013-02-20 14:51:36 +01:00
|
|
|
|
|
|
|
} catch (InsufficientPrivilegesException e) {
|
|
|
|
workspaceLogger.error("Error in server Item remove", e);
|
|
|
|
String error = "An error occurred on deleting item. "+e.getMessage();
|
|
|
|
throw new Exception(error);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server Item remove", e);
|
2013-02-20 14:51:36 +01:00
|
|
|
String error = ConstantsExplorer.SERVER_ERROR +" deleting item. "+e.getMessage();
|
|
|
|
throw new Exception(error);
|
2013-02-06 15:40:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-03-25 17:35:27 +01:00
|
|
|
public Boolean renameItem(String itemId, String newName, String previousName) throws Exception {
|
2013-02-06 15:40:17 +01:00
|
|
|
|
2013-02-27 19:17:22 +01:00
|
|
|
workspaceLogger.trace("renameItem itemId: "+itemId+" newName: "+newName);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
2013-03-25 17:35:27 +01:00
|
|
|
logger.trace("rename item itemId: "+itemId+" old name "+ previousName +", new name: "+newName);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
workspace.renameItem(itemId, newName);
|
2013-03-25 11:14:26 +01:00
|
|
|
|
|
|
|
//NOTIFIER
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(itemId);
|
|
|
|
|
|
|
|
if(wsItem.isShared()){
|
|
|
|
|
|
|
|
try{
|
|
|
|
List<InfoContactModel> listSharedContact = new ArrayList<InfoContactModel>();
|
|
|
|
NotificationsProducer notification = getNotificationProducer();
|
|
|
|
listSharedContact = getListUserSharedByFolderSharedId(wsItem.getIdSharedFolder());
|
|
|
|
if(Util.isASharedFolder(wsItem)){
|
2013-03-25 17:35:27 +01:00
|
|
|
notification.notifyFolderRenamed(listSharedContact, previousName, newName, wsItem.getIdSharedFolder());
|
2013-03-25 11:14:26 +01:00
|
|
|
}else{
|
|
|
|
WorkspaceFolder sharedFolder = (WorkspaceFolder) workspace.getItem(wsItem.getIdSharedFolder());
|
2013-03-25 17:35:27 +01:00
|
|
|
notification.notifyItemRenamed(listSharedContact, previousName, wsItem, sharedFolder);
|
2013-03-25 11:14:26 +01:00
|
|
|
}
|
|
|
|
}catch (Exception e) {
|
|
|
|
workspaceLogger.error("An error occurred in checkNotify ", e);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
return true;
|
|
|
|
|
2013-03-26 17:31:13 +01:00
|
|
|
} catch (ItemAlreadyExistException e) {
|
|
|
|
String error = "An error occurred on copying item, " +e.getMessage();
|
|
|
|
throw new Exception(error);
|
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
} catch (Exception e) {
|
2013-03-26 17:31:13 +01:00
|
|
|
workspaceLogger.error(ConstantsExplorer.SERVER_ERROR + " renaming item. "+ConstantsExplorer.TRY_AGAIN, e);
|
2013-02-06 15:40:17 +01:00
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FolderModel createFolder(String nameFolder, String description, FileModel parent) throws Exception {
|
|
|
|
|
2013-02-27 19:17:22 +01:00
|
|
|
workspaceLogger.trace("create folder");
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
2013-02-27 19:17:22 +01:00
|
|
|
logger.trace("create folder: " + nameFolder);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
WorkspaceFolder wsFolder = workspace.createFolder(nameFolder, description, parent.getIdentifier());
|
2013-02-27 19:17:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
WorkspaceItem folderDestinationItem = workspace.getItem(parent.getIdentifier());
|
|
|
|
|
|
|
|
checkNotifyAddItemToShare(wsFolder, null, folderDestinationItem);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
return builder.buildGXTFolderModelItem(wsFolder, parent);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server create folder", e);
|
|
|
|
// workspaceLogger.trace("Error in server create folder " + e);
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FileDetailsModel getDetailsFile(FileModel folder) throws Exception {
|
|
|
|
|
2013-02-27 19:17:22 +01:00
|
|
|
workspaceLogger.trace("load file details");
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
2013-02-27 19:17:22 +01:00
|
|
|
logger.trace("load file details: " + folder.getName());
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(folder.getIdentifier());
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
return builder.buildGWTWorkspaceFileDetails(wsItem, folder);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in load server file details", e);
|
|
|
|
// workspaceLogger.trace("Error in server load file details" + e);
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ArrayList<SubTree> getChildrenSubTreeToRootByIdentifier(String itemIdentifier) throws Exception {
|
|
|
|
|
|
|
|
ArrayList<SubTree> listSubTree = new ArrayList<SubTree>();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
2013-02-27 19:17:22 +01:00
|
|
|
logger.trace("search itemId: "+itemIdentifier);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
WorkspaceItem item = workspace.getItem(itemIdentifier); //get item from workspace
|
|
|
|
getListsChildrenByParents(listSubTree, item);
|
|
|
|
Collections.reverse(listSubTree); //reverse order of array
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server find Item", e);
|
|
|
|
// workspaceLogger.trace("Error in server find Item " + e);
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
return listSubTree;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<FileGridModel> getSmartFolderResultsByCategory(String category) throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
2013-02-27 19:17:22 +01:00
|
|
|
logger.trace("get smart folder by category: "+category);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
// listWorkspaceItems = workspace.getWorkspaceTree(workspace.getRoot()); //get item from workspace
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
// List<FileGridModel> listFileGridModel = new ArrayList<FileGridModel>();
|
|
|
|
// ArrayList<FolderItemType> listFolderItemType = builder.getListWorkspaceType(category);
|
|
|
|
|
|
|
|
List<SearchItem> listWorkspaceItems = new ArrayList<SearchItem>();
|
|
|
|
|
|
|
|
//Category IMAGES
|
|
|
|
if(category.equals(GXTCategoryItemInterface.SMF_IMAGES.toString())){
|
|
|
|
|
|
|
|
listWorkspaceItems = workspace.getFolderItems(FolderItemType.IMAGE_DOCUMENT, FolderItemType.EXTERNAL_IMAGE);
|
|
|
|
|
|
|
|
//Category BIODIVERSITY
|
|
|
|
}else if(category.equals(GXTCategoryItemInterface.SMF_BIODIVERSITY.toString())){
|
|
|
|
|
|
|
|
listWorkspaceItems = workspace.getFolderItems(FolderItemType.AQUAMAPS_ITEM);
|
|
|
|
|
|
|
|
//Category DOCUMENTS
|
|
|
|
}else if(category.equals(GXTCategoryItemInterface.SMF_DOCUMENTS.toString())){
|
|
|
|
|
|
|
|
listWorkspaceItems = workspace.getFolderItems(
|
|
|
|
FolderItemType.EXTERNAL_FILE,
|
|
|
|
FolderItemType.EXTERNAL_PDF_FILE,
|
|
|
|
FolderItemType.QUERY,
|
|
|
|
FolderItemType.PDF_DOCUMENT,
|
|
|
|
FolderItemType.METADATA,
|
|
|
|
FolderItemType.WORKFLOW_REPORT,
|
|
|
|
FolderItemType.WORKFLOW_TEMPLATE,
|
|
|
|
// FolderItemType.URL_DOCUMENT,
|
|
|
|
FolderItemType.DOCUMENT
|
|
|
|
);
|
|
|
|
|
|
|
|
//Category LINKS
|
|
|
|
}else if(category.equals(GXTCategoryItemInterface.SMF_LINKS.toString())){
|
|
|
|
|
|
|
|
listWorkspaceItems = workspace.getFolderItems(FolderItemType.EXTERNAL_URL, FolderItemType.URL_DOCUMENT, FolderItemType.EXTERNAL_RESOURCE_LINK);
|
|
|
|
|
|
|
|
//Category REPORTS
|
|
|
|
}else if(category.equals(GXTCategoryItemInterface.SMF_REPORTS.toString())){
|
|
|
|
|
|
|
|
listWorkspaceItems = workspace.getFolderItems(FolderItemType.REPORT_TEMPLATE, FolderItemType.REPORT);
|
|
|
|
|
|
|
|
//Category TIME SERIES
|
|
|
|
}else if(category.equals(GXTCategoryItemInterface.SMF_TIMESERIES.toString())){
|
|
|
|
|
|
|
|
listWorkspaceItems = workspace.getFolderItems(FolderItemType.TIME_SERIES);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
new Exception("Smart folder category unknown");
|
|
|
|
|
|
|
|
|
|
|
|
return builder.filterListFileGridModelItemByCategory(listWorkspaceItems, category);
|
|
|
|
|
|
|
|
// workspaceLogger.trace("listFileGridModel " + listFileGridModel.size());
|
|
|
|
// return builder.filterListByCategory(listFileGridModel, category);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server get smart folder by category", e);
|
|
|
|
// workspaceLogger.trace("Error in server get smart folder by category " + e);
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void getListsChildrenByParents(ArrayList<SubTree> listSubTree, WorkspaceItem item) throws Exception{
|
|
|
|
|
|
|
|
if(item==null || item.getParent()==null){
|
|
|
|
// listParents.add(item);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
FolderModel parentModel = new FolderModel(item.getParent().getId(), item.getParent().getName(), null, true, item.getParent().isShared()); //Create parent model
|
|
|
|
|
|
|
|
List<FileModel> childrenList = getFolderChildren(parentModel); //create children list
|
|
|
|
|
|
|
|
SubTree subTree = new SubTree(parentModel, childrenList);
|
|
|
|
|
|
|
|
listSubTree.add(subTree);
|
|
|
|
|
|
|
|
getListsChildrenByParents(listSubTree, item.getParent());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public SmartFolderModel createSmartFolder(String name, String description, String query) throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
2013-02-27 19:17:22 +01:00
|
|
|
logger.trace("create smart folder by name: "+name);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
workspaceLogger.trace("name " + name);
|
|
|
|
workspaceLogger.trace("query " + query);
|
|
|
|
|
|
|
|
/*WorkspaceFolder wsFolder = workspace.createSmartFolder(name, query); //create Smart Folder from workspace
|
|
|
|
|
|
|
|
workspaceLogger.trace("create : " +wsFolder.getName() + " id "+ wsFolder.getId());
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
return builder.buildGXTSmartFolderModel(wsFolder,query);*/
|
|
|
|
|
|
|
|
|
|
|
|
WorkspaceSmartFolder wsSmartFolder = workspace.createSmartFolder(name, description, query); //create Smart Folder from workspace
|
|
|
|
|
|
|
|
workspaceLogger.trace("create : " +wsSmartFolder.getName() + " id "+ wsSmartFolder.getId());
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
return builder.buildGXTSmartFolderModel(wsSmartFolder,query);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server create smart folder by name: ", e);
|
|
|
|
// workspaceLogger.trace("Error in server create smart folder by id " + e);
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Boolean removeSmartFolder(String itemId, String name) throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
2013-02-27 19:17:22 +01:00
|
|
|
logger.trace("remove smart folder by id: "+itemId);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
workspace.removeItem(itemId); //remove Smart Folder from workspace
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in remove smart folder by id: ", e);
|
|
|
|
// workspaceLogger.trace("Error in get smart folder by id " + e);
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<SmartFolderModel> getAllSmartFolders() throws Exception{
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
2013-02-27 19:17:22 +01:00
|
|
|
logger.trace("get all smart folder");
|
2013-02-06 15:40:17 +01:00
|
|
|
// workspaceLogger.trace("get all smart folder");
|
|
|
|
|
|
|
|
// List<WorkspaceFolder> listWorkspaceFolder = new ArrayList<WorkspaceFolder>();
|
|
|
|
// listWorkspaceFolder = workspace.getAllSmartFolders(); //create Smart Folder from workspace
|
|
|
|
|
|
|
|
List<WorkspaceSmartFolder> listWorkspaceFolder = new ArrayList<WorkspaceSmartFolder>();
|
|
|
|
|
|
|
|
listWorkspaceFolder = workspace.getAllSmartFolders(); //create Smart Folder from workspace
|
|
|
|
|
|
|
|
workspaceLogger.trace("listWorkspaceFolder size" + listWorkspaceFolder.size());
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
return builder.buildGXTListSmartFolderModel(listWorkspaceFolder);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server get all smart folder: ", e);
|
|
|
|
// workspaceLogger.trace("Error in server get all smart folder:" + e.getMessage());
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<FileGridModel> getSmartFolderResultsById(String folderId) throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
2013-02-27 19:17:22 +01:00
|
|
|
logger.trace("get smart folder by id: "+folderId);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
// WorkspaceFolder wsFolder = workspace.getSmartFolder(folderId); //get Smart Folder from workspace
|
|
|
|
|
|
|
|
WorkspaceSmartFolder wsSmartFolder = workspace.getSmartFolder(folderId); //get Smart Folder from workspace
|
|
|
|
|
|
|
|
workspaceLogger.trace("wsFolder " + wsSmartFolder.getName());
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
workspaceLogger.trace(" children size "+wsSmartFolder.getSearchItems().size());
|
|
|
|
|
|
|
|
return builder.buildGXTListFileGridModelItemForSearch((List<SearchItem>) wsSmartFolder.getSearchItems(), null);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in get server smart folder by id", e);
|
|
|
|
// workspaceLogger.trace("Error in server get smart folder by id " + e);
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public GWTWorkspaceItem getImageById(String identifier, boolean isInteralImage, boolean fullDetails) throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
2013-02-27 19:17:22 +01:00
|
|
|
logger.trace("get image by id: "+identifier);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
WorkspaceItem item = workspace.getItem(identifier); //get item from workspace
|
|
|
|
|
|
|
|
workspaceLogger.trace("item name " + item.getName());
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
return builder.buildGWTWorkspaceImage(item, isInteralImage, fullDetails);
|
|
|
|
|
|
|
|
// workspaceLogger.trace(" children "+wsFolder.getChildren().size());
|
|
|
|
// return builder.buildGWTWorkspaceItemsForGrid(wsFolder.getChildren(), null);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server get image by id", e);
|
|
|
|
// workspaceLogger.trace("Error in server get image by id " + e);
|
|
|
|
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public GWTWorkspaceItem getTimeSeriesById(String identifier) throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
2013-02-27 19:17:22 +01:00
|
|
|
logger.trace("get timeseries by id: "+identifier);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
WorkspaceItem item = workspace.getItem(identifier); //get item from workspace
|
|
|
|
|
|
|
|
workspaceLogger.trace("item name " + item.getName());
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
return builder.buildGWTTimeSeries((TimeSeries)item, null);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server get timeseries by id", e);
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public GWTWorkspaceItem getUrlById(String identifier, boolean isInternalUrl, boolean fullDetails) throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
2013-02-27 19:17:22 +01:00
|
|
|
logger.trace("get url by id: "+identifier);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
WorkspaceItem item = workspace.getItem(identifier); //get item from workspace
|
|
|
|
|
|
|
|
workspaceLogger.trace("item name " + item.getName());
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
// return builder.buildGXTImage(item, isInteralImage, fullDetails);
|
|
|
|
|
|
|
|
return builder.buildGWTWorspaceUrl(item, isInternalUrl, fullDetails);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server get image by id ", e);
|
|
|
|
// workspaceLogger.trace("Error in server get image by id " + e);
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FileModel createExternalUrl(FileModel parentFileModel, String name, String description, String url) throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
2013-02-27 19:17:22 +01:00
|
|
|
logger.trace("create url in parent id: "+parentFileModel.getIdentifier());
|
2013-02-06 15:40:17 +01:00
|
|
|
|
2013-02-13 18:39:33 +01:00
|
|
|
//DEBUG
|
2013-02-06 15:40:17 +01:00
|
|
|
// workspaceLogger.trace("Name " + name);
|
|
|
|
// workspaceLogger.trace("description " + description);
|
|
|
|
// workspaceLogger.trace("url " + url);
|
2013-02-13 18:39:33 +01:00
|
|
|
// workspaceLogger.trace("parentFileModel " + parentFileModel.getIdentifier() + " " + parentFileModel.getName());
|
2013-02-06 15:40:17 +01:00
|
|
|
// if(description == null)
|
|
|
|
// description = "";
|
|
|
|
|
|
|
|
ExternalUrl ext = workspace.createExternalUrl(name, description, url, parentFileModel.getIdentifier());
|
|
|
|
|
|
|
|
|
|
|
|
WorkspaceItem parent = workspace.getItem(parentFileModel.getIdentifier()); //get item from workspace
|
|
|
|
workspaceLogger.trace("parent name " + parent.getName());
|
|
|
|
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
return builder.buildGXTFileModelItem(ext, parentFileModel);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server create url in parent id ", e);
|
|
|
|
// workspaceLogger.trace("Error in server create url in parent id " + e);
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-14 15:06:34 +01:00
|
|
|
@Override
|
2013-02-20 14:28:25 +01:00
|
|
|
public String getURLFromApplicationProfile(String oid) throws Exception {
|
2013-02-15 12:51:01 +01:00
|
|
|
|
|
|
|
String urlPortlet = "";
|
2013-02-20 14:28:25 +01:00
|
|
|
|
|
|
|
ApplicationReaderFromGenericResource app = new ApplicationReaderFromGenericResource();
|
2013-02-14 15:06:34 +01:00
|
|
|
|
|
|
|
try{
|
2013-03-25 11:14:26 +01:00
|
|
|
|
|
|
|
ASLSession session = Util.getAslSession(this.getThreadLocalRequest().getSession());
|
2013-02-15 12:51:01 +01:00
|
|
|
|
2013-03-25 11:14:26 +01:00
|
|
|
if(Util.isVRE(session)){
|
|
|
|
|
|
|
|
// GET WORKSPACE
|
|
|
|
Workspace workspace = HomeLibrary.getUserWorkspace(session);
|
|
|
|
|
|
|
|
// GET ITEM FROM WORKSPACE
|
|
|
|
WorkspaceItem item = workspace.getItem(oid);
|
|
|
|
|
|
|
|
// ITEM IS A WorkspaceItemType.FOLDER_ITEM?
|
|
|
|
if (item.getType().equals(WorkspaceItemType.FOLDER_ITEM)) {
|
|
|
|
FolderItem folderItem = (FolderItem) item;
|
|
|
|
|
|
|
|
if(folderItem.getFolderItemType().equals(FolderItemType.REPORT)){
|
|
|
|
setValueInSession("idreport", oid);
|
|
|
|
|
|
|
|
}else if(folderItem.getFolderItemType().equals(FolderItemType.REPORT_TEMPLATE)){
|
|
|
|
setValueInSession("idtemplate", oid);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
urlPortlet = app.getURLFromApplicationProfile(oid, Util.getAslSession(this.getThreadLocalRequest().getSession()),this.getThreadLocalRequest().getSession());
|
2013-02-20 14:28:25 +01:00
|
|
|
|
2013-02-14 15:06:34 +01:00
|
|
|
} catch (Exception e) {
|
2013-02-15 12:51:01 +01:00
|
|
|
workspaceLogger.error("getURLFromApplicationProfile", e);
|
|
|
|
throw new Exception("Sorry, an error occurred in retrieve application profile, try again");
|
2013-02-14 15:06:34 +01:00
|
|
|
}
|
2013-02-15 12:51:01 +01:00
|
|
|
|
|
|
|
return urlPortlet;
|
2013-02-14 15:06:34 +01:00
|
|
|
}
|
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
@Override
|
|
|
|
public void setValueInSession(String name, String value) throws Exception {
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
ASLSession session = Util.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());
|
|
|
|
// System.out.println("set value in session with name: "+name+", value: "+value);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("setValueInSession", e);
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<ScopeModel> getAllScope() throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
2013-02-15 12:51:01 +01:00
|
|
|
logger.trace("get all scope");
|
2013-03-27 17:30:37 +01:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
2013-03-27 17:30:37 +01:00
|
|
|
|
|
|
|
ScopeUtilFilter scopeUtilFilter = getScopeUtilFilter();
|
|
|
|
|
|
|
|
Home home = workspace.getHome();
|
|
|
|
if(home!=null){
|
|
|
|
List<String> listIdFilterdScope = scopeUtilFilter.convertListScopeToPortlet(home.listScopes());
|
|
|
|
return builder.buildGXTListScopeModel(listIdFilterdScope, scopeUtilFilter.getHashScopesFiltered());
|
|
|
|
}else{
|
|
|
|
workspaceLogger.error("workspace.getHome() is null");
|
|
|
|
throw new Exception("Sorry, an error occurred on getting all scope. Please try later");
|
|
|
|
}
|
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server get all scope ", e);
|
|
|
|
e.printStackTrace();
|
|
|
|
// workspaceLogger.trace("Error in server get all scope " + e.getMessage());
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<InfoContactModel> getAllContacts() throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
2013-03-11 19:06:56 +01:00
|
|
|
workspaceLogger.trace("get all contacts");
|
2013-02-14 15:06:34 +01:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
// WorkspaceItem parent = workspace.getItem(parentFileModel.getIdentifier()); //get item from workspace
|
|
|
|
// workspace.getAllScope();
|
2013-02-14 15:06:34 +01:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
2013-02-14 15:06:34 +01:00
|
|
|
if(isTestMode()){
|
|
|
|
|
2013-03-11 19:06:56 +01:00
|
|
|
workspaceLogger.warn("WORKSPACE PORTLET IS IN TEST MODE - RETURN TEST USERS");
|
2013-02-14 15:06:34 +01:00
|
|
|
List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>();
|
|
|
|
// //TEST USERS
|
2013-02-27 19:17:22 +01:00
|
|
|
listContactsModel.add(new InfoContactModel("federico.defaveri", "federico.defaveri", "Federico de Faveri"));
|
|
|
|
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"));
|
2013-03-11 19:06:56 +01:00
|
|
|
listContactsModel.add(new InfoContactModel(Util.TEST_USER, Util.TEST_USER, Util.TEST_USER_FULL_NAME));
|
2013-02-27 19:17:22 +01:00
|
|
|
listContactsModel.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa"));
|
2013-02-14 15:06:34 +01:00
|
|
|
listContactsModel.add(new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante"));
|
|
|
|
return listContactsModel;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
return builder.buildGXTListContactsModel(workspace.getHome().getHomeManager().getUsers()); //TODO passare list items
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server get all contacts ", e);
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
// public boolean sendTo(List<InfoContactModel> listContacts, List<FileModel> listAttachments, String subject, String text) throws Exception {
|
|
|
|
//
|
|
|
|
// try {
|
|
|
|
//
|
|
|
|
// Workspace workspace = getWorkspace();
|
|
|
|
//
|
|
|
|
// GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
|
|
|
// logger.info("sendTo");
|
|
|
|
//
|
|
|
|
//// WorkspaceItem parent = workspace.getItem(parentFileModel.getIdentifier()); //get item from workspace
|
|
|
|
//// workspace.getAllScope();
|
|
|
|
//
|
|
|
|
// workspaceLogger.trace("######### SEND TO: ");
|
|
|
|
// workspaceLogger.trace("subject " + subject);
|
|
|
|
// workspaceLogger.trace("text " + text);
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
//
|
|
|
|
// return true;
|
|
|
|
//
|
|
|
|
// } catch (Exception e) {
|
|
|
|
// workspaceLogger.error("Error in server sendTo ", e);
|
|
|
|
// workspaceLogger.trace("Error in server get sendTo " + e.getMessage());
|
|
|
|
// //GWT can't serialize all exceptions
|
|
|
|
// throw new Exception(e.getMessage());
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean sendToById(List<String> listContactsId, List<String> listAttachmentsId, String subject, String body) throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
|
|
|
logger.info("send To");
|
|
|
|
|
|
|
|
// WorkspaceItem parent = workspace.getItem(parentFileModel.getIdentifier()); //get item from workspace
|
|
|
|
// workspace.getAllScope();
|
|
|
|
//
|
|
|
|
workspaceLogger.trace("######### SEND TO: ");
|
|
|
|
workspaceLogger.trace("subject " + subject);
|
|
|
|
workspaceLogger.trace("body " + body);
|
|
|
|
|
|
|
|
for(String contactId : listContactsId)
|
|
|
|
workspaceLogger.trace("contactId " + contactId);
|
|
|
|
|
|
|
|
|
|
|
|
for(String id : listAttachmentsId)
|
|
|
|
workspaceLogger.trace("attachId " + id);
|
|
|
|
|
|
|
|
workspace.getWorkspaceMessageManager().sendMessageToPortalLogins(subject, body, listAttachmentsId, listContactsId);
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server sendTo ", e);
|
|
|
|
// workspaceLogger.trace("Error in server get sendTo " + e.getMessage());
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<MessageModel> getAllMessagesSent() throws Exception {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
|
|
|
logger.info("getAllMessagesSent");
|
|
|
|
workspaceLogger.trace("get All Messages Sent ");
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
List<WorkspaceMessage> listMessages = workspace.getWorkspaceMessageManager().getSentMessages();
|
|
|
|
|
|
|
|
return builder.buildGXTListMessageModelForGrid(listMessages, GXTCategoryItemInterface.MS_SENT);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server getAllMessagesSent ", e);
|
|
|
|
// workspaceLogger.trace("Error in server get getAllMessagesSent " + e.getMessage());
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<MessageModel> getAllMessagesReceived() throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
|
|
|
logger.info("getAllMessagesReceived");
|
|
|
|
workspaceLogger.trace("get All Messages Received ");
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
List<WorkspaceMessage> listMessages = workspace.getWorkspaceMessageManager().getReceivedMessages();
|
|
|
|
|
|
|
|
return builder.buildGXTListMessageModelForGrid(listMessages, GXTCategoryItemInterface.MS_RECEIVED);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server getAllMessagesReceived ", e);
|
|
|
|
// workspaceLogger.trace("Error in server get getAllMessagesReceived " + e.getMessage());
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public MessageModel getMessageById(String messageIdentifier, String messageType) throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
|
|
|
logger.info("get Message by Id");
|
|
|
|
|
|
|
|
// WorkspaceItem parent = workspace.getItem(parentFileModel.getIdentifier()); //get item from workspace
|
|
|
|
// workspace.getAllScope();
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
// return builder.buildGXTListMessageModel();
|
|
|
|
|
|
|
|
WorkspaceMessage message = null;
|
|
|
|
if(messageType.equals(GXTCategoryItemInterface.MS_RECEIVED))
|
|
|
|
message = workspace.getWorkspaceMessageManager().getReceivedMessage(messageIdentifier);
|
|
|
|
else
|
|
|
|
message = workspace.getWorkspaceMessageManager().getSentMessage(messageIdentifier);
|
|
|
|
|
|
|
|
|
|
|
|
List<WorkspaceItem> listWorkspaceItems = getListWorkspaceItemById(workspace,message.getAttachmentsIds());
|
|
|
|
|
|
|
|
return builder.buildGXTMessageModel(message, listWorkspaceItems, messageType);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server get Message by Id ", e);
|
|
|
|
// workspaceLogger.trace("Error in server get Message by Id " + e.getMessage());
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<WorkspaceItem> getListWorkspaceItemById(Workspace workspace, List<String> listItemsId) throws ItemNotFoundException, InternalErrorException{
|
|
|
|
|
|
|
|
List<WorkspaceItem> listWorkspaceItem = new ArrayList<WorkspaceItem>();
|
|
|
|
|
|
|
|
for(String itemId: listItemsId){
|
|
|
|
|
|
|
|
WorkspaceItem item = workspace.getItem(itemId);
|
|
|
|
|
|
|
|
workspaceLogger.trace("Attach name: " +item.getName());
|
|
|
|
workspaceLogger.trace("Attach id: " +item.getId());
|
|
|
|
|
|
|
|
listWorkspaceItem.add(workspace.getItem(itemId)); //get item from workspace
|
|
|
|
}
|
|
|
|
|
|
|
|
return listWorkspaceItem;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<BulkCreatorModel> getListFolderBulkCreator() throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
2013-02-15 12:51:01 +01:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
List<FolderBulkCreator> listFBC = workspace.getFolderBulkCreatorManager().getActiveFolderBulkCreators();
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
return builder.buildGXTListBulkCreatorModel(listFBC);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in getNewFolderBulkCreator ", e);
|
|
|
|
// workspaceLogger.trace("Error in getNewFolderBulkCreator " + e.getMessage());
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean sentToByMessageModel(MessageModel message) throws Exception {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean saveAttachments(String messageIdentifier, String messageType) throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
|
|
|
logger.info("save attachments by messageIdentifier");
|
|
|
|
|
|
|
|
workspaceLogger.trace(" save attachments by messageIdentifier " + messageIdentifier);
|
|
|
|
if(messageType.equals(GXTCategoryItemInterface.MS_SENT))
|
|
|
|
workspace.getWorkspaceMessageManager().getSentMessage(messageIdentifier).saveAttachments(workspace.getRoot().getId());
|
|
|
|
else
|
|
|
|
workspace.getWorkspaceMessageManager().getReceivedMessage(messageIdentifier).saveAttachments(workspace.getRoot().getId());
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server save attachments by messageIdentifier ", e);
|
|
|
|
// workspaceLogger.trace("Error in server save attachments by messageIdentifier " + e.getMessage());
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean saveAttach(String attachId) throws Exception {
|
|
|
|
// TODO NOT USED
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean markMessage(String messageIdentifier, String messageType, boolean boolMark, String markType) throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
|
|
|
// logger.info("markMessageAsRead");
|
|
|
|
|
|
|
|
workspaceLogger.trace(" markMessageAsRead by messageIdentifier " + messageIdentifier + " boolMark " + boolMark + " messageType " +messageType);
|
|
|
|
|
|
|
|
if(messageType.equals(GXTCategoryItemInterface.MS_RECEIVED)){
|
|
|
|
|
|
|
|
// workspaceLogger.trace("#######################################Message identifier: "+messageIdentifier);
|
|
|
|
// workspaceLogger.trace("#######################################Message messageType: "+messageType);
|
|
|
|
|
|
|
|
if(markType.equals("READ")){
|
|
|
|
workspace.getWorkspaceMessageManager().getReceivedMessage(messageIdentifier).setStatus(boolMark);
|
|
|
|
}else if(markType.equals("OPEN")){
|
|
|
|
workspace.getWorkspaceMessageManager().getReceivedMessage(messageIdentifier).open();
|
|
|
|
}else if(markType.equals("BOTH")){
|
|
|
|
workspace.getWorkspaceMessageManager().getReceivedMessage(messageIdentifier).setStatus(boolMark);
|
|
|
|
workspace.getWorkspaceMessageManager().getReceivedMessage(messageIdentifier).open();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
// workspaceLogger.trace("#######################################Message sent identifier: "+messageIdentifier);
|
|
|
|
// workspaceLogger.trace("#######################################Message sent messageType: "+messageType);
|
|
|
|
|
|
|
|
if(markType.equals("READ")){
|
|
|
|
workspace.getWorkspaceMessageManager().getSentMessage(messageIdentifier).setStatus(boolMark);
|
|
|
|
}else if(markType.equals("OPEN")){
|
|
|
|
workspace.getWorkspaceMessageManager().getSentMessage(messageIdentifier).open();
|
|
|
|
}else if(markType.equals("BOTH")){
|
|
|
|
workspace.getWorkspaceMessageManager().getSentMessage(messageIdentifier).setStatus(boolMark);
|
|
|
|
workspace.getWorkspaceMessageManager().getSentMessage(messageIdentifier).open();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server markMessageAsRead by messageIdentifier ", e);
|
|
|
|
// workspaceLogger.trace("Error in server markMessageAsRead by messageIdentifier " + e.getMessage());
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean deleteMessage(String messageIdentifier, String messageType) throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
|
|
|
// logger.info("deleteMessage by messageIdentifier");
|
|
|
|
|
|
|
|
workspaceLogger.trace("deleteMessage by messageIdentifier " + messageIdentifier);
|
|
|
|
|
|
|
|
if(messageType.equals(GXTCategoryItemInterface.MS_RECEIVED))
|
|
|
|
workspace.getWorkspaceMessageManager().deleteReceivedMessage(messageIdentifier);
|
|
|
|
else
|
|
|
|
workspace.getWorkspaceMessageManager().deleteSentMessage(messageIdentifier);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server deleteMessage by messageIdentifier ", e);
|
|
|
|
// workspaceLogger.trace("Error in server deleteMessage by messageIdentifier " + e.getMessage());
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<MessageModel> getNewMessagesReceived() throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
|
|
|
|
|
|
|
// workspaceLogger.trace("in server getNewMessagesReceived ");
|
|
|
|
|
|
|
|
int count = workspace.getWorkspaceMessageManager().getMessagesNotOpened();
|
|
|
|
|
|
|
|
List<MessageModel> listMessageModels = new ArrayList<MessageModel>();
|
|
|
|
|
|
|
|
for(int i=0; i<count; i++)
|
|
|
|
listMessageModels.add(new MessageModel());
|
|
|
|
|
|
|
|
return listMessageModels;
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server getNewMessagesReceived by messageIdentifier ", e);
|
|
|
|
// workspaceLogger.trace("Error in server getNewMessagesReceived by messageIdentifier " + e.getMessage());
|
|
|
|
//GWT can't serialize all exceptions
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<MessageModel> searchInSentMessagesByText(String text) throws Exception {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
|
|
|
logger.info("searchInSentMessagesByText");
|
|
|
|
// workspaceLogger.trace("searchInSentMessagesByText ");
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
List<WorkspaceMessage> listMessages = workspace.getWorkspaceMessageManager().searchOutMessages(text);
|
|
|
|
|
|
|
|
return builder.buildGXTListMessageModelForGrid(listMessages, GXTCategoryItemInterface.MS_SENT);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server searchInSentMessagesByText ", e);
|
|
|
|
// workspaceLogger.trace("Error in server searchInSentMessagesByText " + e.getMessage());
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<MessageModel> searchInReceivedMessagesByText(String text) throws Exception {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
|
|
|
logger.info("searchInSentMessagesByText");
|
|
|
|
// workspaceLogger.trace("searchInSentMessagesByText ");
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
List<WorkspaceMessage> listMessages = workspace.getWorkspaceMessageManager().searchInMessages(text);
|
|
|
|
|
|
|
|
return builder.buildGXTListMessageModelForGrid(listMessages, GXTCategoryItemInterface.MS_RECEIVED);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server searchInSentMessagesByText ", e);
|
|
|
|
// workspaceLogger.trace("Error in server searchInSentMessagesByText " + e.getMessage());
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean copyItem(String itemId, String destinationFolderId) throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
2013-02-27 19:17:22 +01:00
|
|
|
|
|
|
|
WorkspaceItem sourceItem = workspace.getItem(itemId); //GET SOURCE ITEM BEFORE COPY
|
|
|
|
String sourceSharedId = sourceItem.getIdSharedFolder();
|
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
|
|
|
logger.info("copyItem by id: " + itemId);
|
|
|
|
|
2013-02-27 19:17:22 +01:00
|
|
|
WorkspaceItem item = workspace.copy(itemId, destinationFolderId); //copy item
|
|
|
|
|
|
|
|
WorkspaceItem folderDestinationItem = workspace.getItem(destinationFolderId);
|
|
|
|
|
|
|
|
checkNotifyAddItemToShare(sourceItem, sourceSharedId, folderDestinationItem);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
if(item!=null)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
2013-02-20 14:51:36 +01:00
|
|
|
}catch (InsufficientPrivilegesException e) {
|
2013-03-26 17:31:13 +01:00
|
|
|
String error = "An error occurred on copying item, " +e.getMessage() + ". "+ConstantsExplorer.TRY_AGAIN;
|
2013-02-20 14:51:36 +01:00
|
|
|
throw new Exception(error);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
2013-03-26 17:31:13 +01:00
|
|
|
}catch (ItemAlreadyExistException e) {
|
|
|
|
String error = "An error occurred on copying item, " +e.getMessage();
|
|
|
|
throw new Exception(error);
|
2013-02-06 15:40:17 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in server copyItem by id", e);
|
2013-02-20 14:51:36 +01:00
|
|
|
String error = ConstantsExplorer.SERVER_ERROR +" copying item " + ConstantsExplorer.TRY_AGAIN;
|
|
|
|
throw new Exception(error);
|
2013-02-06 15:40:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean deleteBulk(String bulkId) throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
|
|
|
logger.info("delete bulk " + bulkId);
|
|
|
|
|
|
|
|
// workspaceLogger.trace("delete bulk " + bulkId);
|
|
|
|
|
|
|
|
workspace.getFolderBulkCreatorManager().getActiveFolderBulkCreator(bulkId).remove();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in getNewFolderBulkCreator ", e);
|
|
|
|
// workspaceLogger.trace("Error in getNewFolderBulkCreator " + e.getMessage());
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getUrlWebDav(String itemId) throws Exception {
|
|
|
|
|
|
|
|
try {
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
GCUBEClientLog logger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
|
|
|
|
logger.info("getWebDavUrl " + itemId);
|
|
|
|
|
|
|
|
workspaceLogger.trace("getWebDavUrl" + itemId);
|
|
|
|
|
|
|
|
return workspace.getUrlWebDav();
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in getNewFolderBulkCreator ", e);
|
|
|
|
// workspaceLogger.trace("Error in getNewFolderBulkCreator " + e.getMessage());
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-02-12 16:02:00 +01:00
|
|
|
public boolean shareFolder(FileModel folder, List<InfoContactModel> listContacts, boolean isNewFolder) throws Exception {
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
try {
|
2013-02-12 17:17:15 +01:00
|
|
|
|
2013-02-12 16:02:00 +01:00
|
|
|
Workspace workspace = getWorkspace();
|
2013-02-06 15:40:17 +01:00
|
|
|
|
2013-02-12 17:17:15 +01:00
|
|
|
workspaceLogger.trace("shareFolder "+ folder.getIdentifier()
|
|
|
|
+ " name: "+ folder.getName()
|
|
|
|
+ " parent name: " + folder.getParentFileModel().getName()
|
|
|
|
+ " listContacts size: " + listContacts.size());
|
2013-02-12 16:02:00 +01:00
|
|
|
|
|
|
|
// //DEBUG
|
2013-02-28 12:32:45 +01:00
|
|
|
//System.out.println("shareFolder "+ folder.getIdentifier() + " name: "+ folder.getName() + " parent name: " + folder.getParentFileModel().getName() + " listContacts size: " + listContacts.size());
|
2013-02-12 17:17:15 +01:00
|
|
|
|
2013-02-28 12:32:45 +01:00
|
|
|
// for (InfoContactModel infoContactModel : listContacts) {
|
|
|
|
// System.out.println("share with "+ infoContactModel.getLogin());
|
|
|
|
// }
|
|
|
|
|
|
|
|
printContacts(listContacts);
|
2013-03-25 17:35:27 +01:00
|
|
|
|
|
|
|
List<String> listLogin = UserUtil.getListLoginByInfoContactModel(listContacts);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
WorkspaceSharedFolder sharedFolder = null;
|
2013-02-12 17:17:15 +01:00
|
|
|
|
2013-02-27 19:17:22 +01:00
|
|
|
List<InfoContactModel> listSharedContact = null;
|
|
|
|
|
|
|
|
boolean sourceFolderIsShared = folder.isShared();
|
|
|
|
|
|
|
|
if(sourceFolderIsShared){ //if source folder is already share... retrieve old list of sharing to notify
|
|
|
|
listSharedContact = getListUserSharedByFolderSharedId(folder.getIdentifier());
|
|
|
|
}
|
|
|
|
|
2013-02-12 17:17:15 +01:00
|
|
|
if(listLogin.size()>0){
|
|
|
|
|
2013-05-29 14:09:11 +02:00
|
|
|
if(!isNewFolder){
|
2013-02-12 17:17:15 +01:00
|
|
|
sharedFolder = workspace.shareFolder(listLogin, folder.getIdentifier());
|
2013-05-29 14:09:11 +02:00
|
|
|
sharedFolder.setDescription(folder.getDescription()); //SET NEW DESCRIPTION
|
|
|
|
}
|
2013-02-12 17:17:15 +01:00
|
|
|
else
|
2013-02-25 19:03:53 +01:00
|
|
|
sharedFolder = workspace.createSharedFolder(folder.getName(), folder.getDescription(), listLogin, folder.getParentFileModel().getIdentifier());
|
2013-02-12 17:17:15 +01:00
|
|
|
}
|
2013-02-12 16:02:00 +01:00
|
|
|
|
|
|
|
boolean created = sharedFolder==null?false:true;
|
2013-02-13 18:39:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
if(created){
|
|
|
|
NotificationsProducer np = getNotificationProducer();
|
2013-02-27 19:17:22 +01:00
|
|
|
if(!sourceFolderIsShared) //if source folder is not already shared
|
|
|
|
np.notifyFolderSharing(listContacts, sharedFolder);
|
2013-03-25 17:35:27 +01:00
|
|
|
else{
|
|
|
|
System.out.println("SHARED CONTACS: ");
|
|
|
|
printContacts(listSharedContact);
|
|
|
|
System.out.println("NEW CONTACS: ");
|
|
|
|
printContacts(listContacts);
|
|
|
|
np.notifyAddedUsersToSharing(listSharedContact, listContacts, sharedFolder);
|
|
|
|
}
|
2013-02-13 18:39:33 +01:00
|
|
|
}
|
|
|
|
|
2013-02-12 16:02:00 +01:00
|
|
|
return created;
|
2013-02-06 15:40:17 +01:00
|
|
|
|
2013-02-20 14:51:36 +01:00
|
|
|
} catch (InsufficientPrivilegesException e) {
|
|
|
|
workspaceLogger.error("Error in shareFolder ", e);
|
|
|
|
String error = "An error occurred on creating shared folder. "+ e.getMessage();
|
|
|
|
throw new Exception(error);
|
|
|
|
|
|
|
|
} catch (ItemAlreadyExistException e) {
|
|
|
|
workspaceLogger.error("Error in shareFolder ", e);
|
|
|
|
String error = "An error occurred on creating shared folder. "+ e.getMessage();
|
|
|
|
throw new Exception(error);
|
|
|
|
|
|
|
|
} catch (WrongDestinationException e) {
|
|
|
|
workspaceLogger.error("Error in shareFolder ", e);
|
|
|
|
String error = "An error occurred on creating shared folder. "+ e.getMessage();
|
|
|
|
throw new Exception(error);
|
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in shareFolder ", e);
|
2013-02-12 16:02:00 +01:00
|
|
|
e.printStackTrace();
|
2013-02-27 19:17:22 +01:00
|
|
|
String error = ConstantsExplorer.SERVER_ERROR+" creating shared folder.";
|
2013-02-20 14:51:36 +01:00
|
|
|
throw new Exception(error);
|
2013-02-06 15:40:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<InfoContactModel> getListUserSharedByFolderSharedId(String folderSharedId) throws Exception{
|
|
|
|
|
|
|
|
workspaceLogger.trace("getListUserSharedByFolderSharedId "+ folderSharedId);
|
2013-03-11 19:06:56 +01:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
try {
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(folderSharedId);
|
|
|
|
|
2013-03-25 11:14:26 +01:00
|
|
|
if(Util.isASharedFolder(wsItem)){
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) wsItem;
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
2013-03-11 16:37:10 +01:00
|
|
|
List<String> listPortalLogin = wsFolder.getUsers();
|
2013-03-11 19:06:56 +01:00
|
|
|
|
2013-03-11 16:37:10 +01:00
|
|
|
workspaceLogger.trace("getListUserSharedByFolderSharedId return "+ listPortalLogin.size() + " user");
|
2013-03-11 19:06:56 +01:00
|
|
|
|
|
|
|
if(isTestMode())
|
|
|
|
return builder.buildGxtInfoContactFromPortalLoginTestMode(listPortalLogin);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
2013-05-23 19:03:43 +02:00
|
|
|
return builder.buildGxtInfoContactsFromPortalLogins(listPortalLogin);
|
2013-02-06 15:40:17 +01:00
|
|
|
|
|
|
|
}
|
2013-02-13 18:39:33 +01:00
|
|
|
else{
|
|
|
|
workspaceLogger.trace("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER);
|
2013-02-27 19:17:22 +01:00
|
|
|
|
|
|
|
//DEBUG
|
2013-02-28 12:32:45 +01:00
|
|
|
//System.out.println("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER);
|
2013-02-13 18:39:33 +01:00
|
|
|
}
|
2013-02-06 15:40:17 +01:00
|
|
|
return new ArrayList<InfoContactModel>();
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in getListUserSharedByItemId ", e);
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-25 11:14:26 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<InfoContactModel> getListUserSharedBySharedItem(String sharedItemId) throws Exception{
|
|
|
|
|
|
|
|
workspaceLogger.trace("getListUserSharedBySharedItem "+ sharedItemId);
|
|
|
|
|
|
|
|
try {
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(sharedItemId);
|
|
|
|
|
|
|
|
if(wsItem!=null && wsItem.isShared()){
|
|
|
|
|
|
|
|
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) workspace.getItem(wsItem.getIdSharedFolder());
|
|
|
|
|
|
|
|
if(wsFolder!=null){
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
List<String> listPortalLogin = wsFolder.getUsers();
|
|
|
|
|
|
|
|
workspaceLogger.trace("getListUserSharedByFolderSharedId return "+ listPortalLogin.size() + " user");
|
|
|
|
|
|
|
|
if(isTestMode())
|
|
|
|
return builder.buildGxtInfoContactFromPortalLoginTestMode(listPortalLogin);
|
|
|
|
|
|
|
|
|
2013-05-23 19:03:43 +02:00
|
|
|
return builder.buildGxtInfoContactsFromPortalLogins(listPortalLogin);
|
2013-03-25 11:14:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return new ArrayList<InfoContactModel>();
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in getListUserSharedByItemId ", e);
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
@Override
|
|
|
|
public boolean unSharedFolderByFolderSharedId(String folderSharedId) throws Exception{
|
|
|
|
|
|
|
|
boolean unShared = false;
|
|
|
|
|
|
|
|
workspaceLogger.trace("unSharedFolderByFolderSharedId "+ folderSharedId);
|
|
|
|
try {
|
2013-05-29 14:09:11 +02:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(folderSharedId);
|
|
|
|
|
2013-03-27 17:30:37 +01:00
|
|
|
workspaceLogger.trace("workspace return an item with name "+wsItem.getName());
|
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
if(wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
|
|
|
|
|
|
|
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) wsItem;
|
|
|
|
|
|
|
|
WorkspaceFolder unSharedFolder = wsFolder.unShare();
|
|
|
|
|
|
|
|
unShared = unSharedFolder==null?false:true;
|
2013-02-13 18:39:33 +01:00
|
|
|
|
2013-02-28 12:32:45 +01:00
|
|
|
// System.out.println("unShared is "+unShared);
|
|
|
|
|
|
|
|
workspaceLogger.trace("unShared is "+ unShared);
|
2013-02-13 18:39:33 +01:00
|
|
|
|
2013-05-29 14:09:11 +02:00
|
|
|
|
|
|
|
/* INTERNAL POLICY, UN SHARE NOT SHOULD PRODUCE NOTIFICATIONS
|
2013-02-13 18:39:33 +01:00
|
|
|
if(unShared){
|
|
|
|
NotificationsProducer np = getNotificationProducer();
|
2013-05-29 14:09:11 +02:00
|
|
|
|
2013-02-13 18:39:33 +01:00
|
|
|
List<InfoContactModel> contacts = getListUserSharedByFolderSharedId(folderSharedId);
|
2013-02-27 19:17:22 +01:00
|
|
|
|
|
|
|
// if(isTestMode()){
|
|
|
|
// contacts = new ArrayList<InfoContactModel>();
|
|
|
|
// contacts.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa"));
|
|
|
|
// }
|
2013-03-25 11:14:26 +01:00
|
|
|
workspaceLogger.trace("UNSHARE WITH: ");
|
2013-02-27 19:17:22 +01:00
|
|
|
printContacts(contacts);
|
2013-02-13 18:39:33 +01:00
|
|
|
|
2013-02-27 19:17:22 +01:00
|
|
|
np.notifyFolderUnSharing(contacts, unSharedFolder);
|
2013-02-13 18:39:33 +01:00
|
|
|
}
|
2013-05-29 14:09:11 +02:00
|
|
|
|
|
|
|
*/
|
2013-02-13 18:39:33 +01:00
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
workspaceLogger.trace("the item with id: "+folderSharedId+ "is not "+WorkspaceItemType.SHARED_FOLDER);
|
|
|
|
|
2013-05-29 14:09:11 +02:00
|
|
|
} catch (InternalErrorException e) {
|
2013-02-20 14:51:36 +01:00
|
|
|
workspaceLogger.error("Error in unSharedFolderByFolderSharedId ", e);
|
|
|
|
String error = "An error occerred on unsharing folder. "+ e.getMessage();
|
|
|
|
throw new Exception(error);
|
|
|
|
|
2013-02-06 15:40:17 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in unSharedFolderByFolderSharedId ", e);
|
2013-02-27 19:17:22 +01:00
|
|
|
String error = ConstantsExplorer.SERVER_ERROR+" un share folder. Refresh folder and " +ConstantsExplorer.TRY_AGAIN;
|
2013-02-13 18:39:33 +01:00
|
|
|
e.printStackTrace();
|
2013-02-20 14:51:36 +01:00
|
|
|
throw new Exception(error);
|
2013-02-06 15:40:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return unShared;
|
|
|
|
}
|
2013-02-13 18:39:33 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<FileModel> getListParentsByItemIdentifier(String itemIdentifier) throws Exception {
|
|
|
|
List<FileModel> listParents = new ArrayList<FileModel>();
|
|
|
|
workspaceLogger.trace("get List Parents By Item Identifier "+ itemIdentifier);
|
|
|
|
try {
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(itemIdentifier);
|
|
|
|
|
2013-03-26 17:31:13 +01:00
|
|
|
workspaceLogger.trace("workspace retrieve item name: "+wsItem.getName());
|
|
|
|
|
2013-02-13 18:39:33 +01:00
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
while(wsItem!=null && wsItem.getParent()!=null){
|
|
|
|
|
|
|
|
WorkspaceFolder wsFolder = wsItem.getParent();
|
|
|
|
listParents.add(builder.buildGXTFolderModelItem(wsFolder, null));
|
|
|
|
wsItem = wsFolder;
|
|
|
|
}
|
|
|
|
|
|
|
|
Collections.reverse(listParents);
|
|
|
|
|
|
|
|
//SET PARENTS
|
|
|
|
for(int i=0; i<listParents.size()-1; i++){
|
|
|
|
|
|
|
|
FileModel parent = listParents.get(i);
|
|
|
|
FileModel fileModel = listParents.get(i+1);
|
|
|
|
|
|
|
|
fileModel.setParentFileModel(parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
workspaceLogger.trace("list parents return size: "+listParents.size());
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
2013-03-27 17:30:37 +01:00
|
|
|
workspaceLogger.error("Error in get List Parents By Item Identifier ", e);
|
2013-02-13 18:39:33 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
return listParents;
|
|
|
|
}
|
2013-02-25 19:03:53 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public InfoContactModel getOwnerByItemId(String itemId) throws Exception {
|
|
|
|
|
|
|
|
workspaceLogger.trace("get Owner By ItemId "+ itemId);
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(itemId);
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
return builder.buildGXTInfoContactModel(wsItem.getOwner());
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in getOwnerByItemId ", e);
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
2013-03-25 11:14:26 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String itemExistsInWorkpaceFolder(String parentId, String itemName) throws Exception {
|
|
|
|
|
|
|
|
workspaceLogger.trace("get itemExistsInWorkpace by parentId: "+parentId);
|
|
|
|
System.out.println("get itemExistsInWorkpace by parentId: "+parentId);
|
|
|
|
|
|
|
|
try {
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(parentId); //GET PARENT
|
|
|
|
|
|
|
|
if(wsItem.getType().equals(WorkspaceItemType.FOLDER) || wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
|
|
|
|
|
|
|
WorkspaceItem itemFound = workspace.find(itemName, parentId);
|
|
|
|
|
|
|
|
if(itemFound==null)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
return itemFound.getId();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
throw new Exception("Invalid Folder parent");
|
|
|
|
|
|
|
|
|
|
|
|
} catch (InternalErrorException e) {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
} catch (ItemNotFoundException e) {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
String error = "an error occurred on search item in folder ";
|
|
|
|
workspaceLogger.error(error, e);
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
2013-03-25 12:35:05 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public Date getItemCreationDateById(String itemId) throws Exception {
|
|
|
|
workspaceLogger.trace("get Item Creation Date By ItemId "+ itemId);
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(itemId);
|
|
|
|
|
|
|
|
Calendar cl = wsItem.getCreationTime();
|
|
|
|
|
|
|
|
if(cl!=null)
|
|
|
|
return cl.getTime();
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("get Item Creation Date By ItemId ", e);
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Long loadSizeByItemId(String itemId) throws Exception {
|
|
|
|
|
|
|
|
workspaceLogger.trace("get Size By ItemId "+ itemId);
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
2013-03-26 12:35:58 +01:00
|
|
|
|
2013-03-25 12:35:05 +01:00
|
|
|
WorkspaceItem wsItem = workspace.getItem(itemId);
|
2013-03-26 12:35:58 +01:00
|
|
|
|
2013-03-25 12:35:05 +01:00
|
|
|
Long size = new Long(-1);
|
|
|
|
|
|
|
|
if(wsItem instanceof FolderItem){
|
|
|
|
|
|
|
|
FolderItem folderItem = (FolderItem) wsItem;
|
|
|
|
|
|
|
|
size = new Long(folderItem.getLength());
|
|
|
|
}
|
|
|
|
|
|
|
|
return size;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("get Size By ItemId ", e);
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
2013-03-26 12:35:58 +01:00
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Date loadLastModificationDateById(String itemId) throws Exception {
|
|
|
|
|
|
|
|
workspaceLogger.trace("get last modification date ItemId "+ itemId);
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(itemId);
|
|
|
|
|
|
|
|
wsItem.getLastModificationTime().getTime();
|
|
|
|
|
|
|
|
Date lastModification =null;
|
|
|
|
|
|
|
|
if(wsItem.getLastModificationTime()!=null){
|
|
|
|
|
|
|
|
lastModification = wsItem.getLastModificationTime().getTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
return lastModification;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("get last modification date ItemId ", e);
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
2013-03-27 17:30:37 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public FileModel getParentByItemId(String identifier) throws Exception {
|
|
|
|
|
|
|
|
workspaceLogger.trace("get Parent By Item Identifier "+ identifier);
|
|
|
|
try {
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(identifier);
|
|
|
|
|
|
|
|
workspaceLogger.trace("workspace retrieve item name: "+wsItem.getName());
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
while(wsItem!=null && wsItem.getParent()!=null){
|
|
|
|
|
|
|
|
WorkspaceFolder wsFolder = wsItem.getParent();
|
|
|
|
workspaceLogger.trace("parent was found "+wsFolder.getName()+ " retuning");
|
|
|
|
return builder.buildGXTFolderModelItem(wsFolder, null);
|
|
|
|
}
|
|
|
|
workspaceLogger.trace("parent not found - retuning");
|
|
|
|
return null;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error in get Parent By Item Identifier", e);
|
|
|
|
e.printStackTrace();
|
|
|
|
throw new Exception(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
2013-05-23 19:03:43 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<GxtAccountingField> getAccountingReaders(String identifier) throws Exception {
|
|
|
|
|
|
|
|
workspaceLogger.trace("get accounting readers "+ identifier);
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(identifier);
|
|
|
|
|
|
|
|
List<AccountingEntry> accoutings = wsItem.getAccounting();
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
List<GxtAccountingField> listReaders = builder.buildGXTAccountingItemFromReaders(wsItem.getReaders());
|
|
|
|
|
|
|
|
workspaceLogger.trace("get accounting readers - returning size "+listReaders.size());
|
|
|
|
return listReaders;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error get accounting readers ", e);
|
|
|
|
String error = ConstantsExplorer.SERVER_ERROR+" getting account. "+ConstantsExplorer.TRY_AGAIN;
|
|
|
|
throw new Exception(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<GxtAccountingField> getAccountingHistory(String identifier) throws Exception {
|
|
|
|
|
|
|
|
workspaceLogger.trace("get accounting history "+ identifier);
|
|
|
|
try {
|
|
|
|
|
|
|
|
Workspace workspace = getWorkspace();
|
|
|
|
|
|
|
|
WorkspaceItem wsItem = workspace.getItem(identifier);
|
|
|
|
|
|
|
|
List<AccountingEntry> accoutings = wsItem.getAccounting();
|
|
|
|
|
|
|
|
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
|
|
|
|
|
|
|
List<GxtAccountingField> listReaders = builder.buildGXTAccountingItem(accoutings, GxtAccountingEntryType.ALLWITHOUTREAD);
|
|
|
|
|
|
|
|
workspaceLogger.trace("get accounting readers - returning size "+listReaders.size());
|
|
|
|
return listReaders;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
workspaceLogger.error("Error get accounting readers ", e);
|
|
|
|
String error = ConstantsExplorer.SERVER_ERROR+" getting account. "+ConstantsExplorer.TRY_AGAIN;
|
|
|
|
throw new Exception(error);
|
|
|
|
}
|
|
|
|
}
|
2013-02-06 15:40:17 +01:00
|
|
|
}
|