diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a38ed8..e6cb383 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v6.33.0-SNAPSHOT] - 2021-05-11 + +#### Enhancements + +[#21388] Integrated with new workflow to interact with ws-thredds 1.x +[#21444] Moved to maven-portal-bom >= 3.6.2-SNAPSHOT + ## [v6.32.0] - 2021-04-12 #### Enhancements diff --git a/pom.xml b/pom.xml index c3f299c..c315eaa 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.gcube.portlets.user workspace-tree-widget - 6.32.0 + 6.33.0-SNAPSHOT gCube Workspace Tree Widget gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace @@ -46,7 +46,7 @@ org.gcube.distribution maven-portal-bom - 3.6.1 + 3.6.2-SNAPSHOT pom import @@ -65,7 +65,6 @@ org.gcube.portal storagehub-icons-library - [1.0.0, 2.0.0-SNAPSHOT) compile 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 a4ad6c4..8f9f929 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,7 +3,6 @@ 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; @@ -16,13 +15,12 @@ import com.google.gwt.user.client.rpc.IsSerializable; import com.google.gwt.user.client.ui.AbstractImagePrototype; import com.google.gwt.user.client.ui.Image; - - +// TODO: Auto-generated Javadoc /** * The Class FileModel. * * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it - * Sep 15, 2016 + * Sep 15, 2016 */ public class FileModel extends BaseModelData implements Serializable, IsSerializable { @@ -31,8 +29,8 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ */ private static final long serialVersionUID = 1L; - protected GXTFolderItemTypeEnum folderItemType; //It's here to serialization don't remove - protected GXTCategorySmartFolder smartFolders; //It's here to serialization don't remove + protected GXTFolderItemTypeEnum folderItemType; // It's here to serialization don't remove + protected GXTCategorySmartFolder smartFolders; // It's here to serialization don't remove protected InfoContactModel infoContacts; protected boolean isRoot = false; protected boolean isVreFolder; @@ -55,23 +53,23 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ public static final String OWNERFULLNAME = "Owner Name"; public static final String HUMAN_REDABLE_CATEGORY = "HR Category"; - //Thredds Synch status - private Sync_Status synchedThreddsStatus; + // Synched with thredds + private Boolean synchedWithWsThredds = null; /** * Instantiates a new file model. */ - protected FileModel(){ + protected FileModel() { } /** * Instantiates a new file model. * - * @param identifier the identifier - * @param name the name - * @param parent the parent + * @param identifier the identifier + * @param name the name + * @param parent the parent * @param isDirectory the is directory - * @param isShared the is shared + * @param isShared the is shared */ public FileModel(String identifier, String name, FileModel parent, boolean isDirectory, boolean isShared) { setIdentifier(identifier); @@ -85,8 +83,8 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ /** * USED FOR ATTACHMENTS AND FolderBulkCreator. * - * @param identifier the identifier - * @param name the name + * @param identifier the identifier + * @param name the name * @param isDirectory the is directory */ public FileModel(String identifier, String name, boolean isDirectory) { @@ -99,7 +97,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ /** * Inits the default properties. */ - protected void initDefaultProperties(){ + protected void initDefaultProperties() { setShortcutCategory(GXTCategorySmartFolder.SMF_UNKNOWN); setShareable(true); } @@ -110,7 +108,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ * @param bool the new shareable */ public void setShareable(boolean bool) { - set(ConstantsExplorer.ISSHAREABLE,bool); + set(ConstantsExplorer.ISSHAREABLE, bool); } @@ -119,7 +117,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ * * @param description the new description */ - public void setDescription(String description){ + public void setDescription(String description) { set(ConstantsExplorer.DIRECTORYDESCRIPTION, description); } @@ -128,7 +126,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ * * @return the description */ - public String getDescription(){ + public String getDescription() { return get(ConstantsExplorer.DIRECTORYDESCRIPTION); } @@ -139,7 +137,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ */ public boolean isShareable() { Object sharable = get(ConstantsExplorer.ISSHAREABLE); - if(sharable!=null) + if (sharable != null) return (Boolean) sharable; return false; } @@ -147,14 +145,15 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ /** * Instantiates a new file model. * - * @param identifier the identifier - * @param name the name - * @param type the type + * @param identifier the identifier + * @param name the name + * @param type the type * @param folderItemTypeEnum the folder item type enum - * @param isDirectory the is directory - * @param isShared the is shared + * @param isDirectory the is directory + * @param isShared the is shared */ - public FileModel(String identifier, String name, String type, GXTFolderItemTypeEnum folderItemTypeEnum, boolean isDirectory, boolean isShared) { + public FileModel(String identifier, String name, String type, GXTFolderItemTypeEnum folderItemTypeEnum, + boolean isDirectory, boolean isShared) { setIdentifier(identifier); setName(name); setType(type); @@ -170,14 +169,12 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ * @param parent the new parent file model */ public void setParentFileModel(FileModel parent) { - set(PARENT,parent); + set(PARENT, parent); } - /** - * Status values - * ConstantsExplorer.FOLDERNOTLOAD = "notload"; - * ConstantsExplorer.FOLDERLOADED = "loaded"; + * Status values ConstantsExplorer.FOLDERNOTLOAD = "notload"; + * ConstantsExplorer.FOLDERLOADED = "loaded"; * * @param status the new status */ @@ -192,9 +189,9 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ Image icon = (Image) get(ICON); AbstractImagePrototype iconAbs; - if(icon==null){ + if (icon == null) { iconAbs = getAbstractPrototypeIcon(); - }else + } else return; set(ICON, iconAbs.createImage()); @@ -206,7 +203,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ * * @param fullName the new owner full name */ - public void setOwnerFullName(String fullName){ + public void setOwnerFullName(String fullName) { set(FileModel.OWNERFULLNAME, fullName); } @@ -215,17 +212,17 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ * * @return the owner full name */ - public String getOwnerFullName(){ + public String getOwnerFullName() { return get(FileModel.OWNERFULLNAME); } /** * Sets the sharing value. * - * @param isShared the is shared + * @param isShared the is shared * @param listShareUsers the list share users */ - public void setSharingValue(boolean isShared, List listShareUsers){ + public void setSharingValue(boolean isShared, List listShareUsers) { set(ISSHARED, isShared); set(SHAREUSERS, listShareUsers); } @@ -236,7 +233,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ * @return the list user sharing */ @SuppressWarnings("unchecked") - public List getListUserSharing(){ + public List getListUserSharing() { return (List) get(SHAREUSERS); } @@ -245,7 +242,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ * * @param listShareUsers the new list share user */ - public void setListShareUser(List listShareUsers){ + public void setListShareUser(List listShareUsers) { set(SHAREUSERS, listShareUsers); } @@ -254,9 +251,9 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ * * @return true, if is shared */ - public boolean isShared(){ + public boolean isShared() { Object shared = get(ISSHARED); - if(shared!=null) + if (shared != null) return (Boolean) shared; return false; } @@ -266,7 +263,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ * * @return true, if is root */ - public boolean isRoot(){ + public boolean isRoot() { return isRoot; } @@ -275,11 +272,10 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ * * @param isRoot the new checks if is root */ - public void setIsRoot(boolean isRoot){ + public void setIsRoot(boolean isRoot) { this.isRoot = isRoot; } - /** * Gets the icon. * @@ -296,61 +292,56 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ */ public AbstractImagePrototype getAbstractPrototypeIcon() { - GWT.log("My prop: "+this.toString()); + GWT.log("My prop: " + this.toString()); AbstractImagePrototype absImgPr = Resources.getIconTable(); - if (!this.isDirectory()) { //IS FILE - if(this.getType()!=null) + if (!this.isDirectory()) { // IS FILE + if (this.getType() != null) absImgPr = Resources.getIconByType(this.getName(), this.getType()); else absImgPr = Resources.getIconByFolderItemType(this.getGXTFolderItemType()); - }else if(this.isShared()){ //IS A SHARED FOLDER? + } else if (this.isShared()) { // IS A SHARED FOLDER? - //GWT.log("setting icon "+this.getName()+" is shared: "+this.isShared() + ", this.isVreFolder() "+this.isVreFolder() +", this.isShareable() "+this.isShareable()); + // GWT.log("setting icon "+this.getName()+" is shared: "+this.isShared() + ", + // this.isVreFolder() "+this.isVreFolder() +", this.isShareable() + // "+this.isShareable()); - if(this.isVreFolder()) - absImgPr = Resources.getIconVREFolder(); - else{ - if(this.isShareable()){ //IS ROOT SHARED FOLDER - if(this.isPublic()) //IS PLUBIC - absImgPr = Resources.getIconFolderSharedPublic(); + if (this.isVreFolder()) + absImgPr = Resources.getIconVREFolder(); + else { + if (this.isShareable()) { // IS ROOT SHARED FOLDER + if (this.isPublic()) // IS PLUBIC + absImgPr = Resources.getIconFolderSharedPublic(); else - absImgPr = Resources.getIconSharedFolder(); - }else{ //IS A DESCENDANT - if(this.isPublic()) //IS PLUBIC + absImgPr = Resources.getIconSharedFolder(); + } else { // IS A DESCENDANT + if (this.isPublic()) // IS PLUBIC absImgPr = Resources.getIconFolderPublic(); else - absImgPr = Resources.getIconSharedFolder(); //IS A SHARED FOLDER DESCENDANT OF ROOT SHARED FOLDER + absImgPr = Resources.getIconSharedFolder(); // IS A SHARED FOLDER DESCENDANT OF ROOT SHARED + // FOLDER } } - }else if(this.getStatus() == ConstantsExplorer.FOLDERNOTLOAD){ //IS A FOLDER IN LOADING + } else if (this.getStatus() == ConstantsExplorer.FOLDERNOTLOAD) { // IS A FOLDER IN LOADING absImgPr = Resources.getIconLoading2(); - }else{ - //SPECIAL FOLDER? - if(this.isSpecialFolder()) + } else { + // SPECIAL FOLDER? + if (this.isSpecialFolder()) absImgPr = Resources.getIconSpecialFolder(); - else{ //SIMPLE FOLDER - if(this.isPublic()) //IS PLUBIC - absImgPr = Resources.getIconFolderPublic(); + else { // SIMPLE FOLDER + if (this.isPublic()) // IS PLUBIC + absImgPr = Resources.getIconFolderPublic(); 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; + if (this.getSynchedWithWsThredds() != null) { + if(this.getSynchedWithWsThredds()) { + absImgPr = Resources.getIconSynchedFolder(); } - }else - absImgPr = Resources.getIconFolder(); + } else + absImgPr = Resources.getIconFolder(); } } } @@ -358,7 +349,6 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ return absImgPr; } - /** * Gets the status. * @@ -368,13 +358,12 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ return get("status"); } - /** * Sets the checks if is directory. * * @param flag the new checks if is directory */ - public void setIsDirectory(boolean flag){ + public void setIsDirectory(boolean flag) { set(ISDIRECTORY, flag); } @@ -392,7 +381,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ * * @return the identifier */ - public String getIdentifier(){ + public String getIdentifier() { return get(IDENTIFIER); } @@ -403,21 +392,19 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ */ public void setShortcutCategory(GXTCategorySmartFolder smfDocuments) { set(SHORTCUTCATEGORY, smfDocuments); - if(smfDocuments!=null) + if (smfDocuments != null) set(HUMAN_REDABLE_CATEGORY, smfDocuments.getValue()); } - /** * Gets the shortcut category. * * @return the shortcut category */ - public GXTCategorySmartFolder getShortcutCategory(){ + public GXTCategorySmartFolder getShortcutCategory() { return (GXTCategorySmartFolder) get(SHORTCUTCATEGORY); } - /** * Sets the name. * @@ -441,7 +428,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ * * @return the parent file model */ - public FileModel getParentFileModel(){ + public FileModel getParentFileModel() { return (FileModel) get(PARENT); } @@ -450,14 +437,16 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ * * @return true, if is directory */ - public boolean isDirectory(){ + public boolean isDirectory() { Object directory = get(ISDIRECTORY); - if(directory!=null) + if (directory != null) return (Boolean) directory; return false; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#equals(java.lang.Object) */ /** @@ -489,7 +478,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ * * @param type the new type */ - public void setType(String type){ + public void setType(String type) { set(TYPE, type); } @@ -498,7 +487,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ * * @return the type */ - public String getType(){ + public String getType() { return get(TYPE); } @@ -507,7 +496,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ * * @param folderItemTypeEnum the new folder item type */ - public void setFolderItemType(GXTFolderItemTypeEnum folderItemTypeEnum){ + public void setFolderItemType(GXTFolderItemTypeEnum folderItemTypeEnum) { set(FOLDERITEMTYPE, folderItemTypeEnum); } @@ -516,7 +505,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ * * @return the GXT folder item type */ - public GXTFolderItemTypeEnum getGXTFolderItemType(){ + public GXTFolderItemTypeEnum getGXTFolderItemType() { return (GXTFolderItemTypeEnum) get(FOLDERITEMTYPE); } @@ -571,21 +560,31 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ * * @return true, if is public */ - public boolean isPublic(){ + public boolean isPublic() { return isPublic; } - public void setSyncThreddsStatus(Sync_Status status) { - this.synchedThreddsStatus = status; + /** + * Sets the synched with ws thredds. + * + * @param bool the new synched with ws thredds + */ + public void setSynchedWithWsThredds(Boolean bool) { + this.synchedWithWsThredds = bool; } - public Sync_Status getSynchedThreddsStatus() { - return synchedThreddsStatus; + /** + * Gets the synched with ws thredds. + * + * @return the synched with ws thredds + */ + public Boolean getSynchedWithWsThredds() { + return synchedWithWsThredds; } - - - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ /** @@ -620,5 +619,4 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ 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 a640110..6d93119 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 @@ -411,12 +411,15 @@ public interface Icons extends ClientBundle { @Source("icons/sync-icon-to.png") ImageResource syncIconTo(); - - @Source("icons/sync-icon-from.png") - ImageResource syncIconFrom(); - - @Source("icons/sync-icon-synched.png") - ImageResource syncIconSynched(); + + @Source("icons/folder_sync.png") + ImageResource synchedFolder(); + +// @Source("icons/sync-icon-from.png") +// ImageResource syncIconFrom(); +// +// @Source("icons/sync-icon-synched.png") +// ImageResource syncIconSynched(); @Source("icons/no-preview-available.png") ImageResource previewNotAvailable(); 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 b8fcd57..9ebc2bb 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 @@ -59,14 +59,14 @@ public class Resources { private static final String RAR = "x-rar-compressed"; private static final String GZIP = "gzip"; - private static final String WAR ="x-tika-java-web-archive"; + private static final String WAR = "x-tika-java-web-archive"; /** * Gets the cloud drive icon. * * @return the cloud drive icon */ - public static AbstractImagePrototype getCloudDriveIcon(){ + public static AbstractImagePrototype getCloudDriveIcon() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.USER_CIRCLE()); } @@ -76,18 +76,16 @@ public class Resources { * * @return the icon x tex */ - public static AbstractImagePrototype getIconXTex(){ + public static AbstractImagePrototype getIconXTex() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.TXT()); } - - /** * Gets the data catalogue publish. * * @return the data catalogue publish */ - public static AbstractImagePrototype getIconDataCataloguePublish(){ + public static AbstractImagePrototype getIconDataCataloguePublish() { return AbstractImagePrototype.create(ICONS.datacataloguepublish()); } @@ -97,18 +95,17 @@ public class Resources { * * @return the data catalogue publish */ - public static AbstractImagePrototype getIconSendToSwitchboard(){ + public static AbstractImagePrototype getIconSendToSwitchboard() { return AbstractImagePrototype.create(ICONS.switchboard()); } - /** * Gets the icon postscript. * * @return the icon postscript */ - public static AbstractImagePrototype getIconPostscript(){ + public static AbstractImagePrototype getIconPostscript() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.TXT()); } @@ -118,30 +115,27 @@ public class Resources { * * @return the icon dvi */ - public static AbstractImagePrototype getIconDvi(){ + public static AbstractImagePrototype getIconDvi() { return AbstractImagePrototype.create(ICONS.dvi()); } - - /** * Gets the icon folder shared public. * * @return the icon folder shared public */ - public static AbstractImagePrototype getIconFolderSharedPublic(){ + public static AbstractImagePrototype getIconFolderSharedPublic() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.FOLDER_LINK()); } - /** * Gets the icon information. * * @return the icon information */ - public static AbstractImagePrototype getIconAbout(){ + public static AbstractImagePrototype getIconAbout() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.INFO()); } @@ -150,18 +144,16 @@ public class Resources { * * @return the icon shell */ - public static AbstractImagePrototype getIconShell(){ + public static AbstractImagePrototype getIconShell() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.SCRIPT()); } - - /** * Gets the icon information. * * @return the icon information */ - public static AbstractImagePrototype getIconInformation(){ + public static AbstractImagePrototype getIconInformation() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.INFO()); } @@ -170,17 +162,16 @@ public class Resources { * * @return the icon zip */ - public static AbstractImagePrototype getIconZip(){ + public static AbstractImagePrototype getIconZip() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.ARCHIVE()); } - /** * Gets the icon odp. * * @return the icon odp */ - public static AbstractImagePrototype getIconOdp(){ + public static AbstractImagePrototype getIconOdp() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.DOC()); } @@ -189,37 +180,34 @@ public class Resources { * * @return the icon odp */ - public static AbstractImagePrototype getIconOds(){ + public static AbstractImagePrototype getIconOds() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.DOC()); } - /** * Gets the icon odp. * * @return the icon odp */ - public static AbstractImagePrototype getIconOdg(){ + public static AbstractImagePrototype getIconOdg() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.DOC()); } - /** * Gets the icon folder link. * * @return the icon folder link */ - public static AbstractImagePrototype getIconFolderPublic(){ + public static AbstractImagePrototype getIconFolderPublic() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.FOLDER_LINK()); } - /** * Gets the icon odp. * * @return the icon odp */ - public static AbstractImagePrototype getIconOtt(){ + public static AbstractImagePrototype getIconOtt() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.DOC()); } @@ -228,7 +216,7 @@ public class Resources { * * @return the icon odp */ - public static AbstractImagePrototype getIconOdt(){ + public static AbstractImagePrototype getIconOdt() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.DOC()); } @@ -238,7 +226,7 @@ public class Resources { * * @return the icon table */ - public static AbstractImagePrototype getIconTable(){ + public static AbstractImagePrototype getIconTable() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.unknown()); } @@ -248,7 +236,7 @@ public class Resources { * * @return the icon recycle */ - public static AbstractImagePrototype getIconRecycle(){ + public static AbstractImagePrototype getIconRecycle() { return AbstractImagePrototype.create(ICONS.recycle()); } @@ -258,18 +246,17 @@ public class Resources { * * @return the icon undo */ - public static AbstractImagePrototype getIconUndo(){ + public static AbstractImagePrototype getIconUndo() { return AbstractImagePrototype.create(ICONS.undo()); } - /** * Gets the icon archive. * * @return the icon archive */ - public static AbstractImagePrototype getIconArchive(){ + public static AbstractImagePrototype getIconArchive() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.ARCHIVE()); } @@ -279,7 +266,7 @@ public class Resources { * * @return the icon link */ - public static AbstractImagePrototype getIconLink(){ + public static AbstractImagePrototype getIconLink() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.LINK()); } @@ -288,7 +275,7 @@ public class Resources { * * @return the icon share link */ - public static AbstractImagePrototype getIconShareLink(){ + public static AbstractImagePrototype getIconShareLink() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.GET_LINK()); } @@ -297,7 +284,7 @@ public class Resources { * * @return the trash full */ - public static AbstractImagePrototype getTrashFull(){ + public static AbstractImagePrototype getTrashFull() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.BIN()); } @@ -307,7 +294,7 @@ public class Resources { * * @return the trash empty */ - public static AbstractImagePrototype getTrashEmpty(){ + public static AbstractImagePrototype getTrashEmpty() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.BIN()); } @@ -317,7 +304,7 @@ public class Resources { * * @return the icon create new */ - public static AbstractImagePrototype getIconCreateNew(){ + public static AbstractImagePrototype getIconCreateNew() { return AbstractImagePrototype.create(ICONS.createNew()); } @@ -327,7 +314,7 @@ public class Resources { * * @return the icon vre folder */ - public static AbstractImagePrototype getIconVREFolder(){ + public static AbstractImagePrototype getIconVREFolder() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.VRE_FOLDER()); } @@ -337,7 +324,7 @@ public class Resources { * * @return the icon ppt */ - public static AbstractImagePrototype getIconPpt(){ + public static AbstractImagePrototype getIconPpt() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.PPT()); } @@ -347,7 +334,7 @@ public class Resources { * * @return the icon excel */ - public static AbstractImagePrototype getIconExcel(){ + public static AbstractImagePrototype getIconExcel() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.XLS()); } @@ -357,7 +344,7 @@ public class Resources { * * @return the icon users */ - public static AbstractImagePrototype getIconUsers(){ + public static AbstractImagePrototype getIconUsers() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.GROUP()); } @@ -366,7 +353,7 @@ public class Resources { * * @return the icon gcube item */ - public static AbstractImagePrototype getIconGcubeItem(){ + public static AbstractImagePrototype getIconGcubeItem() { return AbstractImagePrototype.create(ICONS.gcubeItem()); } @@ -376,7 +363,7 @@ public class Resources { * * @return the icon share user */ - public static AbstractImagePrototype getIconShareUser(){ + public static AbstractImagePrototype getIconShareUser() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.USER()); } @@ -385,7 +372,7 @@ public class Resources { * * @return the icon share group */ - public static AbstractImagePrototype getIconShareGroup(){ + public static AbstractImagePrototype getIconShareGroup() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.GROUP()); } @@ -394,7 +381,7 @@ public class Resources { * * @return the icon special folder */ - public static AbstractImagePrototype getIconSpecialFolder(){ + public static AbstractImagePrototype getIconSpecialFolder() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.FOLDER_SPECIAL()); } @@ -403,7 +390,7 @@ public class Resources { * * @return the icon administrator */ - public static AbstractImagePrototype getIconAdministrator(){ + public static AbstractImagePrototype getIconAdministrator() { return AbstractImagePrototype.create(ICONS.administrator()); } @@ -413,7 +400,7 @@ public class Resources { * * @return the icon cut */ - public static AbstractImagePrototype getIconCut(){ + public static AbstractImagePrototype getIconCut() { return AbstractImagePrototype.create(ICONS.cut()); } @@ -423,7 +410,7 @@ public class Resources { * * @return the icon info */ - public static AbstractImagePrototype getIconInfo(){ + public static AbstractImagePrototype getIconInfo() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.INFO()); } @@ -432,7 +419,7 @@ public class Resources { * * @return the icon shared folder */ - public static AbstractImagePrototype getIconSharedFolder(){ + public static AbstractImagePrototype getIconSharedFolder() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.SHARED_FOLDER()); } @@ -442,7 +429,7 @@ public class Resources { * * @return the icon csv */ - public static AbstractImagePrototype getIconCsv(){ + public static AbstractImagePrototype getIconCsv() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.CSV()); } @@ -452,7 +439,7 @@ public class Resources { * * @return the icon read */ - public static AbstractImagePrototype getIconRead(){ + public static AbstractImagePrototype getIconRead() { return AbstractImagePrototype.create(ICONS.read()); } @@ -462,28 +449,27 @@ public class Resources { * * @return the icon not read */ - public static AbstractImagePrototype getIconNotRead(){ + public static AbstractImagePrototype getIconNotRead() { return AbstractImagePrototype.create(ICONS.notread()); } - + /** * Gets the icon not read. * * @return the icon not read */ - public static AbstractImagePrototype getSpinner(){ + public static AbstractImagePrototype getSpinner() { return AbstractImagePrototype.create(ICONS.spinner()); } - /** * Gets the close icon. * * @return the close icon */ - public static AbstractImagePrototype getCloseIcon(){ + public static AbstractImagePrototype getCloseIcon() { return AbstractImagePrototype.create(ICONS.close()); } @@ -493,7 +479,7 @@ public class Resources { * * @return the icon gif */ - public static AbstractImagePrototype getIconGif(){ + public static AbstractImagePrototype getIconGif() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.IMAGE()); } @@ -503,7 +489,7 @@ public class Resources { * * @return the icon jpeg */ - public static AbstractImagePrototype getIconJpeg(){ + public static AbstractImagePrototype getIconJpeg() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.IMAGE()); } @@ -513,7 +499,7 @@ public class Resources { * * @return the icon svg */ - public static AbstractImagePrototype getIconSvg(){ + public static AbstractImagePrototype getIconSvg() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.IMAGE()); } @@ -523,7 +509,7 @@ public class Resources { * * @return the icon png */ - public static AbstractImagePrototype getIconPng(){ + public static AbstractImagePrototype getIconPng() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.IMAGE()); } @@ -533,7 +519,7 @@ public class Resources { * * @return the icon tiff */ - public static AbstractImagePrototype getIconTiff(){ + public static AbstractImagePrototype getIconTiff() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.IMAGE()); } @@ -543,7 +529,7 @@ public class Resources { * * @return the icon pdf */ - public static AbstractImagePrototype getIconPdf(){ + public static AbstractImagePrototype getIconPdf() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.PDF()); } @@ -553,10 +539,11 @@ public class Resources { * * @return the icon xml */ - public static AbstractImagePrototype getIconXml(){ + public static AbstractImagePrototype getIconXml() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.XML()); } + /** * Gets the icon permissions. * @@ -565,12 +552,13 @@ public class Resources { public static AbstractImagePrototype getIconCalendar() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.CALENDAR()); } + /** * Gets the icon html. * * @return the icon html */ - public static AbstractImagePrototype getIconHtml(){ + public static AbstractImagePrototype getIconHtml() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.HTML()); } @@ -580,7 +568,7 @@ public class Resources { * * @return the icon java */ - public static AbstractImagePrototype getIconJava(){ + public static AbstractImagePrototype getIconJava() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.SCRIPT()); } @@ -590,7 +578,7 @@ public class Resources { * * @return the icon doc */ - public static AbstractImagePrototype getIconDoc(){ + public static AbstractImagePrototype getIconDoc() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.DOC()); } @@ -600,7 +588,7 @@ public class Resources { * * @return the icon txt */ - public static AbstractImagePrototype getIconTxt(){ + public static AbstractImagePrototype getIconTxt() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.TXT()); } @@ -610,7 +598,7 @@ public class Resources { * * @return the icon movie */ - public static AbstractImagePrototype getIconMovie(){ + public static AbstractImagePrototype getIconMovie() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.MOVIE()); } @@ -620,7 +608,7 @@ public class Resources { * * @return the icon add folder */ - public static AbstractImagePrototype getIconAddFolder(){ + public static AbstractImagePrototype getIconAddFolder() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.NEW_FOLDER()); } @@ -630,7 +618,7 @@ public class Resources { * * @return the icon add folder32 */ - public static AbstractImagePrototype getIconAddFolder32(){ + public static AbstractImagePrototype getIconAddFolder32() { return AbstractImagePrototype.create(ICONS.addFolder32()); } @@ -640,7 +628,7 @@ public class Resources { * * @return the icon rename item */ - public static AbstractImagePrototype getIconRenameItem(){ + public static AbstractImagePrototype getIconRenameItem() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.EDIT()); } @@ -650,7 +638,7 @@ public class Resources { * * @return the icon rename item32 */ - public static AbstractImagePrototype getIconRenameItem32(){ + public static AbstractImagePrototype getIconRenameItem32() { return AbstractImagePrototype.create(ICONS.renameItem32()); } @@ -660,7 +648,7 @@ public class Resources { * * @return the icon rename item32 */ - public static AbstractImagePrototype getSearchIcon(){ + public static AbstractImagePrototype getSearchIcon() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.SEARCH()); } @@ -670,7 +658,7 @@ public class Resources { * * @return the icon file upload */ - public static AbstractImagePrototype getIconFileUpload(){ + public static AbstractImagePrototype getIconFileUpload() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.FILE_UPLOAD()); } @@ -680,7 +668,7 @@ public class Resources { * * @return the icon file upload32 */ - public static AbstractImagePrototype getIconFileUpload32(){ + public static AbstractImagePrototype getIconFileUpload32() { return AbstractImagePrototype.create(ICONS.uploadFile32()); } @@ -690,7 +678,7 @@ public class Resources { * * @return the icon delete folder */ - public static AbstractImagePrototype getIconDeleteFolder(){ + public static AbstractImagePrototype getIconDeleteFolder() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.DELETE()); } @@ -699,7 +687,7 @@ public class Resources { * * @return the icon delete item */ - public static AbstractImagePrototype getIconDeleteItem(){ + public static AbstractImagePrototype getIconDeleteItem() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.DELETE()); } @@ -708,7 +696,7 @@ public class Resources { * * @return the icon delete item32 */ - public static AbstractImagePrototype getIconDeleteItem32(){ + public static AbstractImagePrototype getIconDeleteItem32() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.DELETE()); } @@ -717,7 +705,7 @@ public class Resources { * * @return the icon folder */ - public static AbstractImagePrototype getIconFolder(){ + public static AbstractImagePrototype getIconFolder() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.FOLDER()); } @@ -726,7 +714,7 @@ public class Resources { * * @return the icon audio */ - public static AbstractImagePrototype getIconAudio(){ + public static AbstractImagePrototype getIconAudio() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.MOVIE()); } @@ -735,7 +723,7 @@ public class Resources { * * @return the icon archive upload */ - public static AbstractImagePrototype getIconArchiveUpload(){ + public static AbstractImagePrototype getIconArchiveUpload() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.UNARCHIVE()); } @@ -744,7 +732,7 @@ public class Resources { * * @return the icon biodiversity */ - public static AbstractImagePrototype getIconBiodiversity(){ + public static AbstractImagePrototype getIconBiodiversity() { return AbstractImagePrototype.create(ICONS.biodiversity()); } @@ -754,7 +742,7 @@ public class Resources { * * @return the icon images */ - public static AbstractImagePrototype getIconImages(){ + public static AbstractImagePrototype getIconImages() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.IMAGE()); } @@ -763,7 +751,7 @@ public class Resources { * * @return the icon documents */ - public static AbstractImagePrototype getIconDocuments(){ + public static AbstractImagePrototype getIconDocuments() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.TXT()); } @@ -772,7 +760,7 @@ public class Resources { * * @return the icon pencil */ - public static AbstractImagePrototype getIconPencil(){ + public static AbstractImagePrototype getIconPencil() { return AbstractImagePrototype.create(ICONS.pencil()); } @@ -782,7 +770,7 @@ public class Resources { * * @return the icon edit */ - public static AbstractImagePrototype getIconEdit(){ + public static AbstractImagePrototype getIconEdit() { return AbstractImagePrototype.create(ICONS.edit()); } @@ -792,7 +780,7 @@ public class Resources { * * @return the icon history */ - public static AbstractImagePrototype getIconHistory(){ + public static AbstractImagePrototype getIconHistory() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.HISTORY()); } @@ -806,7 +794,6 @@ public class Resources { return AbstractImagePrototype.create(ICONS.search()); } - /** * Gets the icon search ws. * @@ -817,13 +804,12 @@ public class Resources { return AbstractImagePrototype.create(ICONS.search2()); } - /** * Gets the icon links. * * @return the icon links */ - public static AbstractImagePrototype getIconLinks(){ + public static AbstractImagePrototype getIconLinks() { return AbstractImagePrototype.create(ICONS.links()); } @@ -833,7 +819,7 @@ public class Resources { * * @return the icon report */ - public static AbstractImagePrototype getIconReport(){ + public static AbstractImagePrototype getIconReport() { return AbstractImagePrototype.create(ICONS.report()); } @@ -842,7 +828,7 @@ public class Resources { * * @return the icon grid view */ - public static AbstractImagePrototype getIconGridView(){ + public static AbstractImagePrototype getIconGridView() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.CATEGORY()); } @@ -860,7 +846,7 @@ public class Resources { * * @return the icon time series */ - public static AbstractImagePrototype getIconTimeSeries(){ + public static AbstractImagePrototype getIconTimeSeries() { return AbstractImagePrototype.create(ICONS.timeSeries()); } @@ -869,7 +855,7 @@ public class Resources { * * @return the icon download */ - public static AbstractImagePrototype getIconDownload(){ + public static AbstractImagePrototype getIconDownload() { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.FILE_DOWNLOAD()); } @@ -878,7 +864,7 @@ public class Resources { * * @return the icon cancel */ - public static AbstractImagePrototype getIconCancel(){ + public static AbstractImagePrototype getIconCancel() { return AbstractImagePrototype.create(ICONS.cancel()); } @@ -971,6 +957,7 @@ public class Resources { public static AbstractImagePrototype getIconCheckUser() { return AbstractImagePrototype.create(ICONS.checkUser()); } + /** * Gets the icon hand. * @@ -988,6 +975,7 @@ public class Resources { public static AbstractImagePrototype getIconSaveAttachments() { return AbstractImagePrototype.create(ICONS.saveAttachs()); } + /** * Gets the icon copy. * @@ -1078,7 +1066,6 @@ public class Resources { return AbstractImagePrototype.create(ICONS.removeFilter()); } - /** * Gets the icon public link. * @@ -1088,7 +1075,6 @@ public class Resources { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.PUBLIC_LINK()); } - /** * Gets the icon versioning. * @@ -1098,9 +1084,6 @@ public class Resources { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.VERSIONS()); } - - - /** * Gets the icon web dav. * @@ -1227,7 +1210,6 @@ public class Resources { return AbstractImagePrototype.create(ICONS.folderPublicRemove()); } - /** * Gets the icon add administrator. * @@ -1246,8 +1228,6 @@ public class Resources { return AbstractImagePrototype.create(ICONS.manageAdmin()); } - - /** * Gets the icon thredds publish. * @@ -1258,7 +1238,6 @@ public class Resources { return AbstractImagePrototype.create(ICONS.thredds()); } - /** * Gets the icon sync to. * @@ -1269,22 +1248,12 @@ public class Resources { } /** - * Gets the icon sync from. - * - * @return the icon sync from - */ - public static AbstractImagePrototype getIconSyncFrom() { - return AbstractImagePrototype.create(ICONS.syncIconFrom()); - } - - - /** - * Gets the icon synched. + * Gets the icon synched folder. * - * @return the icon synched + * @return the icon synched folder */ - public static AbstractImagePrototype getIconSynched() { - return AbstractImagePrototype.create(ICONS.syncIconSynched()); + public static AbstractImagePrototype getIconSynchedFolder() { + return AbstractImagePrototype.create(ICONS.synchedFolder()); } /** @@ -1296,14 +1265,13 @@ public class Resources { return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.move24()); } - - //ImageResources + // ImageResources /** * Gets the image path separator. * * @return the image path separator */ - public static ImageResource getImagePathSeparator(){ + public static ImageResource getImagePathSeparator() { return ICONS.separatorPath(); } @@ -1321,7 +1289,7 @@ public class Resources { * * @return the image hard disk */ - public static ImageResource getImageHardDisk(){ + public static ImageResource getImageHardDisk() { return ICONS.hardDisk(); } @@ -1330,7 +1298,7 @@ public class Resources { * * @return the image search */ - public static ImageResource getImageSearch(){ + public static ImageResource getImageSearch() { return ICONS.search(); } @@ -1339,7 +1307,7 @@ public class Resources { * * @return the image folder */ - public static ImageResource getImageFolder(){ + public static ImageResource getImageFolder() { return ICONS.folder(); } @@ -1352,7 +1320,6 @@ public class Resources { return ICONS.cancel(); } - /** * Gets the image delete. * @@ -1370,7 +1337,6 @@ public class Resources { public static ImageResource getImageAttachs() { return ICONS.attach(); } - /** * Gets the preview not available. @@ -1380,7 +1346,7 @@ public class Resources { public static ImageResource getPreviewNotAvailable() { return ICONS.previewNotAvailable(); } - + /** * Gets the preview not available. * @@ -1390,17 +1356,17 @@ public class Resources { return ICONS.previewNotAvailableNoBorder(); } - /** * Gets the icon by media type name. * - * @param name the name + * @param name the name * @param mediaTypeName the media type name * @return the icon by media type name */ public static AbstractImagePrototype getIconByMediaTypeName(String name, String mediaTypeName) { - if (MPEG.equals(mediaTypeName) || SWF.equals(mediaTypeName) || FLV.equals(mediaTypeName) || AVI.equals(mediaTypeName)) { + if (MPEG.equals(mediaTypeName) || SWF.equals(mediaTypeName) || FLV.equals(mediaTypeName) + || AVI.equals(mediaTypeName)) { return Resources.getIconMovie(); } else if (JPEG.equals(mediaTypeName) || JPG.equals(mediaTypeName)) { return Resources.getIconJpeg(); @@ -1412,7 +1378,7 @@ public class Resources { return Resources.getIconXml(); } else if (mediaTypeName.contains(CAL)) { return Resources.getIconCalendar(); - }else if (CSV.equals(mediaTypeName)) { + } else if (CSV.equals(mediaTypeName)) { return Resources.getIconCsv(); } else if (JAVA.equals(mediaTypeName)) { return Resources.getIconJava(); @@ -1430,38 +1396,38 @@ public class Resources { return Resources.getIconGif(); } else if (TXT.equals(mediaTypeName)) { return Resources.getIconTxt(); - }else if (mediaTypeName.contains(PPT) || mediaTypeName.equals(PPTX)) { + } else if (mediaTypeName.contains(PPT) || mediaTypeName.equals(PPTX)) { return Resources.getIconPpt(); - } else if(mediaTypeName.contains(ODP)){ + } else if (mediaTypeName.contains(ODP)) { return Resources.getIconOdp(); - } else if(mediaTypeName.contains(ODS)){ + } else if (mediaTypeName.contains(ODS)) { return Resources.getIconOds(); - } else if(mediaTypeName.contains(ODG)){ + } else if (mediaTypeName.contains(ODG)) { return Resources.getIconOdg(); - } else if(mediaTypeName.contains(OTT)){ + } else if (mediaTypeName.contains(OTT)) { return Resources.getIconOtt(); - }else if(mediaTypeName.contains(ODT)){ - return Resources.getIconOdt(); - }else if (mediaTypeName.contains(EXCEL) || mediaTypeName.contains(XSLX)) { + } else if (mediaTypeName.contains(ODT)) { + return Resources.getIconOdt(); + } else if (mediaTypeName.contains(EXCEL) || mediaTypeName.contains(XSLX)) { return Resources.getIconExcel(); - }else if (mediaTypeName.contains(ZIP) || mediaTypeName.contains(SEVEN_ZIP)) { + } else if (mediaTypeName.contains(ZIP) || mediaTypeName.contains(SEVEN_ZIP)) { int fe = name.lastIndexOf("."); - String fileExtension = name.substring(fe+1, name.length()); - if(fileExtension.compareTo("jar")==0) + String fileExtension = name.substring(fe + 1, name.length()); + if (fileExtension.compareTo("jar") == 0) return Resources.getIconJava(); return Resources.getIconZip(); - }else if (mediaTypeName.contains(DVI)) { - return Resources.getIconDvi(); - }else if (mediaTypeName.contains(X_SH) || mediaTypeName.contains(X_SHELLSCRIPT)) { + } else if (mediaTypeName.contains(DVI)) { + return Resources.getIconDvi(); + } else if (mediaTypeName.contains(X_SH) || mediaTypeName.contains(X_SHELLSCRIPT)) { return Resources.getIconShell(); - }else if (mediaTypeName.contains(XTEX)) { + } else if (mediaTypeName.contains(XTEX)) { return Resources.getIconXTex(); - }else if (mediaTypeName.contains(POSTSCRIPT)) { + } else if (mediaTypeName.contains(POSTSCRIPT)) { return Resources.getIconPostscript(); - }else if (mediaTypeName.contains(RAR) || mediaTypeName.contains(GZIP) || mediaTypeName.contains(X_BZIP)) { + } else if (mediaTypeName.contains(RAR) || mediaTypeName.contains(GZIP) || mediaTypeName.contains(X_BZIP)) { return Resources.getIconArchive(); - }else if (mediaTypeName.contains(WAR)) { + } else if (mediaTypeName.contains(WAR)) { return Resources.getIconJava(); } return Resources.getIconTable(); @@ -1473,44 +1439,43 @@ public class Resources { * @param itemType the item type * @return the icon by folder item type */ - public static AbstractImagePrototype getIconByFolderItemType(GXTFolderItemTypeEnum itemType){ + public static AbstractImagePrototype getIconByFolderItemType(GXTFolderItemTypeEnum itemType) { - if(itemType!=null){ + if (itemType != null) { - if(itemType.equals(GXTFolderItemTypeEnum.ANNOTATION)){ + if (itemType.equals(GXTFolderItemTypeEnum.ANNOTATION)) { return Resources.getIconTxt(); - }else if(itemType.equals(GXTFolderItemTypeEnum.DOCUMENT)){ + } else if (itemType.equals(GXTFolderItemTypeEnum.DOCUMENT)) { return Resources.getIconTxt(); - }else if(itemType.equals(GXTFolderItemTypeEnum.EXTERNAL_FILE)){ + } else if (itemType.equals(GXTFolderItemTypeEnum.EXTERNAL_FILE)) { return Resources.getIconTable(); - }else if(itemType.equals(GXTFolderItemTypeEnum.EXTERNAL_IMAGE)){ + } else if (itemType.equals(GXTFolderItemTypeEnum.EXTERNAL_IMAGE)) { return Resources.getIconJpeg(); - }else if(itemType.equals(GXTFolderItemTypeEnum.EXTERNAL_PDF_FILE)){ + } else if (itemType.equals(GXTFolderItemTypeEnum.EXTERNAL_PDF_FILE)) { return Resources.getIconPdf(); - }else if(itemType.equals(GXTFolderItemTypeEnum.EXTERNAL_URL)){ + } else if (itemType.equals(GXTFolderItemTypeEnum.EXTERNAL_URL)) { return Resources.getIconLink(); - }else if(itemType.equals(GXTFolderItemTypeEnum.IMAGE_DOCUMENT)){ + } else if (itemType.equals(GXTFolderItemTypeEnum.IMAGE_DOCUMENT)) { return Resources.getIconPng(); - }else if(itemType.equals(GXTFolderItemTypeEnum.METADATA)){ + } else if (itemType.equals(GXTFolderItemTypeEnum.METADATA)) { return Resources.getIconSvg(); - }else if(itemType.equals(GXTFolderItemTypeEnum.PDF_DOCUMENT)){ + } else if (itemType.equals(GXTFolderItemTypeEnum.PDF_DOCUMENT)) { return Resources.getIconPdf(); - }else if(itemType.equals(GXTFolderItemTypeEnum.GCUBE_ITEM)){ + } else if (itemType.equals(GXTFolderItemTypeEnum.GCUBE_ITEM)) { return Resources.getIconGcubeItem(); - // }else if(itemType.equals(GXTFolderItemTypeEnum.QUERY)){ - // return Resources.getIconTable(); - }else if(itemType.equals(GXTFolderItemTypeEnum.TIME_SERIES)){ + // }else if(itemType.equals(GXTFolderItemTypeEnum.QUERY)){ + // return Resources.getIconTable(); + } else if (itemType.equals(GXTFolderItemTypeEnum.TIME_SERIES)) { return Resources.getIconTimeSeries(); - }else if(itemType.equals(GXTFolderItemTypeEnum.URL_DOCUMENT)){ + } else if (itemType.equals(GXTFolderItemTypeEnum.URL_DOCUMENT)) { return Resources.getIconLink(); - }else if(itemType.equals(GXTFolderItemTypeEnum.EXTERNAL_RESOURCE_LINK)){ + } else if (itemType.equals(GXTFolderItemTypeEnum.EXTERNAL_RESOURCE_LINK)) { return Resources.getIconResourceLink(); } } return Resources.getIconTxt(); } - /** * Gets the icon by type. * @@ -1518,16 +1483,14 @@ public class Resources { * @param type the type * @return the icon by type */ - public static AbstractImagePrototype getIconByType(String name, String type){ - //RECOVERING "media type name" from type / media type name [+suffix] + public static AbstractImagePrototype getIconByType(String name, String type) { + // RECOVERING "media type name" from type / media type name [+suffix] int sl = type.indexOf("/"); - String mediaTypeName = type.substring(sl+1, type.length()); + String mediaTypeName = type.substring(sl + 1, type.length()); return Resources.getIconByMediaTypeName(name, mediaTypeName); } - - /** * Gets the icon by folder enum. * @@ -1535,15 +1498,15 @@ public class Resources { * @param type the type * @return the icon by folder enum */ - public static AbstractImagePrototype getIconByFolderEnum(String name, String type){ + public static AbstractImagePrototype getIconByFolderEnum(String name, String type) { - if(type.equals(GXTFolderItemTypeEnum.FOLDER.toString())) + if (type.equals(GXTFolderItemTypeEnum.FOLDER.toString())) return Resources.getIconFolder(); - else if(type.equals(GXTFolderItemTypeEnum.FOLDER_PUBLIC.toString())) + else if (type.equals(GXTFolderItemTypeEnum.FOLDER_PUBLIC.toString())) return Resources.getIconFolderPublic(); - else if(type.equals(GXTFolderItemTypeEnum.FOLDER_SHARED.toString())) + else if (type.equals(GXTFolderItemTypeEnum.FOLDER_SHARED.toString())) return Resources.getIconSharedFolder(); - else if(type.equals(GXTFolderItemTypeEnum.FOLDER_SHARED_PUBLIC.toString())) + else if (type.equals(GXTFolderItemTypeEnum.FOLDER_SHARED_PUBLIC.toString())) return Resources.getIconFolderSharedPublic(); return null; diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/folder_sync.png b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/folder_sync.png new file mode 100644 index 0000000..2db5335 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/folder_sync.png differ diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/folder_sync_back.png b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/folder_sync_back.png new file mode 100644 index 0000000..7f69253 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/folder_sync_back.png differ diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/folder_sync_back2.png b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/folder_sync_back2.png new file mode 100644 index 0000000..d8d1746 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/folder_sync_back2.png differ 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 deleted file mode 100644 index 9917b92..0000000 Binary files a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/sync-icon-from.png and /dev/null 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 deleted file mode 100644 index 6d036b1..0000000 Binary files a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/sync-icon-synched.png and /dev/null differ diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/AsyncTreePanel.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/AsyncTreePanel.java index 7c9ce37..8cbb191 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/AsyncTreePanel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/AsyncTreePanel.java @@ -57,7 +57,7 @@ import com.google.gwt.user.client.ui.AbstractImagePrototype; * The Class AsyncTreePanel. * * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it - * Sep 15, 2016 + * Sep 15, 2016 */ public class AsyncTreePanel extends LayoutContainer { @@ -65,7 +65,6 @@ public class AsyncTreePanel extends LayoutContainer { private static final String ROOT_SUFFIX = "'s workspace"; private String myRootDisplayName = null; - // private TreeLoader loader; private TreePanel treePanel; private TreeStore store; private ContextMenuTree contextMenuTree; @@ -73,15 +72,17 @@ public class AsyncTreePanel extends LayoutContainer { private ContentPanel cp = new ContentPanel(); private boolean isSubTreeLoaded = false; private boolean isSearch = false; - //private String scopeId = null; /** * The Enum DragType. * * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it - * Aug 29, 2016 + * Aug 29, 2016 */ - private enum DragType {INSERT, APPEND}; + private enum DragType { + INSERT, APPEND + }; + private boolean rightClick = false; /** @@ -89,13 +90,13 @@ public class AsyncTreePanel extends LayoutContainer { */ public AsyncTreePanel() { - //Init Store + // Init Store store = new TreeStore(); - //Load Root Item + // Load Root Item // this.loadRootItem(); - treePanel = new TreePanel(store){ + treePanel = new TreePanel(store) { @Override public boolean hasChildren(FileModel parent) { if (parent instanceof FolderModel) { @@ -104,42 +105,41 @@ public class AsyncTreePanel extends LayoutContainer { return super.hasChildren(parent); } - @Override - @SuppressWarnings({"unchecked", "rawtypes"}) - public void onComponentEvent(ComponentEvent ce) { - super.onComponentEvent(ce); - TreePanelEvent tpe = (TreePanelEvent) ce; - EventType typeEvent = tpe.getType(); + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void onComponentEvent(ComponentEvent ce) { + super.onComponentEvent(ce); + TreePanelEvent tpe = (TreePanelEvent) ce; + EventType typeEvent = tpe.getType(); - rightClick = false; + rightClick = false; if (typeEvent == Events.OnMouseDown) { - if (ce.isRightClick()){ + if (ce.isRightClick()) { rightClick = true; - } + } } - int type = ce.getEventTypeInt(); - switch (type) { - case Event.ONCLICK: - onClick(tpe); - break; - case Event.ONDBLCLICK: - onDoubleClick(tpe); - break; - case Event.ONSCROLL: - onScroll(tpe); - break; - case Event.ONFOCUS: - onFocus(ce); - break; - } - - view.onEvent(tpe); - } - }; + int type = ce.getEventTypeInt(); + switch (type) { + case Event.ONCLICK: + onClick(tpe); + break; + case Event.ONDBLCLICK: + onDoubleClick(tpe); + break; + case Event.ONSCROLL: + onScroll(tpe); + break; + case Event.ONFOCUS: + onFocus(ce); + break; + } + view.onEvent(tpe); + } + }; treePanel.setStateful(false); treePanel.setDisplayProperty(FileModel.NAME); @@ -154,17 +154,19 @@ public class AsyncTreePanel extends LayoutContainer { // model.setIcon(); // ConstantsExplorer.log("getIcon Model is root?: "+model.isRoot() + " name: "+model.getName()); if (!model.isDirectory()) { - if(model.getType()!=null) + if (model.getType() != null) return Resources.getIconByType(model.getName(), model.getType()); return Resources.getIconByFolderItemType(model.getGXTFolderItemType()); } - if (model.isRoot()) { //IS ROOT? - //ConstantsExplorer.log("getIcon isRoot Model is: "+model); + if (model.isRoot()) { // IS ROOT? + // ConstantsExplorer.log("getIcon isRoot Model is: "+model); - if(AppControllerExplorer.myLoginFirstName==null || AppControllerExplorer.myLoginFirstName.isEmpty()){ - ConstantsExplorer.log("Getting My First Name from server, into myLoginFirstName call is null yet"); + if (AppControllerExplorer.myLoginFirstName == null + || AppControllerExplorer.myLoginFirstName.isEmpty()) { + ConstantsExplorer + .log("Getting My First Name from server, into myLoginFirstName call is null yet"); AppControllerExplorer.rpcWorkspaceService.getMyFirstName(new AsyncCallback() { @Override @@ -176,63 +178,59 @@ public class AsyncTreePanel extends LayoutContainer { @Override public void onSuccess(String firstName) { - if(firstName==null || firstName.isEmpty()) + if (firstName == null || firstName.isEmpty()) model.setName("My Workspace"); else - setRootDisplayName(model, AppControllerExplorer.myLoginFirstName+ROOT_SUFFIX, true); + setRootDisplayName(model, AppControllerExplorer.myLoginFirstName + ROOT_SUFFIX, + true); } }); - }else{ - setRootDisplayName(model, AppControllerExplorer.myLoginFirstName+ROOT_SUFFIX, false); + } else { + setRootDisplayName(model, AppControllerExplorer.myLoginFirstName + ROOT_SUFFIX, false); } return Resources.getCloudDriveIcon(); } - if(model.getStatus() == ConstantsExplorer.FOLDERNOTLOAD) + if (model.getStatus() == ConstantsExplorer.FOLDERNOTLOAD) return Resources.getIconLoading2(); - if(model.isVreFolder()) //IS VRE? + if (model.isVreFolder()) // IS VRE? return Resources.getIconVREFolder(); - if(model.isSpecialFolder()) //IS SPECIAL FOLDER? + if (model.isSpecialFolder()) // IS SPECIAL FOLDER? return Resources.getIconSpecialFolder(); - //SHARE ICON - if(model.isShared()){ - if(model.isShareable()){ //IS ROOT SHARED FOLDER - if(model.isPublic()) //IS PUBLIC + // SHARE ICON + if (model.isShared()) { + if (model.isShareable()) { // IS ROOT SHARED FOLDER + if (model.isPublic()) // IS PUBLIC return Resources.getIconFolderSharedPublic(); else return Resources.getIconSharedFolder(); - }else{//IS DESCENDANT - if(model.isPublic()) //IS PLUBIC - return Resources.getIconFolderPublic(); + } else {// IS DESCENDANT + if (model.isPublic()) // IS PLUBIC + return Resources.getIconFolderPublic(); else - return Resources.getIconSharedFolder(); //IS CHILDREN OF ROOT SHARED FOLDER + return Resources.getIconSharedFolder(); // IS CHILDREN OF ROOT SHARED FOLDER } } - if(model.isDirectory()){ - if(model.isPublic()) //IS PLUBIC - return Resources.getIconFolderPublic(); - else{ - if(model.getSynchedThreddsStatus()!=null) { - switch(model.getSynchedThreddsStatus()) { - case OUTDATED_REMOTE: - return Resources.getIconSyncTo(); - case OUTDATED_WS: - return Resources.getIconSyncFrom(); - case UP_TO_DATE: - return Resources.getIconSynched(); + if (model.isDirectory()) { + if (model.isPublic()) // IS PLUBIC + return Resources.getIconFolderPublic(); + else { + if (model.getSynchedWithWsThredds() != null) { + if (model.getSynchedWithWsThredds()) { + return Resources.getIconSynchedFolder(); } } return Resources.getIconFolder(); } } - return null; //Set default folder icon + return null; // Set default folder icon } }); @@ -240,7 +238,7 @@ public class AsyncTreePanel extends LayoutContainer { treePanel.setContextMenu(contextMenuTree.getContextMenu()); - //Single selection Mode + // Single selection Mode treePanel.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); this.addListners(); @@ -259,7 +257,7 @@ public class AsyncTreePanel extends LayoutContainer { cp.setBodyStyle("padding: 5px"); cp.setLayout(new FitLayout()); - //***For Debug the store + // ***For Debug the store Button butt = new Button(); butt.setText("Print Store"); butt.setVisible(false); @@ -272,7 +270,8 @@ public class AsyncTreePanel extends LayoutContainer { System.out.println("\n\nStore by root"); for (FileModel item : listFileModel) { - System.out.println(item.getName() + " ID " + item.getIdentifier() + " isDirectory " + item.isDirectory()); + System.out.println( + item.getName() + " ID " + item.getIdentifier() + " isDirectory " + item.isDirectory()); // eventBus.fireEvent(new SelectedItemEvent(treePanel.getStore().getRootItems().get(0))); printingTreeLevel(item); @@ -280,65 +279,53 @@ public class AsyncTreePanel extends LayoutContainer { } }); - // cp.add(butt); - - //***End Debug the store - + // ***End Debug the store cp.add(treePanel); - add(cp); - } - /** * Sets the root display name. * - * @param root the root - * @param name the name + * @param root the root + * @param name the name * @param forceOverwrite the force overwrite */ - private void setRootDisplayName(FileModel root, String name, boolean forceOverwrite){ - if(myRootDisplayName==null || forceOverwrite){ + private void setRootDisplayName(FileModel root, String name, boolean forceOverwrite) { + if (myRootDisplayName == null || forceOverwrite) { myRootDisplayName = name; root.setName(myRootDisplayName); } } /** - * Status values - * ConstantsExplorer.FOLDERNOTLOAD = "notload"; - * ConstantsExplorer.FOLDERLOADED = "loaded"; + * Status values ConstantsExplorer.FOLDERNOTLOAD = "notload"; + * ConstantsExplorer.FOLDERLOADED = "loaded"; * * @param itemIdentifier the item identifier - * @param status the status + * @param status the status */ - public void changeFolderIconStatus(String itemIdentifier, String status){ + public void changeFolderIconStatus(String itemIdentifier, String status) { FileModel fileModel = getFileModelByIdentifier(itemIdentifier); fileModel.setStatus(status); } - /** * Load root item. * * @param selectRoot the select root */ - public void loadRootItem(final boolean selectRoot){ - - //this.scopeId = scopeId; - - System.out.println("***Start Root load"); - - //Load Root without filtering on scope id + public void loadRootItem(final boolean selectRoot) { + // Load Root without filtering on scope id AppControllerExplorer.rpcWorkspaceService.getRootForTree(new AsyncCallback() { @Override public void onFailure(Throwable caught) { - new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting root item. " +ConstantsExplorer.TRY_AGAIN, null); + new MessageBoxAlert("Error", + ConstantsExplorer.SERVER_ERROR + " getting root item. " + ConstantsExplorer.TRY_AGAIN, null); } @@ -349,27 +336,26 @@ public class AsyncTreePanel extends LayoutContainer { }); } - /** * Load root in store. * - * @param root the root + * @param root the root * @param selectRootOnLoad the select root on load */ - private void loadRootInStore(FolderModel root, boolean selectRootOnLoad){ + private void loadRootInStore(FolderModel root, boolean selectRootOnLoad) { - if(root!=null){ + if (root != null) { store.removeAll(); store.insert(root, 0, false); GWT.log("Root Name: " + store.getRootItems().get(0).get(FileModel.NAME)); - treePanel.setExpanded(store.getRootItems().get(0),true); //expand level 1 - if(selectRootOnLoad) - selectRootItem(); //select root item + treePanel.setExpanded(store.getRootItems().get(0), true); // expand level 1 + if (selectRootOnLoad) + selectRootItem(); // select root item System.out.println("***End Root load "); - } - else - new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting root item. Root item is null " +ConstantsExplorer.TRY_AGAIN, null); + } else + new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting root item. Root item is null " + + ConstantsExplorer.TRY_AGAIN, null); } @@ -378,7 +364,7 @@ public class AsyncTreePanel extends LayoutContainer { */ private void addDragAndDrop() { - //Drag & Drop Event + // Drag & Drop Event TreePanelDragSource source = new TreePanelDragSource(treePanel); source.addDNDListener(new DNDListener() { @Override @@ -393,21 +379,20 @@ public class AsyncTreePanel extends LayoutContainer { return; } - if(sel.isVreFolder() || sel.isSpecialFolder()){ + if (sel.isVreFolder() || sel.isSpecialFolder()) { event.setCancelled(true); event.getStatus().setStatus(false); return; } - if(sel != null && sel.getName()!= null) + if (sel != null && sel.getName() != null) GWT.log("Start drag of " + sel.getName()); super.dragStart(event); } }); - - TreePanelDropTarget targetTreePanel = new TreePanelDropTarget(treePanel){ + TreePanelDropTarget targetTreePanel = new TreePanelDropTarget(treePanel) { // @Override // protected void onDragDrop(DNDEvent event) { // System.out.println("on Drop"); @@ -422,48 +407,49 @@ public class AsyncTreePanel extends LayoutContainer { // } @Override - protected void showFeedback(DNDEvent event) { - if (!isValidDropTarget(event)) { - Insert.get().hide(); - event.getStatus().setStatus(false); - return; - } - super.showFeedback(event); - } + protected void showFeedback(DNDEvent event) { + if (!isValidDropTarget(event)) { + Insert.get().hide(); + event.getStatus().setStatus(false); + return; + } + super.showFeedback(event); + } @SuppressWarnings("unchecked") - private boolean isValidDropTarget(DNDEvent event) { + private boolean isValidDropTarget(DNDEvent event) { TreePanel target = (TreePanel) event.getDropTarget().getComponent(); TreePanel.TreeNode zone = target.findNode(event.getTarget()); - if (zone == null) { - return true; // let it check from super-class - } + if (zone == null) { + return true; // let it check from super-class + } - Component com = event.getDragSource().getComponent(); + Component com = event.getDragSource().getComponent(); - if(com instanceof TreePanel){ + if (com instanceof TreePanel) { - TreePanel source = (TreePanel) event.getDragSource().getComponent(); - List selection = source.getSelectionModel().getSelection(); + TreePanel source = (TreePanel) event.getDragSource().getComponent(); + List selection = source.getSelectionModel().getSelection(); - for (FileModel model : selection) { - // check the "model" against "zone" and return false - // if "zone" is not a valid drop target for "model", otherwise check the next "model" - // example: - if (source.getStore().getParent(model) == zone.getModel()) - return false; + for (FileModel model : selection) { + // check the "model" against "zone" and return false + // if "zone" is not a valid drop target for "model", otherwise check the next + // "model" + // example: + if (source.getStore().getParent(model) == zone.getModel()) + return false; // if(source.getStore().getParent(model) == target.getModel()) // return false; - if(zone.getModel().isSpecialFolder()) //NOT DROPPABLE INTO SPECIAL FOLDER - return false; + if (zone.getModel().isSpecialFolder()) // NOT DROPPABLE INTO SPECIAL FOLDER + return false; - } - return true; - } - return false; + } + return true; + } + return false; // TreePanel source = (TreePanel) event.getDragSource().getComponent(); // List selection = source.getSelectionModel().getSelection(); @@ -480,25 +466,26 @@ public class AsyncTreePanel extends LayoutContainer { // } // // return true; - } + } - //Called when drop on folder + // Called when drop on folder @Override protected void handleAppendDrop(DNDEvent event, @SuppressWarnings("rawtypes") TreeNode item) { super.handleAppendDrop(event, item); GWT.log("***Event move handleAppendDrop"); - List listFileModel = getDragSource(event); - - if(listFileModel.size() == 1){ - FileModel destination = getDragDestination(item, DragType.APPEND); - if(destination != null){ - //REMOVE THIS COMMENT TODO - eventBus.fireEvent(new DragOnTreeMoveItemEvent(listFileModel.get(0), (FolderModel) destination)); - GWT.log("Destination: " +destination.getName() + " id "+ destination.getIdentifier()); - } - }else{ - //MULTIDRAG + List listFileModel = getDragSource(event); + + if (listFileModel.size() == 1) { + FileModel destination = getDragDestination(item, DragType.APPEND); + if (destination != null) { + // REMOVE THIS COMMENT TODO + eventBus.fireEvent( + new DragOnTreeMoveItemEvent(listFileModel.get(0), (FolderModel) destination)); + GWT.log("Destination: " + destination.getName() + " id " + destination.getIdentifier()); + } + } else { + // MULTIDRAG } GWT.log("***End Event move handleAppendDrop"); } @@ -509,59 +496,64 @@ public class AsyncTreePanel extends LayoutContainer { // super.onDragMove(event); // } - //Called when drop between files + // Called when drop between files @Override protected void handleInsertDrop(DNDEvent event, @SuppressWarnings("rawtypes") TreeNode item, int index) { super.handleInsertDrop(event, item, index); GWT.log("***Event move handleInsertDrop"); - List listFileModel = getDragSource(event); - if(listFileModel.size() == 1){ //one element dragged + List listFileModel = getDragSource(event); + if (listFileModel.size() == 1) { // one element dragged FileModel destination = getDragDestination(item, DragType.INSERT); - if(destination != null){ - GWT.log("Destination: " +destination.getName() + " id "+ destination.getIdentifier()); - //REMOVE THIS COMMENT TODO - eventBus.fireEvent(new DragOnTreeMoveItemEvent(listFileModel.get(0), (FolderModel) destination)); + if (destination != null) { + GWT.log("Destination: " + destination.getName() + " id " + destination.getIdentifier()); + // REMOVE THIS COMMENT TODO + eventBus.fireEvent( + new DragOnTreeMoveItemEvent(listFileModel.get(0), (FolderModel) destination)); } - }else{ - //multi drag + } else { + // multi drag } GWT.log("***End Event move handleInsertDrop"); } - private FileModel getDragDestination(@SuppressWarnings("rawtypes") TreeNode item, DragType insertType){ + private FileModel getDragDestination(@SuppressWarnings("rawtypes") TreeNode item, DragType insertType) { FileModel destination = null; - if(item!=null){ + if (item != null) { destination = (FileModel) item.getModel(); - if(destination != null){ - if(insertType.equals(DragType.APPEND)) - return destination; //APPEND ON FOLDER + if (destination != null) { + if (insertType.equals(DragType.APPEND)) + return destination; // APPEND ON FOLDER else - return destination.getParentFileModel(); //INSERT BETWEEN FILE - RETUR FOLDER PARENT + return destination.getParentFileModel(); // INSERT BETWEEN FILE - RETUR FOLDER PARENT } } return destination; } - private List getDragSource(DNDEvent event){ + private List getDragSource(DNDEvent event) { - List listDraggedFile = new ArrayList(); + List listDraggedFile = new ArrayList(); - if(event.getData() != null){ - List listItemsSource = event.getData(); + if (event.getData() != null) { + List listItemsSource = event.getData(); GWT.log("Number of move " + listItemsSource.size()); - FileModel sourceFileModel = null; //for print + FileModel sourceFileModel = null; // for print - for(TreeStoreModel itemSource : listItemsSource){ + for (TreeStoreModel itemSource : listItemsSource) { listDraggedFile.add((FileModel) itemSource.getModel()); sourceFileModel = (FileModel) itemSource.getModel(); - if(sourceFileModel.getParentFileModel()!=null) - GWT.log("Source Name " + sourceFileModel.getName() + " id " + sourceFileModel.getIdentifier() + " end drag " + " Parent Name: " + sourceFileModel.getParentFileModel().getName() + "id " + sourceFileModel.getParentFileModel().getIdentifier()); + if (sourceFileModel.getParentFileModel() != null) + GWT.log("Source Name " + sourceFileModel.getName() + " id " + + sourceFileModel.getIdentifier() + " end drag " + " Parent Name: " + + sourceFileModel.getParentFileModel().getName() + "id " + + sourceFileModel.getParentFileModel().getIdentifier()); else - GWT.log("Source Name " + sourceFileModel.getName() + " id " + sourceFileModel.getIdentifier() + " end drag "); + GWT.log("Source Name " + sourceFileModel.getName() + " id " + + sourceFileModel.getIdentifier() + " end drag "); GWT.log("Child count: " + itemSource.getChildCount()); } @@ -582,7 +574,6 @@ public class AsyncTreePanel extends LayoutContainer { // targetTreePanel.setAllowDropOnLeaf(true); } - /** * Adds the listners. */ @@ -595,7 +586,7 @@ public class AsyncTreePanel extends LayoutContainer { FileModel fileModel = objEvent.getSelectedItem(); - if(rightClick){ + if (rightClick) { // treePanel.disableEvents(true); // deselectItem(fileModel); // treePanel.enableEvents(true); @@ -604,16 +595,16 @@ public class AsyncTreePanel extends LayoutContainer { System.out.println("***Event selection change"); - if(fileModel != null && !isSearch){ //is null on drag & drop event + if (fileModel != null && !isSearch) { // is null on drag & drop event - //For printing + // For printing String type; - if(fileModel.getType()!=null) + if (fileModel.getType() != null) type = fileModel.getType(); else type = "null"; - //DEBUG + // DEBUG // String folderItemType; // if(fileModel.getGXTFolderItemType()!=null) // folderItemType = fileModel.getGXTFolderItemType().toString(); @@ -630,7 +621,6 @@ public class AsyncTreePanel extends LayoutContainer { } - System.out.println("***End Event selection change"); } @@ -639,25 +629,25 @@ public class AsyncTreePanel extends LayoutContainer { // // Listner on Click treePanel.addListener(Events.OnClick, new Listener>() { - public void handleEvent(TreePanelEvent be) { + public void handleEvent(TreePanelEvent be) { - if(be != null){ - if(isSearch){ //TODO WORK AROUND - used after search - setSearch(false); + if (be != null) { + if (isSearch) { // TODO WORK AROUND - used after search + setSearch(false); // FileModel fileModel = (FileModel) be.getNode().getModel(); // reSelectItem(fileModel.getIdentifier()); - TreeNode node = be.getNode(); + TreeNode node = be.getNode(); - if(node!=null){ - FileModel fileModel = (FileModel) be.getNode().getModel(); - reSelectItem(fileModel.getIdentifier()); - } - } + if (node != null) { + FileModel fileModel = (FileModel) be.getNode().getModel(); + reSelectItem(fileModel.getIdentifier()); } + } + } - }; - }); + }; + }); // // Listner on Menu Hide treePanel.getContextMenu().addListener(Events.Hide, new Listener() { @@ -665,33 +655,32 @@ public class AsyncTreePanel extends LayoutContainer { @Override public void handleEvent(MenuEvent be) { - if(be!=null) + if (be != null) deselectItem(treePanel.getSelectionModel().getSelectedItem()); } }); - treePanel.addListener(Events.BeforeExpand, new Listener>() { - public void handleEvent(final TreePanelEvent be) { + public void handleEvent(final TreePanelEvent be) { - if(be != null && !isSubTreeLoaded){ + if (be != null && !isSubTreeLoaded) { - GWT.log("***Event beforeExpand Node"); + GWT.log("***Event beforeExpand Node"); GWT.log("Expand Folder Model: " + be.getNode().getModel().get(FileModel.NAME)); final FolderModel folder = (FolderModel) be.getNode().getModel(); int numChildrenFolder = store.getChildCount(folder); - if (folder!=null){ + if (folder != null) { eventBus.fireEvent(new ExpandFolderEvent(folder)); - if (numChildrenFolder==0) { - treePanel.mask(ConstantsExplorer.LOADING,ConstantsExplorer.LOADINGSTYLE); + if (numChildrenFolder == 0) { + treePanel.mask(ConstantsExplorer.LOADING, ConstantsExplorer.LOADINGSTYLE); loadTreeLevelFromWorkspace(folder); } } GWT.log("***End Event beforeExpand Node"); - } - } - }); + } + } + }); // Add lister to context menu treePanel.addListener(Events.ContextMenu, new Listener>() { @@ -703,12 +692,12 @@ public class AsyncTreePanel extends LayoutContainer { @SuppressWarnings("rawtypes") TreeNode node = be.getNode(); - if(node!=null){ + if (node != null) { GWT.log("Menu on: " + node.getModel().get(FileModel.NAME)); - GWT.log("node "+ treePanel.findNode(be.getTarget())); - }else{ + GWT.log("node " + treePanel.findNode(be.getTarget())); + } else { GWT.log("Menu on: null"); - GWT.log("node "+ treePanel.findNode(be.getTarget())); + GWT.log("node " + treePanel.findNode(be.getTarget())); } List listSelected = treePanel.getSelectionModel().getSelectedItems(); // @@ -718,67 +707,67 @@ public class AsyncTreePanel extends LayoutContainer { // } - }); - } - /** * Manage context menu. */ - private void manageContextMenu(){ + private void manageContextMenu() { - contextMenuTree.setListSelectedItems(treePanel.getSelectionModel().getSelectedItems()); //Set items list selected in context menu tree + contextMenuTree.setListSelectedItems(treePanel.getSelectionModel().getSelectedItems()); // Set items list + // selected in context + // menu tree List selectedItems = treePanel.getSelectionModel().getSelectedItems(); - contextMenuTree.viewContextMenu(selectedItems,-1,-1); + contextMenuTree.viewContextMenu(selectedItems, -1, -1); } - /** * Reload tree level and expand folder. * * @param folderIdentifier the folder identifier - * @param expandFolder the expand folder + * @param expandFolder the expand folder */ - public void reloadTreeLevelAndExpandFolder(String folderIdentifier, boolean expandFolder){ + public void reloadTreeLevelAndExpandFolder(String folderIdentifier, boolean expandFolder) { FolderModel folder = (FolderModel) getFileModelByIdentifier(folderIdentifier); - if(folder!=null) + if (folder != null) reloadTreeLevelAndExpandFolder(folder, expandFolder); } /** * Adds the item id and expand folder. * - * @param parent the parent - * @param itemId the item id + * @param parent the parent + * @param itemId the item id * @param expandFolder the expand folder */ - public void addItemIdAndExpandFolder(final FileModel parent, String itemId, boolean expandFolder){ + public void addItemIdAndExpandFolder(final FileModel parent, String itemId, boolean expandFolder) { - treePanel.mask(ConstantsExplorer.VALIDATINGOPERATION,ConstantsExplorer.LOADINGSTYLE); + treePanel.mask(ConstantsExplorer.VALIDATINGOPERATION, ConstantsExplorer.LOADINGSTYLE); - AppControllerExplorer.rpcWorkspaceService.getItemForFileTree(itemId, new AsyncCallback(){ + AppControllerExplorer.rpcWorkspaceService.getItemForFileTree(itemId, new AsyncCallback() { @Override public void onFailure(Throwable caught) { - if(caught instanceof SessionExpiredException){ + if (caught instanceof SessionExpiredException) { GWT.log("Session expired"); eventBus.fireEvent(new SessionExpiredEvent()); return; } treePanel.unmask(); - new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting item from workspace." +ConstantsExplorer.TRY_AGAIN, null); + new MessageBoxAlert("Error", + ConstantsExplorer.SERVER_ERROR + " getting item from workspace." + ConstantsExplorer.TRY_AGAIN, + null); removeAllAndRecoveryRoot(); } @Override public void onSuccess(FileModel result) { - GWT.log("GetItemForFileTree adding: "+result); + GWT.log("GetItemForFileTree adding: " + result); treePanel.unmask(); - store.add(parent,result,false); + store.add(parent, result, false); } }); } @@ -786,38 +775,39 @@ public class AsyncTreePanel extends LayoutContainer { /** * Reload tree level and expand folder. * - * @param folder the folder + * @param folder the folder * @param expandFolder the expand folder */ - private void reloadTreeLevelAndExpandFolder(final FolderModel folder, final boolean expandFolder){ - GWT.log("Calling Reload Tree Level and Exand folder: "+expandFolder +" for folder : "+folder.getName()); + private void reloadTreeLevelAndExpandFolder(final FolderModel folder, final boolean expandFolder) { + GWT.log("Calling Reload Tree Level and Exand folder: " + expandFolder + " for folder : " + folder.getName()); - AppControllerExplorer.rpcWorkspaceService.getFolderChildren(folder, new AsyncCallback>(){ + AppControllerExplorer.rpcWorkspaceService.getFolderChildren(folder, new AsyncCallback>() { - @Override - public void onFailure(Throwable caught) { + @Override + public void onFailure(Throwable caught) { - if(caught instanceof SessionExpiredException){ - GWT.log("Session expired"); - eventBus.fireEvent(new SessionExpiredEvent()); - return; + if (caught instanceof SessionExpiredException) { + GWT.log("Session expired"); + eventBus.fireEvent(new SessionExpiredEvent()); + return; + } + treePanel.unmask(); + new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting folder children items." + + ConstantsExplorer.TRY_AGAIN, null); + removeAllAndRecoveryRoot(); } - treePanel.unmask(); - new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting folder children items." +ConstantsExplorer.TRY_AGAIN, null); - removeAllAndRecoveryRoot(); - } - @Override - public void onSuccess(List result) { - GWT.log("Refresh TREE with results: "+result); - treePanel.mask(ConstantsExplorer.VALIDATINGOPERATION,ConstantsExplorer.LOADINGSTYLE); - store.removeAll(folder); + @Override + public void onSuccess(List result) { + GWT.log("Refresh TREE with results: " + result); + treePanel.mask(ConstantsExplorer.VALIDATINGOPERATION, ConstantsExplorer.LOADINGSTYLE); + store.removeAll(folder); // addChildrenToFolder(folder.getIdentifier(), result); - addChildrenToFolder(folder, result); - setExpandTreeLevel(folder, expandFolder); - treePanel.unmask(); - } - }); + addChildrenToFolder(folder, result); + setExpandTreeLevel(folder, expandFolder); + treePanel.unmask(); + } + }); } @@ -826,29 +816,30 @@ public class AsyncTreePanel extends LayoutContainer { * * @param folder the folder */ - private void loadTreeLevelFromWorkspace(final FolderModel folder){ + private void loadTreeLevelFromWorkspace(final FolderModel folder) { GWT.log("Start RPC - getFolderChildren"); // Log.info("Start RPC - getFolderChildren"); // final CountTimer count = new CountTimer(1000); - AppControllerExplorer.rpcWorkspaceService.getFolderChildren(folder, new AsyncCallback>(){ + AppControllerExplorer.rpcWorkspaceService.getFolderChildren(folder, new AsyncCallback>() { @Override public void onFailure(Throwable caught) { - if(caught instanceof SessionExpiredException){ + if (caught instanceof SessionExpiredException) { GWT.log("Session expired"); eventBus.fireEvent(new SessionExpiredEvent()); return; } - new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting folder children items. " +ConstantsExplorer.TRY_AGAIN, null); + new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting folder children items. " + + ConstantsExplorer.TRY_AGAIN, null); removeAllAndRecoveryRoot(); } @Override public void onSuccess(List result) { - if(treePanel.isMasked()) + if (treePanel.isMasked()) treePanel.unmask(); store.removeAll(folder); @@ -868,24 +859,24 @@ public class AsyncTreePanel extends LayoutContainer { * @param idParent the id parent * @param children the children */ - public void addChildrenToFolder(String idParent, List children){ + public void addChildrenToFolder(String idParent, List children) { FileModel parent = getFileModelByIdentifier(idParent); - if(parent!=null) - store.add(parent,children,false); + if (parent != null) + store.add(parent, children, false); } /** * Adds the children to folder. * - * @param parent the parent + * @param parent the parent * @param children the children */ - private void addChildrenToFolder(FolderModel parent, List children){ + private void addChildrenToFolder(FolderModel parent, List children) { - if(parent!=null){ - store.add(parent,children,false); + if (parent != null) { + store.add(parent, children, false); System.out.println("Added children in store"); } } @@ -895,26 +886,17 @@ public class AsyncTreePanel extends LayoutContainer { * * @param bool the new visible rename and remove context menu */ - private void setVisibleRenameAndRemoveContextMenu(boolean bool){ + private void setVisibleRenameAndRemoveContextMenu(boolean bool) { treePanel.getContextMenu().getItemByItemId(WorkspaceOperation.REMOVE.getId()).setVisible(bool); treePanel.getContextMenu().getItemByItemId(WorkspaceOperation.RENAME.getId()).setVisible(bool); } -// /** -// * Sets the visibile get web dav url. -// * -// * @param bool the new visibile get web dav url -// */ -// private void setVisibileGetWebDavUrl(boolean bool){ -// treePanel.getContextMenu().getItemByItemId(WorkspaceOperation.WEBDAV_URL.getId()).setVisible(bool); -// } - /** * Sets the alphanumeric store sorter. */ - private void setAlphanumericStoreSorter(){ + private void setAlphanumericStoreSorter() { // Sorting files store.setStoreSorter(new StoreSorter() { @@ -930,9 +912,9 @@ public class AsyncTreePanel extends LayoutContainer { return 1; } - if(m1.isSpecialFolder() && !m2.isSpecialFolder()) + if (m1.isSpecialFolder() && !m2.isSpecialFolder()) return -1; - else if(!m1.isSpecialFolder() && m2.isSpecialFolder()) + else if (!m1.isSpecialFolder() && m2.isSpecialFolder()) return 1; return m1.getName().compareToIgnoreCase(m2.getName()); @@ -940,25 +922,20 @@ public class AsyncTreePanel extends LayoutContainer { }); } - //TODO for debug + // for debugging /** * Printing tree level. * * @param item the item */ - private void printingTreeLevel(FileModel item){ - + private void printingTreeLevel(FileModel item) { List children = treePanel.getStore().getChildren(item); - if (children != null) { - for (FileModel item2 : children) { - - System.out.println(" " + item2.getName() + " ID " + item2.getIdentifier() + " isDirectory " + item.isDirectory()); - + System.out.println(" " + item2.getName() + " ID " + item2.getIdentifier() + " isDirectory " + + item.isDirectory()); printingTreeLevel(item2); } - System.out.println(" "); } } @@ -969,7 +946,7 @@ public class AsyncTreePanel extends LayoutContainer { * @param identifier the identifier * @return the file model by identifier */ - public FileModel getFileModelByIdentifier(String identifier){ + public FileModel getFileModelByIdentifier(String identifier) { return treePanel.getStore().findModel(FileModel.IDENTIFIER, identifier); } @@ -980,7 +957,7 @@ public class AsyncTreePanel extends LayoutContainer { * @param identifier the identifier * @return the children number */ - public int getChildrenNumber(String identifier){ + public int getChildrenNumber(String identifier) { FolderModel fileModel = (FolderModel) getFileModelByIdentifier(identifier); return getChildrenNumber(fileModel); @@ -992,12 +969,11 @@ public class AsyncTreePanel extends LayoutContainer { * @param folder the folder * @return the children number */ - private int getChildrenNumber(FolderModel folder){ + private int getChildrenNumber(FolderModel folder) { return store.getChildCount(folder); } - /** * Delete item. * @@ -1008,52 +984,48 @@ public class AsyncTreePanel extends LayoutContainer { FileModel fileTarget = getFileModelByIdentifier(identifier); - if(fileTarget!=null){ + if (fileTarget != null) { return deleteItem(fileTarget); - } - else - System.out.println("Delete Error: file target with " + identifier + " identifier not exist in store" ); + } else + System.out.println("Delete Error: file target with " + identifier + " identifier not exist in store"); return false; } - /** * Rename item. * * @param fileTarget (MANDATORY) - * @param newName (MANDATORY) - * @param extension OPTIONAL - string or null + * @param newName (MANDATORY) + * @param extension OPTIONAL - string or null * @return true, if successful */ private boolean renameItem(FileModel fileTarget, String newName, String extension) { - if(fileTarget!=null){ + if (fileTarget != null) { Record record = treePanel.getStore().getRecord(fileTarget); - if(record!=null){ - if(extension!= null) - record.set(FileModel.NAME, newName+extension); + if (record != null) { + if (extension != null) + record.set(FileModel.NAME, newName + extension); else record.set(FileModel.NAME, newName); return true; - } - else - System.out.println("Record Error: file target with " + fileTarget.getIdentifier() + " identifier not exist in store" ); - } - else - System.out.println("Rename Error: file target not exist in store" ); + } else + System.out.println("Record Error: file target with " + fileTarget.getIdentifier() + + " identifier not exist in store"); + } else + System.out.println("Rename Error: file target not exist in store"); return false; } - /** * Rename item. * * @param identifier the identifier - * @param newName (MANDATORY) - * @param extension OPTIONAL - string or null + * @param newName (MANDATORY) + * @param extension OPTIONAL - string or null * @return true, if successful */ public boolean renameItem(String identifier, String newName, String extension) { @@ -1062,7 +1034,7 @@ public class AsyncTreePanel extends LayoutContainer { FileModel fileTarget = getFileModelByIdentifier(identifier); - return renameItem(fileTarget,newName,extension); + return renameItem(fileTarget, newName, extension); } @@ -1083,9 +1055,8 @@ public class AsyncTreePanel extends LayoutContainer { return true; } else - System.out.println("Record Error: file target with " - + fileTarget.getIdentifier() - + " identifier not exist in store"); + System.out.println( + "Record Error: file target with " + fileTarget.getIdentifier() + " identifier not exist in store"); return false; @@ -1094,22 +1065,21 @@ public class AsyncTreePanel extends LayoutContainer { /** * Adds the item. * - * @param parentId the parent id - * @param child the child + * @param parentId the parent id + * @param child the child * @param addChildren the add children */ public void addItem(String parentId, FileModel child, boolean addChildren) { FileModel parent = getFileModelByIdentifier(parentId); - if(parent!=null) - addItem(parent,child,addChildren); + if (parent != null) + addItem(parent, child, addChildren); } - /** * Adds the item. * - * @param parent the parent - * @param child the child + * @param parent the parent + * @param child the child * @param addChildren the add children */ private void addItem(FileModel parent, FileModel child, boolean addChildren) { @@ -1120,7 +1090,7 @@ public class AsyncTreePanel extends LayoutContainer { * Sets the expand tree level. * * @param parent the parent - * @param bool expand true/false + * @param bool expand true/false */ private void setExpandTreeLevel(FileModel parent, boolean bool) { treePanel.setExpanded(parent, bool); @@ -1132,15 +1102,14 @@ public class AsyncTreePanel extends LayoutContainer { * @param identifier the identifier * @return true, if is expanded */ - public boolean isExpanded(String identifier){ + public boolean isExpanded(String identifier) { - if(identifier==null) + if (identifier == null) return false; - FileModel fileTarget = getFileModelByIdentifier(identifier); - if(fileTarget==null) + if (fileTarget == null) return false; return treePanel.isExpanded(fileTarget); @@ -1150,11 +1119,11 @@ public class AsyncTreePanel extends LayoutContainer { * Sets the expand tree level. * * @param identifier the identifier - * @param bool the bool + * @param bool the bool */ public void setExpandTreeLevel(String identifier, boolean bool) { FileModel item = getFileModelByIdentifier(identifier); - if(item!=null) + if (item != null) treePanel.setExpanded(item, bool); } @@ -1164,11 +1133,11 @@ public class AsyncTreePanel extends LayoutContainer { * @param identifier the identifier * @return true, if successful */ - public boolean selectItem(String identifier){ + public boolean selectItem(String identifier) { FileModel fileTarget = getFileModelByIdentifier(identifier); - if(fileTarget!=null){ - treePanel.getSelectionModel().select(fileTarget, true); //Select the item + if (fileTarget != null) { + treePanel.getSelectionModel().select(fileTarget, true); // Select the item return true; } return false; @@ -1180,12 +1149,12 @@ public class AsyncTreePanel extends LayoutContainer { * @param identifier the identifier * @return true, if successful */ - public boolean reSelectItem(String identifier){ + public boolean reSelectItem(String identifier) { FileModel fileTarget = getFileModelByIdentifier(identifier); - if(fileTarget!=null){ + if (fileTarget != null) { treePanel.getSelectionModel().deselect(fileTarget); - treePanel.getSelectionModel().select(fileTarget, true); //Select the item + treePanel.getSelectionModel().select(fileTarget, true); // Select the item return true; } return false; @@ -1198,10 +1167,10 @@ public class AsyncTreePanel extends LayoutContainer { * @return true, if successful */ @SuppressWarnings("unused") - private boolean selectItem(FileModel fileTarget){ + private boolean selectItem(FileModel fileTarget) { - if(fileTarget!=null){ - treePanel.getSelectionModel().select(fileTarget, true); //Select the item + if (fileTarget != null) { + treePanel.getSelectionModel().select(fileTarget, true); // Select the item return true; } return false; @@ -1228,7 +1197,7 @@ public class AsyncTreePanel extends LayoutContainer { /** * Select root by default. */ - public void removeAllAndRecoveryRoot(){ + public void removeAllAndRecoveryRoot() { store.removeAll(); loadRootItem(true); } @@ -1238,7 +1207,7 @@ public class AsyncTreePanel extends LayoutContainer { * * @param selectRoot the select root */ - public void removeAllAndRecoveryRoot(boolean selectRoot){ + public void removeAllAndRecoveryRoot(boolean selectRoot) { store.removeAll(); loadRootItem(selectRoot); } @@ -1246,12 +1215,12 @@ public class AsyncTreePanel extends LayoutContainer { /** * Select root item. */ - public void selectRootItem(){ + public void selectRootItem() { FileModel selectedItem = treePanel.getSelectionModel().getSelectedItem(); - if(selectedItem!=null) - treePanel.getSelectionModel().deselect(selectedItem); + if (selectedItem != null) + treePanel.getSelectionModel().deselect(selectedItem); - treePanel.getSelectionModel().select(store.getRootItems().get(0), true); //select root item + treePanel.getSelectionModel().select(store.getRootItems().get(0), true); // select root item } /** @@ -1259,10 +1228,10 @@ public class AsyncTreePanel extends LayoutContainer { * * @param identifier the identifier */ - public void deselectItem(String identifier){ + public void deselectItem(String identifier) { FileModel fileTarget = getFileModelByIdentifier(identifier); - if(fileTarget!=null) - treePanel.getSelectionModel().deselect(fileTarget); + if (fileTarget != null) + treePanel.getSelectionModel().deselect(fileTarget); } /** @@ -1270,9 +1239,9 @@ public class AsyncTreePanel extends LayoutContainer { * * @param fileTarget the file target */ - public void deselectItem(FileModel fileTarget){ - if(fileTarget!=null) - treePanel.getSelectionModel().deselect(fileTarget); + public void deselectItem(FileModel fileTarget) { + if (fileTarget != null) + treePanel.getSelectionModel().deselect(fileTarget); } /** @@ -1280,12 +1249,12 @@ public class AsyncTreePanel extends LayoutContainer { * * @return the selected file model item */ - public FileModel getSelectedFileModelItem(){ + public FileModel getSelectedFileModelItem() { FileModel selectedItem = treePanel.getSelectionModel().getSelectedItem(); - if(selectedItem!=null) - return selectedItem; + if (selectedItem != null) + return selectedItem; - return store.getRootItems().get(0); //return root item + return store.getRootItems().get(0); // return root item } /** @@ -1310,14 +1279,13 @@ public class AsyncTreePanel extends LayoutContainer { /** * Sets the size tree panel. * - * @param width the width + * @param width the width * @param height the height */ - public void setSizeTreePanel(int width, int height){ + public void setSizeTreePanel(int width, int height) { treePanel.setSize(width, height); } - /** * Gets the context menu tree. * @@ -1332,7 +1300,7 @@ public class AsyncTreePanel extends LayoutContainer { * * @param bool the new header tree visible */ - public void setHeaderTreeVisible(boolean bool){ + public void setHeaderTreeVisible(boolean bool) { cp.setHeaderVisible(bool); } @@ -1341,7 +1309,7 @@ public class AsyncTreePanel extends LayoutContainer { * * @return the root item */ - public FileModel getRootItem(){ + public FileModel getRootItem() { return treePanel.getStore().getRootItems().get(0); } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfo.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfo.java index d080cf3..d943cb3 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfo.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfo.java @@ -114,11 +114,11 @@ public class DialogGetInfo extends Dialog { txtIsPublic.setValue(fileModel.isPublic() + ""); add(txtIsPublic); - if (fileModel.getSynchedThreddsStatus() != null) { + if (fileModel.getSynchedWithWsThredds() != null) { txtThreddsSynched = new TextField(); - txtThreddsSynched.setFieldLabel("Thredds Sync"); + txtThreddsSynched.setFieldLabel("Synched with Thredds"); txtThreddsSynched.setReadOnly(true); - txtThreddsSynched.setValue(fileModel.getSynchedThreddsStatus() + ""); + txtThreddsSynched.setValue(fileModel.getSynchedWithWsThredds() + ""); add(txtThreddsSynched); } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.java index 09c895b..a454f6c 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.java @@ -294,11 +294,16 @@ public class DialogGetInfoBootstrap extends Composite { if (fileModel.isDirectory()) { cgTxtIsPublic.setVisible(true); htmlSetValue(txtIsPublic, fileModel.isPublic() + ""); - - if (fileModel.getSynchedThreddsStatus() != null) { - txtThreddsSynched.setVisible(true); - htmlSetValue(txtThreddsSynched, fileModel.getSynchedThreddsStatus() + ""); - txtThreddsSynched.setHTML(fileModel.getSynchedThreddsStatus() + ""); + + GWT.log("Is synched? "+fileModel.getSynchedWithWsThredds()); + + if (fileModel.getSynchedWithWsThredds() != null) { + if (fileModel.getSynchedWithWsThredds()) { + cgThreddsSynched.setVisible(true); + //txtThreddsSynched.setVisible(true); + htmlSetValue(txtThreddsSynched, fileModel.getSynchedWithWsThredds() + ""); + txtThreddsSynched.setHTML(fileModel.getSynchedWithWsThredds() + ""); + } } } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.ui.xml b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.ui.xml index 4a1a391..dcb10f9 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.ui.xml +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/windows/DialogGetInfoBootstrap.ui.xml @@ -73,7 +73,7 @@ - Thredds Sync + Synched diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java index 85d7556..a5b0bae 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java @@ -32,7 +32,7 @@ import org.gcube.common.storagehubwrapper.shared.tohl.items.URLFileItem; import org.gcube.common.storagehubwrapper.shared.tohl.items.URLItem; import org.gcube.portal.wssynclibrary.shared.ItemNotSynched; import org.gcube.portal.wssynclibrary.shared.WorkspaceFolderLocked; -import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status; +import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncFolderDescriptor; import org.gcube.portal.wssynclibrary.thredds.WorkspaceThreddsSynchronize; import org.gcube.portlets.user.urlshortener.UrlShortener; import org.gcube.portlets.user.workspace.client.ConstantsExplorer; @@ -75,8 +75,10 @@ import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingEntryTyp import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField; import org.gcube.portlets.widgets.workspacesharingwidget.server.notifications.NotificationsProducer; import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel; +import org.gcube.portlets.widgets.wsthreddssync.server.ThreddsWorkspaceSyncServiceImpl; import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.queries.api.SimpleQuery; +import org.gcube.usecases.ws.thredds.faults.WorkspaceNotSynchedException; import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault; import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException; @@ -91,19 +93,18 @@ import org.slf4j.LoggerFactory; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.liferay.portal.service.UserLocalServiceUtil; - // TODO: Auto-generated Javadoc /** * The Class GWTWorkspaceServiceImpl. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Aug 1, 2019 + * Aug 1, 2019 */ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWTWorkspaceService { public static final String JCR_WILDCARD_TO_SEARCH = "%"; - public static final String CHAR_FOR_SEARCHING_WITH_EXACTLY_MATCH = "\""; //is double quote + public static final String CHAR_FOR_SEARCHING_WITH_EXACTLY_MATCH = "\""; // is double quote protected static final String IDENTIFIER_IS_NULL = "Identifier is null"; protected static final String RETRIEVING_ITEM_EITHER_ITEM_DOESN_T_EXIST = " retrieving item. Either the item doesn't exist anymore or you do not have the permission to access it"; private static final long serialVersionUID = 2828885661214875589L; @@ -148,7 +149,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT protected UrlShortener getUrlShortener() { return WsUtil.getUrlShortener(this.getThreadLocalRequest()); } - + /** * Gets the property special folder reader. * @@ -171,7 +172,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT + ConstantsExplorer.SPECIALFOLDERNAMEPROPERTIESFILE; } - /** * Gets the name for special folder. * @@ -194,8 +194,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Gets the servlet context path. * - * @param protocol - * the protocol + * @param protocol the protocol * @return the servlet context path */ @Override @@ -224,28 +223,38 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT return url.toString(); } - /** * Checks if is item under sync. * - * @param itemId - * the item id + * @param itemId the item id * @return true, if is item under sync - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public Boolean isItemUnderSync(String itemId) throws Exception { + ThSyncFolderDescriptor theConfig = null; try { - GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest()); + try { - Sync_Status status = WorkspaceThreddsSynchronize.getInstance().getSynchedStatusFromItemProperty(itemId, - user.getUsername()); + theConfig = WorkspaceThreddsSynchronize.getInstance().getConfiguration(itemId); + } catch (WorkspaceNotSynchedException e) { + workspaceLogger + .debug("WorkspaceNotSynchedException catched, the item with id: " + itemId + " is not synched"); + return false; } catch (Exception e) { + workspaceLogger.debug("Error on getting configuration for the item id: " + itemId + + ", returning null (means not synched)"); + return false; + } + + if (theConfig == null) { + workspaceLogger.debug( + "No ws-thredds config found the item with id:" + itemId + ", returning item is not synched"); return false; } - // HERE THE ITEM IS SYNCHED SO CHECK IF IT IS LOCKED + + // HERE THE ITEM IS SYNCHED SO CHECKING IF IT IS LOCKED checkItemLocked(itemId); return false; @@ -255,7 +264,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT throw new Exception("Error on checking item " + itemId + " is under sync"); } } - + /* * (non-Javadoc) * @@ -265,13 +274,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Gets the my login. * - * @param currentPortletUrl - * the current portlet url + * @param currentPortletUrl the current portlet url * @return the my login */ @Override public UserBean getMyLogin(String currentPortletUrl) { - + PortalContextInfo info = WsUtil.getPortalContext(this.getThreadLocalRequest()); String username = info.getUsername(); String email = info.getUserEmail(); @@ -301,7 +309,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT return us; } - /** * Gets the CLARIN switch board endpoint. * @@ -329,7 +336,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT ScopeProvider.instance.set(currContext); return res.profile().runtime().hostedOn(); } - + /* * (non-Javadoc) * @@ -364,8 +371,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } return firstName; } - - + /* * (non-Javadoc) * @@ -376,8 +382,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * Checks if is session expired. * * @return true, if is session expired - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public boolean isSessionExpired() throws Exception { @@ -399,13 +404,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } } - /** * Gets the workspace from storage hub. * * @return the workspace from storage hub - * @throws Exception - * the exception + * @throws Exception the exception */ protected org.gcube.common.storagehubwrapper.server.tohl.Workspace getWorkspaceFromStorageHub() throws Exception { GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest()); @@ -417,8 +420,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * Gets the storage hub to workpace converter. * * @return the storage hub to workpace converter - * @throws Exception - * the exception + * @throws Exception the exception */ protected StorageHubToWorkpaceConverter getStorageHubToWorkpaceConverter() throws Exception { GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest()); @@ -453,8 +455,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * Gets the root for tree. * * @return the root for tree - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public FolderModel getRootForTree() throws Exception { @@ -487,19 +488,17 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Delete item. * - * @param itemId - * the item id + * @param itemId the item id * @return the boolean - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public Boolean deleteItem(String itemId) throws Exception { org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem theItem = null; try { - - workspaceLogger.error("called deleteItem: "+itemId); + + workspaceLogger.error("called deleteItem: " + itemId); if (itemId == null) throw new Exception(IDENTIFIER_IS_NULL); @@ -519,11 +518,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT // HERE REMOVING THE ITEM workspaceLogger.info("Calling storageHub to delete item with id: " + itemId); workspaceSH.deleteItem(itemId); - + NotificationsProducerToStorageHub np = getNotificationProducerToStorageHub(); if (sourceFolderSharedId != null) - NotificationStorageHubUtil.checkSendNotifyRemovedItemFromShare(this.getThreadLocalRequest(), theItem.isShared(), - itemName, itemId, sourceFolderSharedId, workspaceSH, np); + NotificationStorageHubUtil.checkSendNotifyRemovedItemFromShare(this.getThreadLocalRequest(), + theItem.isShared(), itemName, itemId, sourceFolderSharedId, workspaceSH, np); return Boolean.TRUE; @@ -548,15 +547,17 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } catch (Exception e) { workspaceLogger.error("Removing item error:", e); StringBuilder error = new StringBuilder(); - if(theItem!=null && theItem.isShared()) { - if(theItem.isFolder()) { - error.append("Deleting shared folders is not supported. Please unshare it if your intent is to no longer share its content with your coworkers."); - }else { + if (theItem != null && theItem.isShared()) { + if (theItem.isFolder()) { + error.append( + "Deleting shared folders is not supported. Please unshare it if your intent is to no longer share its content with your coworkers."); + } else { error.append("Ops! This operation is not allowed, we're working hard to make this possible soon."); } throw new SHUBOperationNotAllowedException(error.toString()); - }else { - error.append("Ops an error occurred deleting the item! Either you have not the permission to delete it or a server error occurred. Please, refresh and try again"); + } else { + error.append( + "Ops an error occurred deleting the item! Either you have not the permission to delete it or a server error occurred. Please, refresh and try again"); throw new Exception(error.toString()); } } @@ -573,17 +574,14 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Gets the folder children. * - * @param folder - * the folder + * @param folder the folder * @return the folder children - * @throws Exception - * the exception - * @throws SessionExpiredException - * the session expired exception + * @throws Exception the exception + * @throws SessionExpiredException the session expired exception */ @Override public List getFolderChildren(FolderModel folder) throws Exception, SessionExpiredException { - + org.gcube.common.storagehubwrapper.server.tohl.Workspace shWorkspace; if (isSessionExpired()) @@ -594,7 +592,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT if (folder == null) throw new Exception("Folder is null"); - workspaceLogger.info("Get FolderChildren called for folder: "+folder.getIdentifier()); + workspaceLogger.info("Get FolderChildren called for folder: " + folder.getIdentifier()); shWorkspace = getWorkspaceFromStorageHub(); // REMEMBER wsItem.isRoot() is always false; @@ -604,8 +602,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT .getFilteredChildren(folder.getIdentifier(), org.gcube.common.storagehub.model.items.FolderItem.class); - workspaceLogger.info("The children are: "+children.size()); - + workspaceLogger.info("The children are: " + children.size()); + for (org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem workspaceItem : children) { workspaceLogger .trace("The ITEM: " + workspaceItem.getName() + ", is shared: " + workspaceItem.isShared() @@ -629,8 +627,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } boolean isRoot = WsUtil.isRootFolder(folder, converter); - - workspaceLogger.info("Is the workspace folder "+folder.getName() + "with id: "+folder.getIdentifier()+" the root? "+isRoot); + + workspaceLogger.info("Is the workspace folder " + folder.getName() + "with id: " + folder.getIdentifier() + + " the root? " + isRoot); // ADDING VRE FOLDER? if (isRoot) { @@ -693,19 +692,17 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Gets the folder children for file grid. * - * @param folder - * the folder + * @param folder the folder * @return the folder children for file grid - * @throws Exception - * the exception - * @throws SessionExpiredException - * the session expired exceptionworkspaceLogger.info("The children are: "+children.size()); + * @throws Exception the exception + * @throws SessionExpiredException the session expired + * exceptionworkspaceLogger.info("The children + * are: "+children.size()); */ @Override public List getFolderChildrenForFileGrid(FileModel folder) throws Exception, SessionExpiredException { - - + if (isSessionExpired()) throw new SessionExpiredException(); @@ -713,13 +710,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT if (folder == null) throw new Exception("Folder is null"); - - workspaceLogger.info("Get FolderChildrenForFileGrid called for folder: "+folder.getIdentifier()); + + workspaceLogger.info("Get FolderChildrenForFileGrid called for folder: " + folder.getIdentifier()); org.gcube.common.storagehubwrapper.server.tohl.Workspace shWorkspace = getWorkspaceFromStorageHub(); List children = shWorkspace .getChildren(folder.getIdentifier()); - workspaceLogger.info("The children are: "+children.size()); + workspaceLogger.info("The children are: " + children.size()); StorageHubToWorkpaceConverter converter = getStorageHubToWorkpaceConverter(); List listFileGridModels = new ArrayList(children.size()); // boolean isParentShared = folder.isShared(); @@ -738,7 +735,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT try { String vreFolderId = shWorkspace.getVREFoldersId(); - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem baseVREFolder = shWorkspace.getItem(vreFolderId); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem baseVREFolder = shWorkspace + .getItem(vreFolderId); FileGridModel specialFolderModel = converter.toGridFileModel(baseVREFolder, folder); specialFolderModel.setSpecialFolder(true); @@ -778,13 +776,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Gets the folder children for file grid by id. * - * @param folderId - * the folder id + * @param folderId the folder id * @return the folder children for file grid by id - * @throws Exception - * the exception - * @throws SessionExpiredException - * the session expired exception + * @throws Exception the exception + * @throws SessionExpiredException the session expired exception */ @Override public List getFolderChildrenForFileGridById(String folderId) @@ -857,8 +852,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * Gets the trash content. * * @return the trash content - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public List getTrashContent() throws Exception { @@ -891,11 +885,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Update trash content. * - * @param operation - * the operation + * @param operation the operation * @return the trash content - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public TrashContent updateTrashContent(WorkspaceTrashOperation operation) throws Exception { @@ -928,13 +920,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } } - /** * Execute operation on trash. * - * @param listTrashItemIds the list trash item ids + * @param listTrashItemIds the list trash item ids * @param destinationFolderId the destination folder id - * @param operation the operation + * @param operation the operation * @return the trash operation content * @throws Exception the exception */ @@ -965,27 +956,29 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem trashedItem = null; for (String trashItemId : listTrashItemIds) { try { - trashedItem = workspace - .getItem(trashItemId); + trashedItem = workspace.getItem(trashItemId); if (trashedItem != null && trashedItem.isTrashed()) { workspace.deleteItem(trashedItem.getId()); listUpdatedTrashIds.add(trashItemId); } } catch (Exception e) { - - workspaceLogger.warn("Error occurred on "+WorkspaceTrashOperation.DELETE_PERMANENTLY+" the item : " + trashItemId, e); + + workspaceLogger.warn("Error occurred on " + WorkspaceTrashOperation.DELETE_PERMANENTLY + + " the item : " + trashItemId, e); FileTrashedModel fakeFile = new FileTrashedModel(); fakeFile.setIdentifier(trashItemId); - String itemName = trashedItem!=null?trashedItem.getName():"item"; + String itemName = trashedItem != null ? trashedItem.getName() : "item"; fakeFile.setName(itemName); - String itemRefMsg = trashedItem.isFolder()?"folder":"file"; - itemRefMsg+=" '"+itemName+"'"; - String errorMsg = "Error occurred on deleting permanently the "+itemRefMsg; - if(e instanceof UserNotAuthorizedException) { - errorMsg = String.format("Insufficent privileges for you to delete permanently the %s", itemRefMsg); + String itemRefMsg = trashedItem.isFolder() ? "folder" : "file"; + itemRefMsg += " '" + itemName + "'"; + String errorMsg = "Error occurred on deleting permanently the " + itemRefMsg; + if (e instanceof UserNotAuthorizedException) { + errorMsg = String.format("Insufficent privileges for you to delete permanently the %s", + itemRefMsg); } - TrashOperationError error = new TrashOperationError(fakeFile,WorkspaceTrashOperation.DELETE_PERMANENTLY,errorMsg); + TrashOperationError error = new TrashOperationError(fakeFile, + WorkspaceTrashOperation.DELETE_PERMANENTLY, errorMsg); listOperationError.add(error); } } @@ -993,8 +986,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } case RESTORE: { - - if(destinationFolderId==null) + + if (destinationFolderId == null) throw new Exception("Wrong call, the destionFolderId is null"); org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem trashedItem = null; @@ -1003,26 +996,32 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT trashedItem = workspace.getItem(trashItemId); if (trashedItem != null && trashedItem.isTrashed()) { String destFolderId = destinationFolderId; - workspaceLogger.info("Trying to restore the item id: "+trashedItem.getId()+", in the folder id: "+destFolderId); + workspaceLogger.info("Trying to restore the item id: " + trashedItem.getId() + + ", in the folder id: " + destFolderId); workspace.restoreThrashItem(trashedItem.getId(), destFolderId); listUpdatedTrashIds.add(trashItemId); - //restored = true; + // restored = true; } } catch (Exception e) { - - workspaceLogger.warn("Error occurred on "+WorkspaceTrashOperation.RESTORE+" the item : " + trashItemId, e); + + workspaceLogger.warn( + "Error occurred on " + WorkspaceTrashOperation.RESTORE + " the item : " + trashItemId, + e); FileTrashedModel fakeFile = new FileTrashedModel(); fakeFile.setIdentifier(trashItemId); - String itemName = trashedItem!=null?trashedItem.getName():trashItemId; + String itemName = trashedItem != null ? trashedItem.getName() : trashItemId; fakeFile.setName(itemName); - String itemRefMsg = trashedItem.isFolder()?"folder":"file"; - itemRefMsg+=" '"+itemName+"'"; - String errorMsg = "Error occurred on restoring the "+itemRefMsg+". "+e.getMessage(); - if(e instanceof UserNotAuthorizedException) { - errorMsg = String.format("Insufficent privileges for you to restore the %s in the selected folder", itemRefMsg); + String itemRefMsg = trashedItem.isFolder() ? "folder" : "file"; + itemRefMsg += " '" + itemName + "'"; + String errorMsg = "Error occurred on restoring the " + itemRefMsg + ". " + e.getMessage(); + if (e instanceof UserNotAuthorizedException) { + errorMsg = String.format( + "Insufficent privileges for you to restore the %s in the selected folder", + itemRefMsg); } - TrashOperationError error = new TrashOperationError(fakeFile,WorkspaceTrashOperation.RESTORE,errorMsg); + TrashOperationError error = new TrashOperationError(fakeFile, WorkspaceTrashOperation.RESTORE, + errorMsg); listOperationError.add(error); } } @@ -1057,11 +1056,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Delete list items for ids. * - * @param ids - * the ids + * @param ids the ids * @return the list - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public List deleteListItemsForIds(List ids) throws Exception { @@ -1071,8 +1068,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT if (ids == null) throw new Exception("List identifiers is null"); - workspaceLogger.debug("called deleteListItemsForIds with: " + ids.size() +" id/s"); - + workspaceLogger.debug("called deleteListItemsForIds with: " + ids.size() + " id/s"); + // Workspace workspace = getWorkspace(); org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); String[] items = new String[ids.size()]; @@ -1160,15 +1157,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Creates the folder. * - * @param nameFolder - * the name folder - * @param description - * the description - * @param parent - * the parent + * @param nameFolder the name folder + * @param description the description + * @param parent the parent * @return the folder model - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public FolderModel createFolder(String nameFolder, String description, FileModel parent) throws Exception { @@ -1179,8 +1172,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT try { boolean isParentNull = parent == null; - workspaceLogger.debug("Create folder: " + nameFolder + " parent is null? "+isParentNull); - + workspaceLogger.debug("Create folder: " + nameFolder + " parent is null? " + isParentNull); + if (nameFolder == null) throw new Exception("Folder name is null"); @@ -1227,13 +1220,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Move items. * - * @param ids - * the ids - * @param destinationId - * the destination id + * @param ids the ids + * @param destinationId the destination id * @return the boolean - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public WorkspaceOperationResult moveItems(List ids, String destinationId) throws Exception { @@ -1357,15 +1347,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Rename item. * - * @param itemId - * the item id - * @param newName - * the new name - * @param previousName - * the previous name + * @param itemId the item id + * @param newName the new name + * @param previousName the previous name * @return the boolean - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public Boolean renameItem(String itemId, String newName, String previousName) throws Exception { @@ -1385,10 +1371,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT workspaceLogger.debug("Renaming item with id: " + itemId + " from old name " + previousName + ", to new name: " + newName); - //Needed to check if the item is shared - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(itemId); + // Needed to check if the item is shared + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(itemId); sourceItemIsShared = wsItem.isShared(); - + wsItem = workspace.renameItem(itemId, newName); workspaceLogger.debug("Item renamed is: " + wsItem); @@ -1398,21 +1384,23 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT try { List listSharedContact = new ArrayList(); NotificationsProducerToStorageHub np = getNotificationProducerToStorageHub(); - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem sourceShared = workspace.getRootSharedFolder(wsItem.getId()); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem sourceShared = workspace + .getRootSharedFolder(wsItem.getId()); // NotificationsManager nManager = // WsUtil.getNotificationManager(this.getThreadLocalRequest()); listSharedContact = NotificationStorageHubUtil.getListUserSharedByFolderSharedId(sourceShared, workspace); - + // THE ITEM RENAMED IS A SHARED FOLDER if (NotificationStorageHubUtil.isFolderAndShared(wsItem)) { np.notifyFolderRenamed(listSharedContact, wsItem, previousName, newName, sourceShared.getId()); } else { // THE ITEM RENAMED IS A SHARED ITEM - //if (sourceShared instanceof org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder) - np.notifyItemRenamed(listSharedContact, previousName, wsItem, - (org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) sourceShared, - workspace); + // if (sourceShared instanceof + // org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder) + np.notifyItemRenamed(listSharedContact, previousName, wsItem, + (org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) sourceShared, + workspace); } } catch (Exception e) { workspaceLogger.error("An error occurred in checkNotify ", e); @@ -1433,7 +1421,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT // String error = "An error occurred on renaming item. " + ConstantsExplorer.ERROR_ITEM_DOES_NOT_EXIST; // workspaceLogger.error(error, e2); // throw new Exception(error); - //TO STORAGEHUB EXCEPTION + // TO STORAGEHUB EXCEPTION } catch (UserNotAuthorizedException e) { String error = "Insufficient Privileges to rename the item"; workspaceLogger.error(error, e); @@ -1441,14 +1429,15 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } catch (Exception e) { workspaceLogger.error("Renaming item error:", e); StringBuilder error = new StringBuilder(); - if(sourceItemIsShared) { + if (sourceItemIsShared) { error.append("Renaming shared folders is not supported"); throw new SHUBOperationNotAllowedException(error.toString()); - }else { - error.append("Ops an error occurred renaming the item! Either you have not the permission to rename it or a server error occurred. Please, refresh and try again"); + } else { + error.append( + "Ops an error occurred renaming the item! Either you have not the permission to rename it or a server error occurred. Please, refresh and try again"); throw new Exception(error.toString()); } - + } } @@ -1461,13 +1450,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Copy items. * - * @param idsItem - * the ids item - * @param destinationFolderId - * the destination folder id + * @param idsItem the ids item + * @param destinationFolderId the destination folder id * @return the workspace operation result - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public WorkspaceOperationResult copyItems(List idsItem, String destinationFolderId) throws Exception { @@ -1567,13 +1553,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Gets the public link for file item id. * - * @param itemId - * the item id - * @param shortenUrl - * the shorten url + * @param itemId the item id + * @param shortenUrl the shorten url * @return the public link for file item id - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public PublicLink getPublicLinkForFileItemId(String itemId, boolean shortenUrl) throws Exception { @@ -1622,11 +1605,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Gets the version history. * - * @param fileIdentifier - * the file identifier + * @param fileIdentifier the file identifier * @return the version history - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public List getVersionHistory(String fileIdentifier) throws Exception { @@ -1663,8 +1644,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Gets the public link for file item id to version. * - * @param itemId the item id - * @param version the version + * @param itemId the item id + * @param version the version * @param shortenUrl the shorten url * @return the public link for file item id to version * @throws Exception the exception @@ -1720,19 +1701,16 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT throw new Exception(e.getMessage()); } } - /** * Gets the list parents by item identifier. * - * @param itemIdentifier - * the item identifier - * @param includeItemAsParent - * - if parameter is true and item passed in input is a folder, - * the folder is included in path returned as last parent + * @param itemIdentifier the item identifier + * @param includeItemAsParent - if parameter is true and item passed in input is + * a folder, the folder is included in path returned + * as last parent * @return the list parents by item identifier - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public List getListParentsByItemIdentifier(String itemIdentifier, boolean includeItemAsParent) @@ -1751,57 +1729,64 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); StorageHubToWorkpaceConverter converter = getStorageHubToWorkpaceConverter(); - List parents = workspace.getParentsById(itemIdentifier); + List parents = workspace + .getParentsById(itemIdentifier); workspaceLogger.info("The Parents returned by SHUB are: " + parents.size()); - if(workspaceLogger.isTraceEnabled()) { + if (workspaceLogger.isTraceEnabled()) { workspaceLogger.trace("They are: "); for (org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem workspaceItem : parents) { workspaceLogger.trace(workspaceItem.getName()); } } - - if(parents.size()==0) { - //IT IS THE ROOT - workspaceLogger.info("The item id "+itemIdentifier+" is the root, returning empty list"); + + if (parents.size() == 0) { + // IT IS THE ROOT + workspaceLogger.info("The item id " + itemIdentifier + " is the root, returning empty list"); return new ArrayList(1); } - + String nameSpecialFolder = getNameForSpecialFolder(); - + List arrayParents = new ArrayList(parents.size()); - //loop from last to first index of list of parents - int lastIndex = parents.size()-1; - for (int i=lastIndex; i>=0; i--) { + // loop from last to first index of list of parents + int lastIndex = parents.size() - 1; + for (int i = lastIndex; i >= 0; i--) { org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsFolder = parents.get(i); - workspaceLogger.trace("Adding the item "+ wsFolder.getName()+" at index "+i+" to list of parent"); + workspaceLogger + .trace("Adding the item " + wsFolder.getName() + " at index " + i + " to list of parent"); org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem parent = null; - if(i breadcrumbs = new ArrayList(arrayParents.size() - 1); for (int i = 1; i < arrayParents.size(); i++) { @@ -1824,62 +1809,60 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * @param itemId the item id * @return true, if successful * @throws WorkspaceFolderLocked the workspace folder locked - * @throws Exception the exception + * @throws Exception the exception */ private boolean checkItemLocked(String itemId) throws WorkspaceFolderLocked, Exception { if (itemId == null || itemId.isEmpty()) throw new Exception(IDENTIFIER_IS_NULL); - + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = null; org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = null; try { workspace = getWorkspaceFromStorageHub(); wsItem = workspace.getItem(itemId); - + ; + GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest()); + + ThreddsWorkspaceSyncServiceImpl workspaceServiceServlet = new ThreddsWorkspaceSyncServiceImpl(); // IF THE ITEM IS A FOLDER, CHECKING IT - if (wsItem.isFolder()) - WorkspaceThreddsSynchronize.getInstance().checkItemSynched(wsItem.getId()); - else { + if (wsItem.isFolder()) { + // WorkspaceThreddsSynchronize.getInstance().checkItemSynched(wsItem.getId()); + + workspaceServiceServlet.getConfiguration(itemId, true, this.getThreadLocalRequest(),user); + } else { // IF THE ITEM IS A FILE, CHECKING ITS PARENT - String parentId = wsItem.getParentId(); - if(parentId==null) { + String parentId = wsItem.getParentId(); + if (parentId == null) { workspaceLogger.warn("I'm not able to check the lock because the parent id is null"); - }else { - WorkspaceThreddsSynchronize.getInstance().checkItemSynched(parentId); + } else { + //WorkspaceThreddsSynchronize.getInstance().checkItemSynched(parentId); + workspaceServiceServlet.getConfiguration(itemId, true, this.getThreadLocalRequest(),user); } } // in this case the folder is synched but not locked return false; } catch (ItemNotSynched e1) { - // in this case the folder is not synched; return false; } catch (WorkspaceFolderLocked e2) { // in this case the folder synching is on-going and the folder is // locked; - String msg = "The folder"; msg += wsItem != null ? ": " + wsItem.getName() : ""; msg += " is locked by a sync. You can not change its content"; workspaceLogger.warn(msg, e2); throw new WorkspaceFolderLocked(itemId, msg); -// } catch (InternalErrorException | ItemNotFoundException | HomeNotFoundException -// | WorkspaceFolderNotFoundException e) { -// workspaceLogger.warn(e); -// throw new Exception("Sorry an error occurred during checking is folder locked, Refresh and try again"); - } catch (Exception e) { - workspaceLogger - .warn("Was there an Exception HL side? Ignoring it.. returning false (that means item not locked)"); + workspaceLogger.warn( + "Was there an Exception SHUB or SyncEngine side? Ignoring it.. returning false (that means item not locked)"); return false; } } - /** * Gets the item for file grid. @@ -1888,29 +1871,33 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * @return the item for file grid * @throws Exception the exception */ - /* (non-Javadoc) - * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getItemForFileGrid(java.lang.String) + /* + * (non-Javadoc) + * + * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService# + * getItemForFileGrid(java.lang.String) */ @Override public FileGridModel getItemForFileGrid(String itemId) throws Exception { try { - + if (itemId == null) throw new Exception(IDENTIFIER_IS_NULL); - - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(itemId); + + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(itemId); StorageHubToWorkpaceConverter converter = getStorageHubToWorkpaceConverter(); FileModel parentModel = null; - if(wsItem.getParentId()!=null) { - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem parent = workspace.getItem(wsItem.getParentId()); + if (wsItem.getParentId() != null) { + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem parent = workspace + .getItem(wsItem.getParentId()); parentModel = converter.toTreeFileModel(parent, null, parent.isShared()); } - + return converter.toGridFileModel(wsItem, parentModel); - + } catch (Exception e) { workspaceLogger.error("Error in server during item retrieving, getItemForFileGrid", e); String error = ConstantsExplorer.SERVER_ERROR + RETRIEVING_ITEM_EITHER_ITEM_DOESN_T_EXIST; @@ -1918,7 +1905,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } } - /** * Gets the item for file tree. * @@ -1926,8 +1912,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * @return the item for file tree * @throws Exception the exception */ - /* (non-Javadoc) - * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getItemForFileTree(java.lang.String) + /* + * (non-Javadoc) + * + * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService# + * getItemForFileTree(java.lang.String) */ @Override public FileModel getItemForFileTree(String itemId) throws Exception { @@ -1936,18 +1925,18 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT if (itemId == null) throw new Exception(IDENTIFIER_IS_NULL); - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(itemId); - + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(itemId); + StorageHubToWorkpaceConverter converter = getStorageHubToWorkpaceConverter(); FileModel parentModel = null; org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem parent = null; - if(wsItem.getParentId()!=null) { + if (wsItem.getParentId() != null) { parent = workspace.getItem(wsItem.getParentId()); parentModel = converter.toTreeFileModel(parent, null, parent.isShared()); } - - return converter.toTreeFileModel(wsItem, parentModel, parent!=null?parent.isShared():false); + + return converter.toTreeFileModel(wsItem, parentModel, parent != null ? parent.isShared() : false); } catch (Exception e) { workspaceLogger.error("Error in server during item retrieving, getItemForFileGrid", e); @@ -1955,19 +1944,22 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT throw new Exception(error); } } - /** * Gets the image by id. * - * @param identifier the identifier + * @param identifier the identifier * @param isInteralImage the is interal image - * @param fullDetails the full details + * @param fullDetails the full details * @return the image by id * @throws Exception the exception */ - /* (non-Javadoc) - * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getImageById(java.lang.String, boolean, boolean) + /* + * (non-Javadoc) + * + * @see + * org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getImageById + * (java.lang.String, boolean, boolean) */ @Override public GWTWorkspaceItem getImageById(String identifier, boolean isInteralImage, boolean fullDetails) @@ -1976,20 +1968,19 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT if (identifier == null) throw new Exception(IDENTIFIER_IS_NULL); - try { workspaceLogger.debug("get image by id: " + identifier); - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(identifier); - - if(wsItem instanceof ImageFileItem) { + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(identifier); + + if (wsItem instanceof ImageFileItem) { ImageFileItem imageFile = (ImageFileItem) wsItem; PortalContextInfo context = WsUtil.getPortalContext(this.getThreadLocalRequest()); GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest()); - return ObjectStorageHubToWorkpaceMapper.buildGWTWorkspaceImage(imageFile, isInteralImage, fullDetails, context.getCurrGroupId() + "", - user.getUserId() + ""); - }else { + return ObjectStorageHubToWorkpaceMapper.buildGWTWorkspaceImage(imageFile, isInteralImage, fullDetails, + context.getCurrGroupId() + "", user.getUserId() + ""); + } else { throw new Exception("The input id is not an image"); } } catch (Exception e) { @@ -1997,7 +1988,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT throw new Exception(e.getMessage()); } } - + /* * (non-Javadoc) * @@ -2007,15 +1998,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Gets the url by id. * - * @param identifier - * the identifier - * @param isInternalUrl - * the is internal url - * @param fullDetails - * the full details + * @param identifier the identifier + * @param isInternalUrl the is internal url + * @param fullDetails the full details * @return the url by id - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public GWTWorkspaceItem getUrlById(String identifier, boolean isInternalUrl, boolean fullDetails) throws Exception { @@ -2026,17 +2013,18 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT throw new Exception(IDENTIFIER_IS_NULL); workspaceLogger.debug("get URL by id: " + identifier); - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(identifier); - // workspace - - if(wsItem instanceof org.gcube.common.storagehubwrapper.shared.tohl.impl.URLFileItem) { + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(identifier); + // workspace + + if (wsItem instanceof org.gcube.common.storagehubwrapper.shared.tohl.impl.URLFileItem) { URLFileItem fileItem = (URLFileItem) wsItem; - return ObjectStorageHubToWorkpaceMapper.buildGWTWorspaceUrl(workspace, fileItem, isInternalUrl, fullDetails); - }else if (wsItem instanceof URLItem){ + return ObjectStorageHubToWorkpaceMapper.buildGWTWorspaceUrl(workspace, fileItem, isInternalUrl, + fullDetails); + } else if (wsItem instanceof URLItem) { URLItem urlFile = (URLItem) wsItem; return new GWTExternalUrl(urlFile.getValue().toString()); - }else { + } else { throw new Exception("The input id is not a FILE or a URL"); } @@ -2048,16 +2036,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } } - /** * Sets the value in session. * - * @param name - * the name - * @param value - * the value - * @throws Exception - * the exception + * @param name the name + * @param value the value + * @throws Exception the exception */ @Override public void setValueInSession(String name, String value) throws Exception { @@ -2070,7 +2054,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT throw new Exception(e.getMessage()); } } - /** * Gets the item creation date by id. @@ -2079,8 +2062,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * @return the item creation date by id * @throws Exception the exception */ - /* (non-Javadoc) - * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getItemCreationDateById(java.lang.String) + /* + * (non-Javadoc) + * + * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService# + * getItemCreationDateById(java.lang.String) */ @Override public Date getItemCreationDateById(String itemId) throws Exception { @@ -2091,9 +2077,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT throw new Exception(IDENTIFIER_IS_NULL); workspaceLogger.debug("getItemCreationDateById by id: " + itemId); - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(itemId); - + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(itemId); + Calendar cl = wsItem.getCreationTime(); if (cl != null) @@ -2106,7 +2092,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT throw new Exception(e.getMessage()); } } - + /* * (non-Javadoc) * @@ -2116,23 +2102,21 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Load size by item id. * - * @param itemId - * the item id + * @param itemId the item id * @return the long - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public Long loadSizeByItemId(String itemId) throws Exception { - + if (itemId == null) throw new Exception(IDENTIFIER_IS_NULL); workspaceLogger.info("get Size By ItemId " + itemId); try { - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(itemId); + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(itemId); Long size = new Long(-1); if (wsItem instanceof org.gcube.common.storagehubwrapper.shared.tohl.impl.FileItem) { // ITEM @@ -2140,12 +2124,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT size = new Long(fileItem.getSize()); } else if (wsItem instanceof org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceFolder) { // FOLDER org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceFolder theFolder = (org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceFolder) wsItem; - //TODO ASK TO LUCIO; - //size = theFolder.getSize(); - } else if (wsItem instanceof org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceSharedFolder) { // SHARED FOLDER + // TODO ASK TO LUCIO; + // size = theFolder.getSize(); + } else if (wsItem instanceof org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceSharedFolder) { // SHARED + // FOLDER org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceSharedFolder theFolder = (org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceSharedFolder) wsItem; - //TODO ASK TO LUCIO; - //size = theFolder.getSize(); + // TODO ASK TO LUCIO; + // size = theFolder.getSize(); } workspaceLogger.info("returning size: " + size); return size; @@ -2155,7 +2140,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT throw new Exception(e.getMessage()); } } - /** * Load last modification date by id. @@ -2164,20 +2148,23 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * @return the date * @throws Exception the exception */ - /* (non-Javadoc) - * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#loadLastModificationDateById(java.lang.String) + /* + * (non-Javadoc) + * + * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService# + * loadLastModificationDateById(java.lang.String) */ @Override public Date loadLastModificationDateById(String itemId) throws Exception { - + if (itemId == null) throw new Exception(IDENTIFIER_IS_NULL); workspaceLogger.trace("get last modification date ItemId " + itemId); try { - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(itemId); + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(itemId); Date lastModification = null; if (wsItem.getLastModificationTime() != null) { @@ -2191,10 +2178,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT throw new Exception(e.getMessage()); } } - - /* (non-Javadoc) - * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getParentByItemId(java.lang.String) + /* + * (non-Javadoc) + * + * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService# + * getParentByItemId(java.lang.String) */ /** * Gets the parent by item id. @@ -2203,26 +2192,27 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * @return the parent by item id * @throws Exception the exception */ - //TODO NEED TO TEST IT + // TODO NEED TO TEST IT @Override public FileModel getParentByItemId(String identifier) throws Exception { - + if (identifier == null) throw new Exception(IDENTIFIER_IS_NULL); workspaceLogger.trace("get Parent By Item Identifier " + identifier); try { - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(identifier); + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(identifier); workspaceLogger.trace("workspace has returned item name: " + wsItem.getName()); - + FileModel parentModel = null; - if(wsItem!=null && wsItem.getParentId()!=null) { - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem parent = workspace.getItem(wsItem.getParentId()); + if (wsItem != null && wsItem.getParentId() != null) { + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem parent = workspace + .getItem(wsItem.getParentId()); StorageHubToWorkpaceConverter converter = getStorageHubToWorkpaceConverter(); parentModel = converter.toTreeFileModel(parent, null, parent.isShared()); - + } workspaceLogger.trace("parent not found - retuning"); @@ -2244,11 +2234,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Gets the short url. * - * @param longUrl - * the long url + * @param longUrl the long url * @return the short url - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public String getShortUrl(String longUrl) throws Exception { @@ -2267,7 +2255,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT return null; } } - + /* * (non-Javadoc) * @@ -2277,11 +2265,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Gets the link for send to switch board. * - * @param itemId - * the item id + * @param itemId the item id * @return the link for send to switch board - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public String getLinkForSendToSwitchBoard(String itemId) throws Exception { @@ -2300,8 +2286,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT workspaceLogger.debug("LinkForSendToSwitchBoard: " + encodedURI + " encoded ..."); return new StringBuilder(sbEndpoint).append(encodedURI).toString(); } - - /** * Gets the item description by id. @@ -2310,12 +2294,15 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * @return the item description by id * @throws Exception the exception */ - /* (non-Javadoc) - * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getItemDescriptionById(java.lang.String) + /* + * (non-Javadoc) + * + * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService# + * getItemDescriptionById(java.lang.String) */ @Override public String getItemDescriptionById(String identifier) throws Exception { - + workspaceLogger.info("Getting ItemDescriptionById: " + identifier); if (identifier == null || identifier.isEmpty()) { workspaceLogger.warn("Getting ItemDescriptionById identifier is null or empty, returning null"); @@ -2324,8 +2311,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT try { - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(identifier); + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(identifier); workspaceLogger.trace("workspace has returned item name: " + wsItem.getName()); return wsItem.getDescription(); @@ -2335,7 +2322,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT throw new Exception(error); } } - /** * Gets the user workspace size. @@ -2343,14 +2329,17 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * @return the user workspace size * @throws Exception the exception */ - /* (non-Javadoc) - * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getUserWorkspaceSize() + /* + * (non-Javadoc) + * + * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService# + * getUserWorkspaceSize() */ @Override public String getUserWorkspaceSize() throws Exception { try { workspaceLogger.info("Getting workspace size.."); - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); long size = workspace.getDiskUsage(); // workspaceLogger.info("Root size is: "+size +" formatting.."); String formatSize = FormatterUtil.formatFileSize(size); @@ -2363,7 +2352,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } } - + /* * (non-Javadoc) * @@ -2374,14 +2363,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * Gets the user workspace total items. * * @return the user workspace total items - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public long getUserWorkspaceTotalItems() throws Exception { try { workspaceLogger.info("Getting total items.."); - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); long size = workspace.getTotalItems(); workspaceLogger.info("returning total items value: " + size); return size; @@ -2391,7 +2379,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT throw new Exception(error); } } - + /* * (non-Javadoc) * @@ -2402,14 +2390,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * Gets the user workspace quote. * * @return the user workspace quote - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public WorkspaceUserQuote getUserWorkspaceQuote() throws Exception { try { workspaceLogger.info("Getting UserWorkspaceQuote.."); - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); long size = workspace.getDiskUsage(); workspaceLogger.info("Root size is: " + size + " formatting.."); String formatSize = FormatterUtil.formatFileSize(size); @@ -2426,8 +2413,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT return null; } } - - + /* * (non-Javadoc) * @@ -2437,15 +2423,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Load gcube item properties. * - * @param itemId - * the item id + * @param itemId the item id * @return the map - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public Map loadGcubeItemProperties(String itemId) throws Exception { - + workspaceLogger.info("Getting GcubeItemProperties for itemId: " + itemId); if (itemId == null || itemId.isEmpty()) { workspaceLogger.warn("Getting GcubeItemProperties identifier is null or empty, returning null"); @@ -2453,7 +2437,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } try { - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); PropertyMap properties = workspace.getGcubeItemProperties(itemId); StorageHubToWorkpaceConverter converter = getStorageHubToWorkpaceConverter(); Map mapProperties = converter.toSimpleMap(properties); @@ -2469,7 +2453,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT throw new Exception(error); } } - + /* * (non-Javadoc) * @@ -2479,56 +2463,58 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Gets the items by search name. * - * @param text - * the text - * @param folderId - * the folder id + * @param text the text + * @param folderId the folder id * @return the items by search name - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public List getItemsBySearchName(String text, String folderId) throws Exception { - try { - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); if (folderId == null || folderId.isEmpty()) { workspaceLogger.debug("searching folderId is null, searching from the root folder"); folderId = workspace.getRoot().getId(); } - + workspaceLogger.debug("applying business logic for searching, see #18174"); - + String toSearch = text; - if(toSearch.startsWith(CHAR_FOR_SEARCHING_WITH_EXACTLY_MATCH) && toSearch.endsWith(CHAR_FOR_SEARCHING_WITH_EXACTLY_MATCH)){ - workspaceLogger.info("Detected intent of exactly matching (the input text is between "+CHAR_FOR_SEARCHING_WITH_EXACTLY_MATCH+" char)"); - toSearch = toSearch.substring(1,toSearch.length()-1); - workspaceLogger.info("exactly matching changed the input text to: "+toSearch); - }else { - toSearch = String.format("%s%s%s", JCR_WILDCARD_TO_SEARCH,toSearch,JCR_WILDCARD_TO_SEARCH); - workspaceLogger.info("prepending and appending the wildcard "+JCR_WILDCARD_TO_SEARCH+", changed the input text to: "+toSearch); + if (toSearch.startsWith(CHAR_FOR_SEARCHING_WITH_EXACTLY_MATCH) + && toSearch.endsWith(CHAR_FOR_SEARCHING_WITH_EXACTLY_MATCH)) { + workspaceLogger.info("Detected intent of exactly matching (the input text is between " + + CHAR_FOR_SEARCHING_WITH_EXACTLY_MATCH + " char)"); + toSearch = toSearch.substring(1, toSearch.length() - 1); + workspaceLogger.info("exactly matching changed the input text to: " + toSearch); + } else { + toSearch = String.format("%s%s%s", JCR_WILDCARD_TO_SEARCH, toSearch, JCR_WILDCARD_TO_SEARCH); + workspaceLogger.info("prepending and appending the wildcard " + JCR_WILDCARD_TO_SEARCH + + ", changed the input text to: " + toSearch); } workspaceLogger.info("backend searching for text: " + toSearch + " in the folder id: " + folderId); - List foundItems = workspace.search(toSearch, folderId); - - if(foundItems==null) { + List foundItems = workspace.search(toSearch, + folderId); + + if (foundItems == null) { workspaceLogger.info("Searching by SHUB returned null, instancing empty list"); foundItems = new ArrayList(); } - + workspaceLogger.info("Searching by SHUB returned " + foundItems.size() + " item/s, converting it/them"); StorageHubToWorkpaceConverter converter = getStorageHubToWorkpaceConverter(); List listFileGridModels = new ArrayList(); - + for (org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem workspaceItem : foundItems) { - workspaceLogger.debug("Converting grid item: " + workspaceItem.getId() + " name " + workspaceItem.getName()); + workspaceLogger + .debug("Converting grid item: " + workspaceItem.getId() + " name " + workspaceItem.getName()); listFileGridModels.add(converter.toGridFileModel(workspaceItem, null)); } - - workspaceLogger.info("Search objects converted is/are: "+listFileGridModels.size()+", returning it/them"); + + workspaceLogger + .info("Search objects converted is/are: " + listFileGridModels.size() + ", returning it/them"); return listFileGridModels; } catch (Exception e) { @@ -2536,22 +2522,20 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT throw new Exception("Error occured on searching, please retry or contact the support"); } } - + /** * Gets the children sub tree to root by identifier. * - * @param itemIdentifier - * the item identifier + * @param itemIdentifier the item identifier * @return the children sub tree to root by identifier - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public ArrayList getChildrenSubTreeToRootByIdentifier(String itemIdentifier) throws Exception { - + throw new Exception("The method getChildrenSubTreeToRootByIdentifier is not implement to interact with SHUB"); } - + /* * (non-Javadoc) * @@ -2561,32 +2545,29 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Item exists in workpace folder. * - * @param parentId - * the parent id - * @param itemName - * the item name + * @param parentId the parent id + * @param itemName the item name * @return the string - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public String itemExistsInWorkpaceFolder(String parentId, String itemName) throws Exception { - - workspaceLogger.debug("called itemExistsInWorkpace for name "+itemName+" in the parent Id: " + parentId); + + workspaceLogger.debug("called itemExistsInWorkpace for name " + itemName + " in the parent Id: " + parentId); if (parentId == null) throw new Exception("I'm not able to perform searching.. the folder id is null"); - try { - - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); workspaceLogger.info("finding by name: " + itemName + " in the folder id: " + parentId); - List foundItems = workspace.find(itemName, parentId); + List foundItems = workspace.find(itemName, + parentId); if (foundItems == null || foundItems.isEmpty()) return null; - + return foundItems.get(0).getId(); // } catch (InternalErrorException e) { @@ -2594,12 +2575,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT // } catch (ItemNotFoundException e) { // return null; } catch (Exception e) { - String error = "Error on searching the item "+itemName+" in the passed folder id"; + String error = "Error on searching the item " + itemName + " in the passed folder id"; workspaceLogger.error(error, e); throw new Exception(e.getMessage()); } } - /* * (non-Javadoc) @@ -2610,35 +2590,36 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Gets the accounting history. * - * @param identifier - * the identifier + * @param identifier the identifier * @return the accounting history - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public List getAccountingHistory(String identifier) throws Exception { - + if (identifier == null) throw new Exception("I'm not able to get accounting history... the folder id is null"); - + try { - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(identifier,true,false,false); + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(identifier, true, + false, false); List accoutings = wsItem.getAccounting(); StorageHubToWorkpaceConverter converter = getStorageHubToWorkpaceConverter(); - List listAccounting = converter.buildGXTAccountingItem(accoutings, GxtAccountingEntryType.ALL); + List listAccounting = converter.buildGXTAccountingItem(accoutings, + GxtAccountingEntryType.ALL); workspaceLogger.debug("get accouting returning size " + listAccounting.size()); return listAccounting; } catch (Exception e) { - workspaceLogger.error("Error reading the accounting history for item id: "+identifier, e); - String error = ConstantsExplorer.SERVER_ERROR + " getting accounting History. " + ConstantsExplorer.TRY_AGAIN; + workspaceLogger.error("Error reading the accounting history for item id: " + identifier, e); + String error = ConstantsExplorer.SERVER_ERROR + " getting accounting History. " + + ConstantsExplorer.TRY_AGAIN; throw new Exception(error); } } - + /* * (non-Javadoc) * @@ -2649,8 +2630,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * Gets the list of vr es for logged user. * * @return the list of vr es for logged user - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public List getListOfVREsForLoggedUser() throws Exception { @@ -2689,29 +2669,28 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT workspaceLogger.info("Returning list of VREs: " + listOfVres); return listOfVres; } - + /** * Gets the HTML gcube item properties. * - * @param itemId - * the item id - * @return The Gcube Item Properties in HTML format if itemId is a GcubeItem - * and contains properties, null otherwise - * @throws Exception - * the exception + * @param itemId the item id + * @return The Gcube Item Properties in HTML format if itemId is a GcubeItem and + * contains properties, null otherwise + * @throws Exception the exception */ @Override public String getHTMLGcubeItemProperties(String itemId) throws Exception { workspaceLogger.info("getting HTMLGcubeItemProperties for itemId: " + itemId); if (itemId == null || itemId.isEmpty()) { - workspaceLogger.warn("Error on getting GcubeItemProperties the identifier is null or empty, returning null"); + workspaceLogger + .warn("Error on getting GcubeItemProperties the identifier is null or empty, returning null"); return null; } - + try { - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(itemId); + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(itemId); StorageHubToWorkpaceConverter converter = getStorageHubToWorkpaceConverter(); return converter.getGcubeItemPropertiesForGcubeItemAsHTML(wsItem); @@ -2721,51 +2700,50 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT throw new Exception(error); } } - + /** * Gets the accounting readers. * - * @param identifier - * the identifier + * @param identifier the identifier * @return the accounting readers - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public List getAccountingReaders(String identifier) throws Exception { - + if (identifier == null || identifier.isEmpty()) { workspaceLogger.warn("Error on getting accounting history to readers, identifier is null, returning null"); return null; } - workspaceLogger.debug("reading accounting history only to "+ GxtAccountingEntryType.READ+" for id: " + identifier); + workspaceLogger + .debug("reading accounting history only to " + GxtAccountingEntryType.READ + " for id: " + identifier); try { - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(identifier,true,false,false); + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(identifier, true, + false, false); List accoutings = wsItem.getAccounting(); StorageHubToWorkpaceConverter converter = getStorageHubToWorkpaceConverter(); - List listOfReadFromAccounting = converter.buildGXTAccountingItem(accoutings, GxtAccountingEntryType.READ); - workspaceLogger.info("list of "+GxtAccountingEntryType.READ+" into accounting are:" + listOfReadFromAccounting.size()); + List listOfReadFromAccounting = converter.buildGXTAccountingItem(accoutings, + GxtAccountingEntryType.READ); + workspaceLogger.info("list of " + GxtAccountingEntryType.READ + " into accounting are:" + + listOfReadFromAccounting.size()); return listOfReadFromAccounting; - + } catch (Exception e) { workspaceLogger.error("Error get accounting readers ", e); String error = ConstantsExplorer.SERVER_ERROR + " getting account. " + ConstantsExplorer.TRY_AGAIN; throw new Exception(error); } } - + /** * Sets the gcube item properties. * - * @param itemId - * the item id - * @param properties - * the properties - * @throws Exception - * the exception + * @param itemId the item id + * @param properties the properties + * @throws Exception the exception */ @Override public void setGcubeItemProperties(String itemId, Map properties) throws Exception { @@ -2777,12 +2755,13 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT try { - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(itemId); - + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(itemId); + if (wsItem instanceof org.gcube.common.storagehubwrapper.shared.tohl.impl.GcubeItem) { workspaceLogger.info("Adding " + properties.size() + " properties to GCubeItem: " + itemId); - Map mapObjs = properties==null?null:new HashMap(properties.size()); + Map mapObjs = properties == null ? null + : new HashMap(properties.size()); mapObjs.putAll(properties); workspace.updateMetadata(itemId, mapObjs); } else @@ -2797,40 +2776,35 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT throw new Exception(error); } } - + /** * Creates the external url. * - * @param parentId - * the parent id - * @param name - * the name - * @param description - * the description - * @param url - * the url + * @param parentId the parent id + * @param name the name + * @param description the description + * @param url the url * @return the file model - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public FileModel createExternalUrl(String parentId, String name, String description, String url) throws Exception { - workspaceLogger.info("Called createExternalUrl [parent: "+parentId+", url: "+url+"]"); + workspaceLogger.info("Called createExternalUrl [parent: " + parentId + ", url: " + url + "]"); try { - + if (parentId == null) { workspaceLogger.error("Error on creating url. Parent ID is null"); throw new Exception("Parent ID is null"); } - + checkItemLocked(parentId); - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsFolderParent = workspace.getItem(parentId); - + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsFolderParent = workspace.getItem(parentId); + StorageHubToWorkpaceConverter converter = getStorageHubToWorkpaceConverter(); FileModel parentModel = converter.toTreeFileModel(wsFolderParent, null, wsFolderParent.isShared()); - + workspaceLogger.debug("creating the URL..."); URLItem ext = workspace.createURL(name, description, url, parentId); workspaceLogger.info("created URL file: " + ext.getName()); @@ -2841,11 +2815,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT throw new Exception(e1.getMessage()); } catch (Exception e) { - workspaceLogger.error("Error on creating the URL in the folder id: "+parentId, e); + workspaceLogger.error("Error on creating the URL in the folder id: " + parentId, e); throw new Exception(e.getMessage()); } } - + /* * (non-Javadoc) * @@ -2855,37 +2829,35 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Mark folder as public for folder item id. * - * @param folderId - * the item id - * @param setPublic - * the set public + * @param folderId the item id + * @param setPublic the set public * @return the public link - * @throws SessionExpiredException - * the session expired exception - * @throws Exception - * the exception + * @throws SessionExpiredException the session expired exception + * @throws Exception the exception */ @Override public PublicLink markFolderAsPublicForFolderItemId(String folderId, boolean setPublic) throws SessionExpiredException, Exception { - workspaceLogger.info("called markFolderAsPublicForFolderItemId on folder id: " + folderId +" setPublic: "+setPublic); - + workspaceLogger.info( + "called markFolderAsPublicForFolderItemId on folder id: " + folderId + " setPublic: " + setPublic); + if (isSessionExpired()) throw new SessionExpiredException(); try { - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); String folderLink = null; try { - - //Changing access to.. if needed + + // Changing access to.. if needed boolean newStatus = workspace.setFolderAsPublic(folderId, setPublic); - workspaceLogger.info("The folder "+folderId+" has the public status at " +newStatus+ " on SHUB"); - //If the folder was published + workspaceLogger.info("The folder " + folderId + " has the public status at " + newStatus + " on SHUB"); + // If the folder was published if (newStatus) { - + workspaceLogger.info("SHUB returned the folder link id: " + folderId); - ApplicationProfileReader apReader = new ApplicationProfileReader("Workspace-Explorer-App", "org.gcube.portlets.user.workspaceexplorerapp.server.WorkspaceExplorerAppServiceImpl"); + ApplicationProfileReader apReader = new ApplicationProfileReader("Workspace-Explorer-App", + "org.gcube.portlets.user.workspaceexplorerapp.server.WorkspaceExplorerAppServiceImpl"); ApplicationProfile ap = apReader.readProfileFromInfrastrucure(); String encriptedFId = StringEncrypter.getEncrypter().encrypt(folderId); @@ -2903,24 +2875,25 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT shortURL = "not available"; } PublicLink pubL = new PublicLink(folderLink, shortURL); - workspaceLogger.info("Returning the: "+pubL); + workspaceLogger.info("Returning the: " + pubL); return pubL; } - workspaceLogger.info("The folder has the public status at "+setPublic+" so returning Public Link as null"); + workspaceLogger + .info("The folder has the public status at " + setPublic + " so returning Public Link as null"); return null; - - }catch (Exception e) { - workspaceLogger.error("Error on changing access to folder as public: "+setPublic, e); + + } catch (Exception e) { + workspaceLogger.error("Error on changing access to folder as public: " + setPublic, e); String error = ConstantsExplorer.SERVER_ERROR + " changing access to folder id: " + folderId; throw new Exception(error); } } catch (Exception e) { - workspaceLogger.error("Error on getting the folder id: "+folderId, e); + workspaceLogger.error("Error on getting the folder id: " + folderId, e); throw new Exception(e.getMessage()); } } - + /* * (non-Javadoc) * @@ -2930,13 +2903,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT /** * Gets the images for folder. * - * @param folderId - * the folder id - * @param currentImageId - * the current image id + * @param folderId the folder id + * @param currentImageId the current image id * @return the images for folder - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public List getImagesForFolder(String folderId, String currentImageId) throws Exception { @@ -2946,35 +2916,36 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT try { workspaceLogger.debug("get images for folder id: " + folderId); - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(folderId); + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(folderId); List images = new ArrayList(); if (wsItem.isFolder()) { org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder folder = (org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) wsItem; - List children = workspace.getChildren(folder.getId()); - + List children = workspace + .getChildren(folder.getId()); + // GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder(); PortalContextInfo context = WsUtil.getPortalContext(this.getThreadLocalRequest()); GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest()); for (org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem workspaceItem : children) { boolean foundCurrentImage = false; - //IS AN IMAGE? + // IS AN IMAGE? if (workspaceItem instanceof ImageFileItem) { try { ImageFileItem imageFileItem = (ImageFileItem) workspaceItem; GWTWorkspaceItem image = null; - + image = ObjectStorageHubToWorkpaceMapper.buildGWTWorkspaceImage(imageFileItem, true, false, context.getCurrGroupId() + "", user.getUserId() + ""); image.setId(workspaceItem.getId()); - - + if (image != null) { if (!foundCurrentImage && image.getId().compareTo(currentImageId) == 0) { - workspaceLogger.debug(image.getName() + " is the current displaying image so adding to list as first element"); + workspaceLogger.debug(image.getName() + + " is the current displaying image so adding to list as first element"); images.add(0, image); foundCurrentImage = true; } else { @@ -2982,15 +2953,16 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT images.add(image); } } - }catch (Exception e) { - workspaceLogger.warn("Error on managing the file item: "+workspaceItem.getId() +" as an "+ImageFileItem.class.getName()); + } catch (Exception e) { + workspaceLogger.warn("Error on managing the file item: " + workspaceItem.getId() + " as an " + + ImageFileItem.class.getName()); } } } } - - if(workspaceLogger.isTraceEnabled()) { - workspaceLogger.trace("Returning list of images for folder: "+folderId); + + if (workspaceLogger.isTraceEnabled()) { + workspaceLogger.trace("Returning list of images for folder: " + folderId); for (GWTWorkspaceItem gwtWorkspaceItem : images) { workspaceLogger.trace(gwtWorkspaceItem.toString()); } @@ -3004,64 +2976,63 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } } - /** * Perform operation on versioned file. * - * @param fileId - * the file id - * @param olderVersionIDs - * the older version i ds - * @param operation - * the operation + * @param fileId the file id + * @param olderVersionIDs the older version i ds + * @param operation the operation * @return the list - * @throws Exception - * the exception + * @throws Exception the exception */ @Override public List performOperationOnVersionedFile(String fileId, List olderVersionIDs, WorkspaceVersioningOperation operation) throws Exception { - - workspaceLogger.info("Called perform operation on Versioned File Id: " + fileId + ", Ids Version: " + olderVersionIDs + " perform operation: " + operation); + + workspaceLogger.info("Called perform operation on Versioned File Id: " + fileId + ", Ids Version: " + + olderVersionIDs + " perform operation: " + operation); if (fileId == null || olderVersionIDs == null || olderVersionIDs.size() == 0) throw new Exception("Versioned File id or List of versioned file is null"); try { - - org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); - org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(fileId); + + org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = getWorkspaceFromStorageHub(); + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = workspace.getItem(fileId); if (wsItem instanceof org.gcube.common.storagehubwrapper.shared.tohl.items.FileItem) { - //org.gcube.common.storagehubwrapper.shared.tohl.items.FileItem fileItem = (org.gcube.common.storagehubwrapper.shared.tohl.items.FileItem) wsItem; + // org.gcube.common.storagehubwrapper.shared.tohl.items.FileItem fileItem = + // (org.gcube.common.storagehubwrapper.shared.tohl.items.FileItem) wsItem; switch (operation) { - case DOWNLOAD: { - // IMPLEMENTED CLIENT-SIDE - break; - } - case DELETE_ALL_OLDER_VERSIONS: { - throw new Exception(operation+" must be implemented on SHUB-side"); - // MUST BE OPTIMIZED HL-SIDE - // for (String olderVersionId : olderVersionIDs) { - //// fileItem.removeVersion(olderVersionId); - // throw new Exception(operation+" must be implemented on SHUB-side"); - // workspaceLogger.info("Version " + olderVersionId + " of file id: " + fileId + " removed"); - // } - // return getVersionHistory(fileId); - } - case REFRESH: { - return getVersionHistory(fileId); - } - case DELETE_PERMANENTLY: { - throw new Exception(operation+" must be implemented on SHUB-side"); - // for (String olderVersionId : olderVersionIDs) { - // fileItem.removeVersion(olderVersionId); - // workspaceLogger.info("Version " + olderVersionId + " of file id: " + fileId + " removed"); - // } - // return getVersionHistory(fileId); - } - default: { - break; - } + case DOWNLOAD: { + // IMPLEMENTED CLIENT-SIDE + break; + } + case DELETE_ALL_OLDER_VERSIONS: { + throw new Exception(operation + " must be implemented on SHUB-side"); + // MUST BE OPTIMIZED HL-SIDE + // for (String olderVersionId : olderVersionIDs) { + //// fileItem.removeVersion(olderVersionId); + // throw new Exception(operation+" must be implemented on SHUB-side"); + // workspaceLogger.info("Version " + olderVersionId + " of file id: " + fileId + + // " removed"); + // } + // return getVersionHistory(fileId); + } + case REFRESH: { + return getVersionHistory(fileId); + } + case DELETE_PERMANENTLY: { + throw new Exception(operation + " must be implemented on SHUB-side"); + // for (String olderVersionId : olderVersionIDs) { + // fileItem.removeVersion(olderVersionId); + // workspaceLogger.info("Version " + olderVersionId + " of file id: " + fileId + + // " removed"); + // } + // return getVersionHistory(fileId); + } + default: { + break; + } } return getVersionHistory(fileId); @@ -3070,18 +3041,17 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT throw new FileNotVersionedException("Selected file is not versioned"); } catch (Exception e) { - + workspaceLogger.error("Error during performing operation on versioned file with id: " + fileId, e); String error = ConstantsExplorer.SERVER_ERROR + " updating versioning of file id: " + fileId; throw new Exception(error); } } - /** * Update description for item. * - * @param itemId the item id + * @param itemId the item id * @param newDescription the new description * @return the string * @throws Exception the exception @@ -3102,38 +3072,36 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT } catch (Exception e) { workspaceLogger.error("Error on updating the description for item: " + itemId, e); - - if(e.getMessage().toLowerCase().contains("insufficent privileges")) { + + if (e.getMessage().toLowerCase().contains("insufficent privileges")) { throw new Exception("You don't have permission to update this description"); } - - String error = ConstantsExplorer.SERVER_ERROR + " updating the description for item with id: " - + "" + itemId+". Error reported: "+e.getMessage(); - + + String error = ConstantsExplorer.SERVER_ERROR + " updating the description for item with id: " + "" + itemId + + ". Error reported: " + e.getMessage(); + throw new Exception(error); } return newDescription; } - - /** * Gets the allowed mimetypes for preview. * * @return the allowed mimetypes for preview */ - + @Override - public Map> getAllowedMimetypesForPreview(){ + public Map> getAllowedMimetypesForPreview() { workspaceLogger.info("Called getAllowedMimetypesForPreview"); - + Map> map = MimeTypeUtility.getPreviewMimetypeExtensionMap(); - - workspaceLogger.debug("Returning allowed mimetypes for preview: "+map.keySet()); - + + workspaceLogger.debug("Returning allowed mimetypes for preview: " + map.keySet()); + return map; - + } } diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/ObjectStorageHubToWorkpaceMapper.java b/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/ObjectStorageHubToWorkpaceMapper.java index 02c1908..85eb46c 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/ObjectStorageHubToWorkpaceMapper.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/ObjectStorageHubToWorkpaceMapper.java @@ -63,9 +63,6 @@ public class ObjectStorageHubToWorkpaceMapper { isVreFolder = sharedFolder.isVreFolder(); } -// FolderModel root = new FolderModel(workspaceRoot.getId(),workspaceRoot.getName(),null, true, workspaceRoot.isShared(), false, workspaceRoot.isPublic()); -// root.setIsRoot(true); - FolderModel theFolder = new FolderModel(folder.getId(), folder.getName(), null, folder.isFolder(), folder.isShared(), isVreFolder, isPublicFolder); theFolder.setIsRoot(folder.isRoot()); return theFolder; diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/StorageHubToWorkpaceConverter.java b/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/StorageHubToWorkpaceConverter.java index 0df5efb..5050b63 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/StorageHubToWorkpaceConverter.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/tostoragehub/StorageHubToWorkpaceConverter.java @@ -3,7 +3,6 @@ */ package org.gcube.portlets.user.workspace.server.tostoragehub; - import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; @@ -33,7 +32,6 @@ import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorEx import org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceFileVersion; import org.gcube.common.storagehubwrapper.shared.tohl.items.GCubeItem; import org.gcube.common.storagehubwrapper.shared.tohl.items.PropertyMap; -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.model.FileGridModel; @@ -45,21 +43,18 @@ import org.gcube.portlets.user.workspace.server.util.UserUtil; import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingEntryType; import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField; import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel; +import org.gcube.usecases.ws.thredds.model.ContainerType; import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - - - /** * The Class StorageHubToWorkpaceConverter. * * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it - * Sep 20, 2018 + * Sep 20, 2018 */ -public class StorageHubToWorkpaceConverter implements Serializable{ - +public class StorageHubToWorkpaceConverter implements Serializable { /** * @@ -71,76 +66,12 @@ public class StorageHubToWorkpaceConverter implements Serializable{ private GCubeUser loggedUser; private String workspaceRootId; - - /** * Instantiates a new storage hub to workpace converter. */ public StorageHubToWorkpaceConverter() { } - - /********************************************************************************************************************************************** - * - * - * - * - * TESTING MODE METHODS - * - * - * - * - ***********************************************************************************************************************************************/ - protected static HashMap hashTestUser = null; - /** - * Used in test mode. - * - * @return the hash test users - */ - public static HashMap getHashTestUsers(){ - - if(hashTestUser==null){ - hashTestUser = new HashMap(); - - //USERS - hashTestUser.put("federico.defaveri", new InfoContactModel("federico.defaveri", "federico.defaveri", "Federico de Faveri",null, false)); - hashTestUser.put("antonio.gioia", new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia",null, false)); - hashTestUser.put("fabio.sinibaldi", new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi",null, false)); - hashTestUser.put("pasquale.pagano", new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano",null, false)); - hashTestUser.put("valentina.marioli", new InfoContactModel("valentina.marioli", "valentina.marioli", "Valentina Marioli",null, false)); - hashTestUser.put("roberto.cirillo", new InfoContactModel("roberto.cirillo", "roberto.cirillo", "Roberto Cirillo",null, false)); - hashTestUser.put("francesco.mangiacrapa", new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa",null, false)); - hashTestUser.put("massimiliano.assante", new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante",null, false)); - - } - - return hashTestUser; - } - - - public static List buildGxtInfoContactFromPortalLoginTestMode(List listPortalLogin){ - - List listContact = new ArrayList(); - - for (String portalLogin : listPortalLogin) - listContact.add(getHashTestUsers().get(portalLogin)); - - return listContact; - } - - /********************************************************************************************************************************************** - * - * - * - * - * END TESTING MODE - * - * - * - * - ***********************************************************************************************************************************************/ - - /** * To version history. @@ -148,9 +79,9 @@ public class StorageHubToWorkpaceConverter implements Serializable{ * @param versions the versions * @return the list */ - public List toVersionHistory(List versions){ + public List toVersionHistory(List versions) { - if(versions==null || versions.isEmpty()){ + if (versions == null || versions.isEmpty()) { logger.warn("Version history is null or empty!"); return new ArrayList(); } @@ -158,18 +89,18 @@ public class StorageHubToWorkpaceConverter implements Serializable{ List listVersions = new ArrayList(versions.size()); for (WorkspaceFileVersion wsVersion : versions) { String user = UserUtil.getUserFullName(wsVersion.getOwner()); - FileVersionModel file = new FileVersionModel(wsVersion.getId(), wsVersion.getName(), wsVersion.getRemotePath(), user, FormatterUtil.toDate(wsVersion.getCreated()), wsVersion.isCurrentVersion()); + FileVersionModel file = new FileVersionModel(wsVersion.getId(), wsVersion.getName(), + wsVersion.getRemotePath(), user, FormatterUtil.toDate(wsVersion.getCreated()), + wsVersion.isCurrentVersion()); listVersions.add(file); } return listVersions; } - - /** * Instantiates a new storage hub to workpace converter. * - * @param scope the scope + * @param scope the scope * @param loggedUser the logged user */ public StorageHubToWorkpaceConverter(String scope, GCubeUser loggedUser) { @@ -177,7 +108,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{ this.loggedUser = loggedUser; } - /** * To root folder. * @@ -185,7 +115,8 @@ public class StorageHubToWorkpaceConverter implements Serializable{ * @return the folder model * @throws InternalErrorException the internal error exception */ - public FolderModel toRootFolder(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder folder) throws InternalErrorException{ + public FolderModel toRootFolder(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder folder) + throws InternalErrorException { return ObjectStorageHubToWorkpaceMapper.toRootFolder(folder); @@ -194,70 +125,91 @@ public class StorageHubToWorkpaceConverter implements Serializable{ /** * To tree file model item. * - * @param wrappedItem the wrapped item + * @param wrappedItem the wrapped item * @param parentFolderModel the parent folder model - * @param isParentShared the is parent shared + * @param isParentShared the is parent shared * @return the file model * @throws InternalErrorException the internal error exception */ - public FileModel toTreeFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem, FileModel parentFolderModel, Boolean isParentShared) throws InternalErrorException{ + public FileModel toTreeFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem, + FileModel parentFolderModel, Boolean isParentShared) throws InternalErrorException { FileModel fileModel = ObjectStorageHubToWorkpaceMapper.toTreeFileModelItem(wrappedItem, parentFolderModel, isParentShared); - return setSynchedThreddsStateFor(fileModel, wrappedItem); + return setSynchedWithWsThredds(fileModel, wrappedItem); } - - /** * To grid file model. * - * @param wrappedItem the wrapped item + * @param wrappedItem the wrapped item * @param parentFolderModel the parent folder model * @return the file grid model * @throws InternalErrorException the internal error exception */ - public FileGridModel toGridFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem, FileModel parentFolderModel) throws InternalErrorException{ + public FileGridModel toGridFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem, + FileModel parentFolderModel) throws InternalErrorException { FileGridModel fileGridModel = ObjectStorageHubToWorkpaceMapper.toGridFileModelItem(wrappedItem, parentFolderModel, loggedUser); - return (FileGridModel) setSynchedThreddsStateFor(fileGridModel, wrappedItem); + return (FileGridModel) setSynchedWithWsThredds(fileGridModel, wrappedItem); } + + + protected FileModel setSynchedWithWsThredds(FileModel fileModel, WorkspaceItem wrappedItem) { + logger.debug("called setSynchedThreddsStateFor item id: " + wrappedItem.getId()); + boolean isItemSynched = false; + try { - /** - * Sets the synched thredds state for. - * - * @param fileModel the file model - * @param wrappedItem item - * @return the file model - */ - protected FileModel setSynchedThreddsStateFor(FileModel fileModel, WorkspaceItem wrappedItem) { + Map mapProperties = wrappedItem.getPropertyMap().getValues(); + ContainerType containerItemType = null; - Sync_Status status = null; + // is it a directory? + if (fileModel.isDirectory()) { + containerItemType = ContainerType.FOLDER; + } + + // checking other cases + if (containerItemType == null) { + switch (wrappedItem.getType()) { + case FOLDER: + case VRE_FOLDER: + case SHARED_FOLDER: + case SMART_FOLDER: + containerItemType = ContainerType.FOLDER; + break; + + case FILE_ITEM: + containerItemType = ContainerType.FILE; + break; + + case URL_ITEM: + containerItemType = ContainerType.URL; + break; + + default: + containerItemType = ContainerType.GENERIC_ITEM; + break; - try { - if(wrappedItem.getPropertyMap()!=null) { - String wsSyncStatus = null; - try{ - - PropertyMap map = wrappedItem.getPropertyMap(); - logger.debug("Property Map for folder: "+fileModel.getName()+" has value: "+map.getValues()); - wsSyncStatus = (String) map.getValues().get(WorkspaceThreddsSynchronize.WS_SYNCH_SYNCH_STATUS); - logger.debug("Item id: "+wrappedItem.getId()+" read from Shub has current: "+WorkspaceThreddsSynchronize.WS_SYNCH_SYNCH_STATUS +" value at: "+wsSyncStatus); - if(wsSyncStatus!=null) - status = Sync_Status.valueOf(wsSyncStatus); - }catch (Exception e) { - logger.warn(wsSyncStatus + " is not value of "+Sync_Status.values()+", returning null"); } } + logger.debug( + "calling isItemSynched for id: " + wrappedItem.getId() + ", with name: " + wrappedItem.getName() + + ", with map: " + mapProperties + ", containerItemType: " + containerItemType); + isItemSynched = WorkspaceThreddsSynchronize.getInstance().isItemSynched(wrappedItem.getId(), mapProperties, + containerItemType); + } catch (Exception e) { - logger.warn("It is not possible to get synched status for item: "+fileModel.getIdentifier()); + logger.info("Error on calling isItemSynched for the item id: " + wrappedItem.getId() + + ", (means not synched)"); } - fileModel.setSyncThreddsStatus(status); + logger.debug("the item id: " + wrappedItem.getId() + " with name: " + wrappedItem.getName() + " is synched: " + + isItemSynched); + fileModel.setSynchedWithWsThredds(isItemSynched); + return fileModel; } - /** * To file trashed model. * @@ -268,21 +220,21 @@ public class StorageHubToWorkpaceConverter implements Serializable{ FileTrashedModel fileTrashModel = new FileTrashedModel(); try { - fileTrashModel.setName(trashItem.getTitle()); //ADDING THE TITLE INSTEAD OF NAME + fileTrashModel.setName(trashItem.getTitle()); // ADDING THE TITLE INSTEAD OF NAME fileTrashModel.setIdentifier(trashItem.getId()); - //SETTING PARENT + // SETTING PARENT FileModel oldParent = new FileModel(trashItem.getOriginalParentId(), "", true); fileTrashModel.setOrginalPath(trashItem.getDeletedFrom()); fileTrashModel.setParentFileModel(oldParent); - // - // //SETTING DELETED BY + // + // //SETTING DELETED BY InfoContactModel deleteUser = buildGxtInfoContactFromPortalLogin(trashItem.getDeletedBy()); fileTrashModel.setDeleteUser(deleteUser); - //SETTING MIME TYPE + // SETTING MIME TYPE // String mimeType = ""; // if(trashItem instanceof FileItem){ @@ -290,24 +242,26 @@ public class StorageHubToWorkpaceConverter implements Serializable{ // mimeType = fileItem.getMimeType(); // } - String mimeType = trashItem.getMimeType()!=null?trashItem.getMimeType():""; + String mimeType = trashItem.getMimeType() != null ? trashItem.getMimeType() : ""; fileTrashModel.setType(mimeType); - //SETTING IS DIRECTORY + // SETTING IS DIRECTORY fileTrashModel.setIsDirectory(trashItem.isFolder()); - //SETTING DELETE DATE + // SETTING DELETE DATE fileTrashModel.setDeleteDate(FormatterUtil.toDate(trashItem.getDeletedTime())); fileTrashModel.setShared(trashItem.isShared()); - logger.debug("Converting return trash item: "+fileTrashModel.getName() +" id: "+fileTrashModel.getIdentifier()); + logger.debug("Converting return trash item: " + fileTrashModel.getName() + " id: " + + fileTrashModel.getIdentifier()); - logger.trace("Returning trash item: "+fileTrashModel); + logger.trace("Returning trash item: " + fileTrashModel); - }catch (Exception e) { + } catch (Exception e) { - logger.debug("Error into toFileTrashedModel for item: "+fileTrashModel.getName() +" id: "+fileTrashModel.getIdentifier()); + logger.debug("Error into toFileTrashedModel for item: " + fileTrashModel.getName() + " id: " + + fileTrashModel.getIdentifier()); return null; } @@ -315,94 +269,99 @@ public class StorageHubToWorkpaceConverter implements Serializable{ return fileTrashModel; } - - + /** * Builds the gxt info contact from portal login. * * @param portalLogin the portal login * @return the info contact model */ - public static InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin){ + public static InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin) { - if(portalLogin==null){ + if (portalLogin == null) { logger.warn("portal login is null, return empty"); portalLogin = ""; } GCubeUser theUser = null; try { theUser = UserUtil.getUserByUsername(portalLogin); - }catch (Exception e) { + } catch (Exception e) { logger.warn("Error on retrieving user information, so using the portal login"); } String fullName = null; String emailDomain = null; - if(theUser!=null) { + if (theUser != null) { fullName = theUser.getFullname(); emailDomain = theUser.getEmail(); } - return new InfoContactModel(portalLogin, portalLogin, fullName, emailDomain,false); + return new InfoContactModel(portalLogin, portalLogin, fullName, emailDomain, false); } - + /** - * TODO ********TEMPORARY SOLUTION HL MUST MANAGE SPECIAL FOLDER AS WORKSPACESPECIALFOLDER**** - * REMOVE THIS METHOD AND ADDING INSTANCE OF AT buildGXTFolderModelItem. + * TODO ********TEMPORARY SOLUTION HL MUST MANAGE SPECIAL FOLDER AS + * WORKSPACESPECIALFOLDER**** REMOVE THIS METHOD AND ADDING INSTANCE OF AT + * buildGXTFolderModelItem. * - * @param wsFolder the ws folder - * @param parent the parent + * @param wsFolder the ws folder + * @param parent the parent * @param specialFolderName the special folder name * @return the folder model * @throws InternalErrorException the internal error exception */ - public FolderModel buildGXTFolderModelItemHandleSpecialFolder(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsFolder, org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem parent, String specialFolderName) throws InternalErrorException { + public FolderModel buildGXTFolderModelItemHandleSpecialFolder( + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsFolder, + org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem parent, String specialFolderName) + throws InternalErrorException { String name = ""; - logger.debug("buildGXTFolderModelItemHandleSpecialFolder to folder: "+wsFolder.getName()); - if(logger.isTraceEnabled()) { - logger.trace("buildGXTFolderModelItemHandleSpecialFolder has parent: "+parent); + logger.debug("buildGXTFolderModelItemHandleSpecialFolder to folder: " + wsFolder.getName()); + if (logger.isTraceEnabled()) { + logger.trace("buildGXTFolderModelItemHandleSpecialFolder has parent: " + parent); } - //MANAGEMENT SHARED FOLDER NAME - if(wsFolder.isShared() && wsFolder.getType().equals(WorkspaceItemType.SHARED_FOLDER)){ + // MANAGEMENT SHARED FOLDER NAME + if (wsFolder.isShared() && wsFolder.getType().equals(WorkspaceItemType.SHARED_FOLDER)) { logger.debug("MANAGEMENT SHARED Folder name.."); WorkspaceSharedFolder shared = (WorkspaceSharedFolder) wsFolder; - logger.debug("shared.isVreFolder(): "+shared.isVreFolder()); - //name = shared.isVreFolder()?shared.getName():wsFolder.getName(); + logger.debug("shared.isVreFolder(): " + shared.isVreFolder()); + // name = shared.isVreFolder()?shared.getName():wsFolder.getName(); name = shared.getName(); - //MANAGEMENT SPECIAL FOLDER - }else if(wsFolder.getName().compareTo(ConstantsExplorer.MY_SPECIAL_FOLDERS)==0 && parent!=null && parent.isRoot()){ - //MANAGEMENT SPECIAL FOLDER - logger.debug("MANAGEMENT SPECIAL FOLDER NAME REWRITING AS: "+specialFolderName); - if(specialFolderName!=null && !specialFolderName.isEmpty()) + // MANAGEMENT SPECIAL FOLDER + } else if (wsFolder.getName().compareTo(ConstantsExplorer.MY_SPECIAL_FOLDERS) == 0 && parent != null + && parent.isRoot()) { + // MANAGEMENT SPECIAL FOLDER + logger.debug("MANAGEMENT SPECIAL FOLDER NAME REWRITING AS: " + specialFolderName); + if (specialFolderName != null && !specialFolderName.isEmpty()) name = specialFolderName; else name = wsFolder.getName(); - }else{ + } else { logger.debug("MANAGEMENT Base Folder name.."); name = wsFolder.getName(); } - logger.debug("Name is: "+name); - boolean isPublicDir = ((org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) wsFolder).isPublicFolder(); //TODO + logger.debug("Name is: " + name); + boolean isPublicDir = ((org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) wsFolder) + .isPublicFolder(); // TODO FileModel parentModel = null; - if(parent!=null) + if (parent != null) parentModel = ObjectStorageHubToWorkpaceMapper.toTreeFileModelItem(parent, null, parent.isShared()); - - FolderModel folder = new FolderModel(wsFolder.getId(), name, parentModel, true, wsFolder.isShared(), false, isPublicDir); + + FolderModel folder = new FolderModel(wsFolder.getId(), name, parentModel, true, wsFolder.isShared(), false, + isPublicDir); folder.setShareable(true); folder.setIsRoot(wsFolder.isRoot()); folder.setDescription(wsFolder.getDescription()); - // folder.setOwner(wsFolder.getOwner()); + // folder.setOwner(wsFolder.getOwner()); - if(parent != null && parent.isShared()){ + if (parent != null && parent.isShared()) { folder.setShared(true); folder.setShareable(false); } return folder; } - /** * Gets the workspace root id. * @@ -413,7 +372,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{ return workspaceRootId; } - /** * Sets the workspace root id. * @@ -423,8 +381,6 @@ public class StorageHubToWorkpaceConverter implements Serializable{ this.workspaceRootId = workspaceRootId; } - - /** * To simple map. @@ -440,7 +396,7 @@ public class StorageHubToWorkpaceConverter implements Serializable{ try { Map properties = null; Map map = propertyMap.getValues(); - + if (map != null) { properties = new HashMap(map.size()); for (String key : map.keySet()) { @@ -448,43 +404,43 @@ public class StorageHubToWorkpaceConverter implements Serializable{ properties.put(key, (String) theValue); } } - - if(properties!=null) - logger.error("Converted: "+properties.size()+" property/properties"); - + + if (properties != null) + logger.error("Converted: " + properties.size() + " property/properties"); + return properties; } catch (Exception e) { logger.error("Error on converting a PropertyMap to simple Map: ", e); return null; } } - /** * Builds the GXT accounting item. * - * @param accoutings the accoutings + * @param accoutings the accoutings * @param gxtEntryType the gxt entry type * @return the list */ - public List buildGXTAccountingItem(List accoutings, GxtAccountingEntryType gxtEntryType) { + public List buildGXTAccountingItem(List accoutings, + GxtAccountingEntryType gxtEntryType) { List listAccFields = new ArrayList(); - if(accoutings!=null){ - logger.trace("accouting entry/entrie is/are "+accoutings.size()+ ", converting it/them..."); + if (accoutings != null) { + logger.trace("accouting entry/entrie is/are " + accoutings.size() + ", converting it/them..."); for (AccountEntry shubAccEntry : accoutings) { GxtAccountingField af = new GxtAccountingField(); - + String theUser = shubAccEntry.getUser(); InfoContactModel user = null; - //Ignoring get user details from Liferay in case of user equal to 'ALL' - if(theUser!=null && !theUser.equalsIgnoreCase("ALL")){ + // Ignoring get user details from Liferay in case of user equal to 'ALL' + if (theUser != null && !theUser.equalsIgnoreCase("ALL")) { user = buildGxtInfoContactFromPortalLogin(shubAccEntry.getUser()); } - + af.setUser(user); af.setDate(FormatterUtil.toDate(shubAccEntry.getDate())); @@ -492,20 +448,25 @@ public class StorageHubToWorkpaceConverter implements Serializable{ case CREATE: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.CREATE)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.CREATE)) { AccountEntryCreate create = (AccountEntryCreate) shubAccEntry; af.setOperation(GxtAccountingEntryType.CREATE); - // af.setDescription(GxtAccountingEntryType.CREATE.getName() + " by "+user.getName()); + // af.setDescription(GxtAccountingEntryType.CREATE.getName() + " by + // "+user.getName()); String msg = ""; - if(create.getItemName()==null || create.getItemName().isEmpty()) - msg = GxtAccountingEntryType.CREATE.getId() + " by "+user.getName(); - else{ + if (create.getItemName() == null || create.getItemName().isEmpty()) + msg = GxtAccountingEntryType.CREATE.getId() + " by " + user.getName(); + else { - if(create.getVersion()==null) - msg = create.getItemName() + " " + GxtAccountingEntryType.CREATE.getName() + " by "+user.getName(); + if (create.getVersion() == null) + msg = create.getItemName() + " " + GxtAccountingEntryType.CREATE.getName() + " by " + + user.getName(); else - msg = create.getItemName() + " v. "+create.getVersion()+" "+ GxtAccountingEntryType.CREATE.getName() + " by "+user.getName(); + msg = create.getItemName() + " v. " + create.getVersion() + " " + + GxtAccountingEntryType.CREATE.getName() + " by " + user.getName(); } af.setDescription(msg); @@ -515,21 +476,25 @@ public class StorageHubToWorkpaceConverter implements Serializable{ case READ: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.READ)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.READ)) { AccountEntryRead read = (AccountEntryRead) shubAccEntry; af.setOperation(GxtAccountingEntryType.READ); - af.setDescription(read.getItemName() + " " + GxtAccountingEntryType.READ.getName() + " by "+user.getName()); + af.setDescription(read.getItemName() + " " + GxtAccountingEntryType.READ.getName() + " by " + + user.getName()); String msg = ""; - if(read.getItemName()==null || read.getItemName().isEmpty()) - msg = GxtAccountingEntryType.READ.getId() + " by "+user.getName(); - else{ + if (read.getItemName() == null || read.getItemName().isEmpty()) + msg = GxtAccountingEntryType.READ.getId() + " by " + user.getName(); + else { - if(read.getVersion()==null) - msg = read.getItemName() + " " + GxtAccountingEntryType.READ.getName() + " by "+user.getName(); + if (read.getVersion() == null) + msg = read.getItemName() + " " + GxtAccountingEntryType.READ.getName() + " by " + + user.getName(); else - msg = read.getItemName() + " v."+read.getVersion() +" "+ GxtAccountingEntryType.READ.getName() + " by "+user.getName(); + msg = read.getItemName() + " v." + read.getVersion() + " " + + GxtAccountingEntryType.READ.getName() + " by " + user.getName(); } af.setDescription(msg); @@ -539,27 +504,33 @@ public class StorageHubToWorkpaceConverter implements Serializable{ case CUT: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.CUT)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.CUT)) { af.setOperation(GxtAccountingEntryType.CUT); - - if(shubAccEntry instanceof AccountFolderEntryCut) { - + + if (shubAccEntry instanceof AccountFolderEntryCut) { + AccountFolderEntryCut cut = (AccountFolderEntryCut) shubAccEntry; - + String msg = ""; - if(cut.getItemName()==null || cut.getItemName().isEmpty()) - msg = GxtAccountingEntryType.CUT.getName() +" by "+user.getName(); - else{ - if(cut.getVersion()==null) - msg = cut.getItemName()+" "+GxtAccountingEntryType.CUT.getName() +" by "+user.getName(); + if (cut.getItemName() == null || cut.getItemName().isEmpty()) + msg = GxtAccountingEntryType.CUT.getName() + " by " + user.getName(); + else { + if (cut.getVersion() == null) + msg = cut.getItemName() + " " + GxtAccountingEntryType.CUT.getName() + " by " + + user.getName(); else - msg = cut.getItemName()+" v."+cut.getVersion()+" "+GxtAccountingEntryType.CUT.getName() +" by "+user.getName(); + msg = cut.getItemName() + " v." + cut.getVersion() + " " + + GxtAccountingEntryType.CUT.getName() + " by " + user.getName(); } - + af.setDescription(msg); - }else { - logger.warn("Found an "+AccountingEntryType.class.getSimpleName()+" of kind "+shubAccEntry.getType()+ " not castable to (instance of) "+AccountFolderEntryCut.class.getSimpleName()); + } else { + logger.warn("Found an " + AccountingEntryType.class.getSimpleName() + " of kind " + + shubAccEntry.getType() + " not castable to (instance of) " + + AccountFolderEntryCut.class.getSimpleName()); } } @@ -567,91 +538,118 @@ public class StorageHubToWorkpaceConverter implements Serializable{ case PASTE: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.PASTE)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.PASTE)) { af.setOperation(GxtAccountingEntryType.PASTE); AccountEntryPaste paste = (AccountEntryPaste) shubAccEntry; - if(paste.getVersion()==null) - af.setDescription(GxtAccountingEntryType.PASTE.getName() + " from "+paste.getFromPath()+" by "+user.getName()); + if (paste.getVersion() == null) + af.setDescription(GxtAccountingEntryType.PASTE.getName() + " from " + paste.getFromPath() + + " by " + user.getName()); else - af.setDescription(GxtAccountingEntryType.PASTE.getName() + " v. "+paste.getVersion()+" from "+paste.getFromPath()+" by "+user.getName()); + af.setDescription(GxtAccountingEntryType.PASTE.getName() + " v. " + paste.getVersion() + + " from " + paste.getFromPath() + " by " + user.getName()); } break; case REMOVAL: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.REMOVE)){ - - if(shubAccEntry instanceof AccountFolderEntryRemoval) { + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.REMOVE)) { + + if (shubAccEntry instanceof AccountFolderEntryRemoval) { af.setOperation(GxtAccountingEntryType.REMOVE); AccountFolderEntryRemoval rem = (AccountFolderEntryRemoval) shubAccEntry; - String msg = rem.getItemName()==null || rem.getItemName().isEmpty()?"":rem.getItemName()+" "; - - if(rem.getVersion()==null) - msg+= GxtAccountingEntryType.REMOVE.getName() +" by "+user.getName(); + String msg = rem.getItemName() == null || rem.getItemName().isEmpty() ? "" + : rem.getItemName() + " "; + + if (rem.getVersion() == null) + msg += GxtAccountingEntryType.REMOVE.getName() + " by " + user.getName(); else - msg+= GxtAccountingEntryType.REMOVE.getName() +" v."+rem.getVersion()+" by "+user.getName(); - + msg += GxtAccountingEntryType.REMOVE.getName() + " v." + rem.getVersion() + " by " + + user.getName(); + af.setDescription(msg); - }else { - logger.warn("Found an "+AccountingEntryType.class.getSimpleName()+" of kind "+shubAccEntry.getType()+ " not castable to (instance of) "+AccountFolderEntryRemoval.class.getSimpleName()); + } else { + logger.warn("Found an " + AccountingEntryType.class.getSimpleName() + " of kind " + + shubAccEntry.getType() + " not castable to (instance of) " + + AccountFolderEntryRemoval.class.getSimpleName()); } } break; case RENAMING: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.RENAME)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.RENAME)) { - if(shubAccEntry instanceof AccountFolderEntryRenaming) { + if (shubAccEntry instanceof AccountFolderEntryRenaming) { af.setOperation(GxtAccountingEntryType.RENAME); AccountFolderEntryRenaming ren = (AccountFolderEntryRenaming) shubAccEntry; - String msg = ren.getOldItemName()==null || ren.getOldItemName().isEmpty()?"":ren.getOldItemName()+" "; - if(ren.getVersion()==null) - msg+= GxtAccountingEntryType.RENAME.getName() +" to "+ ren.getNewItemName()+ " by "+user.getName(); + String msg = ren.getOldItemName() == null || ren.getOldItemName().isEmpty() ? "" + : ren.getOldItemName() + " "; + if (ren.getVersion() == null) + msg += GxtAccountingEntryType.RENAME.getName() + " to " + ren.getNewItemName() + " by " + + user.getName(); else - msg+= " v."+ren.getVersion() +" "+GxtAccountingEntryType.RENAME.getName() +" to "+ ren.getNewItemName()+ " by "+user.getName(); - + msg += " v." + ren.getVersion() + " " + GxtAccountingEntryType.RENAME.getName() + " to " + + ren.getNewItemName() + " by " + user.getName(); + af.setDescription(msg); - }else { - logger.warn("Found an "+AccountingEntryType.class.getSimpleName()+" of kind "+shubAccEntry.getType()+ " not castable to (instance of) "+AccountFolderEntryRenaming.class.getSimpleName()); + } else { + logger.warn("Found an " + AccountingEntryType.class.getSimpleName() + " of kind " + + shubAccEntry.getType() + " not castable to (instance of) " + + AccountFolderEntryRenaming.class.getSimpleName()); } } break; case ADD: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.ADD)){ - - if(shubAccEntry instanceof AccountFolderEntryAdd) { + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.ADD)) { + + if (shubAccEntry instanceof AccountFolderEntryAdd) { af.setOperation(GxtAccountingEntryType.ADD); AccountFolderEntryAdd acc = (AccountFolderEntryAdd) shubAccEntry; - String msg = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" "; - if(acc.getVersion()==null) - msg+=GxtAccountingEntryType.ADD.getName()+ " by "+user.getName(); + String msg = acc.getItemName() == null || acc.getItemName().isEmpty() ? "" + : acc.getItemName() + " "; + if (acc.getVersion() == null) + msg += GxtAccountingEntryType.ADD.getName() + " by " + user.getName(); else - msg+=" v."+acc.getVersion()+ " "+GxtAccountingEntryType.ADD.getName()+ " by "+user.getName(); - + msg += " v." + acc.getVersion() + " " + GxtAccountingEntryType.ADD.getName() + " by " + + user.getName(); + af.setDescription(msg); - }else { - logger.warn("Found an "+AccountingEntryType.class.getSimpleName()+" of kind "+shubAccEntry.getType()+ " not castable to (instance of) "+AccountFolderEntryAdd.class.getSimpleName()); + } else { + logger.warn("Found an " + AccountingEntryType.class.getSimpleName() + " of kind " + + shubAccEntry.getType() + " not castable to (instance of) " + + AccountFolderEntryAdd.class.getSimpleName()); } } break; case UPDATE: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.UPDATE)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.UPDATE)) { af.setOperation(GxtAccountingEntryType.UPDATE); AccountEntryUpdate upd = (AccountEntryUpdate) shubAccEntry; - String msg = upd.getItemName()==null || upd.getItemName().isEmpty()?"":upd.getItemName()+" "; - if(upd.getVersion()==null) - msg+=GxtAccountingEntryType.UPDATE.getName()+" by "+user.getName(); + String msg = upd.getItemName() == null || upd.getItemName().isEmpty() ? "" + : upd.getItemName() + " "; + if (upd.getVersion() == null) + msg += GxtAccountingEntryType.UPDATE.getName() + " by " + user.getName(); else - msg+=" v."+upd.getVersion()+" "+GxtAccountingEntryType.UPDATE.getName()+" by "+user.getName(); + msg += " v." + upd.getVersion() + " " + GxtAccountingEntryType.UPDATE.getName() + " by " + + user.getName(); af.setDescription(msg); } @@ -659,20 +657,24 @@ public class StorageHubToWorkpaceConverter implements Serializable{ case SHARE: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.SHARE)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.SHARE)) { af.setOperation(GxtAccountingEntryType.SHARE); AccountEntryShare acc = (AccountEntryShare) shubAccEntry; String msg = ""; - if(acc.getItemName()==null || acc.getItemName().isEmpty()) - msg = "\""+user.getName() + "\" "+GxtAccountingEntryType.SHARE.getName()+ " folder"; + if (acc.getItemName() == null || acc.getItemName().isEmpty()) + msg = "\"" + user.getName() + "\" " + GxtAccountingEntryType.SHARE.getName() + " folder"; else - msg = user.getName() + " "+GxtAccountingEntryType.SHARE.getName()+ " folder "+acc.getItemName(); + msg = user.getName() + " " + GxtAccountingEntryType.SHARE.getName() + " folder " + + acc.getItemName(); - if(acc.getMembers()!=null && acc.getMembers().length>0) - msg+=" with "+UserUtil.separateFullNameToCommaForPortalLogin(Arrays.asList(acc.getMembers())); + if (acc.getMembers() != null && acc.getMembers().length > 0) + msg += " with " + + UserUtil.separateFullNameToCommaForPortalLogin(Arrays.asList(acc.getMembers())); af.setDescription(msg); } @@ -680,19 +682,22 @@ public class StorageHubToWorkpaceConverter implements Serializable{ case UNSHARE: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.UNSHARE)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.UNSHARE)) { af.setOperation(GxtAccountingEntryType.UNSHARE); AccountEntryUnshare uns = (AccountEntryUnshare) shubAccEntry; String msg = "Folder "; - msg+= uns.getItemName()==null || uns.getItemName().isEmpty()?"":"\""+uns.getItemName()+"\" "; - //see Task #19544 - if(shubAccEntry.getUser().equalsIgnoreCase("ALL")) { - //CASE ALL - msg= "The folder is no longer shared with others"; + msg += uns.getItemName() == null || uns.getItemName().isEmpty() ? "" + : "\"" + uns.getItemName() + "\" "; + // see Task #19544 + if (shubAccEntry.getUser().equalsIgnoreCase("ALL")) { + // CASE ALL + msg = "The folder is no longer shared with others"; user = new InfoContactModel(theUser, "n.a.", "n.a.", null, false); - }else { - msg+= "is no longer shared with "+user.getName(); + } else { + msg += "is no longer shared with " + user.getName(); user = new InfoContactModel(theUser, "Owner / Admin", "Owner / Admin", null, false); } af.setUser(user); @@ -702,16 +707,20 @@ public class StorageHubToWorkpaceConverter implements Serializable{ case RESTORE: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.RESTORE)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.RESTORE)) { af.setOperation(GxtAccountingEntryType.RESTORE); AccountEntryRestore acc = (AccountEntryRestore) shubAccEntry; - String msg = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" "; + String msg = acc.getItemName() == null || acc.getItemName().isEmpty() ? "" + : acc.getItemName() + " "; - if(acc.getVersion()==null) - msg+=GxtAccountingEntryType.RESTORE.getName()+" by "+user.getName(); + if (acc.getVersion() == null) + msg += GxtAccountingEntryType.RESTORE.getName() + " by " + user.getName(); else - msg+=" v."+acc.getVersion()+" "+GxtAccountingEntryType.RESTORE.getName() +" by "+user.getName(); + msg += " v." + acc.getVersion() + " " + GxtAccountingEntryType.RESTORE.getName() + " by " + + user.getName(); af.setDescription(msg); } @@ -719,13 +728,16 @@ public class StorageHubToWorkpaceConverter implements Serializable{ case DISABLED_PUBLIC_ACCESS: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS)) { af.setOperation(GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS); AccountEntryDisabledPublicAccess acc = (AccountEntryDisabledPublicAccess) shubAccEntry; - //TODO acc.getItemName() is missing in SHUB - //String msg = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" "; - String msg=GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS.getName()+" by "+user.getName(); + // TODO acc.getItemName() is missing in SHUB + // String msg = acc.getItemName()==null || + // acc.getItemName().isEmpty()?"":acc.getItemName()+" "; + String msg = GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS.getName() + " by " + user.getName(); af.setDescription(msg); } @@ -733,13 +745,16 @@ public class StorageHubToWorkpaceConverter implements Serializable{ case ENABLED_PUBLIC_ACCESS: - if(gxtEntryType==null || gxtEntryType.equals(GxtAccountingEntryType.ALL) || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) || gxtEntryType.equals(GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS)){ + if (gxtEntryType == null || gxtEntryType.equals(GxtAccountingEntryType.ALL) + || gxtEntryType.equals(GxtAccountingEntryType.ALLWITHOUTREAD) + || gxtEntryType.equals(GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS)) { af.setOperation(GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS); AccountEntryEnabledPublicAccess acc = (AccountEntryEnabledPublicAccess) shubAccEntry; - //TODO acc.getItemName() is missing in SHUB - //String msg = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" "; - String msg=GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS.getName()+" by "+user.getName(); + // TODO acc.getItemName() is missing in SHUB + // String msg = acc.getItemName()==null || + // acc.getItemName().isEmpty()?"":acc.getItemName()+" "; + String msg = GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS.getName() + " by " + user.getName(); af.setDescription(msg); } @@ -753,13 +768,12 @@ public class StorageHubToWorkpaceConverter implements Serializable{ listAccFields.add(af); } } - logger.debug("get accounting readers converting completed - returning size "+listAccFields.size()); + logger.debug("get accounting readers converting completed - returning size " + listAccFields.size()); return listAccFields; } - /** * Gets the gcube item properties for gcube item as HTML. * @@ -768,37 +782,35 @@ public class StorageHubToWorkpaceConverter implements Serializable{ */ public String getGcubeItemPropertiesForGcubeItemAsHTML(WorkspaceItem wsItem) { - Map properties = getGcubeItemProperties(wsItem); - - if(properties!=null){ - - if(properties.size()==0){ - logger.warn("Map of Gcube Item Properties is empty for item: "+wsItem.getId()); + + if (properties != null) { + + if (properties.size() == 0) { + logger.warn("Map of Gcube Item Properties is empty for item: " + wsItem.getId()); return null; } - + String html = "
"; - + for (String key : properties.keySet()) { String value = properties.get(key); - logger.trace("Getting property: ["+key+","+properties.get(key)+"]"); - html+=""+key+": "; - html+=""; - html+=value; - html+="
"; + logger.trace("Getting property: [" + key + "," + properties.get(key) + "]"); + html += "" + key + ": "; + html += ""; + html += value; + html += "
"; } - - html+="
"; - + + html += ""; + return html; - }else { - logger.warn("Gcube Item Properties not found for item: "+wsItem.getId()); + } else { + logger.warn("Gcube Item Properties not found for item: " + wsItem.getId()); return null; } } - /** * Gets the gcube item properties. * @@ -807,10 +819,10 @@ public class StorageHubToWorkpaceConverter implements Serializable{ */ public Map getGcubeItemProperties(WorkspaceItem wsItem) { - if(wsItem instanceof org.gcube.common.storagehubwrapper.shared.tohl.items.GCubeItem){ + if (wsItem instanceof org.gcube.common.storagehubwrapper.shared.tohl.items.GCubeItem) { GCubeItem gItem = (GCubeItem) wsItem; try { - if(gItem.getProperties()!=null){ + if (gItem.getProperties() != null) { PropertyMap map = gItem.getProperty(); return toSimpleMap(map); } @@ -820,6 +832,75 @@ public class StorageHubToWorkpaceConverter implements Serializable{ } } return null; - + + } + + /********************************************************************************************************************************************** + * + * + * + * + * TESTING MODE METHODS + * + * + * + * + ***********************************************************************************************************************************************/ + protected static HashMap hashTestUser = null; + + /** + * Used in test mode. + * + * @return the hash test users + */ + public static HashMap getHashTestUsers() { + + if (hashTestUser == null) { + hashTestUser = new HashMap(); + + // USERS + hashTestUser.put("federico.defaveri", + new InfoContactModel("federico.defaveri", "federico.defaveri", "Federico de Faveri", null, false)); + hashTestUser.put("antonio.gioia", + new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia", null, false)); + hashTestUser.put("fabio.sinibaldi", + new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi", null, false)); + hashTestUser.put("pasquale.pagano", + new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano", null, false)); + hashTestUser.put("valentina.marioli", + new InfoContactModel("valentina.marioli", "valentina.marioli", "Valentina Marioli", null, false)); + hashTestUser.put("roberto.cirillo", + new InfoContactModel("roberto.cirillo", "roberto.cirillo", "Roberto Cirillo", null, false)); + hashTestUser.put("francesco.mangiacrapa", new InfoContactModel("francesco.mangiacrapa", + "francesco.mangiacrapa", "Francesco Mangiacrapa", null, false)); + hashTestUser.put("massimiliano.assante", new InfoContactModel("massimiliano.assante", + "massimiliano.assante", "Massimiliano Assante", null, false)); + + } + + return hashTestUser; } + + public static List buildGxtInfoContactFromPortalLoginTestMode(List listPortalLogin) { + + List listContact = new ArrayList(); + + for (String portalLogin : listPortalLogin) + listContact.add(getHashTestUsers().get(portalLogin)); + + return listContact; + } + + /********************************************************************************************************************************************** + * + * + * + * + * END TESTING MODE + * + * + * + * + ***********************************************************************************************************************************************/ + }