diff --git a/.classpath b/.classpath
index dd89720..58453db 100644
--- a/.classpath
+++ b/.classpath
@@ -10,6 +10,7 @@
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index b257af7..a5c7673 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -5,4 +5,5 @@ org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.7
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 74ca8ba..07a8151 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
@@ -133,16 +133,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
/**
* Gets the workspace.
*
- *
* @return Workspace
- * @throws InternalErrorException
- * Internal error
- * @throws HomeNotFoundException
- * Home not found error
- * @throws WorkspaceFolderNotFoundException
- * Folder not found error
- * @throws org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException
- * StorageHub Internal error
+ * @throws InternalErrorException Internal error
+ * @throws InternalErrorException Internal error
+ * @throws HomeNotFoundException Home not found error
+ * @throws WorkspaceFolderNotFoundException Folder not found error
*/
protected Workspace getWorkspace()
throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException,
@@ -287,49 +282,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
return sfReader.getSpecialFolderName();
}
- /*
- * (non-Javadoc)
- *
- * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#
- * getItemForFileGrid(java.lang.String)
- */
- /**
- * Gets the item for file grid.
- *
- * @param itemId
- * the item id
- * @return the item for file grid
- * @throws Exception
- * the exception
- */
- @Override
- public FileGridModel getItemForFileGrid(String itemId) throws Exception {
-
- try {
-
- if (itemId == null)
- throw new Exception(IDENTIFIER_IS_NULL);
-
- Workspace workspace = getWorkspace();
- workspaceLogger.trace("get child for Grid by id: " + itemId);
- WorkspaceItem wsItem = workspace.getItem(itemId);
- GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
- Long startTime = System.currentTimeMillis();
- Long endTime = System.currentTimeMillis() - startTime;
- String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
- workspaceLogger.debug("get child for Grid by id returning element in " + time);
- // BUILD PARENT
- WorkspaceFolder folder = wsItem.getParent(); // get parent
- FileGridModel wsFolder = builder.buildGXTFileGridModelItem(folder, null);
- // BUILD ITEM
- return builder.buildGXTFileGridModelItem(wsItem, wsFolder);
-
- } catch (Exception e) {
- workspaceLogger.error("Error in server during item retrieving, getItemForFileGrid", e);
- String error = ConstantsExplorer.SERVER_ERROR + RETRIEVING_ITEM_EITHER_ITEM_DOESN_T_EXIST;
- throw new Exception(error);
- }
- }
/*
* (non-Javadoc)
@@ -2223,70 +2175,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
return listOfVres;
}
- /**
- * Check item locked.
- *
- * @param itemId
- * the item id
- * @return true, if successful
- * @throws WorkspaceFolderLocked
- * the workspace folder locked
- * @throws Exception
- * the exception
- */
- private boolean checkItemLocked(String itemId) throws WorkspaceFolderLocked, Exception {
-
- if (itemId == null || itemId.isEmpty())
- throw new Exception(IDENTIFIER_IS_NULL);
-
- Workspace ws;
- WorkspaceItem workItem = null;
-
- try {
-
- ws = getWorkspace();
- workItem = ws.getItem(itemId);
-
- // IF THE ITEM IS A FOLDER, CHECKING IT
- if (workItem.isFolder())
- WorkspaceThreddsSynchronize.getInstance().checkItemSynched(workItem.getId());
- else {
- // IF THE ITEM IS A FILE, CHECKING ITS PARENT
- WorkspaceFolder parent = workItem.getParent();
- if (parent != null) {
- WorkspaceThreddsSynchronize.getInstance().checkItemSynched(parent.getId());
- }
- }
- // in this case the folder is synched but not locked
- return false;
-
- } catch (ItemNotSynched e1) {
-
- // in this case the folder is not synched;
- return false;
-
- } catch (WorkspaceFolderLocked e2) {
- // in this case the folder synching is on-going and the folder is
- // locked;
-
- String msg = "The folder";
- msg += workItem != null ? ": " + workItem.getName() : "";
- msg += " is locked by a sync. You can not change its content";
- workspaceLogger.warn(msg, e2);
- throw new WorkspaceFolderLocked(itemId, msg);
-
- } catch (InternalErrorException | ItemNotFoundException | HomeNotFoundException
- | WorkspaceFolderNotFoundException e) {
- workspaceLogger.warn(e);
- throw new Exception("Sorry an error occurred during checking is folder locked, Refresh and try again");
-
- } catch (Exception e) {
- workspaceLogger
- .warn("Was there an Exception HL side? Ignoring it.. returning false (that means item not locked)");
- return false;
- }
- }
-
/**
* Checks if is item under sync.
*
@@ -3771,5 +3659,125 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
}
}
+ /**
+ * Check item locked.
+ *
+ * @param itemId the item id
+ * @return true, if successful
+ * @throws WorkspaceFolderLocked the workspace folder locked
+ * @throws Exception the exception
+ */
+ private boolean checkItemLocked(String itemId) throws WorkspaceFolderLocked, Exception {
+
+ if (itemId == null || itemId.isEmpty())
+ throw new Exception(IDENTIFIER_IS_NULL);
+
+ org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = null;
+ org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = null;
+ try {
+
+ workspace = getWorkspaceFromStorageHub();
+ wsItem = workspace.getItem(itemId);
+
+ // IF THE ITEM IS A FOLDER, CHECKING IT
+ if (wsItem.isFolder())
+ WorkspaceThreddsSynchronize.getInstance().checkItemSynched(wsItem.getId());
+ else {
+ // IF THE ITEM IS A FILE, CHECKING ITS PARENT
+ String parentId = wsItem.getParentId();
+ if(parentId==null) {
+ workspaceLogger.warn("I'm not able to check the lock because the parent id is null");
+ }else {
+ WorkspaceThreddsSynchronize.getInstance().checkItemSynched(parentId);
+ }
+ }
+ // in this case the folder is synched but not locked
+ return false;
+
+ } catch (ItemNotSynched e1) {
+
+ // in this case the folder is not synched;
+ return false;
+
+ } catch (WorkspaceFolderLocked e2) {
+ // in this case the folder synching is on-going and the folder is
+ // locked;
+
+ String msg = "The folder";
+ msg += wsItem != null ? ": " + wsItem.getName() : "";
+ msg += " is locked by a sync. You can not change its content";
+ workspaceLogger.warn(msg, e2);
+ throw new WorkspaceFolderLocked(itemId, msg);
+
+ } catch (InternalErrorException | ItemNotFoundException | HomeNotFoundException
+ | WorkspaceFolderNotFoundException e) {
+ workspaceLogger.warn(e);
+ throw new Exception("Sorry an error occurred during checking is folder locked, Refresh and try again");
+
+ } catch (Exception e) {
+ workspaceLogger
+ .warn("Was there an Exception HL side? Ignoring it.. returning false (that means item not locked)");
+ return false;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#
+ * getItemForFileGrid(java.lang.String)
+ */
+ /**
+ * Gets the item for file grid.
+ *
+ * @param itemId
+ * the item id
+ * @return the item for file grid
+ * @throws Exception
+ * the exception
+ */
+ @Override
+ public FileGridModel getItemForFileGrid(String itemId) throws Exception {
+
+ try {
+
+ //TOOD MOVE TO SHUB
+
+ if (itemId == null)
+ throw new Exception(IDENTIFIER_IS_NULL);
+
+ org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace = null;
+ org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wsItem = null;
+ workspace = getWorkspaceFromStorageHub();
+ wsItem = workspace.getItem(itemId);
+
+ StorageHubToWorkpaceConverter converter = getStorageHubToWorkpaceConverter();
+ FileModel parentModel = null;
+ if(wsItem.getParentId()!=null) {
+ org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem parent = workspace.getItem(wsItem.getParentId());
+ parentModel = converter.toTreeFileModel(parent, null, parent.isShared());
+ }
+
+ return converter.toGridFileModel(wsItem, parentModel);
+
+ /*GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
+ Long startTime = System.currentTimeMillis();
+ Long endTime = System.currentTimeMillis() - startTime;
+ String time = String.format("%d msc %d sec", endTime, TimeUnit.MILLISECONDS.toSeconds(endTime));
+ workspaceLogger.debug("get child for Grid by id returning element in " + time);
+ // BUILD PARENT
+ WorkspaceFolder folder = wsItem.getParent(); // get parent
+ FileGridModel wsFolder = builder.buildGXTFileGridModelItem(folder, null);
+ // BUILD ITEM
+ return builder.buildGXTFileGridModelItem(wsItem, wsFolder);*/
+
+ } catch (Exception e) {
+ workspaceLogger.error("Error in server during item retrieving, getItemForFileGrid", e);
+ String error = ConstantsExplorer.SERVER_ERROR + RETRIEVING_ITEM_EITHER_ITEM_DOESN_T_EXIST;
+ throw new Exception(error);
+ }
+ }
+
+
}