migrating to shub

This commit is contained in:
Francesco Mangiacrapa 2020-04-09 17:58:03 +02:00
parent dc656a78e2
commit 7280ed8138
14 changed files with 605 additions and 554 deletions

View File

@ -3,10 +3,6 @@
*/
package org.gcube.portlets.user.workspaceexplorerapp.client;
import gwt.material.design.client.ui.MaterialColumn;
import gwt.material.design.client.ui.MaterialLink;
import gwt.material.design.client.ui.MaterialRow;
import java.util.List;
import org.gcube.portlets.user.workspaceexplorerapp.client.event.OrderDataByEvent;
@ -17,6 +13,10 @@ import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.PopupPanel;
import gwt.material.design.client.ui.MaterialColumn;
import gwt.material.design.client.ui.MaterialLink;
import gwt.material.design.client.ui.MaterialRow;
/**
*

View File

@ -81,13 +81,13 @@ public class Util {
if (item.isSharedFolder()) return WorkspaceExplorerResources.INSTANCE.shared_folder();
else return WorkspaceExplorerResources.INSTANCE.folder();
}
case EXTERNAL_IMAGE: return WorkspaceLightTreeResources.INSTANCE.external_image();
case EXTERNAL_FILE: return WorkspaceLightTreeResources.INSTANCE.external_file();
case EXTERNAL_PDF_FILE: return WorkspaceLightTreeResources.INSTANCE.external_pdf();
case EXTERNAL_URL: return WorkspaceLightTreeResources.INSTANCE.external_url();
case REPORT_TEMPLATE: return WorkspaceLightTreeResources.INSTANCE.report_template();
case REPORT: return WorkspaceLightTreeResources.INSTANCE.report();
case QUERY: return WorkspaceLightTreeResources.INSTANCE.query();
// case EXTERNAL_IMAGE: return WorkspaceLightTreeResources.INSTANCE.external_image();
// case EXTERNAL_FILE: return WorkspaceLightTreeResources.INSTANCE.external_file();
// case EXTERNAL_PDF_FILE: return WorkspaceLightTreeResources.INSTANCE.external_pdf();
// case EXTERNAL_URL: return WorkspaceLightTreeResources.INSTANCE.external_url();
// case REPORT_TEMPLATE: return WorkspaceLightTreeResources.INSTANCE.report_template();
// case REPORT: return WorkspaceLightTreeResources.INSTANCE.report();
// case QUERY: return WorkspaceLightTreeResources.INSTANCE.query();
case DOCUMENT: return WorkspaceLightTreeResources.INSTANCE.document();
case METADATA: return WorkspaceLightTreeResources.INSTANCE.metadata();
case PDF_DOCUMENT: return WorkspaceLightTreeResources.INSTANCE.pdf_document();

View File

@ -3,12 +3,6 @@
*/
package org.gcube.portlets.user.workspaceexplorerapp.client;
import gwt.material.design.client.constants.IconPosition;
import gwt.material.design.client.constants.IconType;
import gwt.material.design.client.ui.MaterialLink;
import gwt.material.design.client.ui.MaterialNavBar;
import gwt.material.design.client.ui.MaterialNavSection;
import java.util.ArrayList;
import java.util.List;
@ -28,6 +22,12 @@ import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget;
import gwt.material.design.client.constants.IconPosition;
import gwt.material.design.client.constants.IconType;
import gwt.material.design.client.ui.MaterialLink;
import gwt.material.design.client.ui.MaterialNavBar;
import gwt.material.design.client.ui.MaterialNavSection;
/**

View File

@ -3,14 +3,14 @@
*/
package org.gcube.portlets.user.workspaceexplorerapp.client;
import gwt.material.design.client.ui.MaterialFooter;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import gwt.material.design.client.ui.MaterialFooter;
/**
*

View File

@ -3,8 +3,6 @@
*/
package org.gcube.portlets.user.workspaceexplorerapp.client;
import gwt.material.design.client.ui.MaterialToast;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@ -42,6 +40,8 @@ import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import gwt.material.design.client.ui.MaterialToast;
/**
* The Class WorkspaceResourcesExplorerPanel.

View File

@ -3,13 +3,6 @@
*/
package org.gcube.portlets.user.workspaceexplorerapp.client.grid;
import gwt.material.design.client.base.MaterialImageCell;
import gwt.material.design.client.constants.IconPosition;
import gwt.material.design.client.constants.IconType;
import gwt.material.design.client.constants.ImageType;
import gwt.material.design.client.ui.MaterialIcon;
import gwt.material.design.client.ui.MaterialImage;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
@ -48,6 +41,13 @@ import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import gwt.material.design.client.base.MaterialImageCell;
import gwt.material.design.client.constants.IconPosition;
import gwt.material.design.client.constants.IconType;
import gwt.material.design.client.constants.ImageType;
import gwt.material.design.client.ui.MaterialIcon;
import gwt.material.design.client.ui.MaterialImage;
/**
* The Class PackagesTable.
*

View File

@ -4,14 +4,14 @@
package org.gcube.portlets.user.workspaceexplorerapp.client.grid;
import gwt.material.design.client.ui.MaterialIcon;
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.cell.client.ValueUpdater;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import gwt.material.design.client.ui.MaterialIcon;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Mar 8, 2016
*/

View File

@ -3,8 +3,6 @@
*/
package org.gcube.portlets.user.workspaceexplorerapp.client.grid;
import gwt.material.design.client.ui.MaterialLink;
import org.gcube.portlets.user.workspaceexplorerapp.client.download.DownloadType;
import org.gcube.portlets.user.workspaceexplorerapp.client.event.DownloadItemEvent;
import org.gcube.portlets.user.workspaceexplorerapp.shared.ItemInterface;
@ -19,6 +17,8 @@ import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import gwt.material.design.client.ui.MaterialLink;
/**
*

View File

@ -4,156 +4,79 @@ import java.util.List;
import org.gcube.portlets.user.workspaceexplorerapp.shared.FilterCriteria;
import org.gcube.portlets.user.workspaceexplorerapp.shared.Item;
import org.gcube.portlets.user.workspaceexplorerapp.shared.ItemCategory;
import org.gcube.portlets.user.workspaceexplorerapp.shared.ItemType;
import org.gcube.portlets.user.workspaceexplorerapp.shared.WorkspaceNavigatorServiceException;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
/**
* The Interface WorkspaceExplorerAppService.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jul 3, 2017
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jul 3, 2017
*/
@RemoteServiceRelativePath("WorkspaceExplorerAppService")
public interface WorkspaceExplorerAppService extends RemoteService {
/**
* Gets the breadcrumbs by item identifier.
*
* @param itemIdentifier the item identifier
* @param includeItemAsParent the include item as parent
* @return the breadcrumbs by item identifier
* @throws Exception the exception
*/
List<Item> getBreadcrumbsByItemIdentifier(String itemIdentifier,
boolean includeItemAsParent) throws Exception;
/**
* Check name.
*
* @param name the name
* @return true, if successful
* @throws WorkspaceNavigatorServiceException the workspace navigator service exception
*/
boolean checkName(String name) throws WorkspaceNavigatorServiceException;
/**
* Gets the folder.
*
* @param folder the folder
* @param showableTypes the showable types
* @param purgeEmpyFolders the purge empy folders
* @param filterCriteria the filter criteria
* @return the folder
* @throws WorkspaceNavigatorServiceException the workspace navigator service exception
* @throws
* @param folder the folder @param showableTypes the showable types @param
* purgeEmpyFolders the purge empy folders @param filterCriteria
* the filter criteria @return the folder @throws
* WorkspaceNavigatorServiceException the workspace navigator
* service exception @throws
*/
Item getFolder(
Item folder, List<ItemType> showableTypes, boolean purgeEmpyFolders,
FilterCriteria filterCriteria) throws WorkspaceNavigatorServiceException;
Item getFolder(Item folder, List<ItemType> showableTypes, boolean purgeEmpyFolders, FilterCriteria filterCriteria)
throws WorkspaceNavigatorServiceException;
/**
* Gets the root.
*
* @param showableTypes the showable types
* @param showableTypes the showable types
* @param purgeEmpyFolders the purge empy folders
* @param filterCriteria the filter criteria
* @param filterCriteria the filter criteria
* @return the root
* @throws WorkspaceNavigatorServiceException the workspace navigator service exception
* @throws WorkspaceNavigatorServiceException the workspace navigator service
* exception
*/
Item getRoot(List<ItemType> showableTypes, boolean purgeEmpyFolders,
FilterCriteria filterCriteria)
Item getRoot(List<ItemType> showableTypes, boolean purgeEmpyFolders, FilterCriteria filterCriteria)
throws WorkspaceNavigatorServiceException;
/**
* Gets the my special folder.
*
* @param showableTypes the showable types
* @param showableTypes the showable types
* @param purgeEmpyFolders the purge empy folders
* @param filterCriteria the filter criteria
* @param filterCriteria the filter criteria
* @return the my special folder
* @throws WorkspaceNavigatorServiceException the workspace navigator service exception
* @throws WorkspaceNavigatorServiceException the workspace navigator service
* exception
*/
Item getMySpecialFolder(List<ItemType> showableTypes,
boolean purgeEmpyFolders, FilterCriteria filterCriteria)
Item getMySpecialFolder(List<ItemType> showableTypes, boolean purgeEmpyFolders, FilterCriteria filterCriteria)
throws WorkspaceNavigatorServiceException;
/**
* Gets the item by category.
*
* @param category the category
* @return the item by category
* @throws WorkspaceNavigatorServiceException the workspace navigator service exception
*/
Item getItemByCategory(ItemCategory category)throws WorkspaceNavigatorServiceException;
/**
* Gets the size by item id.
*
* @param itemId the item id
* @return the size by item id
* @throws Exception the exception
*/
Long getSizeByItemId(String itemId) throws Exception;
/**
* Gets the mime type.
*
* @param itemId the item id
* @return the mime type
* @throws Exception the exception
*/
String getMimeType(String itemId) throws Exception;
/**
* Gets the user acl for folder id.
*
* @param folderId the folder id
* @return the user acl for folder id
* @throws Exception the exception
*/
String getUserACLForFolderId(String folderId) throws Exception;
/**
* Gets the readable size by item id.
*
* @param id the id
* @return the readable size by item id
* @throws Exception the exception
*/
String getReadableSizeByItemId(String id) throws Exception;
/**
* Gets the breadcrumbs by item identifier to parent limit.
*
* @param itemIdentifier the item identifier
* @param parentLimit the parent limit
* @param itemIdentifier the item identifier
* @param parentLimit the parent limit
* @param includeItemAsParent the include item as parent
* @return the breadcrumbs by item identifier to parent limit
* @throws Exception the exception
*/
List<Item> getBreadcrumbsByItemIdentifierToParentLimit(
String itemIdentifier, String parentLimit,
List<Item> getBreadcrumbsByItemIdentifierToParentLimit(String itemIdentifier, String parentLimit,
boolean includeItemAsParent) throws Exception;
/**
* Creates the folder.
* Gets the breadcrumbs by item identifier.
*
* @param nameFolder the name folder
* @param description the description
* @param parentId the parent id
* @return the item
* @param itemIdentifier the item identifier
* @param includeItemAsParent the include item as parent
* @return the breadcrumbs by item identifier
* @throws Exception the exception
*/
Item createFolder(
String nameFolder, String description, String parentId)
throws Exception;
List<Item> getBreadcrumbsByItemIdentifier(String itemIdentifier, boolean includeItemAsParent) throws Exception;
/**
* Gets the public link for item id.
@ -162,8 +85,7 @@ public interface WorkspaceExplorerAppService extends RemoteService {
* @return the public link for item id
* @throws Exception the exception
*/
String getPublicLinkForItemId(String itemId)
throws Exception;
String getPublicLinkForItemId(String itemId) throws Exception;
/**
* Gets the folder id from encrypted.
@ -172,6 +94,77 @@ public interface WorkspaceExplorerAppService extends RemoteService {
* @return the folder id from encrypted
* @throws Exception the exception
*/
String getFolderIdFromEncrypted(String encryptedFolderId)
throws Exception;
String getFolderIdFromEncrypted(String encryptedFolderId) throws Exception;
//
// /**
// * Check name.
// *
// * @param name the name
// * @return true, if successful
// * @throws WorkspaceNavigatorServiceException the workspace navigator service exception
// */
// boolean checkName(String name) throws WorkspaceNavigatorServiceException;
//
//
// /**
// * Gets the item by category.
// *
// * @param category the category
// * @return the item by category
// * @throws WorkspaceNavigatorServiceException the workspace navigator service exception
// */
// Item getItemByCategory(ItemCategory category)throws WorkspaceNavigatorServiceException;
//
// /**
// * Gets the size by item id.
// *
// * @param itemId the item id
// * @return the size by item id
// * @throws Exception the exception
// */
// Long getSizeByItemId(String itemId) throws Exception;
//
// /**
// * Gets the mime type.
// *
// * @param itemId the item id
// * @return the mime type
// * @throws Exception the exception
// */
// String getMimeType(String itemId) throws Exception;
//
// /**
// * Gets the user acl for folder id.
// *
// * @param folderId the folder id
// * @return the user acl for folder id
// * @throws Exception the exception
// */
// String getUserACLForFolderId(String folderId) throws Exception;
//
//
// /**
// * Gets the readable size by item id.
// *
// * @param id the id
// * @return the readable size by item id
// * @throws Exception the exception
// */
// String getReadableSizeByItemId(String id) throws Exception;
//
// /**
// * Creates the folder.
// *
// * @param nameFolder the name folder
// * @param description the description
// * @param parentId the parent id
// * @return the item
// * @throws Exception the exception
// */
// Item createFolder(
// String nameFolder, String description, String parentId)
// throws Exception;
}

View File

@ -7,162 +7,21 @@ import java.util.List;
import org.gcube.portlets.user.workspaceexplorerapp.shared.FilterCriteria;
import org.gcube.portlets.user.workspaceexplorerapp.shared.Item;
import org.gcube.portlets.user.workspaceexplorerapp.shared.ItemCategory;
import org.gcube.portlets.user.workspaceexplorerapp.shared.ItemType;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
* The Interface WorkspaceExplorerAppServiceAsync.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jul 3, 2017
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jul 3, 2017
*/
public interface WorkspaceExplorerAppServiceAsync {
/**
* Gets the root.
*
* @param showableTypes the showable types
* @param purgeEmpyFolders the purge empy folders
* @param filterCriteria the filter criteria
* @param callback the callback
* @return the root
*/
public void getRoot(List<ItemType> showableTypes, boolean purgeEmpyFolders,
FilterCriteria filterCriteria, AsyncCallback<Item> callback);
/**
* Check name.
*
* @param name the name
* @param callback the callback
*/
public void checkName(String name, AsyncCallback<Boolean> callback);
/**
* Gets the folder.
*
* @param folder the folder
* @param showableTypes the showable types
* @param purgeEmpyFolders the purge empy folders
* @param filterCriteria the filter criteria
* @param callback the callback
* @return the folder
*/
public void getFolder(Item folder, List<ItemType> showableTypes,
boolean purgeEmpyFolders, FilterCriteria filterCriteria,
AsyncCallback<Item> callback);
/**
* Gets the breadcrumbs by item identifier.
*
* @param itemIdentifier the item identifier
* @param includeItemAsParent the include item as parent
* @param asyncCallback the async callback
* @return the breadcrumbs by item identifier
*/
public void getBreadcrumbsByItemIdentifier(String itemIdentifier,
boolean includeItemAsParent, AsyncCallback<List<Item>> asyncCallback);
/**
* Gets the my special folder.
*
* @param showableTypes the showable types
* @param purgeEmpyFolders the purge empy folders
* @param filterCriteria the filter criteria
* @param asyncCallback the async callback
* @return the my special folder
*/
public void getMySpecialFolder(List<ItemType> showableTypes, boolean purgeEmpyFolders, FilterCriteria filterCriteria, AsyncCallback<Item> asyncCallback);
/**
* Gets the item by category.
*
* @param category the category
* @param asyncCallback the async callback
* @return the item by category
*/
public void getItemByCategory(ItemCategory category, AsyncCallback<Item> asyncCallback);
/**
* Gets the size by item id.
*
* @param id the id
* @param asyncCallback the async callback
* @return the size by item id
*/
public void getSizeByItemId(String id, AsyncCallback<Long> asyncCallback);
/**
* Gets the readable size by item id.
*
* @param id the id
* @param asyncCallback the async callback
* @return the readable size by item id
*/
public void getReadableSizeByItemId(String id, AsyncCallback<String> asyncCallback);
/**
* Gets the mime type.
*
* @param id the id
* @param asyncCallback the async callback
* @return the mime type
*/
public void getMimeType(String id, AsyncCallback<String> asyncCallback);
/**
* Gets the user acl for folder id.
*
* @param id the id
* @param asyncCallback the async callback
* @return the user acl for folder id
*/
public void getUserACLForFolderId(String id,
AsyncCallback<String> asyncCallback);
/**
* Gets the breadcrumbs by item identifier to parent limit.
*
* @param itemIdentifier the item identifier
* @param parentLimit the parent limit
* @param includeItemAsParent the include item as parent
* @param callback the callback
* @return the breadcrumbs by item identifier to parent limit
*/
void getBreadcrumbsByItemIdentifierToParentLimit(String itemIdentifier,
String parentLimit, boolean includeItemAsParent,
AsyncCallback<List<Item>> callback);
/**
* Creates the folder.
*
* @param nameFolder the name folder
* @param description the description
* @param parentId the parent id
* @param callback the callback
*/
void createFolder(
String nameFolder, String description, String parentId,
AsyncCallback<Item> callback);
/**
* Gets the public link for item id.
*
* @param itemId the item id
* @param itemId the item id
* @param callback the callback
* @return the public link for item id
*/
@ -172,10 +31,140 @@ public interface WorkspaceExplorerAppServiceAsync {
* Gets the folder id from encrypted.
*
* @param encodedFolderID the encoded folder id
* @param callback the callback
* @param callback the callback
* @return the folder id from encrypted
*/
void getFolderIdFromEncrypted(
String encodedFolderID, AsyncCallback<String> callback);
void getFolderIdFromEncrypted(String encodedFolderID, AsyncCallback<String> callback);
/**
* Gets the root.
*
* @param showableTypes the showable types
* @param purgeEmpyFolders the purge empy folders
* @param filterCriteria the filter criteria
* @param callback the callback
* @return the root
*/
public void getRoot(List<ItemType> showableTypes, boolean purgeEmpyFolders, FilterCriteria filterCriteria,
AsyncCallback<Item> callback);
/**
* Gets the folder.
*
* @param folder the folder
* @param showableTypes the showable types
* @param purgeEmpyFolders the purge empy folders
* @param filterCriteria the filter criteria
* @param callback the callback
* @return the folder
*/
public void getFolder(Item folder, List<ItemType> showableTypes, boolean purgeEmpyFolders,
FilterCriteria filterCriteria, AsyncCallback<Item> callback);
/**
* Gets the breadcrumbs by item identifier.
*
* @param itemIdentifier the item identifier
* @param includeItemAsParent the include item as parent
* @param asyncCallback the async callback
* @return the breadcrumbs by item identifier
*/
public void getBreadcrumbsByItemIdentifier(String itemIdentifier, boolean includeItemAsParent,
AsyncCallback<List<Item>> asyncCallback);
/**
* Gets the my special folder.
*
* @param showableTypes the showable types
* @param purgeEmpyFolders the purge empy folders
* @param filterCriteria the filter criteria
* @param asyncCallback the async callback
* @return the my special folder
*/
public void getMySpecialFolder(List<ItemType> showableTypes, boolean purgeEmpyFolders,
FilterCriteria filterCriteria, AsyncCallback<Item> asyncCallback);
/**
* Gets the breadcrumbs by item identifier to parent limit.
*
* @param itemIdentifier the item identifier
* @param parentLimit the parent limit
* @param includeItemAsParent the include item as parent
* @param callback the callback
* @return the breadcrumbs by item identifier to parent limit
*/
void getBreadcrumbsByItemIdentifierToParentLimit(String itemIdentifier, String parentLimit,
boolean includeItemAsParent, AsyncCallback<List<Item>> callback);
//
//
// /**
// * Check name.
// *
// * @param name the name
// * @param callback the callback
// */
// public void checkName(String name, AsyncCallback<Boolean> callback);
//
//
//
//
// /**
// * Gets the item by category.
// *
// * @param category the category
// * @param asyncCallback the async callback
// * @return the item by category
// */
// public void getItemByCategory(ItemCategory category, AsyncCallback<Item> asyncCallback);
//
// /**
// * Gets the size by item id.
// *
// * @param id the id
// * @param asyncCallback the async callback
// * @return the size by item id
// */
// public void getSizeByItemId(String id, AsyncCallback<Long> asyncCallback);
// /**
// * Gets the readable size by item id.
// *
// * @param id the id
// * @param asyncCallback the async callback
// * @return the readable size by item id
// */
// public void getReadableSizeByItemId(String id, AsyncCallback<String> asyncCallback);
//
// /**
// * Gets the mime type.
// *
// * @param id the id
// * @param asyncCallback the async callback
// * @return the mime type
// */
// public void getMimeType(String id, AsyncCallback<String> asyncCallback);
// /**
// * Gets the user acl for folder id.
// *
// * @param id the id
// * @param asyncCallback the async callback
// * @return the user acl for folder id
// */
// public void getUserACLForFolderId(String id,
// AsyncCallback<String> asyncCallback);
// /**
// * Creates the folder.
// *
// * @param nameFolder the name folder
// * @param description the description
// * @param parentId the parent id
// * @param callback the callback
// */
// void createFolder(String nameFolder, String description, String parentId, AsyncCallback<Item> callback);
}

View File

@ -21,24 +21,21 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalImage;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalUrl;
import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
import org.gcube.common.homelibrary.home.workspace.folder.items.Query;
import org.gcube.common.homelibrary.home.workspace.folder.items.Report;
import org.gcube.common.homelibrary.home.workspace.folder.items.ReportTemplate;
import org.gcube.common.homelibrary.home.workspace.folder.items.ts.TimeSeries;
import org.gcube.common.homelibrary.util.Extensions;
import org.gcube.common.homelibrary.util.MimeTypeUtil;
import org.gcube.common.homelibrary.util.zip.ZipUtil;
import org.gcube.common.storagehub.model.items.FolderItem;
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
import org.gcube.portlets.user.workspaceexplorerapp.client.WorkspaceExplorerAppConstants;
import org.gcube.portlets.user.workspaceexplorerapp.server.workspace.WsUtil;
import org.gcube.portlets.user.workspaceexplorerapp.shared.HandlerResultMessage;
/**

View File

@ -1,24 +1,28 @@
package org.gcube.portlets.user.workspaceexplorerapp.server;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpSession;
import org.gcube.common.encryption.StringEncrypter;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItemType;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.items.FileItem;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
import org.gcube.portlets.user.workspaceexplorerapp.client.WorkspaceExplorerAppConstants;
import org.gcube.portlets.user.workspaceexplorerapp.client.rpc.WorkspaceExplorerAppService;
import org.gcube.portlets.user.workspaceexplorerapp.server.workspace.ItemBuilder;
import org.gcube.portlets.user.workspaceexplorerapp.server.workspace.WorkspaceInstance;
import org.gcube.portlets.user.workspaceexplorerapp.server.workspace.WsUtil;
import org.gcube.portlets.user.workspaceexplorerapp.shared.FilterCriteria;
import org.gcube.portlets.user.workspaceexplorerapp.shared.Item;
import org.gcube.portlets.user.workspaceexplorerapp.shared.ItemCategory;
import org.gcube.portlets.user.workspaceexplorerapp.shared.ItemType;
import org.gcube.portlets.user.workspaceexplorerapp.shared.WorkspaceNavigatorServiceException;
import org.slf4j.Logger;
@ -37,12 +41,32 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
@SuppressWarnings("serial")
public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implements WorkspaceExplorerAppService {
public static final String THE_WORKSPACE_SHUB_INSTANCIED = "THE_WORKSPACE_SHUB_INSTANCIED";
/**
*
*/
public static final Logger logger = LoggerFactory.getLogger(WorkspaceExplorerAppServiceImpl.class);
public static final String UTF_8 = "UTF-8";
/**
* Gets the workspace.
*
* @return the workspace
* @throws Exception
*/
private Workspace getWorkspace() throws Exception {
HttpSession httpSession = this.getThreadLocalRequest().getSession();
Workspace workspace = (Workspace) httpSession.getAttribute(THE_WORKSPACE_SHUB_INSTANCIED);
if(workspace==null) {
WorkspaceInstance workspaceInstance = new WorkspaceInstance(httpSession);
workspace = workspaceInstance.get();
httpSession.setAttribute(THE_WORKSPACE_SHUB_INSTANCIED, workspace);
}
return workspace;
}
/**
* {@inheritDoc}
@ -53,7 +77,7 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
try {
Workspace workspace = WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
Workspace workspace = getWorkspace();
logger.trace("Start getRoot...");
org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder root = workspace.getRoot();
@ -62,7 +86,11 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
long startTime = System.currentTimeMillis();
logger.trace("start time - " + startTime);
Item rootItem = ItemBuilder.getItem(null, root, root.getPath(), showableTypes, filterCriteria, true);
Item rootItem = ItemBuilder.getItem(null, root, root.getPath(), showableTypes, filterCriteria);
//adding the children
List<? extends WorkspaceItem> children = workspace.getChildren(root.getId());
rootItem = ItemBuilder.addChildren(rootItem, "", children, showableTypes, filterCriteria);
rootItem.setName(WorkspaceExplorerAppConstants.HOME_LABEL);
rootItem.setIsRoot(true);
@ -100,19 +128,20 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
* @param purgeEmpyFolders the purge empy folders
* @param filterCriteria the filter criteria
* @return the folder
* @throws Exception the exception
* @throws WorkspaceNavigatorServiceException the workspace navigator service exception
*/
@Override
public Item getFolder(Item item, List<ItemType> showableTypes, boolean purgeEmpyFolders, FilterCriteria filterCriteria) throws WorkspaceNavigatorServiceException {
logger.trace("getFolder item: "+item+" showableTypes: "+showableTypes+" purgeEmpyFolders: "+purgeEmpyFolders+" filterCriteria: "+filterCriteria);
WorkspaceItem workspaceItem = null;
Workspace workspace = null;
try {
if(item==null || item.getId()==null)
throw new Exception("Item id is null");
Workspace workspace = WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
workspace = getWorkspace();
workspaceItem = workspace.getItem(item.getId());
} catch (Exception e) {
@ -131,8 +160,10 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
logger.trace("start time - " + startTime);
String path = item.getPath()!=null && !item.getPath().isEmpty()?item.getPath():folder.getPath();
Item itemFolder = ItemBuilder.getItem(null, folder, path, showableTypes, filterCriteria, true);
Item itemFolder = ItemBuilder.getItem(null, folder, path, showableTypes, filterCriteria);
//adding the children
List<? extends WorkspaceItem> children = workspace.getChildren(itemFolder.getId());
itemFolder = ItemBuilder.addChildren(itemFolder, path, children, showableTypes, filterCriteria);
// _log.trace("Only showable types:");
if (purgeEmpyFolders) {
@ -160,21 +191,21 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
}
/**
* Gets the item by category.
*
* @param category the category
* @return the item by category
* @throws WorkspaceNavigatorServiceException the workspace navigator service exception
*/
/* (non-Javadoc)
* @see org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService#getItemByCategory(org.gcube.portlets.widgets.wsexplorer.shared.ItemCategory)
*/
@Override
public Item getItemByCategory(ItemCategory category) throws WorkspaceNavigatorServiceException{
logger.trace("GetItemByCategory category: "+category);
throw new WorkspaceNavigatorServiceException("The method getItemByCategory is not implemented");
}
// /**
// * Gets the item by category.
// *
// * @param category the category
// * @return the item by category
// * @throws WorkspaceNavigatorServiceException the workspace navigator service exception
// */
// /* (non-Javadoc)
// * @see org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService#getItemByCategory(org.gcube.portlets.widgets.wsexplorer.shared.ItemCategory)
// */
// @Override
// public Item getItemByCategory(ItemCategory category) throws WorkspaceNavigatorServiceException{
// logger.trace("GetItemByCategory category: "+category);
// throw new WorkspaceNavigatorServiceException("The method getItemByCategory is not implemented");
// }
/**
* {@inheritDoc}
@ -185,12 +216,16 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
try {
Workspace workspace = WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
Workspace workspace = getWorkspace();
WorkspaceItem folder = workspace.getMySpecialFolders();
long startTime = System.currentTimeMillis();
logger.trace("start time - " + startTime);
Item itemFolder = ItemBuilder.getItem(null, folder, folder.getPath(), showableTypes, filterCriteria, true);
Item itemFolder = ItemBuilder.getItem(null, folder, folder.getPath(), showableTypes, filterCriteria);
//adding the children
List<? extends WorkspaceItem> children = workspace.getChildren(itemFolder.getId());
itemFolder = ItemBuilder.addChildren(itemFolder, "", children, showableTypes, filterCriteria);
//OVERRIDING VRE FOLDERS NAME - SET SPECIAL FOLDER /Workspace/MySpecialFolders
itemFolder.setName(WorkspaceExplorerAppConstants.VRE_FOLDERS_LABEL);
itemFolder.setSpecialFolder(true);
@ -213,21 +248,21 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
}
}
/**
* {@inheritDoc}
*/
@Override
public boolean checkName(String name) throws WorkspaceNavigatorServiceException {
logger.trace("checkName name: "+name);
throw new WorkspaceNavigatorServiceException("The method checkName is not implemented");
// try {
// Workspace workspace = WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
// return workspace.isValidName(name);
// } catch (Exception e) {
// logger.error("Error during folder retrieving", e);
// throw new WorkspaceNavigatorServiceException(e.getMessage());
// }
}
// /**
// * {@inheritDoc}
// */
// @Override
// public boolean checkName(String name) throws WorkspaceNavigatorServiceException {
// logger.trace("checkName name: "+name);
// throw new WorkspaceNavigatorServiceException("The method checkName is not implemented");
//// try {
//// Workspace workspace = WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
//// return workspace.isValidName(name);
//// } catch (Exception e) {
//// logger.error("Error during folder retrieving", e);
//// throw new WorkspaceNavigatorServiceException(e.getMessage());
//// }
// }
/*protected void printName(String indentation, Item item)
{
@ -250,7 +285,7 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
logger.trace("ListParents By Item Identifier "+ itemIdentifier);
try {
Workspace workspace = WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
Workspace workspace = getWorkspace();
WorkspaceItem wsItem = workspace.getItem(itemIdentifier);
logger.trace("workspace retrieve item name: "+wsItem.getName());
List<? extends WorkspaceItem> parents = workspace.getParentsById(itemIdentifier);
@ -368,7 +403,7 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
logger.trace("getBreadcrumbsByItemIdentifierToParentLimit by Item Identifier " + itemIdentifier +" and limit: "+parentLimit);
try {
Workspace workspace = WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
Workspace workspace = getWorkspace();
WorkspaceItem wsItem = workspace.getItem(itemIdentifier);
logger.trace("workspace retrieve item name: "+wsItem.getName());
List<? extends WorkspaceItem> parents = null;
@ -477,103 +512,103 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
}
}
/**
* Gets the size by item id.
*
* @param itemId the item id
* @return the size by item id
* @throws Exception the exception
*/
/* (non-Javadoc)
* @see org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService#loadSizeByItemId(java.lang.String)
*/
@Override
public Long getSizeByItemId(String itemId) throws Exception {
// /**
// * Gets the size by item id.
// *
// * @param itemId the item id
// * @return the size by item id
// * @throws Exception the exception
// */
// /* (non-Javadoc)
// * @see org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService#loadSizeByItemId(java.lang.String)
// */
// @Override
// public Long getSizeByItemId(String itemId) throws Exception {
//
// logger.info("get Size By ItemId "+ itemId);
// try {
//
// Workspace workspace = getWorkspace();
// WorkspaceItem wsItem = workspace.getItem(itemId);
// Long size = new Long(-1);
//
// if(wsItem instanceof FileItem){ //ITEM
// FileItem fileItem = (FileItem) wsItem;
// size = new Long(fileItem.getSize());
// } else if (wsItem instanceof WorkspaceFolder ){ //FOLDER
// WorkspaceFolder theFolder = (WorkspaceFolder) wsItem;
// //size = theFolder.getSize(); NOT SUPPORTED BY SHUB
// } else if (wsItem instanceof WorkspaceSharedFolder){ //SHARED FOLDER
// WorkspaceSharedFolder theFolder = (WorkspaceSharedFolder) wsItem;
// //size = theFolder.getSize(); NOT SUPPORTED BY SHUB
// }
// logger.info("returning size: " +size);
// return size;
//
// } catch (Exception e) {
// logger.error("get Size By ItemId ", e);
// throw new Exception(e.getMessage());
// }
// }
logger.info("get Size By ItemId "+ itemId);
try {
Workspace workspace = WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
WorkspaceItem wsItem = workspace.getItem(itemId);
Long size = new Long(-1);
if(wsItem instanceof FileItem){ //ITEM
FileItem fileItem = (FileItem) wsItem;
size = new Long(fileItem.getSize());
} else if (wsItem instanceof WorkspaceFolder ){ //FOLDER
WorkspaceFolder theFolder = (WorkspaceFolder) wsItem;
//size = theFolder.getSize(); NOT SUPPORTED BY SHUB
} else if (wsItem instanceof WorkspaceSharedFolder){ //SHARED FOLDER
WorkspaceSharedFolder theFolder = (WorkspaceSharedFolder) wsItem;
//size = theFolder.getSize(); NOT SUPPORTED BY SHUB
}
logger.info("returning size: " +size);
return size;
} catch (Exception e) {
logger.error("get Size By ItemId ", e);
throw new Exception(e.getMessage());
}
}
/**
* Gets the mime type.
*
* @param itemId the item id
* @return the mime type
* @throws Exception the exception
*/
/* (non-Javadoc)
* @see org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService#getMimeType(java.lang.String)
*/
@Override
public String getMimeType(String itemId) throws Exception {
logger.info("get MimeType By ItemId "+ itemId);
try {
Workspace workspace = WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
WorkspaceItem wsItem = workspace.getItem(itemId);
if(wsItem instanceof FileItem) {
FileItem fileItem = (FileItem) wsItem;
return fileItem.getMimeType();
}else
return null;
} catch (Exception e) {
logger.error("get MimeType By ItemId ", e);
throw new Exception(e.getMessage());
}
}
// /**
// * Gets the mime type.
// *
// * @param itemId the item id
// * @return the mime type
// * @throws Exception the exception
// */
// /* (non-Javadoc)
// * @see org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService#getMimeType(java.lang.String)
// */
// @Override
// public String getMimeType(String itemId) throws Exception {
//
// logger.info("get MimeType By ItemId "+ itemId);
// try {
//
// Workspace workspace = getWorkspace();
// WorkspaceItem wsItem = workspace.getItem(itemId);
//
// if(wsItem instanceof FileItem) {
// FileItem fileItem = (FileItem) wsItem;
// return fileItem.getMimeType();
// }else
// return null;
//
// } catch (Exception e) {
// logger.error("get MimeType By ItemId ", e);
// throw new Exception(e.getMessage());
// }
// }
/**
* Gets the user acl for folder id.
*
* @param folderId the folder id
* @return the user acl for folder id
* @throws Exception the exception
*/
@Override
public String getUserACLForFolderId(String folderId) throws Exception{
try {
logger.info("Get user ACL to FOLDER id: "+folderId);
Workspace workspace = WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
WorkspaceItem wsItem = workspace.getItem(folderId);
if(!isASharedFolder(wsItem, false)) {
return "OWNER";
}
else {
return wsItem.getACLUser().toString();
}
} catch (Exception e) {
logger.error("Error in server get UserACLForFolderId", e);
String error = "An error occurred when getting ACL rules for selected folder. "+e.getMessage();
throw new Exception(error);
}
}
// /**
// * Gets the user acl for folder id.
// *
// * @param folderId the folder id
// * @return the user acl for folder id
// * @throws Exception the exception
// */
// @Override
// public String getUserACLForFolderId(String folderId) throws Exception{
// try {
// logger.info("Get user ACL to FOLDER id: "+folderId);
// Workspace workspace = getWorkspace();
// WorkspaceItem wsItem = workspace.getItem(folderId);
//
// if(!isASharedFolder(wsItem, false)) {
// return "OWNER";
// }
// else {
// return wsItem.getACLUser().toString();
// }
// } catch (Exception e) {
// logger.error("Error in server get UserACLForFolderId", e);
// String error = "An error occurred when getting ACL rules for selected folder. "+e.getMessage();
// throw new Exception(error);
// }
// }
/**
@ -601,92 +636,93 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
}
/**
* Gets the readable size by item id.
*
* @param itemId the item id
* @return the readable size by item id
* @throws Exception the exception
*/
/* (non-Javadoc)
* @see org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService#getFormattedSizeByItemId(java.lang.String, org.gcube.portlets.widgets.wsexplorer.shared.SizeFormatter)
*/
@Override
public String getReadableSizeByItemId(String itemId) throws Exception {
// /**
// * Gets the readable size by item id.
// *
// * @param itemId the item id
// * @return the readable size by item id
// * @throws Exception the exception
// */
// /* (non-Javadoc)
// * @see org.gcube.portlets.widgets.wsexplorer.client.rpc.WorkspaceExplorerService#getFormattedSizeByItemId(java.lang.String, org.gcube.portlets.widgets.wsexplorer.shared.SizeFormatter)
// */
// @Override
// public String getReadableSizeByItemId(String itemId) throws Exception {
//
// try{
// logger.info("getFormattedSize ByItemId "+ itemId);
// long size = getSizeByItemId(itemId);
// return StringUtil.readableFileSize(size);
// } catch (Exception e) {
// logger.error("getFormattedSize By ItemId ", e);
// throw new Exception(e.getMessage());
// }
// }
try{
logger.info("getFormattedSize ByItemId "+ itemId);
long size = getSizeByItemId(itemId);
return StringUtil.readableFileSize(size);
} catch (Exception e) {
logger.error("getFormattedSize By ItemId ", e);
throw new Exception(e.getMessage());
}
}
/**
* Creates the folder.
*
* @param nameFolder the name folder
* @param description the description
* @param parentId the parent id
* @return the item
* @throws Exception the exception
*/
/* (non-Javadoc)
* @see org.gcube.portlets.user.workspaceexplorerapp.client.rpc.WorkspaceExplorerAppService#createFolder(java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public Item createFolder(String nameFolder, String description, String parentId) throws Exception {
logger.debug("creating folder: "+nameFolder +", parent id: "+parentId);
try {
if(parentId==null || parentId.isEmpty())
throw new Exception("Parent id is null or empty");
if(nameFolder == null)
nameFolder = "Empty Folder";
Workspace workspace = WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
WorkspaceFolder wsFolder = workspace.createFolder(nameFolder, description, parentId);
List<ItemType> allTypes = Arrays.asList(ItemType.values());
Item parent = null;
try{
String parentPath = wsFolder.getParent()!=null?wsFolder.getParent().getPath():"";
parent = ItemBuilder.getItem(null, wsFolder.getParent(), parentPath, allTypes, null, false);
}catch(Exception e){
logger.error("Get parent thown an exception, is it the root id? "+parentId);
}
//TODO PATCH TO AVOID PROBLEM ON GETPATH. FOR EXAMPLE WHEN PARENT IS ROOT
String itemPath = null;
try{
itemPath = wsFolder.getPath();
}catch(Exception e){
logger.error("Get path thown an exception, for id: "+wsFolder.getId());
itemPath= wsFolder.isFolder()?workspace.getRoot().getPath()+"/"+wsFolder.getName():workspace.getRoot().getPath();
}
return ItemBuilder.getItem(parent, wsFolder, itemPath, allTypes, null, false);
} catch(InsufficientPrivilegesException e){
String error = "Insufficient Privileges to create the folder";
logger.error(error, e);
throw new Exception(error);
} catch (ItemAlreadyExistException e) {
String error = "An error occurred on creating folder, " +e.getMessage();
logger.error(error, e);
throw new Exception(error);
} catch (Exception e) {
String error = "An error occurred on the sever during creating folder. Try again";
logger.error(error, e);
throw new Exception(error);
}
}
// /**
// * Creates the folder.
// *
// * @param nameFolder the name folder
// * @param description the description
// * @param parentId the parent id
// * @return the item
// * @throws Exception the exception
// */
// /* (non-Javadoc)
// * @see org.gcube.portlets.user.workspaceexplorerapp.client.rpc.WorkspaceExplorerAppService#createFolder(java.lang.String, java.lang.String, java.lang.String)
// */
// @Override
// public Item createFolder(String nameFolder, String description, String parentId) throws Exception {
//
// logger.debug("creating folder: "+nameFolder +", parent id: "+parentId);
// throw new WorkspaceNavigatorServiceException("The method 'createFolder' is not implemented");
//
// /*try {
//
// if(parentId==null || parentId.isEmpty())
// throw new Exception("Parent id is null or empty");
//
// if(nameFolder == null)
// nameFolder = "Empty Folder";
//
// Workspace workspace = getWorkspace();
// WorkspaceFolder wsFolder = workspace.createFolder(nameFolder, description, parentId);
// List<ItemType> allTypes = Arrays.asList(ItemType.values());
//
// Item parent = null;
// try{
// String parentPath = wsFolder.getParent()!=null?wsFolder.getParent().getPath():"";
// parent = ItemBuilder.getItem(null, wsFolder.getParent(), parentPath, allTypes, null, false);
// }catch(Exception e){
// logger.error("Get parent thown an exception, is it the root id? "+parentId);
// }
//
// //TODO PATCH TO AVOID PROBLEM ON GETPATH. FOR EXAMPLE WHEN PARENT IS ROOT
// String itemPath = null;
// try{
// itemPath = wsFolder.getPath();
// }catch(Exception e){
// logger.error("Get path thown an exception, for id: "+wsFolder.getId());
// itemPath= wsFolder.isFolder()?workspace.getRoot().getPath()+"/"+wsFolder.getName():workspace.getRoot().getPath();
// }
//
// return ItemBuilder.getItem(parent, wsFolder, itemPath, allTypes, null, false);
//
// } catch(InsufficientPrivilegesException e){
// String error = "Insufficient Privileges to create the folder";
// logger.error(error, e);
// throw new Exception(error);
// } catch (ItemAlreadyExistException e) {
// String error = "An error occurred on creating folder, " +e.getMessage();
// logger.error(error, e);
// throw new Exception(error);
// } catch (Exception e) {
// String error = "An error occurred on the sever during creating folder. Try again";
// logger.error(error, e);
// throw new Exception(error);
// }*/
//
// }
/**
@ -703,31 +739,30 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
try{
if(itemId==null)
throw new Exception("Sorry, The Public Link for empty item is unavailable (itemId is null)");
throw new Exception("Sorry, the itemId is null. The public link for empty item is unavailable");
Workspace workspace = WsUtil.getWorkspace(this.getThreadLocalRequest().getSession());
Workspace workspace = getWorkspace();
WorkspaceItem wsItem = workspace.getItem(itemId);
if(wsItem==null)
throw new Exception("Sorry, The Public Link for empty item is unavailable");
throw new Exception("Sorry, the workspace item is null. The public link for empty item is unavailable");
if(wsItem.getType().equals(WorkspaceItemType.FOLDER_ITEM)){
if(wsItem instanceof FileItem){
FolderItem folderItem = (FolderItem) wsItem;
String uriRequest = folderItem.getPublicLink(false);
URL theURL = workspace.getPublicLinkForFile(wsItem.getId());
if(uriRequest==null || uriRequest.isEmpty())
throw new Exception("Sorry, public link on "+folderItem.getName() +" is not available");
return uriRequest;
if(theURL==null)
throw new Exception("Sorry, the public link for "+wsItem.getName() +" is not available");
return theURL.toString();
}else{
logger.warn("ItemId: "+ itemId +" is not available, sent exception Public Link unavailable");
throw new Exception("Sorry, The Public Link for selected item is unavailable");
throw new Exception("Sorry, the Public Link for selected item is unavailable");
}
}catch (Exception e) {
logger.error("Error getPublicLinkForItemId for item: "+itemId, e);
logger.error("Error on getting public link for item: "+itemId, e);
throw new Exception(e.getMessage());
}

View File

@ -1,7 +1,7 @@
/**
*
*/
package org.gcube.portlets.user.workspaceexplorerapp.server;
package org.gcube.portlets.user.workspaceexplorerapp.server.workspace;
import java.util.Calendar;
import java.util.Date;
@ -12,8 +12,8 @@ import java.util.Map.Entry;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItemType;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
import org.gcube.common.storagehubwrapper.shared.tohl.items.FileItem;
import org.gcube.common.storagehubwrapper.shared.tohl.items.PropertyMap;
import org.gcube.portlets.user.workspaceexplorerapp.client.Util;
@ -84,7 +84,7 @@ public class ItemBuilder {
* @return the item
* @throws InternalErrorException the internal error exception
*/
public static Item getItem(Item parent, WorkspaceItem workspaceItem, String workspaceItemPath, List<ItemType> showableTypes, FilterCriteria filterCriteria, boolean loadChildren) throws Exception
public static Item getItem(Item parent, WorkspaceItem workspaceItem, String workspaceItemPath, List<ItemType> showableTypes, FilterCriteria filterCriteria) throws Exception
{
try {
@ -129,22 +129,22 @@ public class ItemBuilder {
return null;
}
if(loadChildren){
//TODO A PATCH TO AVOID A SLOW GETPATH
// workspaceItemPath = workspaceItem.getPath();
for (WorkspaceItem child: workspaceItem.getChildren()){
String itemPath = workspaceItemPath;
if(child.isFolder())
itemPath+="/"+child.getName();
// _log.trace("\nConverting child item: "+child.getName());
Item itemChild = getItem(item, child, itemPath, showableTypes, filterCriteria, false);
// _log.trace("Item: "+child.getName() +" converted!!!");
if (itemChild!=null){
item.addChild(itemChild);
}
}
}
// if(loadChildren){
// //TODO A PATCH TO AVOID A SLOW GETPATH
// // workspaceItemPath = workspaceItem.getPath();
// for (WorkspaceItem child: workspaceItem.getChildren()){
// String itemPath = workspaceItemPath;
// if(child.isFolder())
// itemPath+="/"+child.getName();
//
// // _log.trace("\nConverting child item: "+child.getName());
// Item itemChild = getItem(item, child, itemPath, showableTypes, filterCriteria, false);
// // _log.trace("Item: "+child.getName() +" converted!!!");
// if (itemChild!=null){
// item.addChild(itemChild);
// }
// }
// }
return item;
}catch (Exception e) {
@ -152,6 +152,42 @@ public class ItemBuilder {
throw new Exception("Error on retrieving the item: "+workspaceItem.getName());
}
}
/**
* Adds the children.
*
* @param item the item
* @param itemPathBuilt the item path built
* @param children the children
* @param showableTypes the showable types
* @param filterCriteria the filter criteria
* @return the item with the children added
* @throws Exception the exception
*/
public static Item addChildren(Item item, String itemPathBuilt, List<? extends WorkspaceItem> children, List<ItemType> showableTypes, FilterCriteria filterCriteria) throws Exception {
if(item==null)
return null;
if(children==null)
return item;
for (WorkspaceItem child: children){
String itemPath = itemPathBuilt;
if(child.isFolder()) {
itemPath+="/"+child.getName();
}
Item itemChild = getItem(item, child, itemPath, showableTypes, filterCriteria);
// _log.trace("Item: "+child.getName() +" converted!!!");
if (itemChild!=null){
item.addChild(itemChild);
}
}
return item;
}
/**
@ -375,7 +411,7 @@ public class ItemBuilder {
//name = shared.isVreFolder()?shared.getDisplayName():wsFolder.getName();
name = shared.isVreFolder()?shared.getName():wsFolder.getName(); //not implemented by SHUB
}else if(isSpecialFolder(wsFolder)){
}else {if(isSpecialFolder(wsFolder)){
//MANAGEMENT SPECIAL FOLDER
name = WorkspaceExplorerAppConstants.VRE_FOLDERS_LABEL;
isSpecialFolder = true;
@ -399,10 +435,10 @@ public class ItemBuilder {
* @param wsFolder the ws folder
* @return true, if is special folder
*/
public static boolean isSpecialFolder(WorkspaceFolder wsFolder){
public static boolean isSpecialFolder(WorkspaceFolder wsFolder, boolean parentIsRoot){
try {
return wsFolder.getName().compareTo(WorkspaceExplorerAppConstants.SPECIAL_FOLDERS_NAME)==0 && wsFolder.getParentId()!=null && wsFolder.getParent().isRoot();
return wsFolder.getName().compareTo(WorkspaceExplorerAppConstants.SPECIAL_FOLDERS_NAME)==0 && wsFolder.getParentId()!=null && parentIsRoot;
} catch (Exception e) {
_log.warn("isSpecialFolder exception, returning false");
return false;

View File

@ -1,7 +1,7 @@
/**
*
*/
package org.gcube.portlets.user.workspaceexplorerapp.server;
package org.gcube.portlets.user.workspaceexplorerapp.server.workspace;
import javax.servlet.http.HttpSession;
@ -9,11 +9,12 @@ import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// TODO: Auto-generated Javadoc
/**
* The Class WsUtil.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Sep 13, 2016
* @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy)
* Apr 9, 2020
*/
public class WsUtil {
@ -28,7 +29,7 @@ public class WsUtil {
* @return the storage hub wrapper
* @throws Exception the exception
*/
public static StorageHubWrapper getStorageHubWrapper(HttpSession httpSession) throws Exception {
private static StorageHubWrapper getStorageHubWrapper(HttpSession httpSession) throws Exception {
try {
String scope = getScope(httpSession);
@ -52,7 +53,7 @@ public class WsUtil {
* @return the workpace
* @throws Exception the exception
*/
public static org.gcube.common.storagehubwrapper.server.tohl.Workspace getWorkspace(HttpSession httpSession) throws Exception {
protected static org.gcube.common.storagehubwrapper.server.tohl.Workspace getWorkspace(HttpSession httpSession) throws Exception {
try {
StorageHubWrapper wrapper = getStorageHubWrapper(httpSession);