get size method now returns 0 for folder and not null

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-explorer@169514 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2018-06-28 08:33:54 +00:00
parent 7b9708d2e2
commit a8722fb26a
1 changed files with 28 additions and 41 deletions

View File

@ -327,19 +327,13 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
@Override @Override
public Long getSizeByItemId(String itemId) throws Exception { public Long getSizeByItemId(String itemId) throws Exception {
_log.debug("get Size By ItemId "+ itemId); _log.debug("get Size By ItemId "+ itemId);
try {
Item wsItem = StorageHubServiceUtil.getItem(getThreadLocalRequest(), itemId); Item wsItem = StorageHubServiceUtil.getItem(getThreadLocalRequest(), itemId);
_log.trace("workspace retrieve item name: "+wsItem.getName()); _log.trace("workspace retrieved item name: "+wsItem.getName());
if((wsItem instanceof FolderItem)) //if is a folder no mime if((wsItem instanceof FolderItem)) //if is a folder no Size
return null; return 0L;
AbstractFileItem file = (AbstractFileItem) wsItem; AbstractFileItem file = (AbstractFileItem) wsItem;
return file.getContent().getSize(); return file.getContent().getSize();
} catch (Exception e) {
_log.error("get MimeType By ItemId ", e);
throw new Exception(e.getMessage());
}
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -355,19 +349,12 @@ public class WorkspaceExplorerServiceImpl extends RemoteServiceServlet implement
@Override @Override
public String getMimeType(String itemId) throws Exception { public String getMimeType(String itemId) throws Exception {
_log.debug("get MimeType By ItemId "+ itemId); _log.debug("get MimeType By ItemId "+ itemId);
try {
Item wsItem = StorageHubServiceUtil.getItem(getThreadLocalRequest(), itemId); Item wsItem = StorageHubServiceUtil.getItem(getThreadLocalRequest(), itemId);
_log.trace("workspace retrieve item name: "+wsItem.getName()); _log.trace("workspace retrieved item name: "+wsItem.getName());
if((wsItem instanceof FolderItem)) //if is a folder no mime if((wsItem instanceof FolderItem)) //if is a folder no mime
return null; return null;
AbstractFileItem file = (AbstractFileItem) wsItem; AbstractFileItem file = (AbstractFileItem) wsItem;
return file.getContent().getMimeType(); return file.getContent().getMimeType();
} catch (Exception e) {
_log.error("get MimeType By ItemId ", e);
throw new Exception(e.getMessage());
}
} }