Compare commits

..

15 Commits

Author SHA1 Message Date
Francesco Mangiacrapa ddc6045607 changed dependency ws-task-executor-widget at version [0.0.1,
1.0.0-SNAPSHOT)
2020-07-28 14:59:33 +02:00
Francesco Mangiacrapa 2e6b3d031f changed the business logic to show the preview on files 2020-07-22 17:35:33 +02:00
Francesco Mangiacrapa aec8ae3332 Implemented improvement #19695#note-4 2020-07-21 15:55:39 +02:00
Francesco Mangiacrapa 2c4b91e835 #19695#note-1 integrated with Google Docs Viewer as first version 2020-07-20 16:39:13 +02:00
Francesco Mangiacrapa 6c1c00c238 integrated the Google Docs viewer 2020-07-17 18:05:47 +02:00
Francesco Mangiacrapa 4721a48c31 Implemented improvements reported at #19600#note-4 2020-07-17 13:02:54 +02:00
Francesco Mangiacrapa ed37efe568 added the method updateDescriptionForItem 2020-07-16 12:01:36 +02:00
Francesco Mangiacrapa b86510ee92 added download facility 2020-07-15 15:01:18 +02:00
Francesco Mangiacrapa ad937c9f13 first release for testing of #19600 2020-07-14 15:43:41 +02:00
Francesco Mangiacrapa 239810f194 working on show preview for image 2020-07-13 18:04:53 +02:00
Francesco Mangiacrapa b9370463b0 working on #19600 2020-07-13 15:35:02 +02:00
Francesco Mangiacrapa 2ff9cbaf35 building the GUI 2020-07-10 18:14:15 +02:00
Francesco Mangiacrapa af8d2525b9 on going on #19600 2020-07-10 15:07:03 +02:00
Francesco Mangiacrapa 98b5ae5fd7 building the Get Info... 2020-07-10 12:55:36 +02:00
Francesco Mangiacrapa 0a1e418d13 just started to work on this task 2020-07-08 18:14:06 +02:00
40 changed files with 1849 additions and 2283 deletions

View File

@ -6,21 +6,26 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
@ -35,16 +40,5 @@
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -2,5 +2,4 @@ eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8

View File

@ -1,72 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="workspace-tree-widget">
<wb-resource deploy-path="/" source-path="/src/main/java"/>
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
<wb-resource deploy-path="/" source-path="/target/generated-sources/annotations"/>
</wb-module>
</project-modules>

View File

@ -4,90 +4,7 @@
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.35.3] - 2024-03-19
- Moved to maven parent 1.2.0
- Added lombok 1.18.4 (provided) to avoid `java.lang.ClassNotFoundException: com.sun.tools.javac.code.TypeTags`
- Equipped with the new Catalogue Publishing Widget [#26825]
- image-previewer-widget range at [1.0.0, 1.3.0-SNAPSHOT)
## [v6.35.2] - 2022-09-14
#### Bug fixed
- [#23676] Fixed - Added extension .txt to ASC files when dowloaded
- [#23789] Fixed - Notebook files (.ipynb) are downloaded with .txt attached.
- [#23862] Fixed - Downloading folders containing a "." in the name, the .zip is appended to file name
## [v6.35.1] - 2022-06-27
- [#23523] Updated to maven-portal-bom 3.6.4
## [v6.35.0] - 2022-05-03
#### Enhancements
- [#23225] Updated the method to read the members of (VRE or Simple) shared folders
## [v6.34.3] - 2022-03-24
#### Enhancements
- [#23020] Reinforce the (ApplicationProfile-)Workspace-Explorer-App discovery
- [#22923] Migrate to maven-portal-bom 3.7.0[-SNAPSHOT]
## [v6.34.1] - 2021-12-20
#### Fixes
- [#22578] GetInfo facility invoked by Tree View does not display properly the Owner field
## [v6.34.0] - 2021-11-05
#### Enhancements
- [#22251] Make workspace file size field smart
## [v6.33.1] - 2021-06-11
#### Fixes
[#21575] Fixed icon associated with simple folders in the grid view
Moved to maven-portal-bom 3.6.3
## [v6.33.0] - 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
[#21153] Upgrade the maven-portal-bom to 3.6.1 version
[#20762] Moved to ckan-metadata-publisher-widget 2.X
## [v6.31.3] - 2021-03-25
#### Bug Fixes
Declared the workspace-uploader range [2.X, 3.X-SNAPSHOT)
## [v6.31.2] - 2021-01-18
#### Bug Fixes
[#20457] Just including patched library
## [v6.31.1] - 2020-10-19
#### Bug Fixes
[#19952] Fixed incident
## [v6.31.0] - 2020-09-29
## [v6.31.0] [r4.25.0] - 2020-07-16
#### Enhancements
@ -97,18 +14,15 @@ Declared the workspace-uploader range [2.X, 3.X-SNAPSHOT)
[#19695] Show the file preview via Google Docs Viewer
#### Bug Fixes
[#19759#note-12] Fixed updating the description of a folder
## [v6.30.1] - 2020-06-25
## [v6.30.1] [r4.24.0] - 2020-06-25
#### Fixes
[#19544] update the unsharing messages in the accounting history
## [v6.30.0] - 2020-05-18
## [v6.30.0] [r4.23.0] - 2020-05-18
#### New Features
@ -121,7 +35,7 @@ Declared the workspace-uploader range [2.X, 3.X-SNAPSHOT)
[#19243] Fixed upload archive facility does not work properly with Windows OS
## [v6.29.0] - 2020-03-27
## [v6.29.0] [r4.21.0] - 2020-03-27
#### New Features

109
pom.xml
View File

@ -5,13 +5,13 @@
<parent>
<artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId>
<version>1.2.0</version>
<version>1.1.0</version>
<relativePath />
</parent>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>workspace-tree-widget</artifactId>
<version>6.35.3</version>
<version>6.31.0-SNAPSHOT</version>
<name>gCube Workspace Tree Widget</name>
<description>
gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace
@ -27,7 +27,7 @@
<repositories>
<repository>
<id>eclipselink</id>
<url>https://nexus.d4science.org/nexus/content/repositories/eclipselink/</url>
<url>http://maven.research-infrastructures.eu:8081/nexus/content/repositories/eclipselink/</url>
</repository>
</repositories>
@ -39,9 +39,6 @@
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<gxt2.2.5-gwt2.X-version>2.7.0</gxt2.2.5-gwt2.X-version>
<gcube-portal-bom-version>3.7.0</gcube-portal-bom-version>
</properties>
<dependencyManagement>
@ -49,40 +46,31 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>${gcube-portal-bom-version}</version>
<version>3.6.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!-- <profiles> -->
<!-- <profile> -->
<!-- <id>workspace-tree-release-profile</id> -->
<!-- <activation> -->
<!-- <property> -->
<!-- <name>Release</name> -->
<!-- </property> -->
<!-- </activation> -->
<!-- <properties> -->
<!-- <gcube-portal-bom-version>3.7.0</gcube-portal-bom-version> -->
<!-- </properties> -->
<!-- </profile> -->
<!-- <profile> -->
<!-- <id>workspace-tree-snapshot-profile</id> -->
<!-- <activation> -->
<!-- <property> -->
<!-- <name>!Release</name> -->
<!-- </property> -->
<!-- </activation> -->
<!-- <properties> -->
<!-- <gcube-portal-bom-version>3.8.0-SNAPSHOT</gcube-portal-bom-version> -->
<!-- </properties> -->
<!-- </profile> -->
<!-- </profiles> -->
<dependencies>
<!-- UNCOMMENT THIS TO RUN IN DEVO MODE -->
<!-- <dependency> -->
<!-- <groupId>xerces</groupId> -->
<!-- <artifactId>xerces</artifactId> -->
<!-- <version>2.4.0</version> -->
<!-- </dependency> -->
<!-- This dependency is needed to use GWT UI BInder without old Xerces
version of gCore complaining -->
<!-- <dependency> -->
<!-- <groupId>xerces</groupId> -->
<!-- <artifactId>xercesImpl</artifactId> -->
<!-- <version>2.9.1</version> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<!-- Google Web Toolkit (GWT) -->
<dependency>
<groupId>com.google.gwt</groupId>
@ -93,12 +81,13 @@
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>storagehub-icons-library</artifactId>
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sencha.gxt</groupId>
<artifactId>gxt2.2.5-gwt2.X</artifactId>
<version>${gxt2.2.5-gwt2.X-version}</version>
<version>${gwtVersion}</version>
<scope>compile</scope>
</dependency>
@ -166,7 +155,7 @@
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>image-previewer-widget</artifactId>
<version>[1.0.0, 1.3.0-SNAPSHOT)</version>
<version>[1.0.0,)</version>
<exclusions>
<exclusion>
<groupId>com.google.gwt</groupId>
@ -188,24 +177,10 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>ws-task-executor-widget</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<version>[0.0.1, 1.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
@ -227,23 +202,23 @@
<scope>compile</scope>
</dependency>
<!-- <dependency> -->
<!-- <groupId>com.thoughtworks.xstream</groupId> -->
<!-- <artifactId>xstream</artifactId> -->
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<!-- <version>1.4.5</version> -->
<!-- </dependency> -->
</dependency>
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>workspace-uploader</artifactId>
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
<version>[1.0.0, 3.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>storagehub-client-wrapper</artifactId>
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
@ -266,7 +241,6 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@ -275,22 +249,9 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>social-library-stubs</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.social-networking</groupId>
<artifactId>social-service-client</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId>
</exclusion>
</exclusions>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
@ -302,14 +263,8 @@
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>ckan-metadata-publisher-widget</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0)</version>
<version>[1.0.0,2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>com.allen-sauer.gwt.log</groupId>
<artifactId>gwt-log</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- JSON PARSER -->

View File

@ -174,7 +174,6 @@ import com.github.gwtbootstrap.client.ui.Modal;
import com.github.gwtbootstrap.client.ui.event.HideEvent;
import com.github.gwtbootstrap.client.ui.event.HideHandler;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.http.client.RequestBuilder;
@ -312,7 +311,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
modal.setTitle("Publish Item");
modal.addStyleName("insert-metadata-modal-style");
modal.addStyleName("modal-top-custom");
((Element)modal.getElement().getChildNodes().getItem(1)).addClassName("modal-body-ws-tree ");
// ((Element)modal.getElement().getChildNodes().getItem(1)).addClassName("modal-body-custom");
modal.add(new CreateDatasetForm(folderId, eventBus));
modal.setCloseVisible(true);
modal.show();

View File

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.Map;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.NumberFormat;
//import com.google.gwt.dom.client.Element;
//import com.google.gwt.user.client.Element;
@ -216,7 +217,7 @@ public static enum WS_UPLOAD_TYPE {File, Archive};
public static final String ACCOUNTING_HISTORY_OF = "Accounting history of: ";
public static final String ACCOUNTING_READERS_OF = "Accounting readers of: ";
//public static final NumberFormat numberFormatterKB = NumberFormat.getFormat("#,##0 KB;(#,##0 KB)");
public static final NumberFormat numberFormatterKB = NumberFormat.getFormat("#,##0 KB;(#,##0 KB)");
//USED IN HTTP GET AS PARAMETER.. THIS PARAMS ARE REPLICATED IN THE CONSTANTS OF TREE WIDGET
public static final String GET_SEARCH_PARAMETER ="search";

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.workspace.client.model;
import java.io.Serializable;
import java.util.List;
import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder;
import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum;
@ -15,7 +16,8 @@ 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.
*
@ -53,8 +55,8 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
public static final String OWNERFULLNAME = "Owner Name";
public static final String HUMAN_REDABLE_CATEGORY = "HR Category";
// Synched with thredds
private Boolean synchedWithWsThredds = null;
//Thredds Synch status
private Sync_Status synchedThreddsStatus;
/**
* Instantiates a new file model.
@ -152,8 +154,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* @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);
@ -172,8 +173,10 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
set(PARENT,parent);
}
/**
* Status values ConstantsExplorer.FOLDERNOTLOAD = "notload";
* Status values
* ConstantsExplorer.FOLDERNOTLOAD = "notload";
* ConstantsExplorer.FOLDERLOADED = "loaded";
*
* @param status the new status
@ -276,6 +279,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
this.isRoot = isRoot;
}
/**
* Gets the icon.
*
@ -304,9 +308,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
}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();
@ -320,8 +322,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
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
}
}
@ -330,18 +331,26 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
}else{
//SPECIAL FOLDER?
if (this.isSpecialFolder()) {
if(this.isSpecialFolder())
absImgPr = Resources.getIconSpecialFolder();
} else { // SIMPLE FOLDER
if (this.isPublic()) { // IS PLUBIC
else{ //SIMPLE FOLDER
if(this.isPublic()) //IS PLUBIC
absImgPr = Resources.getIconFolderPublic();
} else {
Boolean isSynched = this.getSynchedWithWsThredds();
if (isSynched != null && isSynched) {
absImgPr = Resources.getIconSynchedFolder();
} else {
absImgPr = Resources.getIconFolder();
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;
}
}else
absImgPr = Resources.getIconFolder();
}
}
}
@ -349,6 +358,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
return absImgPr;
}
/**
* Gets the status.
*
@ -358,6 +368,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
return get("status");
}
/**
* Sets the checks if is directory.
*
@ -396,6 +407,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
set(HUMAN_REDABLE_CATEGORY, smfDocuments.getValue());
}
/**
* Gets the shortcut category.
*
@ -405,6 +417,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
return (GXTCategorySmartFolder) get(SHORTCUTCATEGORY);
}
/**
* Sets the name.
*
@ -444,9 +457,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
return false;
}
/*
* (non-Javadoc)
*
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
/**
@ -564,27 +575,17 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
return isPublic;
}
/**
* Sets the synched with ws thredds.
*
* @param bool the new synched with ws thredds
*/
public void setSynchedWithWsThredds(Boolean bool) {
this.synchedWithWsThredds = bool;
public void setSyncThreddsStatus(Sync_Status status) {
this.synchedThreddsStatus = status;
}
/**
* Gets the synched with ws thredds.
*
* @return the synched with ws thredds
*/
public Boolean getSynchedWithWsThredds() {
return synchedWithWsThredds;
public Sync_Status getSynchedThreddsStatus() {
return synchedThreddsStatus;
}
/*
* (non-Javadoc)
*
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
/**
@ -619,4 +620,5 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
return builder.toString();
}
}

View File

@ -412,24 +412,15 @@ public interface Icons extends ClientBundle {
@Source("icons/sync-icon-to.png")
ImageResource syncIconTo();
@Source("icons/folder_sync.png")
ImageResource synchedFolder();
@Source("icons/sync-icon-from.png")
ImageResource syncIconFrom();
// @Source("icons/sync-icon-from.png")
// ImageResource syncIconFrom();
//
// @Source("icons/sync-icon-synched.png")
// ImageResource syncIconSynched();
@Source("icons/sync-icon-synched.png")
ImageResource syncIconSynched();
@Source("icons/no-preview-available.png")
ImageResource previewNotAvailable();
@Source("icons/no-preview-available-no-border.png")
ImageResource previewNotAvailableNoBorder();
@Source("icons/spinner2.gif")
ImageResource spinner();
}

View File

@ -80,6 +80,8 @@ public class Resources {
return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.TXT());
}
/**
* Gets the data catalogue publish.
*
@ -100,6 +102,7 @@ public class Resources {
return AbstractImagePrototype.create(ICONS.switchboard());
}
/**
* Gets the icon postscript.
*
@ -120,6 +123,8 @@ public class Resources {
return AbstractImagePrototype.create(ICONS.dvi());
}
/**
* Gets the icon folder shared public.
*
@ -130,6 +135,7 @@ public class Resources {
return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.FOLDER_LINK());
}
/**
* Gets the icon information.
*
@ -148,6 +154,8 @@ public class Resources {
return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.SCRIPT());
}
/**
* Gets the icon information.
*
@ -166,6 +174,7 @@ public class Resources {
return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.ARCHIVE());
}
/**
* Gets the icon odp.
*
@ -184,6 +193,7 @@ public class Resources {
return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.DOC());
}
/**
* Gets the icon odp.
*
@ -193,6 +203,7 @@ public class Resources {
return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.DOC());
}
/**
* Gets the icon folder link.
*
@ -202,6 +213,7 @@ public class Resources {
return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.FOLDER_LINK());
}
/**
* Gets the icon odp.
*
@ -251,6 +263,7 @@ public class Resources {
return AbstractImagePrototype.create(ICONS.undo());
}
/**
* Gets the icon archive.
*
@ -454,15 +467,6 @@ public class Resources {
return AbstractImagePrototype.create(ICONS.notread());
}
/**
* Gets the icon not read.
*
* @return the icon not read
*/
public static AbstractImagePrototype getSpinner() {
return AbstractImagePrototype.create(ICONS.spinner());
}
/**
* Gets the close icon.
@ -543,7 +547,6 @@ public class Resources {
return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.XML());
}
/**
* Gets the icon permissions.
*
@ -552,7 +555,6 @@ public class Resources {
public static AbstractImagePrototype getIconCalendar() {
return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.CALENDAR());
}
/**
* Gets the icon html.
*
@ -794,6 +796,7 @@ public class Resources {
return AbstractImagePrototype.create(ICONS.search());
}
/**
* Gets the icon search ws.
*
@ -804,6 +807,7 @@ public class Resources {
return AbstractImagePrototype.create(ICONS.search2());
}
/**
* Gets the icon links.
*
@ -957,7 +961,6 @@ public class Resources {
public static AbstractImagePrototype getIconCheckUser() {
return AbstractImagePrototype.create(ICONS.checkUser());
}
/**
* Gets the icon hand.
*
@ -975,7 +978,6 @@ public class Resources {
public static AbstractImagePrototype getIconSaveAttachments() {
return AbstractImagePrototype.create(ICONS.saveAttachs());
}
/**
* Gets the icon copy.
*
@ -1066,6 +1068,7 @@ public class Resources {
return AbstractImagePrototype.create(ICONS.removeFilter());
}
/**
* Gets the icon public link.
*
@ -1075,6 +1078,7 @@ public class Resources {
return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.PUBLIC_LINK());
}
/**
* Gets the icon versioning.
*
@ -1084,6 +1088,9 @@ public class Resources {
return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.VERSIONS());
}
/**
* Gets the icon web dav.
*
@ -1210,6 +1217,7 @@ public class Resources {
return AbstractImagePrototype.create(ICONS.folderPublicRemove());
}
/**
* Gets the icon add administrator.
*
@ -1228,6 +1236,8 @@ public class Resources {
return AbstractImagePrototype.create(ICONS.manageAdmin());
}
/**
* Gets the icon thredds publish.
*
@ -1238,6 +1248,7 @@ public class Resources {
return AbstractImagePrototype.create(ICONS.thredds());
}
/**
* Gets the icon sync to.
*
@ -1248,12 +1259,22 @@ public class Resources {
}
/**
* Gets the icon synched folder.
* Gets the icon sync from.
*
* @return the icon synched folder
* @return the icon sync from
*/
public static AbstractImagePrototype getIconSynchedFolder() {
return AbstractImagePrototype.create(ICONS.synchedFolder());
public static AbstractImagePrototype getIconSyncFrom() {
return AbstractImagePrototype.create(ICONS.syncIconFrom());
}
/**
* Gets the icon synched.
*
* @return the icon synched
*/
public static AbstractImagePrototype getIconSynched() {
return AbstractImagePrototype.create(ICONS.syncIconSynched());
}
/**
@ -1265,6 +1286,7 @@ public class Resources {
return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.move24());
}
//ImageResources
/**
* Gets the image path separator.
@ -1320,6 +1342,7 @@ public class Resources {
return ICONS.cancel();
}
/**
* Gets the image delete.
*
@ -1338,6 +1361,7 @@ public class Resources {
return ICONS.attach();
}
/**
* Gets the preview not available.
*
@ -1347,14 +1371,6 @@ public class Resources {
return ICONS.previewNotAvailable();
}
/**
* Gets the preview not available.
*
* @return the preview not available
*/
public static ImageResource getPreviewNotAvailableNoBorder() {
return ICONS.previewNotAvailableNoBorder();
}
/**
* Gets the icon by media type name.
@ -1365,8 +1381,7 @@ public class Resources {
*/
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();
@ -1476,6 +1491,7 @@ public class Resources {
return Resources.getIconTxt();
}
/**
* Gets the icon by type.
*
@ -1491,6 +1507,8 @@ public class Resources {
return Resources.getIconByMediaTypeName(name, mediaTypeName);
}
/**
* Gets the icon by folder enum.
*

Binary file not shown.

Before

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 625 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 660 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,42 +0,0 @@
package org.gcube.portlets.user.workspace.client.util;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.NumberFormat;
/**
* The Class SizeUtil.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 5, 2021
*/
public class SizeUtil {
public static final NumberFormat numberFormat = NumberFormat.getFormat("#,##0.#");
/**
* Readable file size.
*
* @param size the size
* @return the string
*/
public static String readableFileSize(long size) {
GWT.log("Converting size: "+size);
// -1 should be the size of a folder
if (size == -1)
return "";
// in some cases the size returned by SHUB is negative,
// so reporting as 1B to user
if (size < 0)
return "1 byte";
if (size == 0)
return "0 byte";
final String[] units = new String[] { "bytes", "kB", "MB", "GB", "TB" };
int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
return numberFormat.format(size / Math.pow(1024, digitGroups)) +" " +units[digitGroups];
}
}

View File

@ -65,6 +65,7 @@ public class AsyncTreePanel extends LayoutContainer {
private static final String ROOT_SUFFIX = "'s workspace";
private String myRootDisplayName = null;
// private TreeLoader<FileModel> loader;
private TreePanel<FileModel> treePanel;
private TreeStore<FileModel> store;
private ContextMenuTree contextMenuTree;
@ -72,6 +73,7 @@ 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.
@ -79,10 +81,7 @@ public class AsyncTreePanel extends LayoutContainer {
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
* Aug 29, 2016
*/
private enum DragType {
INSERT, APPEND
};
private enum DragType {INSERT, APPEND};
private boolean rightClick = false;
/**
@ -141,6 +140,7 @@ public class AsyncTreePanel extends LayoutContainer {
}
};
treePanel.setStateful(false);
treePanel.setDisplayProperty(FileModel.NAME);
@ -163,10 +163,8 @@ public class AsyncTreePanel extends LayoutContainer {
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<String>() {
@Override
@ -181,8 +179,7 @@ public class AsyncTreePanel extends LayoutContainer {
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{
@ -221,9 +218,14 @@ public class AsyncTreePanel extends LayoutContainer {
if(model.isPublic()) //IS PLUBIC
return Resources.getIconFolderPublic();
else{
if (model.getSynchedWithWsThredds() != null) {
if (model.getSynchedWithWsThredds()) {
return Resources.getIconSynchedFolder();
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();
}
}
return Resources.getIconFolder();
@ -270,8 +272,7 @@ 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);
@ -279,12 +280,18 @@ public class AsyncTreePanel extends LayoutContainer {
}
});
// cp.add(butt);
//***End Debug the store
cp.add(treePanel);
add(cp);
}
/**
* Sets the root display name.
*
@ -300,7 +307,8 @@ public class AsyncTreePanel extends LayoutContainer {
}
/**
* Status values ConstantsExplorer.FOLDERNOTLOAD = "notload";
* Status values
* ConstantsExplorer.FOLDERNOTLOAD = "notload";
* ConstantsExplorer.FOLDERLOADED = "loaded";
*
* @param itemIdentifier the item identifier
@ -313,19 +321,24 @@ public class AsyncTreePanel extends LayoutContainer {
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
AppControllerExplorer.rpcWorkspaceService.getRootForTree(new AsyncCallback<FolderModel>() {
@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);
}
@ -336,6 +349,7 @@ public class AsyncTreePanel extends LayoutContainer {
});
}
/**
* Load root in store.
*
@ -353,9 +367,9 @@ public class AsyncTreePanel extends LayoutContainer {
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);
}
@ -392,6 +406,7 @@ public class AsyncTreePanel extends LayoutContainer {
}
});
TreePanelDropTarget targetTreePanel = new TreePanelDropTarget(treePanel){
// @Override
// protected void onDragDrop(DNDEvent event) {
@ -434,8 +449,7 @@ public class AsyncTreePanel extends LayoutContainer {
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"
// 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;
@ -480,8 +494,7 @@ public class AsyncTreePanel extends LayoutContainer {
FileModel destination = getDragDestination(item, DragType.APPEND);
if(destination != null){
//REMOVE THIS COMMENT TODO
eventBus.fireEvent(
new DragOnTreeMoveItemEvent(listFileModel.get(0), (FolderModel) destination));
eventBus.fireEvent(new DragOnTreeMoveItemEvent(listFileModel.get(0), (FolderModel) destination));
GWT.log("Destination: " +destination.getName() + " id "+ destination.getIdentifier());
}
}else{
@ -509,8 +522,7 @@ public class AsyncTreePanel extends LayoutContainer {
if(destination != null){
GWT.log("Destination: " +destination.getName() + " id "+ destination.getIdentifier());
//REMOVE THIS COMMENT TODO
eventBus.fireEvent(
new DragOnTreeMoveItemEvent(listFileModel.get(0), (FolderModel) destination));
eventBus.fireEvent(new DragOnTreeMoveItemEvent(listFileModel.get(0), (FolderModel) destination));
}
}else{
//multi drag
@ -547,13 +559,9 @@ public class AsyncTreePanel extends LayoutContainer {
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());
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());
}
@ -574,6 +582,7 @@ public class AsyncTreePanel extends LayoutContainer {
// targetTreePanel.setAllowDropOnLeaf(true);
}
/**
* Adds the listners.
*/
@ -621,6 +630,7 @@ public class AsyncTreePanel extends LayoutContainer {
}
System.out.println("***End Event selection change");
}
@ -660,6 +670,7 @@ public class AsyncTreePanel extends LayoutContainer {
}
});
treePanel.addListener(Events.BeforeExpand, new Listener<TreePanelEvent<ModelData>>() {
public void handleEvent(final TreePanelEvent<ModelData> be) {
@ -707,22 +718,24 @@ public class AsyncTreePanel extends LayoutContainer {
//
}
});
}
/**
* Manage context menu.
*/
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<FileModel> selectedItems = treePanel.getSelectionModel().getSelectedItems();
contextMenuTree.viewContextMenu(selectedItems,-1,-1);
}
/**
* Reload tree level and expand folder.
*
@ -757,9 +770,7 @@ public class AsyncTreePanel extends LayoutContainer {
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();
}
@ -792,8 +803,7 @@ public class AsyncTreePanel extends LayoutContainer {
return;
}
treePanel.unmask();
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();
}
@ -832,8 +842,7 @@ public class AsyncTreePanel extends LayoutContainer {
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();
}
@ -893,6 +902,15 @@ public class AsyncTreePanel extends LayoutContainer {
}
// /**
// * 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.
*/
@ -922,20 +940,25 @@ public class AsyncTreePanel extends LayoutContainer {
});
}
// for debugging
//TODO for debug
/**
* Printing tree level.
*
* @param item the item
*/
private void printingTreeLevel(FileModel item){
List<FileModel> 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(" ");
}
}
@ -974,6 +997,7 @@ public class AsyncTreePanel extends LayoutContainer {
return store.getChildCount(folder);
}
/**
* Delete item.
*
@ -986,12 +1010,14 @@ public class AsyncTreePanel extends LayoutContainer {
if(fileTarget!=null){
return deleteItem(fileTarget);
} else
}
else
System.out.println("Delete Error: file target with " + identifier + " identifier not exist in store" );
return false;
}
/**
* Rename item.
*
@ -1011,15 +1037,17 @@ public class AsyncTreePanel extends LayoutContainer {
record.set(FileModel.NAME, newName);
return true;
} else
System.out.println("Record Error: file target with " + fileTarget.getIdentifier()
+ " identifier not exist in store");
} else
}
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.
*
@ -1055,8 +1083,9 @@ 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;
@ -1075,6 +1104,7 @@ public class AsyncTreePanel extends LayoutContainer {
addItem(parent,child,addChildren);
}
/**
* Adds the item.
*
@ -1107,6 +1137,7 @@ public class AsyncTreePanel extends LayoutContainer {
if(identifier==null)
return false;
FileModel fileTarget = getFileModelByIdentifier(identifier);
if(fileTarget==null)
@ -1286,6 +1317,7 @@ public class AsyncTreePanel extends LayoutContainer {
treePanel.setSize(width, height);
}
/**
* Gets the context menu tree.
*

View File

@ -4,10 +4,10 @@ import java.util.Date;
import java.util.List;
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
import org.gcube.portlets.user.workspace.client.model.FileModel;
import org.gcube.portlets.user.workspace.client.resources.Resources;
import org.gcube.portlets.user.workspace.client.util.SizeUtil;
import org.gcube.portlets.widgets.workspacesharingwidget.client.rpc.WorkspaceSharingServiceAsync;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
@ -26,6 +26,7 @@ import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Image;
@ -59,7 +60,7 @@ public class DialogGetInfo extends Dialog {
// private TextArea textAreaSharedWith = new TextArea();
private Html htmlUsersWidget = new Html();
private Html htmlPropertiesWidget = new Html();
//private final NumberFormat number = ConstantsExplorer.numberFormatterKB;
private final NumberFormat number = ConstantsExplorer.numberFormatterKB;
// private TextField<String> txtGcubeItemProperties;
private HorizontalPanel hpGcubeProperties;
private DialogEditProperties editProperties = null;
@ -113,11 +114,11 @@ public class DialogGetInfo extends Dialog {
txtIsPublic.setValue(fileModel.isPublic() + "");
add(txtIsPublic);
if (fileModel.getSynchedWithWsThredds() != null) {
if (fileModel.getSynchedThreddsStatus() != null) {
txtThreddsSynched = new TextField<String>();
txtThreddsSynched.setFieldLabel("Synched with Thredds");
txtThreddsSynched.setFieldLabel("Thredds Sync");
txtThreddsSynched.setReadOnly(true);
txtThreddsSynched.setValue(fileModel.getSynchedWithWsThredds() + "");
txtThreddsSynched.setValue(fileModel.getSynchedThreddsStatus() + "");
add(txtThreddsSynched);
}
@ -447,7 +448,10 @@ public class DialogGetInfo extends Dialog {
private String getFormattedSize(long value) {
if (value > 0) {
return SizeUtil.readableFileSize(value);
double kb = value / 1024;
if (kb < 1)
kb = 1;
return number.format(kb);
} else if (value == 0) {
return EMPTY;
} else

View File

@ -5,6 +5,7 @@ import java.util.List;
import java.util.Map;
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.event.CreateSharedFolderEvent;
import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent;
import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent.DownloadType;
@ -12,7 +13,6 @@ import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
import org.gcube.portlets.user.workspace.client.model.FileModel;
import org.gcube.portlets.user.workspace.client.resources.Resources;
import org.gcube.portlets.user.workspace.client.util.SizeUtil;
import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
import org.gcube.portlets.user.workspace.client.workspace.folder.item.GWTExternalImage;
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTImageDocument;
@ -37,6 +37,7 @@ import com.google.gwt.event.dom.client.LoadEvent;
import com.google.gwt.event.dom.client.LoadHandler;
import com.google.gwt.http.client.URL;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Command;
@ -50,6 +51,7 @@ import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.NamedFrame;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.server.Base64Utils;
// TODO: Auto-generated Javadoc
/**
@ -61,9 +63,6 @@ import com.google.gwt.user.client.ui.Widget;
public class DialogGetInfoBootstrap extends Composite {
private static final int PREVIEW_WAITING_TIME = 9000; //9 sec
private static final int PREVIEW_MAX_RETRIES = 3;
private int showPreviewAttempt = 0;
private long loaderPreviewStartTime = 0;
private static DialogGetInfoBootstrapUiBinder uiBinder = GWT.create(DialogGetInfoBootstrapUiBinder.class);
@ -78,7 +77,7 @@ public class DialogGetInfoBootstrap extends Composite {
public static final String EMPTY = "empty";
//private final NumberFormat number = ConstantsExplorer.numberFormatterKB;
private final NumberFormat number = ConstantsExplorer.numberFormatterKB;
/**
* Instantiates a new dialog get info bootstrap.
@ -194,9 +193,9 @@ public class DialogGetInfoBootstrap extends Composite {
private Map<String, List<String>> mapAllowedMimeTypesForPreview;
private Image spinnerImage = Resources.getSpinner().createImage();
private Image spinnerImage = Resources.getIconLoading().createImage();
private Image noPreviewAvailable = new Image(Resources.getPreviewNotAvailableNoBorder());
private Image noPreviewAvailable = new Image(Resources.getPreviewNotAvailable());
private Frame iFrameGDV = null;
@ -294,15 +293,10 @@ public class DialogGetInfoBootstrap extends Composite {
cgTxtIsPublic.setVisible(true);
htmlSetValue(txtIsPublic, fileModel.isPublic() + "");
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() + "");
}
if (fileModel.getSynchedThreddsStatus() != null) {
txtThreddsSynched.setVisible(true);
htmlSetValue(txtThreddsSynched, fileModel.getSynchedThreddsStatus() + "");
txtThreddsSynched.setHTML(fileModel.getSynchedThreddsStatus() + "");
}
}
@ -311,8 +305,13 @@ public class DialogGetInfoBootstrap extends Composite {
htmlSetValue(txtMimeType, fileModel.getType());
txtAreaDescription.setResize(ResizeType.VERTICAL);
//load description
if (fileModel.isDirectory()) {
txtAreaDescription.setValue(fileModel.getDescription());
// add(txtAreaDescription);
} else
loadDescription(fileModel.getIdentifier());
//owner
htmlSetValue(txtOwner, fileModel.getOwnerFullName());
//creation date
@ -328,12 +327,14 @@ public class DialogGetInfoBootstrap extends Composite {
}else {
loadLastModificationDate(fileModel.getIdentifier());
loadSize(fileModel.getIdentifier());
}
htmlSetValue(txtShared, fileModel.isShared()+"");
// USERS SHARED
if (fileModel.isShared()) {
cgSharedWith.setVisible(true);
loadACLsDescriptionForSharedFolder(fileModel.getIdentifier());
}
@ -396,14 +397,12 @@ public class DialogGetInfoBootstrap extends Composite {
return;
}
final String googleDocViewerURL = "https://docs.google.com/viewer?url="
String googleDocViewerURL = "https://docs.google.com/viewer?url="
+ URL.encode(result.getCompleteURL()) + "&embedded=true";
iFrameGDV = instanceFrame(googleDocViewerURL, loadingPreviewHTML);
loaderPreviewStartTime = new Date().getTime();
showPreviewAttempt = 1;
final long startTime = new Date().getTime();
timerGDV = new Timer() {
@Override
@ -416,11 +415,10 @@ public class DialogGetInfoBootstrap extends Composite {
return;
}
long checkTime = new Date().getTime();
long diff = checkTime - loaderPreviewStartTime;
if (diff > PREVIEW_WAITING_TIME) { // is greater than PREVIEW_WAITING_TIME, performs a new attempt or terminate
if(showPreviewAttempt >= PREVIEW_MAX_RETRIES) {
long diff = checkTime - startTime;
if (diff > PREVIEW_WAITING_TIME) {// is greater than 10 sec
try {
GWT.log("iFrameGoogleDocViewer not loaded within "+PREVIEW_WAITING_TIME+" sec and max retries "+PREVIEW_MAX_RETRIES+", cancelling timer, removing iframe");
GWT.log("iFrameGoogleDocViewer not loaded within "+PREVIEW_WAITING_TIME+" sec, cancelling timer, removing iframe");
cancel();
removePlaceHolder(loadingPreviewHTML);
htmlPanelFilePreview.add(noPreviewAvailable);
@ -429,29 +427,10 @@ public class DialogGetInfoBootstrap extends Composite {
} catch (Exception e) {
// Silent
}
}else {
GWT.log("iFrameGoogleDocViewer not loaded on attempt "+showPreviewAttempt+", instancing new iFrame");
//new retry by instancing the iFrame again...
iFrameGDV = instanceFrame(googleDocViewerURL, loadingPreviewHTML);
try {
//removing old iFrame
htmlPanelFilePreview.remove(iFrameGDV);
}catch (Exception e) {
//silent
}
//adding the new one
htmlPanelFilePreview.add(iFrameGDV);
//new attempt so incrementing it
showPreviewAttempt++;
GWT.log("Retry, go to attempt "+showPreviewAttempt);
//resetting start time for new attempt
loaderPreviewStartTime = new Date().getTime();
}
}
}
};
int attemptRepeater = PREVIEW_WAITING_TIME / 3;
timerGDV.scheduleRepeating(attemptRepeater);
timerGDV.scheduleRepeating(PREVIEW_WAITING_TIME/3);
htmlPanelFilePreview.add(iFrameGDV);
}
@ -467,9 +446,6 @@ public class DialogGetInfoBootstrap extends Composite {
addHandlers();
}
/**
* On detach.
*/
@Override
protected void onDetach() {
super.onDetach();
@ -484,13 +460,6 @@ public class DialogGetInfoBootstrap extends Composite {
}
}
/**
* Instance frame.
*
* @param fileURL the file URL
* @param thePreviewPlaceholder the the preview placeholder
* @return the frame
*/
public Frame instanceFrame(String fileURL, final HTML thePreviewPlaceholder) {
//addLoading();
String urlEncoded = URL.encode(fileURL);
@ -552,7 +521,6 @@ public class DialogGetInfoBootstrap extends Composite {
@Override
public void onFailure(Throwable caught) {
loadDescription(fileModel.getIdentifier());
new MessageBoxAlert("Error on updating description...", caught.getMessage(), null);
}
@ -627,7 +595,10 @@ public class DialogGetInfoBootstrap extends Composite {
private String getFormattedSize(long value) {
if (value > 0) {
return SizeUtil.readableFileSize(value);
double kb = value / 1024;
if (kb < 1)
kb = 1;
return number.format(kb);
} else if (value == 0) {
return EMPTY;
} else
@ -900,7 +871,6 @@ public class DialogGetInfoBootstrap extends Composite {
* Sets the placeholder.
*
* @param html the html
* @param spinner the spinner
* @param placeholder the placeholder
*/
private void setPlaceholder(HTML html, boolean spinner, String placeholder) {
@ -923,13 +893,6 @@ public class DialogGetInfoBootstrap extends Composite {
}
/**
* Show PDF preview.
*
* @param pdfURL the pdf URL
* @param divId the div id
* @return the string
*/
public static native String showPDFPreview(String pdfURL, String divId)/*-{
var theDivContainer = "#"+divId;
$wnd.PDFObject.embed(pdfURL, theDivContainer);

View File

@ -73,7 +73,7 @@
<b:ControlGroup
addStyleNames="my-control-group-get-info"
ui:field="cgThreddsSynched" visible="false">
<b:ControlLabel title="Synched with THREDDS">Synched</b:ControlLabel>
<b:ControlLabel>Thredds Sync</b:ControlLabel>
<b:Controls>
<g:HTML ui:field="txtThreddsSynched">
</g:HTML>

View File

@ -264,8 +264,9 @@ table.userssuggest th {
margin-left: -600px !important;
}
.modal-body-ws-tree {
max-height: 700px !important;
.modal-body-custom {
height: 550px !important;
max-height: none !important;
}
.modal-top-custom {
@ -412,12 +413,6 @@ IN THE 'DETAILS' PANEL*/
display: flex;
align-items: center;
justify-content: center;
margin-left: 10px;
border: 1px solid #e6e6e6;
padding-top: 5px;
padding-bottom: 5px;
border-left: none;
border-right: none;
}
.preview-image-style img {
@ -429,12 +424,6 @@ IN THE 'DETAILS' PANEL*/
display: flex;
align-items: center;
justify-content: center;
margin-left: 10px;
border: 1px solid #e6e6e6;
padding-top: 5px;
padding-bottom: 5px;
border-left: none;
border-right: none;
}
.my-preview-doc {

View File

@ -153,7 +153,7 @@ public class DownloadServlet extends HttpServlet{
ByteArrayInputStream is = new ByteArrayInputStream(fileContent.getBytes());
String contentDisposition = viewContent?"inline":"attachment";
String urlMimeType = "text/uri-list";
String itemName = MimeTypeUtility.getNameWithExtension(item.getName(), urlMimeType, false);
String itemName = MimeTypeUtility.getNameWithExtension(item.getName(), urlMimeType);
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
resp.setContentType(urlMimeType);
@ -190,7 +190,7 @@ public class DownloadServlet extends HttpServlet{
logger.info("Downloading the folder: "+workspaceFolder);
String contentDisposition = viewContent?"inline":"attachment";
String mimeType = "application/zip";
String itemName = MimeTypeUtility.getNameWithExtension(item.getName(), mimeType,true);
String itemName = MimeTypeUtility.getNameWithExtension(item.getName(), mimeType);
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
resp.setContentType(mimeType);
@ -233,7 +233,7 @@ public class DownloadServlet extends HttpServlet{
String mimeType = pdfFile.getMimeType();
logger.trace("EXTERNAL_FILE DOWNLOAD FOR "+pdfFile.getId());
String contentDisposition = viewContent?"inline":"attachment";
String itemName = MimeTypeUtility.getNameWithExtension(descr.getItemName(), mimeType,false);
String itemName = MimeTypeUtility.getNameWithExtension(descr.getItemName(), mimeType);
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
resp.setContentType(mimeType);
@ -267,7 +267,7 @@ public class DownloadServlet extends HttpServlet{
ImageFileItem imageFile = (ImageFileItem) workspaceFileItem;
logger.info("Downloading: "+imageFile);
String mimeType = imageFile.getMimeType();
String itemName = MimeTypeUtility.getNameWithExtension(descr.getItemName(), mimeType,false);
String itemName = MimeTypeUtility.getNameWithExtension(descr.getItemName(), mimeType);
String contentDisposition = viewContent?"inline":"attachment";
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
resp.setContentType(mimeType);
@ -298,7 +298,7 @@ public class DownloadServlet extends HttpServlet{
URLFileItem externalUrl = (URLFileItem) workspaceFileItem;
logger.info("Downloading: "+externalUrl);
String urlMimeType = "text/uri-list";
String itemName = MimeTypeUtility.getNameWithExtension(descr.getItemName(), urlMimeType,false);
String itemName = MimeTypeUtility.getNameWithExtension(descr.getItemName(), urlMimeType);
String contentDisposition = viewContent?"inline":"attachment";
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
resp.setContentType(urlMimeType);
@ -347,7 +347,7 @@ public class DownloadServlet extends HttpServlet{
try{
String itemName = MimeTypeUtility.getNameWithExtension(descr.getItemName(), workspaceFileItem.getMimeType(),false);
String itemName = MimeTypeUtility.getNameWithExtension(descr.getItemName(), workspaceFileItem.getMimeType());
logger.info("Downloading default item: "+workspaceFileItem);
//String contentDisposition = viewContent?"inline":"attachment";

View File

@ -9,7 +9,6 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.gcube.common.storagehub.model.types.WorkspaceItemType;
import org.gcube.common.storagehubwrapper.shared.Member;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
@ -161,13 +160,18 @@ public class NotificationStorageHubUtil {
if(isFolderAndShared(rootSharedFolder)){ //JUST TO BE SURE
List<Member> listMembers = workspace.getSharedFolderMembers(rootSharedFolder.getId());
logger.debug("StorageHub returned "+ listMembers.size() + " user/s");
List<String> listPortalLogin = workspace.getSharedFolderMembers(rootSharedFolder.getId());
logger.debug("StorageHub returned "+ listPortalLogin.size() + " user/s");
if(!WsUtil.isWithinPortal())
return StorageHubToWorkpaceConverter.buildGxtInfoContactFromPortalLoginTestMode(listMembers);
return StorageHubToWorkpaceConverter.buildGxtInfoContactFromPortalLoginTestMode(listPortalLogin);
return StorageHubToWorkpaceConverter.listMembersToListContact(listMembers);
List<InfoContactModel> listContacts = new ArrayList<InfoContactModel>(listPortalLogin.size());
for (String login : listPortalLogin) {
listContacts.add(StorageHubToWorkpaceConverter.buildGxtInfoContactFromPortalLogin(login));
}
return listContacts;
}
else
logger.debug("the item with id: "+rootSharedFolder.getId()+ " is not "+WorkspaceItemType.SHARED_FOLDER);

View File

@ -10,8 +10,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.gcube.common.resources.gcore.utils.XPathHelper;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.common.scope.impl.ScopeBean.Type;
import org.gcube.portlets.user.workspace.server.util.WsUtil;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.Query;
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
@ -20,6 +19,7 @@ import org.slf4j.LoggerFactory;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
/**
* The Class ApplicationProfileReader.
*
@ -48,20 +48,6 @@ public class ApplicationProfileReader {
private String resourceName;
private String appID;
public enum APPLICATION_PROFILE_ITEM {
SCOPE("/Scope/text()"), URL("/URL/text()");
private String xPath;
APPLICATION_PROFILE_ITEM(String xpath) {
this.xPath = xpath;
}
public String getXPath() {
return xPath;
}
}
/**
* Instantiates a new application profile reader.
@ -78,17 +64,15 @@ public class ApplicationProfileReader {
this.scope = ScopeProvider.instance.get();
}
/**
* this method looks up the generic resource among the ones available in the
* infrastructure using scope provider {@link ScopeProvider.instance.get()}
* resource name {@value #WORKSPACE_EXPLORER_APP_NAME} and secondaryType
* {@value #SECONDARY_TYPE}
* this method looks up the generic resource among the ones available in the infrastructure using scope provider {@link ScopeProvider.instance.get()}
* resource name {@value #WORKSPACE_EXPLORER_APP_NAME} and secondaryType {@value #SECONDARY_TYPE}
*
* @return the applicationProfile profile
*/
/**
* this method looks up the applicationProfile profile among the ones available
* in the infrastructure.
* this method looks up the applicationProfile profile among the ones available in the infrastructure.
*
* @return the applicationProfile profile
*/
@ -102,15 +86,13 @@ public class ApplicationProfileReader {
if(scope==null)
throw new Exception("Scope is null, set scope into ScopeProvider");
logger.info("Trying to fetch " + SECONDARY_TYPE + " in the scope: " + scope + ", SecondaryType: "
+ secondaryType + ", AppId: " + appID);
logger.info("Trying to fetch ApplicationProfile in the scope: "+scope+", SecondaryType: " + secondaryType + ", AppId: " + appID);
Query q = new QueryBox(queryString);
DiscoveryClient<String> client = client();
List<String> appProfile = client.submit(q);
if (appProfile == null || appProfile.size() == 0)
throw new ApplicationProfileNotFoundException("Generic Resource with SecondaryType: " + secondaryType
+ ", AppId: " + appID + " is not registered in the scope: " + scope);
throw new ApplicationProfileNotFoundException("ApplicationProfile with SecondaryType: " + secondaryType + ", AppId: " + appID +" is not registered in the scope: "+scope);
else {
String elem = appProfile.get(0);
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
@ -121,36 +103,77 @@ public class ApplicationProfileReader {
currValue = helper.evaluate(RESOURCE_PROFILE_NAME_TEXT);
if (currValue != null && currValue.size() > 0) {
appProf.setName(currValue.get(0));
} else
throw new ApplicationProfileNotFoundException(
"Your " + SECONDARY_TYPE + " NAME was not found in the generic resource");
}
else throw new ApplicationProfileNotFoundException("Your applicationProfile NAME was not found in the profile");
currValue = helper.evaluate(RESOURCE_PROFILE_DESCRIPTION_TEXT);
if (currValue != null && currValue.size() > 0) {
appProf.setDescription(currValue.get(0));
} else
logger.warn("No Description exists for " + appProf.getName());
}
else logger.warn("No Description exists for " + appProf.getName());
currValue = helper.evaluate(RESOURCE_PROFILE_BODY_APP_ID_TEXT);
if (currValue != null && currValue.size() > 0) {
appProf.setKey(currValue.get(0));
} else
throw new ApplicationProfileNotFoundException("Your " + SECONDARY_TYPE
+ " ID was not found in the generic resource, consider adding <AppId> element in <Body>");
}
else throw new ApplicationProfileNotFoundException("Your applicationProfile ID n was not found in the profile, consider adding <AppId> element in <Body>");
currValue = helper.evaluate(RESOURCE_PROFILE_BODY_THUMBNAIL_URL_TEXT);
if (currValue != null && currValue.size() > 0) {
appProf.setImageUrl(currValue.get(0));
} else {
logger.warn("Null or empty <ThumbnailURL> element in <Body> of " + appProf.getName());
}
else{
logger.warn("Null or empty <ThumbnailURL> element in <Body>" + appProf.getName());
}
currValue = helper
.evaluate("/Resource/Profile/Body/EndPoint[Scope='" + scope.toString() + "']/Scope/text()");
currValue = helper.evaluate("/Resource/Profile/Body/EndPoint[Scope='"+scope.toString()+"']/Scope/text()");
appProf = readEndPointForScopeWithRetry(helper, scope, APPLICATION_PROFILE_ITEM.SCOPE, appProf);
if (currValue != null && currValue.size() > 0) {
List<String> scopes = currValue;
String currentScope = scopes.get(0);
appProf = readEndPointForScopeWithRetry(helper, scope, APPLICATION_PROFILE_ITEM.URL, appProf);
//int slashCount = StringUtils.countMatches(currentScope, "/");
boolean isVRE = WsUtil.isVRE(currentScope);
//if(slashCount < 3){//CASE not VRE - set session scope
if(!isVRE){//CASE not VRE - set session scope
logger.info("Scope "+ scope.toString() + " is not a VRE");
List<String> listSessionScope = helper.evaluate("/Resource/Profile/Body/EndPoint[Scope='"+scope.toString()+"']/Sessionscope/text()"); //get session scope of i+1-mo scope
logger.debug("ListSessionScope is: "+ listSessionScope.toString());
if(listSessionScope!=null && listSessionScope.size()>0){ //If sessions scope exists
logger.debug("setting session scope "+ listSessionScope.get(0));
appProf.setScope(listSessionScope.get(0));
}
else{
logger.trace("session scope not exists setting scope "+ scope.toString());
appProf.setScope(scope.toString());
}
}
else{ //CASE IS A VRE
logger.info("Scope "+ scope.toString() + " is a VRE");
appProf.setScope(scope.toString());
}
//RETRIEVE URL
currValue = helper.evaluate("/Resource/Profile/Body/EndPoint[Scope='"+scope.toString()+"']/URL/text()");
if (currValue != null && currValue.size() > 0) {
String url = currValue.get(0);
// System.out.println("URL "+url);
if(url!=null)
appProf.setUrl(url);
else
throw new ApplicationProfileNotFoundException("Your applicationProfile URL was not found in the profile for Scope: " + scope.toString());
}
else throw new ApplicationProfileNotFoundException("Your applicationProfile URL was not found in the profile for Scope: " + scope.toString());
}
else throw new ApplicationProfileNotFoundException("Your applicationProfile with scope "+scope.toString()+" was not found in the profile, consider adding <EndPoint><Scope> element in <Body>");
logger.debug("returning: "+appProf);
return appProf;
@ -161,84 +184,30 @@ public class ApplicationProfileReader {
return null;
}finally{
/*
* if(originalScope!=null && !originalScope.isEmpty()){
* ScopeProvider.instance.set(originalScope);
* logger.info("scope provider setted to orginal scope: "+originalScope); }else{
* ScopeProvider.instance.reset(); logger.info("scope provider reset"); }
*/
if(originalScope!=null && !originalScope.isEmpty()){
ScopeProvider.instance.set(originalScope);
logger.info("scope provider setted to orginal scope: "+originalScope);
}else{
ScopeProvider.instance.reset();
logger.info("scope provider reset");
}*/
}
}
private ApplicationProfile readEndPointForScopeWithRetry(XPathHelper helper, String scope,
APPLICATION_PROFILE_ITEM searchItem, ApplicationProfile appProf)
throws ApplicationProfileNotFoundException {
String xPathToQuery = "/Resource/Profile/Body/EndPoint[Scope='" + scope + "']" + searchItem.getXPath();
logger.debug("Identifying path with current scope: " + xPathToQuery);
List<String> currValue = helper.evaluate(xPathToQuery);
String queryResult = null;
if (currValue == null || currValue.isEmpty()) {
logger.warn("In the " + SECONDARY_TYPE + " with name " + appProf.getName() + " the xPath " + xPathToQuery
+ " returned with no results");
ScopeBean scopeBean = new ScopeBean(scope);
if (scopeBean.is(Type.VRE) || scopeBean.is(Type.VO)) {
String pathSeparator = "/";
String[] components = scope.split(pathSeparator);
scope = pathSeparator + components[1];
logger.info("The scope "+scopeBean.toString()+" is of kind " + Type.VRE + " or " + Type.VO
+ ". Retry in action - going to search the default <EndPoint> with the root scope: " + scope);
xPathToQuery = "/Resource/Profile/Body/EndPoint[Scope='" + scope + "']" + searchItem.getXPath();
logger.debug("Identifying path with root scope: " + xPathToQuery);
currValue = helper.evaluate(xPathToQuery);
if (currValue == null || currValue.isEmpty()) {
logger.warn("In the " + SECONDARY_TYPE + " with name " + appProf.getName() + " the xPath " + xPathToQuery
+ " returned with no results");
}
}
}
if (currValue == null || currValue.isEmpty()) {
throw new ApplicationProfileNotFoundException("Your ApplicationProfile in the scope " + scope
+ " have not an <EndPoint> accessible, consider adding <EndPoint><Scope></Scope> element in <Body>");
}
queryResult = currValue.get(0);
logger.info("The xPath: " + xPathToQuery + " returned with the result: " + queryResult);
switch (searchItem) {
case SCOPE:
appProf.setScope(currValue.get(0));
break;
case URL:
appProf.setUrl(currValue.get(0));
break;
default:
break;
}
return appProf;
}
/**
* Gets the gcube generic xPath string.
* Gets the gcube generic query string.
*
* @param secondaryType the secondary type
* @param appId the app id
* @return the gcube generic xPath string
* @return the gcube generic query string
*/
public static String getGcubeGenericQueryString(String secondaryType, String appId){
return "for $profile in collection('/db/Profiles/GenericResource')//Resource "
+ "where $profile/Profile/SecondaryType/string() eq '" + secondaryType
+ "' and $profile/Profile/Body/AppId/string() " + " eq '" + appId + "'" + "return $profile";
return "for $profile in collection('/db/Profiles/GenericResource')//Resource " +
"where $profile/Profile/SecondaryType/string() eq '"+secondaryType+"' and $profile/Profile/Body/AppId/string() " +
" eq '" + appId + "'" +
"return $profile";
}
/**
@ -250,6 +219,7 @@ public class ApplicationProfileReader {
return secondaryType;
}
/**
* Gets the scope.
*
@ -268,9 +238,8 @@ public class ApplicationProfileReader {
return resourceName;
}
/*
* (non-Javadoc)
*
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
@ -289,4 +258,20 @@ public class ApplicationProfileReader {
return builder.toString();
}
// public static void main(String[] args) {
//
// try {
// ScopeProvider.instance.set("/gcube");
// ApplicationProfileReader ap = new ApplicationProfileReader("Workspace-Explorer-App", "org.gcube.portlets.user.workspaceexplorerapp.server.WorkspaceExplorerAppServiceImpl");
// System.out.println(ap.readProfileFromInfrastrucure());
// }
// catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
//
//
// }
}

View File

@ -63,6 +63,9 @@ 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;
@ -79,7 +82,7 @@ public class ObjectStorageHubToWorkpaceMapper {
* @return the file model
* @throws InternalErrorException the internal error exception
*/
public static FileModel toTreeFileModelItem(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem, FileModel parentFolderModel, boolean isParentShared, GCubeUser loggedUser) throws InternalErrorException{
public static FileModel toTreeFileModelItem(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem, FileModel parentFolderModel, boolean isParentShared) throws InternalErrorException{
FileModel fileModel = null;
//boolean isPublic = false;
@ -145,8 +148,6 @@ public class ObjectStorageHubToWorkpaceMapper {
fileModel.setShareable(false);
}
setFullNameOwner(wrappedItem, fileModel, loggedUser);
//setSynchedThreddsStateFor(fileModel);
fileModel.setIsRoot(wrappedItem.isRoot());
logger.trace("Returning converted tree item: "+fileModel);
@ -249,32 +250,27 @@ public class ObjectStorageHubToWorkpaceMapper {
fileGridModel.setShareable(false); //UPDATED TO CHANGE PERMISSIONS TO SHARED SUBFOLDERS
}
setFullNameOwner(wrappedItem, fileGridModel, loggedUser);
logger.trace("Returning converted grid item: "+fileGridModel);
return fileGridModel;
}
private static void setFullNameOwner(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem, FileModel fileModel, GCubeUser loggedUser) {
//OWNER
if(wrappedItem.isShared()){ //IT IS READ FROM SHUB ONLY IF THE ITEM IS SHARED
fileModel.setShared(true); //NOT REMOVE IT IS IMPORTANT, SEE #1459
fileGridModel.setShared(true); //NOT REMOVE IT IS IMPORTANT, SEE #1459
String ownerUsername = wrappedItem.getOwner();
if(ownerUsername!=null){
// System.out.println("++++reading owner");
//String portalLogin = owner.getPortalLogin();
fileModel.setOwnerFullName(UserUtil.getUserFullName(ownerUsername));
fileGridModel.setOwnerFullName(UserUtil.getUserFullName(ownerUsername));
}
}
else{
String ownerUsername = wrappedItem.getOwner();
//Task #12911 I'm calling getUserFullName for any user other than logged user
if(ownerUsername!=null && ownerUsername.compareToIgnoreCase(loggedUser.getUsername())!=0){
fileModel.setOwnerFullName(UserUtil.getUserFullName(ownerUsername));
fileGridModel.setOwnerFullName(UserUtil.getUserFullName(ownerUsername));
}else
fileModel.setOwnerFullName(loggedUser.getFullname());
fileGridModel.setOwnerFullName(loggedUser.getFullname());
}
logger.trace("Returning converted grid item: "+fileGridModel);
return fileGridModel;
}

View File

@ -3,6 +3,7 @@
*/
package org.gcube.portlets.user.workspace.server.tostoragehub;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
@ -25,7 +26,6 @@ import org.gcube.common.storagehub.model.items.nodes.accounting.AccountFolderEnt
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountFolderEntryRemoval;
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountFolderEntryRenaming;
import org.gcube.common.storagehub.model.items.nodes.accounting.AccountingEntryType;
import org.gcube.common.storagehubwrapper.shared.Member;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItemType;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
@ -33,6 +33,7 @@ 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;
@ -44,16 +45,13 @@ 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.UserManager;
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class StorageHubToWorkpaceConverter.
*
@ -62,6 +60,7 @@ import org.slf4j.LoggerFactory;
*/
public class StorageHubToWorkpaceConverter implements Serializable{
/**
*
*/
@ -72,6 +71,8 @@ public class StorageHubToWorkpaceConverter implements Serializable {
private GCubeUser loggedUser;
private String workspaceRootId;
/**
* Instantiates a new storage hub to workpace converter.
*/
@ -79,6 +80,68 @@ public class StorageHubToWorkpaceConverter implements Serializable {
}
/**********************************************************************************************************************************************
*
*
*
*
* TESTING MODE METHODS
*
*
*
*
***********************************************************************************************************************************************/
protected static HashMap<String, InfoContactModel> hashTestUser = null;
/**
* Used in test mode.
*
* @return the hash test users
*/
public static HashMap<String, InfoContactModel> getHashTestUsers(){
if(hashTestUser==null){
hashTestUser = new HashMap<String, InfoContactModel>();
//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<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode(List<String> listPortalLogin){
List<InfoContactModel> listContact = new ArrayList<InfoContactModel>();
for (String portalLogin : listPortalLogin)
listContact.add(getHashTestUsers().get(portalLogin));
return listContact;
}
/**********************************************************************************************************************************************
*
*
*
*
* END TESTING MODE
*
*
*
*
***********************************************************************************************************************************************/
/**
* To version history.
*
@ -95,14 +158,14 @@ public class StorageHubToWorkpaceConverter implements Serializable {
List<FileVersionModel> listVersions = new ArrayList<FileVersionModel>(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.
*
@ -114,6 +177,7 @@ public class StorageHubToWorkpaceConverter implements Serializable {
this.loggedUser = loggedUser;
}
/**
* To root folder.
*
@ -121,8 +185,7 @@ 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);
@ -137,14 +200,14 @@ public class StorageHubToWorkpaceConverter implements Serializable {
* @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, loggedUser);
return setSynchedWithWsThredds(fileModel, wrappedItem);
FileModel fileModel = ObjectStorageHubToWorkpaceMapper.toTreeFileModelItem(wrappedItem, parentFolderModel, isParentShared);
return setSynchedThreddsStateFor(fileModel, wrappedItem);
}
/**
* To grid file model.
*
@ -153,70 +216,48 @@ public class StorageHubToWorkpaceConverter implements Serializable {
* @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) setSynchedWithWsThredds(fileGridModel, wrappedItem);
FileGridModel fileGridModel = ObjectStorageHubToWorkpaceMapper.toGridFileModelItem(wrappedItem, parentFolderModel, loggedUser);
return (FileGridModel) setSynchedThreddsStateFor(fileGridModel, wrappedItem);
}
protected FileModel setSynchedWithWsThredds(FileModel fileModel, WorkspaceItem wrappedItem) {
logger.debug("called setSynchedThreddsStateFor item id: " + wrappedItem.getId());
boolean isItemSynched = false;
/**
* 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) {
Sync_Status status = null;
try {
if(wrappedItem.getPropertyMap()!=null) {
String wsSyncStatus = null;
try{
Map<String, Object> mapProperties = wrappedItem.getPropertyMap().getValues();
ContainerType containerItemType = 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;
}
}
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);
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.info("Error on calling isItemSynched for the item id: " + wrappedItem.getId()
+ ", (means not synched)");
logger.warn(wsSyncStatus + " is not value of "+Sync_Status.values()+", returning null");
}
}
} catch (Exception e) {
logger.warn("It is not possible to get synched status for item: "+fileModel.getIdentifier());
}
logger.debug("the item id: " + wrappedItem.getId() + " with name: " + wrappedItem.getName() + " is synched: "
+ isItemSynched);
fileModel.setSynchedWithWsThredds(isItemSynched);
fileModel.setSyncThreddsStatus(status);
return fileModel;
}
/**
* To file trashed model.
*
@ -260,15 +301,13 @@ public class StorageHubToWorkpaceConverter implements Serializable {
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);
}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;
}
@ -277,6 +316,7 @@ public class StorageHubToWorkpaceConverter implements Serializable {
}
/**
* Builds the gxt info contact from portal login.
*
@ -304,51 +344,9 @@ public class StorageHubToWorkpaceConverter implements Serializable {
return new InfoContactModel(portalLogin, portalLogin, fullName, emailDomain,false);
}
public static List<InfoContactModel> listMembersToListContact(List<Member> members) {
logger.info("listMembersToListContact called for " + members.size() + " member/s");
List<InfoContactModel> listContacts = new ArrayList<InfoContactModel>();
UserManager userManager = new LiferayUserManager();
for (Member member : members) {
logger.debug("Resolving member: " + member);
boolean isGroup = member.getMemberType().equals(Member.TYPE.GROUP) ? true : false;
if (!isGroup) {
InfoContactModel icm = buildGxtInfoContactFromPortalLogin(member.getIdentity());
// HE/SHE IS A USER
listContacts.add(icm);
} else {
// HE/SHE IS A GROUP
logger.debug("The member: " + member + " is a group, resolving list of Users from "
+ LiferayUserManager.class.getSimpleName() + " for the group name: " + member.getName());
try {
List<GCubeUser> listUsers = userManager.listUsersByGroupName(member.getName());
if (listUsers != null) {
logger.debug("List of user for groupName are: " + listUsers.size());
for (GCubeUser user : listUsers) {
InfoContactModel icm = buildGxtInfoContactFromPortalLogin(user.getUsername());
listContacts.add(icm);
}
} else {
logger.warn("List of user for groupName: " + member.getName() + " is null");
}
} catch (UserManagementSystemException | GroupRetrievalFault | UserRetrievalFault e) {
logger.warn("Error occurrend on resolving the member: " + member.getName(), e);
}
}
}
logger.info("Returning " + listContacts.size() + " from members");
return listContacts;
}
/**
* 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
@ -356,10 +354,7 @@ public class StorageHubToWorkpaceConverter implements Serializable {
* @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 = "";
@ -376,8 +371,7 @@ public class StorageHubToWorkpaceConverter implements Serializable {
name = shared.getName();
//MANAGEMENT SPECIAL FOLDER
} else if (wsFolder.getName().compareTo(ConstantsExplorer.MY_SPECIAL_FOLDERS) == 0 && parent != null
&& parent.isRoot()) {
}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())
@ -390,15 +384,12 @@ public class StorageHubToWorkpaceConverter implements Serializable {
}
logger.debug("Name is: "+name);
boolean isPublicDir = ((org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) wsFolder)
.isPublicFolder(); // TODO
boolean isPublicDir = ((org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) wsFolder).isPublicFolder(); //TODO
FileModel parentModel = null;
if(parent!=null)
parentModel = ObjectStorageHubToWorkpaceMapper.toTreeFileModelItem(parent, null, parent.isShared(),
loggedUser);
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());
@ -411,6 +402,7 @@ public class StorageHubToWorkpaceConverter implements Serializable {
return folder;
}
/**
* Gets the workspace root id.
*
@ -421,6 +413,7 @@ public class StorageHubToWorkpaceConverter implements Serializable {
return workspaceRootId;
}
/**
* Sets the workspace root id.
*
@ -431,6 +424,8 @@ public class StorageHubToWorkpaceConverter implements Serializable {
this.workspaceRootId = workspaceRootId;
}
/**
* To simple map.
*
@ -464,6 +459,7 @@ public class StorageHubToWorkpaceConverter implements Serializable {
}
}
/**
* Builds the GXT accounting item.
*
@ -471,8 +467,7 @@ public class StorageHubToWorkpaceConverter implements Serializable {
* @param gxtEntryType the gxt entry type
* @return the list
*/
public List<GxtAccountingField> buildGXTAccountingItem(List<AccountEntry> accoutings,
GxtAccountingEntryType gxtEntryType) {
public List<GxtAccountingField> buildGXTAccountingItem(List<AccountEntry> accoutings, GxtAccountingEntryType gxtEntryType) {
List<GxtAccountingField> listAccFields = new ArrayList<GxtAccountingField>();
@ -497,25 +492,20 @@ 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.getVersion()==null)
msg = create.getItemName() + " " + GxtAccountingEntryType.CREATE.getName() + " by "
+ user.getName();
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);
@ -525,13 +515,11 @@ 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())
@ -539,11 +527,9 @@ public class StorageHubToWorkpaceConverter implements Serializable {
else{
if(read.getVersion()==null)
msg = read.getItemName() + " " + GxtAccountingEntryType.READ.getName() + " by "
+ user.getName();
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);
@ -553,9 +539,7 @@ 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);
@ -568,18 +552,14 @@ public class StorageHubToWorkpaceConverter implements Serializable {
msg = GxtAccountingEntryType.CUT.getName() +" by "+user.getName();
else{
if(cut.getVersion()==null)
msg = cut.getItemName() + " " + GxtAccountingEntryType.CUT.getName() + " by "
+ user.getName();
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());
logger.warn("Found an "+AccountingEntryType.class.getSimpleName()+" of kind "+shubAccEntry.getType()+ " not castable to (instance of) "+AccountFolderEntryCut.class.getSimpleName());
}
}
@ -587,118 +567,91 @@ 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());
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(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() + " ";
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());
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) {
af.setOperation(GxtAccountingEntryType.RENAME);
AccountFolderEntryRenaming ren = (AccountFolderEntryRenaming) shubAccEntry;
String msg = ren.getOldItemName() == null || ren.getOldItemName().isEmpty() ? ""
: ren.getOldItemName() + " ";
String msg = ren.getOldItemName()==null || ren.getOldItemName().isEmpty()?"":ren.getOldItemName()+" ";
if(ren.getVersion()==null)
msg += GxtAccountingEntryType.RENAME.getName() + " to " + ren.getNewItemName() + " by "
+ user.getName();
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());
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(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() + " ";
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());
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() + " ";
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);
}
@ -706,9 +659,7 @@ 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);
@ -718,12 +669,10 @@ public class StorageHubToWorkpaceConverter implements Serializable {
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()));
msg+=" with "+UserUtil.separateFullNameToCommaForPortalLogin(Arrays.asList(acc.getMembers()));
af.setDescription(msg);
}
@ -731,15 +680,12 @@ 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() + "\" ";
msg+= uns.getItemName()==null || uns.getItemName().isEmpty()?"":"\""+uns.getItemName()+"\" ";
//see Task #19544
if(shubAccEntry.getUser().equalsIgnoreCase("ALL")) {
//CASE ALL
@ -756,20 +702,16 @@ 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();
else
msg += " v." + acc.getVersion() + " " + GxtAccountingEntryType.RESTORE.getName() + " by "
+ user.getName();
msg+=" v."+acc.getVersion()+" "+GxtAccountingEntryType.RESTORE.getName() +" by "+user.getName();
af.setDescription(msg);
}
@ -777,15 +719,12 @@ 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 = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" ";
String msg=GxtAccountingEntryType.DISABLED_PUBLIC_ACCESS.getName()+" by "+user.getName();
af.setDescription(msg);
}
@ -794,15 +733,12 @@ 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 = acc.getItemName()==null || acc.getItemName().isEmpty()?"":acc.getItemName()+" ";
String msg=GxtAccountingEntryType.ENABLED_PUBLIC_ACCESS.getName()+" by "+user.getName();
af.setDescription(msg);
}
@ -823,6 +759,7 @@ public class StorageHubToWorkpaceConverter implements Serializable {
}
/**
* Gets the gcube item properties for gcube item as HTML.
*
@ -831,6 +768,7 @@ public class StorageHubToWorkpaceConverter implements Serializable {
*/
public String getGcubeItemPropertiesForGcubeItemAsHTML(WorkspaceItem wsItem) {
Map<String, String> properties = getGcubeItemProperties(wsItem);
if(properties!=null){
@ -860,6 +798,7 @@ public class StorageHubToWorkpaceConverter implements Serializable {
}
}
/**
* Gets the gcube item properties.
*
@ -883,73 +822,4 @@ public class StorageHubToWorkpaceConverter implements Serializable {
return null;
}
/**********************************************************************************************************************************************
*
*
*
*
* TESTING MODE METHODS
*
*
*
*
***********************************************************************************************************************************************/
protected static HashMap<String, InfoContactModel> hashTestUser = null;
/**
* Used in test mode.
*
* @return the hash test users
*/
public static HashMap<String, InfoContactModel> getHashTestUsers() {
if (hashTestUser == null) {
hashTestUser = new HashMap<String, InfoContactModel>();
// 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<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode(List<Member> listMemebers) {
List<InfoContactModel> listContact = new ArrayList<InfoContactModel>();
for (Member member : listMemebers)
listContact.add(getHashTestUsers().get(member.getIdentity()));
return listContact;
}
/**********************************************************************************************************************************************
*
*
*
*
* END TESTING MODE
*
*
*
*
***********************************************************************************************************************************************/
}

View File

@ -120,6 +120,7 @@ public class MimeTypeUtility {
br.close();
}
/**
* Load preview mime types.
*
@ -163,12 +164,12 @@ public class MimeTypeUtility {
*
* @param name the file name.
* @param mimeType the mime type.
* @param isFolder the is folder
* @return the right name.
* @throws IOException Signals that an I/O exception has occurred.
*/
public static String getNameWithExtension(String name, String mimeType, boolean isFolder) throws IOException {
logger.debug("Deriving the file extension for file name: " + name + ", with mimeType: " + mimeType+", isFolder: "+isFolder);
public static String getNameWithExtension(String name, String mimeType) throws IOException {
logger.debug("Deriving the file extension for file name: " + name + ", with mimeType: " + mimeType);
if (mimeType == null || mimeType.isEmpty()) {
logger.debug("Input mime type is null or empty returning passed name: " + name);
@ -176,30 +177,52 @@ public class MimeTypeUtility {
}
String declaredExtension = FilenameUtils.getExtension(name);
logger.info("The name " + name + " contains the extension: " + declaredExtension);
logger.debug("The name " + name + " contains the extension: " + declaredExtension);
//If the filename contains the extension returning the name like it is (skipping the folder)
if (declaredExtension != null && !declaredExtension.isEmpty() && !isFolder) {
logger.debug(
"The filename contains a not empty extension: " + declaredExtension + ", so returning the name like it is");
if (declaredExtension.equals("exe"))
return name;
List<String> extensions = MimeTypeUtility.getExtension(mimeType);
logger.trace("Extension/s available for input mimetype: " + mimeType + " into map is/are: " + extensions);
String toMimeTypeExtension = "";
if (extensions != null) {
toMimeTypeExtension = extensions.get(extensions.size() - 1); // I'm reading the last extension in the map
// (myme type - list of extensions)
logger.debug("Using the last extension read into list of available extensions: " + toMimeTypeExtension);
}
// MANAGING ALREADY DECLARED EXTENSION IN THE FILE NAME
if (!declaredExtension.isEmpty() && !toMimeTypeExtension.isEmpty()) {
String dEextL = declaredExtension.toLowerCase();
String mtExtL = toMimeTypeExtension.toLowerCase();
// The extension writes in the file name is matching the mime type extension
// declared in the map
if (dEextL.equals(mtExtL)) {
logger.trace("The Extension declared in the name " + name
+ " is matching derived mime type extension so returning the input name: " + name);
return name;
}
logger.debug("Either the name does not contains the extension or it is a folder, deriving extension from mimeType");
List<String> extensions = MimeTypeUtility.getExtension(mimeType);
logger.debug("Extension/s available for input mimetype: " + mimeType + " into map is/are: " + extensions);
// if(!dEextL.trim().contains(" ")) {
// logger.trace("The Extension declared in the name "+name+" seems a valid suffix (without other spaces) so returning the input name: "+name);
// return name;
// }
String toMimeTypeExtension = "";
String fullName = name;
if (extensions != null && extensions.size() > 0) {
// I'm reading the last extension in the map (myme type - list of extensions)
toMimeTypeExtension = extensions.get(extensions.size() - 1);
logger.info("Using the last extension read into list of available extensions: " + toMimeTypeExtension);
fullName = String.format("%s%s%s", name, DOT_STRING, toMimeTypeExtension);
logger.debug("No logic seems to match the extension declared in the name " + declaredExtension
+ " as a valid extension so I'm adding the extension derived from mime type map: "
+ toMimeTypeExtension);
}
logger.info("returning full name:" + fullName);
return fullName;
// CHECKING THE FOLLOWING IN ORDER TO AVOID THE DOT AS LAST CHAR OF FILENAME
if (toMimeTypeExtension.isEmpty()) {
return name;
}
String fullname = String.format("%s%s%s", name, DOT_STRING, toMimeTypeExtension);
logger.trace("returning full name:" + fullname);
return fullname;
}
@ -291,9 +314,10 @@ public class MimeTypeUtility {
return extension_mimetype_map;
}
/**
* Gets the preview mimetype extension map with the mime types allowed for
* preview displaying
* Gets the preview mimetype extension map with the
* mime types allowed for preview displaying
*
* @return the preview mimetype extension map
*/

View File

@ -181,7 +181,6 @@ text/iuls=uls
text/plain=bas
text/plain=c
text/plain=h
text/plain=asc
text/plain=txt
text/richtext=rtx
text/scriptlet=sct

View File

@ -149,7 +149,6 @@ text/iuls=uls
text/plain=bas
text/plain=c
text/plain=h
text/plain=asc
text/plain=txt
text/richtext=rtx
text/scriptlet=sct

1
src/test/.gitignore vendored
View File

@ -1 +0,0 @@
/resources/

View File

@ -1,71 +0,0 @@
package org.gcube.portlets.user.workspace;
import org.gcube.common.storagehubwrapper.server.StorageHubClientService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MappingGroupNameToScopeName {
private static Logger logger = LoggerFactory.getLogger(MappingGroupNameToScopeName.class);
public static void main(String[] args) {
// VRE
String context = "d4science.research-infrastructures.eu-D4OS-FAO-Tuna_Atlas";
String rootName = "/d4science.research-infrastructures.eu";
String vreName = "FAO-Tuna_Atlas";
//
// //VO
// String context = "d4science.research-infrastructures.eu-D4OS";
// String rootName = "/d4science.research-infrastructures.eu";
// String vreName = null;
// ROOT
// String context = "d4science.research-infrastructures.eu";
// String rootName = "/d4science.research-infrastructures.eu";
// String vreName = null;
System.out.println(getScopeFromVREGroupName(context, rootName, vreName));
}
/**
* Gets the scope from VRE group name.
*
* @param context the context
* @return the scope from VRE group name. Eg. with the input
* 'gcube-devNext-NextNext' returns '/gcube/devNext/NextNext'
*/
public static String getScopeFromVREGroupName(String context, String infrastructurName, String vreName) {
// String entireScopeName = context.replaceAll("^/(.*)/?$", "$1").replaceAll("-", "/");
// return entireScopeName;
if (vreName == null)
vreName = "";
logger.debug("vreName: " + vreName);
if (infrastructurName.startsWith("/"))
infrastructurName = infrastructurName.substring(1, infrastructurName.length());
logger.debug("infrastructurName: " + infrastructurName);
String voGroup = context.replaceAll(infrastructurName, "");
if (vreName != null) {
voGroup = voGroup.replaceAll(vreName, "").replaceAll("-", "");
}
String voName = voGroup.replaceAll("-", "");
logger.debug("voName: " + voName);
StringBuilder theScopeBuilder = new StringBuilder();
theScopeBuilder.append("/" + infrastructurName);
if (voName != null && !voName.isEmpty()) {
theScopeBuilder.append("/" + voName);
}
if (vreName != null && !vreName.isEmpty()) {
theScopeBuilder.append("/" + vreName);
}
String theScope = theScopeBuilder.toString();
logger.info("Built scope: " + theScope);
return theScope;
}
}

View File

@ -38,7 +38,7 @@ public class MimeTypeUtilityTest {
for (String keyFileName : fileNamesToMimeTypes.keySet()) {
try {
System.out.println("\nResolving file name with extension for name: "+keyFileName);
String toFileName = MimeTypeUtility.getNameWithExtension(keyFileName, fileNamesToMimeTypes.get(keyFileName), false);
String toFileName = MimeTypeUtility.getNameWithExtension(keyFileName, fileNamesToMimeTypes.get(keyFileName));
System.out.println("Assigned the file name: "+toFileName);
} catch (IOException e) {
e.printStackTrace();

View File

@ -3,7 +3,10 @@
*/
package org.gcube.portlets.user.workspace;
import java.util.Iterator;
import org.gcube.common.encryption.StringEncrypter;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.workspace.server.util.StringUtil;

View File

@ -1,25 +1,29 @@
package org.gcube.portlets.user.workspace;
import java.io.IOException;
import java.util.Properties;
import org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl;
public class TestProperties {
// public static void main(String[] args) {
//
// Properties prop = new Properties();
//
// try {
// // load a properties file from class path, inside static method
// prop.load(GWTWorkspaceServiceImpl.class.getClassLoader().getResourceAsStream("portletClassName.properties"));
//
// // get the property value and print it out
// System.out.println(prop.getProperty("idreport"));
// System.out.println(prop.getProperty("idtemplate"));
//
//
// } catch (IOException ex) {
// ex.printStackTrace();
// }
//
// }
public static void main(String[] args) {
Properties prop = new Properties();
try {
// load a properties file from class path, inside static method
prop.load(GWTWorkspaceServiceImpl.class.getClassLoader().getResourceAsStream("portletClassName.properties"));
// get the property value and print it out
System.out.println(prop.getProperty("idreport"));
System.out.println(prop.getProperty("idtemplate"));
} catch (IOException ex) {
ex.printStackTrace();
}
}
}

View File

@ -1,26 +0,0 @@
package org.gcube.portlets.user.workspace.junit;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.workspace.server.reader.ApplicationProfileReader;
public class WEA_AP_Reader {
public static String SCOPE = "/d4science.research-infrastructures.eu";
public static String resourceName = "Workspace-Explorer-App";
public static String appID = "org.gcube.portlets.user.workspaceexplorerapp.server.WorkspaceExplorerAppServiceImpl";
// @Test
public void readAP() {
try {
// ScopeProvider.instance.set("/d4science.research-infrastructures.eu/D4Research/Limnodata");
ScopeProvider.instance.set(SCOPE);
ApplicationProfileReader ap = new ApplicationProfileReader(resourceName, appID);
System.out.println("ApplicationProfile found: " + ap.readProfileFromInfrastrucure());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}