diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java index 79d34e2..1529050 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java @@ -3,6 +3,7 @@ package org.gcube.portlets.user.workspace.client.model; import java.io.Serializable; import java.util.List; +import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status; import org.gcube.portlets.user.workspace.client.ConstantsExplorer; import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder; import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum; @@ -35,7 +36,6 @@ public class FileModel extends BaseModelData implements Serializable { protected boolean isSpecialFolder = false; protected boolean isPublic = false; // IS IT A PUBLIC FOLDER? - public static final String NAME = "Name"; public static final String TYPE = "Type"; public static final String ICON = "Icon"; @@ -52,6 +52,9 @@ public class FileModel extends BaseModelData implements Serializable { public static final String OWNERFULLNAME = "Owner Name"; public static final String HUMAN_REDABLE_CATEGORY = "HR Category"; + //Thredds Synch status + private Sync_Status synchedThreddsStatus; + /** * Instantiates a new file model. */ @@ -328,8 +331,22 @@ public class FileModel extends BaseModelData implements Serializable { else{ //SIMPLE FOLDER if(this.isPublic()) //IS PLUBIC absImgPr = Resources.getIconFolderPublic(); - else + else { + if(this.getSynchedThreddsStatus()!=null) { + switch(this.getSynchedThreddsStatus()) { + case OUTDATED_REMOTE: + absImgPr = Resources.getIconSyncTo(); + break; + case OUTDATED_WS: + absImgPr = Resources.getIconSyncFrom(); + break; + case UP_TO_DATE: + absImgPr = Resources.getIconSynched(); + break; + } + } absImgPr = Resources.getIconFolder(); + } } } @@ -552,6 +569,15 @@ public class FileModel extends BaseModelData implements Serializable { public boolean isPublic(){ return isPublic; } + + public void setSyncThreddsStatus(Sync_Status status) { + this.synchedThreddsStatus = status; + } + + public Sync_Status getSynchedThreddsStatus() { + return synchedThreddsStatus; + } + /* (non-Javadoc) @@ -587,4 +613,5 @@ public class FileModel extends BaseModelData implements Serializable { return builder.toString(); } + } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java index df3a7ba..693b7fe 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java @@ -457,5 +457,21 @@ public interface Icons extends ClientBundle { */ @Source("icons/thredds.gif") ImageResource thredds(); + + /** + * Sync icon to. + * + * @return the image resource + */ + @Source("icons/sync-icon-to.png") + ImageResource syncIconTo(); + + @Source("icons/sync-icon-from.png") + ImageResource syncIconFrom(); + + @Source("icons/sync-icon-synched.png") + ImageResource syncIconSynched(); + } + diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java index 37fc54f..5634615 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java @@ -4,6 +4,7 @@ import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum import com.google.gwt.core.client.GWT; import com.google.gwt.resources.client.ImageResource; +import com.google.gwt.resources.client.ClientBundle.Source; import com.google.gwt.user.client.ui.AbstractImagePrototype; /** @@ -1372,7 +1373,20 @@ public class Resources { return AbstractImagePrototype.create(ICONS.thredds()); } - + + + public static AbstractImagePrototype getIconSyncTo() { + return AbstractImagePrototype.create(ICONS.syncIconTo()); + } + + public static AbstractImagePrototype getIconSyncFrom() { + return AbstractImagePrototype.create(ICONS.syncIconFrom()); + } + + + public static AbstractImagePrototype getIconSynched() { + return AbstractImagePrototype.create(ICONS.syncIconSynched()); + } //ImageResources /** diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/sync-icon-from.png b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/sync-icon-from.png new file mode 100644 index 0000000..9304515 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/sync-icon-from.png differ diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/sync-icon-synched.png b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/sync-icon-synched.png new file mode 100644 index 0000000..0a4ab4b Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/sync-icon-synched.png differ diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/sync-icon-to.png b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/sync-icon-to.png new file mode 100644 index 0000000..0973ec2 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/sync-icon-to.png differ diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java index 8b06a95..4b0eb64 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java @@ -55,6 +55,10 @@ import org.gcube.common.homelibrary.home.workspace.sharing.WorkspaceMessage; import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashFolder; import org.gcube.common.homelibrary.home.workspace.trash.WorkspaceTrashItem; import org.gcube.common.homelibrary.home.workspace.usermanager.GCubeGroup; +import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.portal.wssynclibrary.shared.ItemNotSynched; +import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status; +import org.gcube.portal.wssynclibrary.thredds.WorkspaceThreddsSynchronize; import org.gcube.portlets.user.workspace.client.ConstantsExplorer; import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder; import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum; @@ -89,6 +93,7 @@ import org.gcube.vomanagement.usermanagement.model.GCubeUser; import com.thoughtworks.xstream.XStream; +// TODO: Auto-generated Javadoc /** * The Class GWTWorkspaceBuilder. * @@ -100,6 +105,7 @@ public class GWTWorkspaceBuilder { protected static final String IMAGE_SERVICE_URL = "ImageService"; protected static Logger logger = Logger.getLogger(GWTWorkspaceBuilder.class); private InfoContactModel userLogged; + private String scope; protected static HashMap hashTestUser = null; /** @@ -741,6 +747,7 @@ public class GWTWorkspaceBuilder { fileModel.setShareable(false); } + setSynchedThreddsStateFor(fileModel, scope, userLogged.getLogin()); return fileModel; } @@ -820,6 +827,7 @@ public class GWTWorkspaceBuilder { fileGridModel.setOwnerFullName(userLogged.getName()); } + setSynchedThreddsStateFor(fileGridModel, scope, userLogged.getLogin()); return fileGridModel; }catch (Exception e) { @@ -937,6 +945,7 @@ public class GWTWorkspaceBuilder { fileGridModel.setOwnerFullName(userLogged.getName()); } + setSynchedThreddsStateFor(fileGridModel, scope, userLogged.getLogin()); return fileGridModel; } @@ -1949,15 +1958,17 @@ public class GWTWorkspaceBuilder { return listAccFields; } - - + + /** - * Sets the user logged. + * Sets the contex info. * - * @param infoContactModel the new user logged + * @param infoContactModel the info contact model + * @param scope the scope */ - public void setUserLogged(InfoContactModel infoContactModel) { + public void setContexInfo(InfoContactModel infoContactModel, String scope) { this.userLogged = infoContactModel; + this.scope = scope; } @@ -2299,5 +2310,34 @@ public class GWTWorkspaceBuilder { } return listVersions; } + + + /** + * Sets the synched thredds state for. + * + * @param fileModel the file model + * @param scope the scope + * @param username the username + * @return the file model + */ + protected FileModel setSynchedThreddsStateFor(FileModel fileModel, String scope, String username) { + + try { + + if(fileModel.isDirectory()) { + ScopeProvider.instance.set(scope); + Sync_Status status = WorkspaceThreddsSynchronize.getInstance().getSynchedStatusFromItemProperty(fileModel.getIdentifier(), username); + fileModel.setSyncThreddsStatus(status); + } + + } catch (ItemNotSynched e) { + //silent + logger.trace("Item: "+fileModel.getIdentifier() + " name: "+fileModel.getName() +" is not synched"); + } catch (Exception e) { + logger.warn("It is not possible to get synched status for item: "+fileModel.getIdentifier()); + } + + return fileModel; + } } diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java b/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java index c04fc07..d745e64 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java @@ -218,7 +218,7 @@ public class WsUtil { logger.info("Initializing the workspace area builder"); builder = new GWTWorkspaceBuilder(); //ADDED 03/09/2013 - builder.setUserLogged(new InfoContactModel(info.getUsername(), info.getUsername(), info.getUserFullName(), false)); + builder.setContexInfo(new InfoContactModel(info.getUsername(), info.getUsername(), info.getUserFullName(), false), info.getCurrentScope()); session.setAttribute(WORKSPACEBUILDER_ATTRIBUTE, builder); }