added get size

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-explorer@167708 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2018-05-23 14:34:06 +00:00
parent 0977484ebc
commit fef8b056a3
4 changed files with 27 additions and 29 deletions

View File

@ -72,6 +72,10 @@ public class Util {
return null; return null;
if (item.isFolder()) if (item.isFolder())
return GWTIconsManager.getIconFolder(item.isSharedFolder()); return GWTIconsManager.getIconFolder(item.isSharedFolder());
if (item.getType() == ItemType.EXTERNAL_URL)
return GWTIconsManager.getIconTypeLink();
if (item.getType() == ItemType.XML)
return GWTIconsManager.getXMLTypeLink();
return GWTIconsManager.getIconFile(item.getName()); return GWTIconsManager.getIconFile(item.getName());
} }

View File

@ -13,6 +13,7 @@ import java.util.Map.Entry;
import org.gcube.common.storagehub.client.plugins.AbstractPlugin; import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
import org.gcube.common.storagehub.client.proxies.ItemManagerClient; import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
import org.gcube.common.storagehub.model.items.AbstractFileItem; import org.gcube.common.storagehub.model.items.AbstractFileItem;
import org.gcube.common.storagehub.model.items.ExternalURL;
import org.gcube.common.storagehub.model.items.FolderItem; import org.gcube.common.storagehub.model.items.FolderItem;
import org.gcube.common.storagehub.model.items.Item; import org.gcube.common.storagehub.model.items.Item;
import org.gcube.common.storagehub.model.items.SharedFolder; import org.gcube.common.storagehub.model.items.SharedFolder;
@ -195,7 +196,7 @@ public class ItemBuilder {
else if (item instanceof FolderItem) { else if (item instanceof FolderItem) {
return getFolderItemType(item); return getFolderItemType(item);
} }
_log.warn("\n\n\n**** Item Type non found: "); _log.warn("Item Type non found: " + item.toString());
return ItemType.UNKNOWN_TYPE; return ItemType.UNKNOWN_TYPE;
} }
@ -205,6 +206,12 @@ public class ItemBuilder {
* @return the item type based on the extension of the file * @return the item type based on the extension of the file
*/ */
private static ItemType getFileIconImageType(Item item) { private static ItemType getFileIconImageType(Item item) {
if (item instanceof ExternalURL)
return ItemType.EXTERNAL_URL;
AbstractFileItem aItem = (AbstractFileItem) item;
if (aItem.getContent().getMimeType().compareTo("application/xml") == 0) {
return ItemType.XML;
}
String[] splits = item.getName().split("\\."); String[] splits = item.getName().split("\\.");
String extension = ""; String extension = "";
if (splits.length > 0) { if (splits.length > 0) {
@ -344,7 +351,6 @@ public class ItemBuilder {
if (allowedFileExtension==null || allowedFileExtension.size()==0) { if (allowedFileExtension==null || allowedFileExtension.size()==0) {
return true; return true;
} }
try { try {
if (! (item instanceof FolderItem)) { if (! (item instanceof FolderItem)) {
String name = item.getName(); String name = item.getName();

View File

@ -322,32 +322,20 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
*/ */
@Override @Override
public Long getSizeByItemId(String itemId) throws Exception { public Long getSizeByItemId(String itemId) throws Exception {
//TODO: implementation missing _log.debug("get Size By ItemId "+ itemId);
return 0L; try {
// logger.info("get Size By ItemId "+ itemId); Item wsItem = Whorespace.getItem(getThreadLocalRequest(), itemId);
// try { _log.trace("workspace retrieve item name: "+wsItem.getName());
// if((wsItem instanceof FolderItem)) //if is a folder no mime
// Workspace workspace = getWorkspace(); return null;
// WorkspaceItem wsItem = workspace.getItem(itemId);
// Long size = new Long(-1); AbstractFileItem file = (AbstractFileItem) wsItem;
// return file.getContent().getSize();
// if(wsItem instanceof FolderItem){ //ITEM
// FolderItem folderItem = (FolderItem) wsItem; } catch (Exception e) {
// size = new Long(folderItem.getLength()); _log.error("get MimeType By ItemId ", e);
// } else if (wsItem instanceof WorkspaceFolder ){ //FOLDER throw new Exception(e.getMessage());
// WorkspaceFolder theFolder = (WorkspaceFolder) wsItem; }
// size = theFolder.getSize();
// } else if (wsItem instanceof WorkspaceSharedFolder){ //SHARED FOLDER
// WorkspaceSharedFolder theFolder = (WorkspaceSharedFolder) wsItem;
// size = theFolder.getSize();
// }
// logger.info("returning size: " +size);
// return size;
//
// } catch (Exception e) {
// logger.error("get Size By ItemId ", e);
// throw new Exception(e.getMessage());
// }
} }
/* (non-Javadoc) /* (non-Javadoc)

View File

@ -8,7 +8,6 @@ package org.gcube.portlets.widgets.wsexplorer.shared;
* The Enum ItemType. * The Enum ItemType.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jun 18, 2015
*/ */
public enum ItemType { public enum ItemType {
PRIVATE_FOLDER, PRIVATE_FOLDER,
@ -28,6 +27,7 @@ public enum ItemType {
ZIP, ZIP,
RAR, RAR,
HTML, HTML,
XML,
TEXT_PLAIN, TEXT_PLAIN,
DOCUMENT, DOCUMENT,
PRESENTATION, PRESENTATION,