added junit test
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/storagehub-client-wrapper@169463 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
eed3901008
commit
c70d574f45
|
@ -597,17 +597,6 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#find(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public WorkspaceItem find(String path)
|
|
||||||
throws InternalErrorException {
|
|
||||||
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#searchByName(java.lang.String, java.lang.String)
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#searchByName(java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -344,16 +344,6 @@ public interface Workspace{
|
||||||
public WorkspaceItem copy(String itemId, String destinationFolderId) throws ItemNotFoundException, WrongDestinationException, InternalErrorException, ItemAlreadyExistException, InsufficientPrivilegesException, WorkspaceFolderNotFoundException;
|
public WorkspaceItem copy(String itemId, String destinationFolderId) throws ItemNotFoundException, WrongDestinationException, InternalErrorException, ItemAlreadyExistException, InsufficientPrivilegesException, WorkspaceFolderNotFoundException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find an item using the specified path.
|
|
||||||
*
|
|
||||||
* @param path the item path.
|
|
||||||
* @return the item if the item is found, <code>null</code> otherwise.
|
|
||||||
* @throws InternalErrorException if an error occurs.
|
|
||||||
*/
|
|
||||||
public WorkspaceItem find(String path) throws InternalErrorException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search by Name.
|
* Search by Name.
|
||||||
*
|
*
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WrongItemTypeException;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.impl.FileItem;
|
import org.gcube.common.storagehubwrapper.shared.tohl.impl.FileItem;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.impl.ImageFile;
|
import org.gcube.common.storagehubwrapper.shared.tohl.impl.ImageFile;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.impl.PDFFile;
|
import org.gcube.common.storagehubwrapper.shared.tohl.impl.PDFFile;
|
||||||
|
@ -32,6 +33,10 @@ public class WorkspaceInstance {
|
||||||
public static String SCOPE = "/gcube";
|
public static String SCOPE = "/gcube";
|
||||||
public static String TOKEN = "0e2c7963-8d3e-4ea6-a56d-ffda530dd0fa-98187548";
|
public static String TOKEN = "0e2c7963-8d3e-4ea6-a56d-ffda530dd0fa-98187548";
|
||||||
|
|
||||||
|
public static String FIND_FILE_NAME = "francesco";
|
||||||
|
|
||||||
|
public static String rootId = null;
|
||||||
|
|
||||||
StorageHubWrapper storageHubWrapper = null;
|
StorageHubWrapper storageHubWrapper = null;
|
||||||
//Workspace workspace = null;
|
//Workspace workspace = null;
|
||||||
|
|
||||||
|
@ -57,6 +62,7 @@ public class WorkspaceInstance {
|
||||||
WorkspaceFolder root;
|
WorkspaceFolder root;
|
||||||
try {
|
try {
|
||||||
root = storageHubWrapper.getWorkspace().getRoot();
|
root = storageHubWrapper.getWorkspace().getRoot();
|
||||||
|
rootId = root.getId();
|
||||||
System.out.println(root);
|
System.out.println(root);
|
||||||
}
|
}
|
||||||
catch (InternalErrorException e) {
|
catch (InternalErrorException e) {
|
||||||
|
@ -89,7 +95,7 @@ public class WorkspaceInstance {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getWorkspaceId() {
|
public void getWorkspaceId() {
|
||||||
System.out.println("Getting the workspaceId");
|
System.out.println("Getting the workspaceId test");
|
||||||
try {
|
try {
|
||||||
Workspace workspace = storageHubWrapper.getWorkspace();
|
Workspace workspace = storageHubWrapper.getWorkspace();
|
||||||
if(workspace!=null){
|
if(workspace!=null){
|
||||||
|
@ -159,4 +165,28 @@ public class WorkspaceInstance {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void findFileName() throws InternalErrorException{
|
||||||
|
System.out.println("Find file name test");
|
||||||
|
getRoot();
|
||||||
|
try {
|
||||||
|
List<WorkspaceItem> foundItems = storageHubWrapper.getWorkspace().find(FIND_FILE_NAME,rootId);
|
||||||
|
|
||||||
|
if(foundItems==null || foundItems.size()==0){
|
||||||
|
System.out.println("No Items found with name: "+FIND_FILE_NAME+ " in the parent: "+rootId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Items found with name: "+FIND_FILE_NAME+ " in the parent: "+rootId +" are:");
|
||||||
|
for (WorkspaceItem workspaceItem : foundItems) {
|
||||||
|
System.out.println(workspaceItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ItemNotFoundException | WrongItemTypeException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue