Added method loadItemDetails
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/workspace-task-executor-library@169022 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7535dafa6e
commit
fad77cedec
|
@ -4,12 +4,14 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.ExecutableItem;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.ExecutableTask;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.TaskOperator;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.TaskOutput;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.TaskParameterType;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.WSItemObject;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskComputation;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration;
|
||||
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskExecutionStatus;
|
||||
|
@ -223,6 +225,52 @@ public class WorkspaceDataMinerTaskExecutor implements ExecutableTask<TaskConfig
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load item details.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @return the WS item object
|
||||
*/
|
||||
public WSItemObject loadItemDetails(String itemId){
|
||||
WorkspaceItem item = null;
|
||||
Validate.notNull(itemId, "Input parameter itemId is null");
|
||||
try{
|
||||
item = WsUtil.getItem(usernameOwner, itemId);
|
||||
}catch(Exception e){
|
||||
logger.error("Error during get item with id: "+itemId, e);
|
||||
throw new Error("Error during get item with id: "+itemId+". Eihter it does not exit or you have not permissions to read it");
|
||||
}
|
||||
|
||||
Validate.notNull(item, "The item with id: "+itemId+" is null");
|
||||
WSItemObject wsItem = new WSItemObject();
|
||||
try {
|
||||
wsItem.setItemId(item.getId());
|
||||
wsItem.setItemName(item.getName());
|
||||
wsItem.setOwner(item.getOwner().getPortalLogin());
|
||||
wsItem.setFolder(item.isFolder());
|
||||
if(!item.isFolder()){
|
||||
wsItem.setPublicLink(item.getPublicLink(false));
|
||||
}
|
||||
|
||||
return wsItem;
|
||||
}
|
||||
catch (InternalErrorException e) {
|
||||
//silent
|
||||
logger.warn("Error during filling item properties for item id: "+itemId, e);
|
||||
try {
|
||||
wsItem.setItemId(item.getId());
|
||||
wsItem.setItemName(item.getName());
|
||||
return wsItem;
|
||||
}
|
||||
catch (InternalErrorException e1) {
|
||||
logger.error("Error during filling id and name for item id: "+itemId, e);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.common.workspacetaskexecutor.ConfigurableTask#removeTaskConfig(java.lang.Object)
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,198 @@
|
|||
|
||||
package org.gcube.common.workspacetaskexecutor.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* The Class WSItemObject.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
* Jun 11, 2018
|
||||
*/
|
||||
public class WSItemObject implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3466278154835064930L;
|
||||
private String itemId;
|
||||
private String itemName;
|
||||
|
||||
private String owner;
|
||||
private String publicLink;
|
||||
private boolean isFolder;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new WS item object.
|
||||
*/
|
||||
public WSItemObject() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new WS item object.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @param itemName the item name
|
||||
* @param owner the owner
|
||||
* @param publicLink the public link
|
||||
* @param isFolder the is folder
|
||||
*/
|
||||
public WSItemObject(
|
||||
String itemId, String itemName, String owner, String publicLink,
|
||||
boolean isFolder) {
|
||||
|
||||
this.itemId = itemId;
|
||||
this.itemName = itemName;
|
||||
this.owner = owner;
|
||||
this.publicLink = publicLink;
|
||||
this.isFolder = isFolder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the item id.
|
||||
*
|
||||
* @return the itemId
|
||||
*/
|
||||
public String getItemId() {
|
||||
|
||||
return itemId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the item name.
|
||||
*
|
||||
* @return the itemName
|
||||
*/
|
||||
public String getItemName() {
|
||||
|
||||
return itemName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the owner.
|
||||
*
|
||||
* @return the owner
|
||||
*/
|
||||
public String getOwner() {
|
||||
|
||||
return owner;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the public link.
|
||||
*
|
||||
* @return the publicLink
|
||||
*/
|
||||
public String getPublicLink() {
|
||||
|
||||
return publicLink;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Checks if is folder.
|
||||
*
|
||||
* @return the isFolder
|
||||
*/
|
||||
public boolean isFolder() {
|
||||
|
||||
return isFolder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the item id.
|
||||
*
|
||||
* @param itemId the itemId to set
|
||||
*/
|
||||
public void setItemId(String itemId) {
|
||||
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the item name.
|
||||
*
|
||||
* @param itemName the itemName to set
|
||||
*/
|
||||
public void setItemName(String itemName) {
|
||||
|
||||
this.itemName = itemName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the owner.
|
||||
*
|
||||
* @param owner the owner to set
|
||||
*/
|
||||
public void setOwner(String owner) {
|
||||
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the public link.
|
||||
*
|
||||
* @param publicLink the publicLink to set
|
||||
*/
|
||||
public void setPublicLink(String publicLink) {
|
||||
|
||||
this.publicLink = publicLink;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the folder.
|
||||
*
|
||||
* @param isFolder the isFolder to set
|
||||
*/
|
||||
public void setFolder(boolean isFolder) {
|
||||
|
||||
this.isFolder = isFolder;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("WSItemObject [itemId=");
|
||||
builder.append(itemId);
|
||||
builder.append(", itemName=");
|
||||
builder.append(itemName);
|
||||
builder.append(", owner=");
|
||||
builder.append(owner);
|
||||
builder.append(", publicLink=");
|
||||
builder.append(publicLink);
|
||||
builder.append(", isFolder=");
|
||||
builder.append(isFolder);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue