diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileTrashedModel.java b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileTrashedModel.java index 0e1eea3..736860e 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileTrashedModel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileTrashedModel.java @@ -18,6 +18,9 @@ public class FileTrashedModel extends FileGridModel { private Date deleteDate; private InfoContactModel deleteUser; + public static enum STOREINFO {ORIGINALPATH, DELETEDATE, DELETEUSER} + + public FileTrashedModel() { } @@ -87,18 +90,21 @@ public class FileTrashedModel extends FileGridModel { public void setOrginalPath(String orginalPath) { + set(STOREINFO.ORIGINALPATH.toString(), orginalPath); this.orginalPath = orginalPath; } public void setDeleteDate(Date deleteDate) { + set(STOREINFO.DELETEDATE.toString(), deleteDate); this.deleteDate = deleteDate; } public void setDeleteUser(InfoContactModel deleteUser) { + set(STOREINFO.DELETEUSER.toString(), deleteUser); this.deleteUser = deleteUser; } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java index 2d81d40..0106c37 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java @@ -17,7 +17,9 @@ import org.gcube.portlets.user.workspace.client.model.SmartFolderModel; import org.gcube.portlets.user.workspace.client.model.SubTree; import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem; import org.gcube.portlets.user.workspace.shared.SessionExpiredException; +import org.gcube.portlets.user.workspace.shared.TrashOperationResult; import org.gcube.portlets.user.workspace.shared.WorkspaceACL; +import org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation; import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField; import com.google.gwt.user.client.rpc.RemoteService; @@ -217,4 +219,13 @@ public interface GWTWorkspaceService extends RemoteService{ */ List getTrashContent() throws Exception; + /** + * @param trashItemId + * @param operation + * @return + * @throws Exception + */ + TrashOperationResult executeOperationOnTrash(String trashItemId, + WorkspaceTrashOperation operation) throws Exception; + } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java index de16697..da22af0 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java @@ -16,7 +16,9 @@ import org.gcube.portlets.user.workspace.client.model.ScopeModel; import org.gcube.portlets.user.workspace.client.model.SmartFolderModel; import org.gcube.portlets.user.workspace.client.model.SubTree; import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem; +import org.gcube.portlets.user.workspace.shared.TrashOperationResult; import org.gcube.portlets.user.workspace.shared.WorkspaceACL; +import org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation; import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -188,4 +190,8 @@ public interface GWTWorkspaceServiceAsync { void getTrashContent(AsyncCallback> callback); + void executeOperationOnTrash(String trashItemId, + WorkspaceTrashOperation operation, + AsyncCallback callback); + } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/util/GetPermissionIconByACL.java b/src/main/java/org/gcube/portlets/user/workspace/client/util/GetPermissionIconByACL.java new file mode 100644 index 0000000..aca2022 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/workspace/client/util/GetPermissionIconByACL.java @@ -0,0 +1,37 @@ +/** + * + */ +package org.gcube.portlets.user.workspace.client.util; + +import org.gcube.portlets.user.workspace.client.resources.Resources; +import org.gcube.portlets.user.workspace.shared.WorkspaceACL; + +import com.google.gwt.user.client.ui.AbstractImagePrototype; + +/** + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * @Feb 17, 2014 + * + */ +public class GetPermissionIconByACL { + + public static AbstractImagePrototype getImage(WorkspaceACL acl) { + + if(acl==null || acl.getId()==null) + return null; + + String id = acl.getId(); + + if (id.compareTo("ADMINISTRATOR") == 0) { + } else if (id.compareTo("READ_ONLY") == 0) { + return Resources.getIconReadOnly(); + } else if (id.compareTo("WRITE_OWNER") == 0) { + return Resources.getIconWriteOwn(); + } else if (id.compareTo("WRITE_ALL") == 0) { + return Resources.getIconWriteAll(); + } + + return null; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelPermission.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelPermission.java index 69f9bc9..88b9750 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelPermission.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelPermission.java @@ -56,36 +56,4 @@ public class PanelPermission extends LayoutContainer { return null; } - - /* - public List getCheckedGroupList() { - - List listDS = new ArrayList(); - - List values = new ArrayList(); - - if (radioGroup.getValue()!=null){ - Radio radio = radioGroup.getValue(); - values.add((Radio) radio); - } - else { - List> listChecks = radioGroup.getAll(); - for (Field field : listChecks) { - values.add((Radio) field); - } - } - - for (Radio radio : values) { - if (radio.isEnabled()){ - WorkspaceACL acl = (WorkspaceACL) radio.getData(WORKSPACEACL); - listDS.add(acl); - } - } - - if (listDS.size() == 0) - return null; - - return listDS; - } - */ } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelTogglePermission.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelTogglePermission.java index 3daca05..048e390 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelTogglePermission.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/sharing/PanelTogglePermission.java @@ -3,6 +3,7 @@ package org.gcube.portlets.user.workspace.client.view.sharing; import java.util.List; import org.gcube.portlets.user.workspace.client.resources.Resources; +import org.gcube.portlets.user.workspace.client.util.GetPermissionIconByACL; import org.gcube.portlets.user.workspace.shared.WorkspaceACL; import org.gcube.portlets.user.workspace.shared.WorkspaceACL.USER_TYPE; @@ -16,6 +17,7 @@ import com.extjs.gxt.ui.client.widget.LayoutContainer; import com.extjs.gxt.ui.client.widget.button.ToggleButton; import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig; import com.google.gwt.core.shared.GWT; +import com.google.gwt.user.client.ui.AbstractImagePrototype; public class PanelTogglePermission extends LayoutContainer { @@ -71,24 +73,29 @@ public class PanelTogglePermission extends LayoutContainer { } }); bToggle.setToolTip(new ToolTipConfig(acl.getDescription())); - setIcon(bToggle, acl.getId()); + AbstractImagePrototype img = GetPermissionIconByACL.getImage(acl); + + if(img!=null) + bToggle.setIcon(img); + +// setIcon(bToggle, acl.getId()); return bToggle; } - private void setIcon(ToggleButton bToggle, String id){ - - if(id.compareTo("ADMINISTRATOR")==0){ - - }else if(id.compareTo("READ_ONLY")==0){ - bToggle.setIcon(Resources.getIconReadOnly()); - }else if(id.compareTo("WRITE_OWNER")==0){ - bToggle.setIcon(Resources.getIconWriteOwn()); - }else if(id.compareTo("WRITE_ALL")==0){ - bToggle.setIcon(Resources.getIconWriteAll()); - } - - } +// private void setIcon(ToggleButton bToggle, String id){ +// +// if(id.compareTo("ADMINISTRATOR")==0){ +// +// }else if(id.compareTo("READ_ONLY")==0){ +// bToggle.setIcon(Resources.getIconReadOnly()); +// }else if(id.compareTo("WRITE_OWNER")==0){ +// bToggle.setIcon(Resources.getIconWriteOwn()); +// }else if(id.compareTo("WRITE_ALL")==0){ +// bToggle.setIcon(Resources.getIconWriteAll()); +// } +// +// } public WorkspaceACL getSelectedACL() { GWT.log("Selected ACL is: "+selectedAcl); diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/TrashInfoContainer.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/TrashInfoContainer.java deleted file mode 100644 index c485685..0000000 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/TrashInfoContainer.java +++ /dev/null @@ -1,373 +0,0 @@ -package org.gcube.portlets.user.workspace.client.view.trash; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.gcube.portlets.user.workspace.client.ConstantsExplorer; -import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum; -import org.gcube.portlets.user.workspace.client.model.FileModel; -import org.gcube.portlets.user.workspace.client.resources.Resources; - -import com.extjs.gxt.ui.client.Style.ButtonScale; -import com.extjs.gxt.ui.client.Style.HorizontalAlignment; -import com.extjs.gxt.ui.client.data.BaseModelData; -import com.extjs.gxt.ui.client.dnd.GridDropTarget; -import com.extjs.gxt.ui.client.event.ButtonEvent; -import com.extjs.gxt.ui.client.event.DNDEvent; -import com.extjs.gxt.ui.client.event.SelectionListener; -import com.extjs.gxt.ui.client.store.GroupingStore; -import com.extjs.gxt.ui.client.store.ListStore; -import com.extjs.gxt.ui.client.store.Record; -import com.extjs.gxt.ui.client.widget.ContentPanel; -import com.extjs.gxt.ui.client.widget.LayoutContainer; -import com.extjs.gxt.ui.client.widget.button.ToggleButton; -import com.extjs.gxt.ui.client.widget.grid.ColumnConfig; -import com.extjs.gxt.ui.client.widget.grid.ColumnData; -import com.extjs.gxt.ui.client.widget.grid.ColumnModel; -import com.extjs.gxt.ui.client.widget.grid.Grid; -import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer; -import com.extjs.gxt.ui.client.widget.grid.GroupingView; -import com.extjs.gxt.ui.client.widget.grid.filters.GridFilters; -import com.extjs.gxt.ui.client.widget.grid.filters.StringFilter; -import com.extjs.gxt.ui.client.widget.layout.FitLayout; -import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; -import com.google.gwt.i18n.client.NumberFormat; - -public class TrashInfoContainer extends LayoutContainer { - - /** - * - */ - - - private Grid grid; - private ContentPanel cp; - private GroupingStore store = new GroupingStore(); - private boolean groupingEnabled; - private ListStore typeStoreOperation = new ListStore(); - private NumberFormat number = ConstantsExplorer.numberFormatterKB; - private GridDropTarget gridDropTarget; - - public TrashInfoContainer() { - initContentPanel(); - initGrid(); - createToolBar(); - initDropTarget(); - } - - /** - * - */ - private void initDropTarget() { - this.gridDropTarget = new GridDropTarget(grid){ - /* (non-Javadoc) - * @see com.extjs.gxt.ui.client.dnd.GridDropTarget#onDragDrop(com.extjs.gxt.ui.client.event.DNDEvent) - */ - - @Override - protected void onDragDrop(DNDEvent e) { - // TODO Auto-generated method stub - - List listFileModel = getDragSource(e); - - for (FileModel fileModel : listFileModel) { - fileModel.setIcon(); - } - - System.out.println("** Trash Event move handleInsertDrop is completed"); - - super.onDragDrop(e); - } - - private List getDragSource(DNDEvent event){ - - List listDraggedFile = new ArrayList(); - - if(event.getData() != null){ - - List listItemsSource = event.getData(); - - System.out.println("Trash - Number of move " + listItemsSource.size()); - - FileModel sourceFileModel = null; //for print - - - for(int i=0; i() { - - @Override - public void componentSelected(ButtonEvent ce) { - - if (buttonGrouping.isPressed()) - enableGrouping(); - else - disableGrouping(); - } - }); - -// bar.add(buttonGrouping); - cp.setTopComponent(bar); - - } - - public void initGrid() { - -// store.groupBy(ConstantsExplorer.SHORTCUTCATEGORY); -// groupingEnabled = true; - - ColumnConfig icon = new ColumnConfig(ConstantsExplorer.ICON, "", 25); - ColumnConfig name = createSortableColumnConfig(ConstantsExplorer.NAME, ConstantsExplorer.NAME, 300); - ColumnConfig type = createSortableColumnConfig(ConstantsExplorer.TYPE, ConstantsExplorer.TYPE, 50); -// ColumnConfig category = createSortableColumnConfig(ConstantsExplorer.SHORTCUTCATEGORY, ConstantsExplorer.SHORTCUTCATEGORY, 100); - ColumnConfig ownerFullName = createSortableColumnConfig(ConstantsExplorer.OWNERFULLNAME, ConstantsExplorer.OWNER, 100); - - - ColumnModel cm = new ColumnModel(Arrays.asList(icon, name, type, ownerFullName)); - - final ColumnModel columnModel = cm; - - grid = new Grid(this.store, cm); - - GroupingView view = new GroupingView(); - view.setShowGroupedColumn(true); - this.grid.setView(view); - -// view.setGroupRenderer(new GridGroupRenderer() { -// public String render(GroupColumnData data) { -// String f = columnModel.getColumnById(data.field).getHeader(); -// String l = data.models.size() == 1 ? "Item" : "Items"; -// return f + ": " + data.group + " (" + data.models.size() + " " -// + l + ")"; -// } -// }); - - - GridCellRenderer folderRender = new GridCellRenderer() { - @Override - public String render(FileModel model, String property, ColumnData config, int rowIndex, int colIndex, ListStore store, Grid grid) { - String val = model.get(property); - String color = "black"; - - if(val != null && val.equals(GXTFolderItemTypeEnum.FOLDER.toString())){ -// color = "#EEC900"; - return "" + val + ""; - }else{ - if(val==null) - val = ""; - return "" + val + ""; - } - } - }; - - type.setRenderer(folderRender); - - GridFilters filters = new GridFilters(); - filters.setLocal(true); - - - StringFilter nameFilter = new StringFilter(ConstantsExplorer.NAME); - StringFilter authorFilter = new StringFilter(ConstantsExplorer.TYPE); - - filters.addFilter(nameFilter); - filters.addFilter(authorFilter); - - grid.addPlugin(filters); - - grid.setBorders(true); - grid.setStripeRows(true); - grid.getView().setAutoFill(true); - grid.setColumnLines(true); - grid.setColumnReordering(true); - grid.setStyleAttribute("borderTop", "none"); - cp.add(grid); - - - } - - public void setPanelSize(int width, int height) { - - if (width > 0 && height > 0 && grid != null) { - cp.setSize(width, height); - // grid.setSize(width, height); - } - } - - public TrashInfoContainer(List trashFiles) { - - initContentPanel(); - initGrid(); - updateTrash(trashFiles); - } - - public void disableGrouping() { - GroupingStore groupingStore = null; - if (store instanceof GroupingStore) { - groupingStore = (GroupingStore) store; - if (groupingStore != null) { - groupingStore.clearGrouping(); - } - this.groupingEnabled = false; - } - } - - public void enableGrouping() { - GroupingStore groupingStore = null; - if (store instanceof GroupingStore) { - groupingStore = (GroupingStore) store; - if (groupingStore != null) { - groupingStore.groupBy(ConstantsExplorer.SHORTCUTCATEGORY); - } - this.groupingEnabled = true; - } - } - - public void updateTrash(List trashFiles) { - - store.removeAll(); - typeStoreOperation.removeAll(); - store.add(trashFiles); - } - - private void updateStore(ListStore store) { - - resetStore(); - this.grid.getStore().add(store.getModels()); - } - - public void resetStore() { - this.grid.getStore().removeAll(); - } - - public ColumnConfig createSortableColumnConfig(String id, String name, - int width) { - ColumnConfig columnConfig = new ColumnConfig(id, name, width); - columnConfig.setSortable(true); - - return columnConfig; - } - - public void setHeaderTitle(String title) { - cp.setHeading(title); - // cp.layout(); - } - - public boolean isGroupingEnabled() { - return groupingEnabled; - } - - public void setGroupingEnabled(boolean groupingEnabled) { - this.groupingEnabled = groupingEnabled; - } - - - /** - * - * @param identifier - * @return - */ - public FileModel getFileModelByIdentifier(String identifier){ - - return store.findModel(ConstantsExplorer.IDENTIFIER, identifier); - - } - - /** - * - * @param identifier (MANDATORY) - * @return - */ - public boolean deleteItem(String identifier) { - - FileModel fileTarget = getFileModelByIdentifier(identifier); - - - if(fileTarget!=null){ - return deleteItem(fileTarget); - } - else - System.out.println("Delete Error: file target with " + identifier + " identifier not exist in store" ); - - return false; - } - - /** - * - * @param fileTarget (MANDATORY) - * @return - */ - private boolean deleteItem(FileModel fileTarget) { - - Record record = store.getRecord(fileTarget); - - if (record != null) { - - FileModel item = (FileModel) record.getModel(); - store.remove(item); - - return true; - } else - System.out.println("Record Error: file target with " - + fileTarget.getIdentifier() - + " identifier not exist in store"); - - return false; - - } - -} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/WindowTrash.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/WindowTrash.java deleted file mode 100644 index b56a250..0000000 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/trash/WindowTrash.java +++ /dev/null @@ -1,119 +0,0 @@ -package org.gcube.portlets.user.workspace.client.view.trash; - -import java.util.List; - -import org.gcube.portlets.user.workspace.client.ConstantsExplorer; -import org.gcube.portlets.user.workspace.client.model.FileModel; -import org.gcube.portlets.user.workspace.client.resources.Resources; - -import com.extjs.gxt.ui.client.widget.Window; -import com.extjs.gxt.ui.client.widget.layout.FitLayout; - -/** - * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * @May 23, 2013 - * - * Singleton - */ -public class WindowTrash extends Window { - - private List trashedFiles; - private TrashInfoContainer trashContainers; - private static WindowTrash INSTANCE = null; - - - private WindowTrash() { - initAccounting(); - setIcon(Resources.getTrash()); //TODO - setHeading("Trash"); -// addResizeListner(); - } - - /** - * - * @return - */ - public static synchronized WindowTrash getInstance(){ - if(INSTANCE==null) - INSTANCE = new WindowTrash(); - - return INSTANCE; - } - -// public void addResizeListner(){ -// -// this.addListener(Events.Resize, new Listener() { -// -// @Override -// public void handleEvent(WindowEvent we ) -// { -// -// if(trashContainers!=null){ -//// System.out.println("Size in event: " + we.getWidth() + "x" + we.getHeight() ); -//// accountingsContainers.setPanelSize(we.getWidth()-14, we.getHeight()-30); -// } -// } -// -// }); -// } - -// public WindowTrash(List trashFiles) { -// updateTrashContainer(trashFiles); -// } - - private void initAccounting() { -// setModal(true); - setLayout(new FitLayout()); - setSize(700, 350); - setResizable(true); - setMaximizable(true); -// setCollapsible(true); - this.trashContainers = new TrashInfoContainer(); - add(trashContainers); - } - - public void setWindowTitle(String title) { - this.setHeading(title); - - } - - - /** - * - * @param fileModelId - * @return - */ - public boolean deleteFileFromTrash(String fileModelId){ - return this.trashContainers.deleteItem(fileModelId); - } - - - public void updateTrashContainer(List trashFiles) { - - this.trashContainers.resetStore(); - this.trashedFiles = trashFiles; - this.trashContainers.updateTrash(trashFiles); - } - - public List getTrashedFiles() { - return trashedFiles; - } - - public void maskAccountingInfo(boolean bool){ - -// if(accountingsContainers!=null){ -// -// if(bool) -// accountingsContainers.mask(ConstantsExplorer.LOADING, ConstantsExplorer.LOADINGSTYLE); -// else -// accountingsContainers.unmask(); -// } - - if(bool) - this.mask(ConstantsExplorer.LOADING, ConstantsExplorer.LOADINGSTYLE); - else - this.unmask(); - } - -} diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/DownloadServlet.java b/src/main/java/org/gcube/portlets/user/workspace/server/DownloadServlet.java index 7946eff..ce5847e 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/DownloadServlet.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/DownloadServlet.java @@ -531,6 +531,7 @@ public class DownloadServlet extends HttpServlet{ try{ ExternalResourceLink externalResourceLink = (ExternalResourceLink) folderItem; OutputStream out = resp.getOutputStream(); + try { String mimeType = externalResourceLink.getMimeType(); @@ -538,7 +539,7 @@ public class DownloadServlet extends HttpServlet{ logger.trace("mimeType is null... recover from MimeTypeUtil by BufferedInputStream"); BufferedInputStream bufferedStream = new BufferedInputStream(externalResourceLink.getData(), (int) externalResourceLink.getLength()); - mimeType = MimeTypeUtil.getMimeType(bufferedStream); + mimeType = MimeTypeUtil.getMimeType(externalResourceLink.getName(), bufferedStream); } logger.trace("setContentType with mimeType " + mimeType); diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java index 4b381a3..0de71fb 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java @@ -2158,7 +2158,7 @@ public class GWTWorkspaceBuilder { //TODO SETTING IS FOLDER // fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getCreationTime()), parentFileModel, folderItem.getLength(), false, false); fileTrashModel = new FileTrashedModel(trashedItem.getId(), trashedItem.getName(), toDate(trashedItem.getLastModificationTime()), null, trashedItem.getLength(), false, trashedItem.isShared()); - fileTrashModel.setOrginalPath(trashedItem.getOriginalPath()); + fileTrashModel.setOrginalPath(trashedItem.getOriginalParentId()); fileTrashModel.setDeleteDate(fileTrashModel.getDeleteDate()); InfoContactModel deleteUser = buildGxtInfoContactFromPortalLogin(trashedItem.getDeleteUser()); fileTrashModel.setDeleteUser(deleteUser); @@ -2178,35 +2178,6 @@ public class GWTWorkspaceBuilder { } public FileTrashedModel buildGXTTrashModelItemById(String itemId, WorkspaceTrashFolder trash) throws InternalErrorException{ - -// FileTrashedModel fileTrashModel = null; -// -// WorkspaceTrashItem trashedItem = trash.findItem(itemId); -// -// switch (trashedItem.getType()) { -// -// case TRASH_ITEM: -// -// //TODO SETTING IS FOLDER -// // fileGridModel = new FileGridModel(item.getId(), item.getName(), toDate(item.getCreationTime()), parentFileModel, folderItem.getLength(), false, false); -// fileTrashModel = new FileTrashedModel(trashedItem.getId(), trashedItem.getName(), toDate(trashedItem.getLastModificationTime()), null, trashedItem.getLength(), false, trashedItem.isShared()); -// fileTrashModel.setOrginalPath(trashedItem.getOriginalPath()); -// fileTrashModel.setDeleteDate(fileTrashModel.getDeleteDate()); -// InfoContactModel deleteUser = buildGxtInfoContactFromPortalLogin(trashedItem.getDeleteUser()); -// fileTrashModel.setDeleteUser(deleteUser); -// FolderItem folderItem = (FolderItem) trashedItem; -// fileTrashModel = (FileTrashedModel) setFolderItemType(fileTrashModel, folderItem); -// break; -// -// -// default: -// logger.error("gxt conversion return null for trash item "+trashedItem.getName()); -// break; -// -// } -// -// return fileTrashModel; - return null; } diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java index 259b757..67918c1 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java @@ -2590,10 +2590,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT if(wsItem.isShared() && (wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER))){ WorkspaceSharedFolder ite = (WorkspaceSharedFolder) workspace.getItemByPath(wsItem.getPath()); GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder(); - - //TODO - ite.getACL(); - return builder.getWorkspaceACLFromACLs(Arrays.asList(ACLType.values())); + return builder.getWorkspaceACLFromACLs(Arrays.asList(ite.getACLUser())); }else throw new Exception("Source item is not shared or shared folder"); @@ -2637,8 +2634,8 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * @return * @throws Exception */ - - public TrashOperationResult executeOperationOnTrashItem(String trashItemId, WorkspaceTrashOperation operation) throws Exception{ + @Override + public TrashOperationResult executeOperationOnTrash(String trashItemId, WorkspaceTrashOperation operation) throws Exception{ workspaceLogger.trace("Get TrashContent: "); Workspace workspace; diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/LocalUploadServlet.java b/src/main/java/org/gcube/portlets/user/workspace/server/LocalUploadServlet.java index 63f8feb..9907323 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/LocalUploadServlet.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/LocalUploadServlet.java @@ -220,7 +220,7 @@ public class LocalUploadServlet extends HttpServlet { else itemName = file.getName(); - String contentType = MimeTypeUtil.getMimeType(new BufferedInputStream(fileUploadIS)); + String contentType = MimeTypeUtil.getMimeType(itemName, new BufferedInputStream(fileUploadIS)); logger.trace("Content type (mime type): "+contentType + " unique name: "+itemName); // System.out.println("Content type: "+contentType + " unique name: "+itemName); diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/UploadServlet.java b/src/main/java/org/gcube/portlets/user/workspace/server/UploadServlet.java index aa1fefd..862e706 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/UploadServlet.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/UploadServlet.java @@ -199,7 +199,7 @@ public class UploadServlet extends HttpServlet { else itemName = uploadItem.getName(); - String contentType = MimeTypeUtil.getMimeType(new BufferedInputStream(uploadItem.getInputStream())); + String contentType = MimeTypeUtil.getMimeType(itemName, new BufferedInputStream(uploadItem.getInputStream())); logger.trace("Content type (mime type): "+contentType + " unique name: "+itemName); // System.out.println("Content type: "+contentType + " unique name: "+itemName); diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java b/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java index bec085b..f03106a 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java @@ -74,10 +74,10 @@ public class WsUtil { /*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING * COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/ - user=TEST_USER; +// user=TEST_USER; //UNCOMMENT THIS IN DEVELOP ENVIROMENT -// user = "francesco.mangiacrapa"; + user = "francesco.mangiacrapa"; logger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:"); logger.warn("session id: "+sessionID); @@ -105,10 +105,10 @@ public class WsUtil { withoutPortal = true; //COMMENT THIS IN PRODUCTION ENVIROMENT -// }else if(user.compareToIgnoreCase("francesco.mangiacrapa")==0){ -// -// withoutPortal = true; -// //END UNCOMMENT + }else if(user.compareToIgnoreCase("francesco.mangiacrapa")==0){ + + withoutPortal = true; + //END UNCOMMENT }else{ withoutPortal = false; diff --git a/src/test/java/org/gcube/portlets/user/workspace/UploadServletTest.java b/src/test/java/org/gcube/portlets/user/workspace/UploadServletTest.java index fb980ba..dd33ecb 100644 --- a/src/test/java/org/gcube/portlets/user/workspace/UploadServletTest.java +++ b/src/test/java/org/gcube/portlets/user/workspace/UploadServletTest.java @@ -65,7 +65,7 @@ public class UploadServletTest { // ExternalImage file = (ExternalImage) root.find(name); // UPLOAD FILE - String contentType = MimeTypeUtil.getMimeType(new BufferedInputStream( + String contentType = MimeTypeUtil.getMimeType(fileName, new BufferedInputStream( new FileInputStream(new File(fullPath)))); String itemName = WorkspaceUtil.getUniqueName(fileName, root);