moved to SHUB getItemForFileGrid
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@179905 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
6a1fc7cb54
commit
bf1cd86926
|
@ -10,6 +10,7 @@
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="src" path="src/main/resources"/>
|
<classpathentry kind="src" path="src/main/resources"/>
|
||||||
|
|
|
@ -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.assertIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.release=disabled
|
||||||
org.eclipse.jdt.core.compiler.source=1.7
|
org.eclipse.jdt.core.compiler.source=1.7
|
||||||
|
|
|
@ -133,16 +133,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
/**
|
/**
|
||||||
* Gets the workspace.
|
* Gets the workspace.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @return Workspace
|
* @return Workspace
|
||||||
* @throws InternalErrorException
|
* @throws InternalErrorException Internal error
|
||||||
* Internal error
|
* @throws InternalErrorException Internal error
|
||||||
* @throws HomeNotFoundException
|
* @throws HomeNotFoundException Home not found error
|
||||||
* Home not found error
|
* @throws WorkspaceFolderNotFoundException Folder not found error
|
||||||
* @throws WorkspaceFolderNotFoundException
|
|
||||||
* Folder not found error
|
|
||||||
* @throws org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException
|
|
||||||
* StorageHub Internal error
|
|
||||||
*/
|
*/
|
||||||
protected Workspace getWorkspace()
|
protected Workspace getWorkspace()
|
||||||
throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException,
|
throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException,
|
||||||
|
@ -287,49 +282,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
return sfReader.getSpecialFolderName();
|
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)
|
* (non-Javadoc)
|
||||||
|
@ -2223,70 +2175,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
return listOfVres;
|
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.
|
* 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue