in progess on #21388

This commit is contained in:
Francesco Mangiacrapa 2021-05-14 17:18:16 +02:00
parent cc17be1761
commit 996c982b39
11 changed files with 643 additions and 687 deletions

View File

@ -3,7 +3,6 @@ package org.gcube.portlets.user.workspace.client.model;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; 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.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder; import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder;
import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum; import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum;
@ -16,13 +15,12 @@ import com.google.gwt.user.client.rpc.IsSerializable;
import com.google.gwt.user.client.ui.AbstractImagePrototype; import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Image;
// TODO: Auto-generated Javadoc
/** /**
* The Class FileModel. * The Class FileModel.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
* Sep 15, 2016 * Sep 15, 2016
*/ */
public class FileModel extends BaseModelData implements Serializable, IsSerializable { public class FileModel extends BaseModelData implements Serializable, IsSerializable {
@ -31,8 +29,8 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
protected GXTFolderItemTypeEnum folderItemType; //It's here to serialization don't remove protected GXTFolderItemTypeEnum folderItemType; // It's here to serialization don't remove
protected GXTCategorySmartFolder smartFolders; //It's here to serialization don't remove protected GXTCategorySmartFolder smartFolders; // It's here to serialization don't remove
protected InfoContactModel infoContacts; protected InfoContactModel infoContacts;
protected boolean isRoot = false; protected boolean isRoot = false;
protected boolean isVreFolder; protected boolean isVreFolder;
@ -55,23 +53,23 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
public static final String OWNERFULLNAME = "Owner Name"; public static final String OWNERFULLNAME = "Owner Name";
public static final String HUMAN_REDABLE_CATEGORY = "HR Category"; public static final String HUMAN_REDABLE_CATEGORY = "HR Category";
//Thredds Synch status // Synched with thredds
private Sync_Status synchedThreddsStatus; private Boolean synchedWithWsThredds = null;
/** /**
* Instantiates a new file model. * Instantiates a new file model.
*/ */
protected FileModel(){ protected FileModel() {
} }
/** /**
* Instantiates a new file model. * Instantiates a new file model.
* *
* @param identifier the identifier * @param identifier the identifier
* @param name the name * @param name the name
* @param parent the parent * @param parent the parent
* @param isDirectory the is directory * @param isDirectory the is directory
* @param isShared the is shared * @param isShared the is shared
*/ */
public FileModel(String identifier, String name, FileModel parent, boolean isDirectory, boolean isShared) { public FileModel(String identifier, String name, FileModel parent, boolean isDirectory, boolean isShared) {
setIdentifier(identifier); setIdentifier(identifier);
@ -85,8 +83,8 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
/** /**
* USED FOR ATTACHMENTS AND FolderBulkCreator. * USED FOR ATTACHMENTS AND FolderBulkCreator.
* *
* @param identifier the identifier * @param identifier the identifier
* @param name the name * @param name the name
* @param isDirectory the is directory * @param isDirectory the is directory
*/ */
public FileModel(String identifier, String name, boolean isDirectory) { public FileModel(String identifier, String name, boolean isDirectory) {
@ -99,7 +97,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
/** /**
* Inits the default properties. * Inits the default properties.
*/ */
protected void initDefaultProperties(){ protected void initDefaultProperties() {
setShortcutCategory(GXTCategorySmartFolder.SMF_UNKNOWN); setShortcutCategory(GXTCategorySmartFolder.SMF_UNKNOWN);
setShareable(true); setShareable(true);
} }
@ -110,7 +108,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* @param bool the new shareable * @param bool the new shareable
*/ */
public void setShareable(boolean bool) { public void setShareable(boolean bool) {
set(ConstantsExplorer.ISSHAREABLE,bool); set(ConstantsExplorer.ISSHAREABLE, bool);
} }
@ -119,7 +117,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* *
* @param description the new description * @param description the new description
*/ */
public void setDescription(String description){ public void setDescription(String description) {
set(ConstantsExplorer.DIRECTORYDESCRIPTION, description); set(ConstantsExplorer.DIRECTORYDESCRIPTION, description);
} }
@ -128,7 +126,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* *
* @return the description * @return the description
*/ */
public String getDescription(){ public String getDescription() {
return get(ConstantsExplorer.DIRECTORYDESCRIPTION); return get(ConstantsExplorer.DIRECTORYDESCRIPTION);
} }
@ -139,7 +137,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
*/ */
public boolean isShareable() { public boolean isShareable() {
Object sharable = get(ConstantsExplorer.ISSHAREABLE); Object sharable = get(ConstantsExplorer.ISSHAREABLE);
if(sharable!=null) if (sharable != null)
return (Boolean) sharable; return (Boolean) sharable;
return false; return false;
} }
@ -147,14 +145,15 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
/** /**
* Instantiates a new file model. * Instantiates a new file model.
* *
* @param identifier the identifier * @param identifier the identifier
* @param name the name * @param name the name
* @param type the type * @param type the type
* @param folderItemTypeEnum the folder item type enum * @param folderItemTypeEnum the folder item type enum
* @param isDirectory the is directory * @param isDirectory the is directory
* @param isShared the is shared * @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); setIdentifier(identifier);
setName(name); setName(name);
setType(type); setType(type);
@ -170,14 +169,12 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* @param parent the new parent file model * @param parent the new parent file model
*/ */
public void setParentFileModel(FileModel parent) { public void setParentFileModel(FileModel parent) {
set(PARENT,parent); set(PARENT, parent);
} }
/** /**
* Status values * Status values ConstantsExplorer.FOLDERNOTLOAD = "notload";
* ConstantsExplorer.FOLDERNOTLOAD = "notload"; * ConstantsExplorer.FOLDERLOADED = "loaded";
* ConstantsExplorer.FOLDERLOADED = "loaded";
* *
* @param status the new status * @param status the new status
*/ */
@ -192,9 +189,9 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
Image icon = (Image) get(ICON); Image icon = (Image) get(ICON);
AbstractImagePrototype iconAbs; AbstractImagePrototype iconAbs;
if(icon==null){ if (icon == null) {
iconAbs = getAbstractPrototypeIcon(); iconAbs = getAbstractPrototypeIcon();
}else } else
return; return;
set(ICON, iconAbs.createImage()); set(ICON, iconAbs.createImage());
@ -206,7 +203,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* *
* @param fullName the new owner full name * @param fullName the new owner full name
*/ */
public void setOwnerFullName(String fullName){ public void setOwnerFullName(String fullName) {
set(FileModel.OWNERFULLNAME, fullName); set(FileModel.OWNERFULLNAME, fullName);
} }
@ -215,17 +212,17 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* *
* @return the owner full name * @return the owner full name
*/ */
public String getOwnerFullName(){ public String getOwnerFullName() {
return get(FileModel.OWNERFULLNAME); return get(FileModel.OWNERFULLNAME);
} }
/** /**
* Sets the sharing value. * Sets the sharing value.
* *
* @param isShared the is shared * @param isShared the is shared
* @param listShareUsers the list share users * @param listShareUsers the list share users
*/ */
public void setSharingValue(boolean isShared, List<InfoContactModel> listShareUsers){ public void setSharingValue(boolean isShared, List<InfoContactModel> listShareUsers) {
set(ISSHARED, isShared); set(ISSHARED, isShared);
set(SHAREUSERS, listShareUsers); set(SHAREUSERS, listShareUsers);
} }
@ -236,7 +233,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* @return the list user sharing * @return the list user sharing
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<InfoContactModel> getListUserSharing(){ public List<InfoContactModel> getListUserSharing() {
return (List<InfoContactModel>) get(SHAREUSERS); return (List<InfoContactModel>) get(SHAREUSERS);
} }
@ -245,7 +242,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* *
* @param listShareUsers the new list share user * @param listShareUsers the new list share user
*/ */
public void setListShareUser(List<InfoContactModel> listShareUsers){ public void setListShareUser(List<InfoContactModel> listShareUsers) {
set(SHAREUSERS, listShareUsers); set(SHAREUSERS, listShareUsers);
} }
@ -254,9 +251,9 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* *
* @return true, if is shared * @return true, if is shared
*/ */
public boolean isShared(){ public boolean isShared() {
Object shared = get(ISSHARED); Object shared = get(ISSHARED);
if(shared!=null) if (shared != null)
return (Boolean) shared; return (Boolean) shared;
return false; return false;
} }
@ -266,7 +263,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* *
* @return true, if is root * @return true, if is root
*/ */
public boolean isRoot(){ public boolean isRoot() {
return isRoot; return isRoot;
} }
@ -275,11 +272,10 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* *
* @param isRoot the new checks if is root * @param isRoot the new checks if is root
*/ */
public void setIsRoot(boolean isRoot){ public void setIsRoot(boolean isRoot) {
this.isRoot = isRoot; this.isRoot = isRoot;
} }
/** /**
* Gets the icon. * Gets the icon.
* *
@ -296,61 +292,56 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
*/ */
public AbstractImagePrototype getAbstractPrototypeIcon() { public AbstractImagePrototype getAbstractPrototypeIcon() {
GWT.log("My prop: "+this.toString()); GWT.log("My prop: " + this.toString());
AbstractImagePrototype absImgPr = Resources.getIconTable(); AbstractImagePrototype absImgPr = Resources.getIconTable();
if (!this.isDirectory()) { //IS FILE if (!this.isDirectory()) { // IS FILE
if(this.getType()!=null) if (this.getType() != null)
absImgPr = Resources.getIconByType(this.getName(), this.getType()); absImgPr = Resources.getIconByType(this.getName(), this.getType());
else else
absImgPr = Resources.getIconByFolderItemType(this.getGXTFolderItemType()); absImgPr = Resources.getIconByFolderItemType(this.getGXTFolderItemType());
}else if(this.isShared()){ //IS A SHARED FOLDER? } else if (this.isShared()) { // IS A SHARED FOLDER?
//GWT.log("setting icon "+this.getName()+" is shared: "+this.isShared() + ", this.isVreFolder() "+this.isVreFolder() +", this.isShareable() "+this.isShareable()); // GWT.log("setting icon "+this.getName()+" is shared: "+this.isShared() + ",
// this.isVreFolder() "+this.isVreFolder() +", this.isShareable()
// "+this.isShareable());
if(this.isVreFolder()) if (this.isVreFolder())
absImgPr = Resources.getIconVREFolder(); absImgPr = Resources.getIconVREFolder();
else{ else {
if(this.isShareable()){ //IS ROOT SHARED FOLDER if (this.isShareable()) { // IS ROOT SHARED FOLDER
if(this.isPublic()) //IS PLUBIC if (this.isPublic()) // IS PLUBIC
absImgPr = Resources.getIconFolderSharedPublic(); absImgPr = Resources.getIconFolderSharedPublic();
else else
absImgPr = Resources.getIconSharedFolder(); absImgPr = Resources.getIconSharedFolder();
}else{ //IS A DESCENDANT } else { // IS A DESCENDANT
if(this.isPublic()) //IS PLUBIC if (this.isPublic()) // IS PLUBIC
absImgPr = Resources.getIconFolderPublic(); absImgPr = Resources.getIconFolderPublic();
else else
absImgPr = Resources.getIconSharedFolder(); //IS A SHARED FOLDER DESCENDANT OF ROOT SHARED FOLDER absImgPr = Resources.getIconSharedFolder(); // IS A SHARED FOLDER DESCENDANT OF ROOT SHARED
// FOLDER
} }
} }
}else if(this.getStatus() == ConstantsExplorer.FOLDERNOTLOAD){ //IS A FOLDER IN LOADING } else if (this.getStatus() == ConstantsExplorer.FOLDERNOTLOAD) { // IS A FOLDER IN LOADING
absImgPr = Resources.getIconLoading2(); absImgPr = Resources.getIconLoading2();
}else{ } else {
//SPECIAL FOLDER? // SPECIAL FOLDER?
if(this.isSpecialFolder()) if (this.isSpecialFolder())
absImgPr = Resources.getIconSpecialFolder(); absImgPr = Resources.getIconSpecialFolder();
else{ //SIMPLE FOLDER else { // SIMPLE FOLDER
if(this.isPublic()) //IS PLUBIC if (this.isPublic()) // IS PLUBIC
absImgPr = Resources.getIconFolderPublic(); absImgPr = Resources.getIconFolderPublic();
else { else {
if(this.getSynchedThreddsStatus()!=null) { if (this.getSynchedWithWsThredds() != null) {
switch(this.getSynchedThreddsStatus()) { if(this.getSynchedWithWsThredds()) {
case OUTDATED_REMOTE: absImgPr = Resources.getIconSyncTo();
absImgPr = Resources.getIconSyncTo();
break;
case OUTDATED_WS:
absImgPr = Resources.getIconSyncFrom();
break;
case UP_TO_DATE:
absImgPr = Resources.getIconSynched();
break;
} }
}else } else
absImgPr = Resources.getIconFolder(); absImgPr = Resources.getIconFolder();
} }
} }
} }
@ -358,7 +349,6 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
return absImgPr; return absImgPr;
} }
/** /**
* Gets the status. * Gets the status.
* *
@ -368,13 +358,12 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
return get("status"); return get("status");
} }
/** /**
* Sets the checks if is directory. * Sets the checks if is directory.
* *
* @param flag the new checks if is directory * @param flag the new checks if is directory
*/ */
public void setIsDirectory(boolean flag){ public void setIsDirectory(boolean flag) {
set(ISDIRECTORY, flag); set(ISDIRECTORY, flag);
} }
@ -392,7 +381,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* *
* @return the identifier * @return the identifier
*/ */
public String getIdentifier(){ public String getIdentifier() {
return get(IDENTIFIER); return get(IDENTIFIER);
} }
@ -403,21 +392,19 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
*/ */
public void setShortcutCategory(GXTCategorySmartFolder smfDocuments) { public void setShortcutCategory(GXTCategorySmartFolder smfDocuments) {
set(SHORTCUTCATEGORY, smfDocuments); set(SHORTCUTCATEGORY, smfDocuments);
if(smfDocuments!=null) if (smfDocuments != null)
set(HUMAN_REDABLE_CATEGORY, smfDocuments.getValue()); set(HUMAN_REDABLE_CATEGORY, smfDocuments.getValue());
} }
/** /**
* Gets the shortcut category. * Gets the shortcut category.
* *
* @return the shortcut category * @return the shortcut category
*/ */
public GXTCategorySmartFolder getShortcutCategory(){ public GXTCategorySmartFolder getShortcutCategory() {
return (GXTCategorySmartFolder) get(SHORTCUTCATEGORY); return (GXTCategorySmartFolder) get(SHORTCUTCATEGORY);
} }
/** /**
* Sets the name. * Sets the name.
* *
@ -441,7 +428,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* *
* @return the parent file model * @return the parent file model
*/ */
public FileModel getParentFileModel(){ public FileModel getParentFileModel() {
return (FileModel) get(PARENT); return (FileModel) get(PARENT);
} }
@ -450,14 +437,16 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* *
* @return true, if is directory * @return true, if is directory
*/ */
public boolean isDirectory(){ public boolean isDirectory() {
Object directory = get(ISDIRECTORY); Object directory = get(ISDIRECTORY);
if(directory!=null) if (directory != null)
return (Boolean) directory; return (Boolean) directory;
return false; return false;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object) * @see java.lang.Object#equals(java.lang.Object)
*/ */
/** /**
@ -489,7 +478,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* *
* @param type the new type * @param type the new type
*/ */
public void setType(String type){ public void setType(String type) {
set(TYPE, type); set(TYPE, type);
} }
@ -498,7 +487,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* *
* @return the type * @return the type
*/ */
public String getType(){ public String getType() {
return get(TYPE); return get(TYPE);
} }
@ -507,7 +496,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* *
* @param folderItemTypeEnum the new folder item type * @param folderItemTypeEnum the new folder item type
*/ */
public void setFolderItemType(GXTFolderItemTypeEnum folderItemTypeEnum){ public void setFolderItemType(GXTFolderItemTypeEnum folderItemTypeEnum) {
set(FOLDERITEMTYPE, folderItemTypeEnum); set(FOLDERITEMTYPE, folderItemTypeEnum);
} }
@ -516,7 +505,7 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* *
* @return the GXT folder item type * @return the GXT folder item type
*/ */
public GXTFolderItemTypeEnum getGXTFolderItemType(){ public GXTFolderItemTypeEnum getGXTFolderItemType() {
return (GXTFolderItemTypeEnum) get(FOLDERITEMTYPE); return (GXTFolderItemTypeEnum) get(FOLDERITEMTYPE);
} }
@ -571,21 +560,31 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
* *
* @return true, if is public * @return true, if is public
*/ */
public boolean isPublic(){ public boolean isPublic() {
return isPublic; return isPublic;
} }
public void setSyncThreddsStatus(Sync_Status status) { /**
this.synchedThreddsStatus = status; * Sets the synched with ws thredds.
*
* @param bool the new synched with ws thredds
*/
public void setSynchedWithWsThredds(Boolean bool) {
this.synchedWithWsThredds = bool;
} }
public Sync_Status getSynchedThreddsStatus() { /**
return synchedThreddsStatus; * Gets the synched with ws thredds.
*
* @return the synched with ws thredds
*/
public Boolean getSynchedWithWsThredds() {
return synchedWithWsThredds;
} }
/*
* (non-Javadoc)
/* (non-Javadoc) *
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */
/** /**
@ -620,5 +619,4 @@ public class FileModel extends BaseModelData implements Serializable, IsSerializ
return builder.toString(); return builder.toString();
} }
} }

View File

@ -412,11 +412,11 @@ public interface Icons extends ClientBundle {
@Source("icons/sync-icon-to.png") @Source("icons/sync-icon-to.png")
ImageResource syncIconTo(); ImageResource syncIconTo();
@Source("icons/sync-icon-from.png") // @Source("icons/sync-icon-from.png")
ImageResource syncIconFrom(); // ImageResource syncIconFrom();
//
@Source("icons/sync-icon-synched.png") // @Source("icons/sync-icon-synched.png")
ImageResource syncIconSynched(); // ImageResource syncIconSynched();
@Source("icons/no-preview-available.png") @Source("icons/no-preview-available.png")
ImageResource previewNotAvailable(); ImageResource previewNotAvailable();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -114,11 +114,11 @@ public class DialogGetInfo extends Dialog {
txtIsPublic.setValue(fileModel.isPublic() + ""); txtIsPublic.setValue(fileModel.isPublic() + "");
add(txtIsPublic); add(txtIsPublic);
if (fileModel.getSynchedThreddsStatus() != null) { if (fileModel.getSynchedWithWsThredds() != null) {
txtThreddsSynched = new TextField<String>(); txtThreddsSynched = new TextField<String>();
txtThreddsSynched.setFieldLabel("Thredds Sync"); txtThreddsSynched.setFieldLabel("Synched with Thredds");
txtThreddsSynched.setReadOnly(true); txtThreddsSynched.setReadOnly(true);
txtThreddsSynched.setValue(fileModel.getSynchedThreddsStatus() + ""); txtThreddsSynched.setValue(fileModel.getSynchedWithWsThredds() + "");
add(txtThreddsSynched); add(txtThreddsSynched);
} }

View File

@ -295,10 +295,12 @@ public class DialogGetInfoBootstrap extends Composite {
cgTxtIsPublic.setVisible(true); cgTxtIsPublic.setVisible(true);
htmlSetValue(txtIsPublic, fileModel.isPublic() + ""); htmlSetValue(txtIsPublic, fileModel.isPublic() + "");
if (fileModel.getSynchedThreddsStatus() != null) { if (fileModel.getSynchedWithWsThredds() != null) {
txtThreddsSynched.setVisible(true); if (fileModel.getSynchedWithWsThredds()) {
htmlSetValue(txtThreddsSynched, fileModel.getSynchedThreddsStatus() + ""); txtThreddsSynched.setVisible(true);
txtThreddsSynched.setHTML(fileModel.getSynchedThreddsStatus() + ""); htmlSetValue(txtThreddsSynched, fileModel.getSynchedWithWsThredds() + "");
txtThreddsSynched.setHTML(fileModel.getSynchedWithWsThredds() + "");
}
} }
} }

View File

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

View File

@ -32,7 +32,6 @@ import org.gcube.common.storagehubwrapper.shared.tohl.items.URLFileItem;
import org.gcube.common.storagehubwrapper.shared.tohl.items.URLItem; import org.gcube.common.storagehubwrapper.shared.tohl.items.URLItem;
import org.gcube.portal.wssynclibrary.shared.ItemNotSynched; import org.gcube.portal.wssynclibrary.shared.ItemNotSynched;
import org.gcube.portal.wssynclibrary.shared.WorkspaceFolderLocked; import org.gcube.portal.wssynclibrary.shared.WorkspaceFolderLocked;
import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status;
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncFolderDescriptor; import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncFolderDescriptor;
import org.gcube.portal.wssynclibrary.thredds.WorkspaceThreddsSynchronize; import org.gcube.portal.wssynclibrary.thredds.WorkspaceThreddsSynchronize;
import org.gcube.portlets.user.urlshortener.UrlShortener; import org.gcube.portlets.user.urlshortener.UrlShortener;

View File

@ -29,27 +29,34 @@ import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItemType; import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItemType;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder; import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException; import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
import org.gcube.common.storagehubwrapper.shared.tohl.impl.URLFile;
import org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceFileVersion; import org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceFileVersion;
import org.gcube.common.storagehubwrapper.shared.tohl.items.FileItem;
import org.gcube.common.storagehubwrapper.shared.tohl.items.GCubeItem; import org.gcube.common.storagehubwrapper.shared.tohl.items.GCubeItem;
import org.gcube.common.storagehubwrapper.shared.tohl.items.PropertyMap; import org.gcube.common.storagehubwrapper.shared.tohl.items.PropertyMap;
import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status;
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncFolderDescriptor; import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncFolderDescriptor;
import org.gcube.portal.wssynclibrary.thredds.WorkspaceThreddsSynchronize; import org.gcube.portal.wssynclibrary.thredds.WorkspaceThreddsSynchronize;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer; 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;
import org.gcube.portlets.user.workspace.client.model.FileGridModel; import org.gcube.portlets.user.workspace.client.model.FileGridModel;
import org.gcube.portlets.user.workspace.client.model.FileModel; import org.gcube.portlets.user.workspace.client.model.FileModel;
import org.gcube.portlets.user.workspace.client.model.FileTrashedModel; import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
import org.gcube.portlets.user.workspace.client.model.FileVersionModel; import org.gcube.portlets.user.workspace.client.model.FileVersionModel;
import org.gcube.portlets.user.workspace.client.model.FolderGridModel;
import org.gcube.portlets.user.workspace.client.model.FolderModel; import org.gcube.portlets.user.workspace.client.model.FolderModel;
import org.gcube.portlets.user.workspace.server.util.UserUtil; 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.GxtAccountingEntryType;
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField; import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel; import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import org.gcube.usecases.ws.thredds.faults.WorkspaceNotSynchedException; import org.gcube.usecases.ws.thredds.faults.WorkspaceNotSynchedException;
import org.gcube.usecases.ws.thredds.model.ContainerType;
import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.allen_sauer.gwt.log.client.Log;
/** /**
* The Class StorageHubToWorkpaceConverter. * The Class StorageHubToWorkpaceConverter.
* *
@ -136,9 +143,8 @@ public class StorageHubToWorkpaceConverter implements Serializable {
public FileModel toTreeFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem, public FileModel toTreeFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem,
FileModel parentFolderModel, Boolean isParentShared) throws InternalErrorException { FileModel parentFolderModel, Boolean isParentShared) throws InternalErrorException {
FileModel fileModel = ObjectStorageHubToWorkpaceMapper.toTreeFileModelItem(wrappedItem, parentFolderModel, FileModel fileModel = ObjectStorageHubToWorkpaceMapper.toTreeFileModelItem(wrappedItem, parentFolderModel, isParentShared);
isParentShared); return setSynchedWithWsThredds(fileModel, wrappedItem);
return setSynchedThreddsStateFor(fileModel, wrappedItem);
} }
/** /**
@ -152,35 +158,64 @@ public class StorageHubToWorkpaceConverter implements Serializable {
public FileGridModel toGridFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem, public FileGridModel toGridFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem,
FileModel parentFolderModel) throws InternalErrorException { FileModel parentFolderModel) throws InternalErrorException {
FileGridModel fileGridModel = ObjectStorageHubToWorkpaceMapper.toGridFileModelItem(wrappedItem, FileGridModel fileGridModel = ObjectStorageHubToWorkpaceMapper.toGridFileModelItem(wrappedItem, parentFolderModel, loggedUser);
parentFolderModel, loggedUser); return (FileGridModel) setSynchedWithWsThredds(fileGridModel, wrappedItem);
return (FileGridModel) setSynchedThreddsStateFor(fileGridModel, wrappedItem);
} }
/**
* Sets the synched thredds state for. protected FileModel setSynchedWithWsThredds(FileModel fileModel, WorkspaceItem wrappedItem) {
*
* @param fileModel the file model
* @param wrappedItem item
* @return the file model
*/
protected FileModel setSynchedThreddsStateFor(FileModel fileModel, WorkspaceItem wrappedItem) {
logger.debug("called setSynchedThreddsStateFor item id: " + wrappedItem.getId()); logger.debug("called setSynchedThreddsStateFor item id: " + wrappedItem.getId());
Sync_Status status = null;
boolean isItemSynched = false;
try { try {
status = WorkspaceThreddsSynchronize.getInstance().getInfo(wrappedItem.getId());
logger.debug("item id: " + wrappedItem.getId() + " has ws-thredds sync status: " + status);
} catch (WorkspaceNotSynchedException e) {
logger.debug("WorkspaceNotSynchedException catched, the item with id: " + wrappedItem.getId() Map<String, Object> mapProperties = wrappedItem.getPropertyMap().getValues();
+ " is not synched"); 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);
} catch (Exception e) { } catch (Exception e) {
logger.info( logger.info("Error on calling isItemSynched for the item id: " + wrappedItem.getId()
"Error on getting configuration for the item id: " + wrappedItem.getId() + ", (means not synched)"); + ", (means not synched)");
} }
fileModel.setSyncThreddsStatus(status); logger.debug("the item id: " + wrappedItem.getId() + " with name: " + wrappedItem.getName() + " is synched: "
+ isItemSynched);
fileModel.setSynchedWithWsThredds(isItemSynched);
return fileModel; return fileModel;
} }