ref 11720: DataMiner - Update to StorageHUB

https://support.d4science.org/issues/11720

Integrated DataMiner CL for simplify integration with new StorageHub

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@167300 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2018-05-03 14:30:34 +00:00
parent 85f986f6ac
commit 35a9aa2ad0
1 changed files with 71 additions and 142 deletions

View File

@ -40,11 +40,9 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
*
*/
@SuppressWarnings("serial")
public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
DataMinerPortletService {
public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements DataMinerPortletService {
private static Logger logger = LoggerFactory
.getLogger(DataMinerManagerServiceImpl.class);
private static Logger logger = LoggerFactory.getLogger(DataMinerManagerServiceImpl.class);
/**
* {@inheritDoc}
@ -64,22 +62,17 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
@Override
public UserInfo hello() throws ServiceException {
try {
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(this.getThreadLocalRequest());
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
logger.debug("hello()");
UserInfo userInfo = new UserInfo(serviceCredentials.getUserName(),
serviceCredentials.getGroupId(),
serviceCredentials.getGroupName(),
serviceCredentials.getScope(),
serviceCredentials.getEmail(),
UserInfo userInfo = new UserInfo(serviceCredentials.getUserName(), serviceCredentials.getGroupId(),
serviceCredentials.getGroupName(), serviceCredentials.getScope(), serviceCredentials.getEmail(),
serviceCredentials.getFullName());
logger.debug("UserInfo: " + userInfo);
return userInfo;
} catch (ServiceException e) {
e.printStackTrace();
logger.error(e.getLocalizedMessage(), e);
throw e;
} catch (Throwable e) {
e.printStackTrace();
logger.error("Hello(): " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
@ -87,40 +80,30 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
}
@Override
public List<OperatorsClassification> getOperatorsClassifications()
throws ServiceException {
public List<OperatorsClassification> getOperatorsClassifications() throws ServiceException {
try {
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(httpRequest);
SClient smClient = SessionUtil.getSClient(httpRequest,
serviceCredentials);
List<OperatorsClassification> list = smClient
.getOperatorsClassifications();
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
SClient smClient = SessionUtil.getSClient(httpRequest, serviceCredentials);
List<OperatorsClassification> list = smClient.getOperatorsClassifications();
return list;
} catch (ServiceException e) {
logger.error(e.getLocalizedMessage());
logger.error(e.getLocalizedMessage(), e);
throw e;
} catch (Throwable e) {
logger.error(
"An error occurred getting the OperatorsClassifications list: "
+ e.getLocalizedMessage(), e);
e.printStackTrace();
logger.error("An error occurred getting the OperatorsClassifications list: " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
@Override
public List<Parameter> getParameters(Operator operator)
throws ServiceException {
public List<Parameter> getParameters(Operator operator) throws ServiceException {
try {
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(httpRequest);
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
SClient smClient = SessionUtil.getSClient(httpRequest,
serviceCredentials);
SClient smClient = SessionUtil.getSClient(httpRequest, serviceCredentials);
List<Parameter> list = smClient.getInputParameters(operator);
return list;
@ -128,23 +111,18 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
logger.error(e.getLocalizedMessage());
throw e;
} catch (Throwable e) {
logger.error("Error retrieving parameters: "
+ e.getLocalizedMessage());
e.printStackTrace();
logger.error("Error retrieving parameters: " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
@Override
public ComputationId startComputation(Operator operator)
throws ServiceException {
public ComputationId startComputation(Operator operator) throws ServiceException {
try {
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(httpRequest);
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
SClient smClient = SessionUtil.getSClient(httpRequest,
serviceCredentials);
SClient smClient = SessionUtil.getSClient(httpRequest, serviceCredentials);
logger.debug("StartComputation(): [ operator=" + operator + "]");
ComputationId computationId = smClient.startComputation(operator);
@ -153,104 +131,83 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
logger.error(e.getLocalizedMessage());
throw e;
} catch (Throwable e) {
logger.error("Error in start computation: "
+ e.getLocalizedMessage());
e.printStackTrace();
logger.error("Error in start computation: " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
@Override
public ComputationId resubmit(ItemDescription itemDescription)
throws ServiceException {
public ComputationId resubmit(ItemDescription itemDescription) throws ServiceException {
try {
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(httpRequest);
Map<String, String> properties = StorageUtil.getProperties(
serviceCredentials.getUserName(), itemDescription.getId());
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
Map<String, String> properties = StorageUtil.getProperties(serviceCredentials.getUserName(),
itemDescription.getId());
logger.debug("Properties: " + properties);
SClient smClient = SessionUtil.getSClient(httpRequest,
serviceCredentials);
SClient smClient = SessionUtil.getSClient(httpRequest, serviceCredentials);
ComputationId computationId = smClient
.resubmitComputation(properties);
ComputationId computationId = smClient.resubmitComputation(properties);
return computationId;
} catch (ServiceException e) {
logger.error(e.getLocalizedMessage());
logger.error(e.getLocalizedMessage(), e);
throw e;
} catch (Throwable e) {
logger.error("Error in resubmit computation: "
+ e.getLocalizedMessage());
e.printStackTrace();
logger.error("Error in resubmit computation: " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage());
}
}
@Override
public ComputationStatus getComputationStatus(ComputationId computationId)
throws ServiceException {
public ComputationStatus getComputationStatus(ComputationId computationId) throws ServiceException {
try {
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(httpRequest);
SClient smClient = SessionUtil.getSClient(httpRequest,
serviceCredentials);
ComputationStatus computationStatus = smClient
.getComputationStatus(computationId);
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
SClient smClient = SessionUtil.getSClient(httpRequest, serviceCredentials);
ComputationStatus computationStatus = smClient.getComputationStatus(computationId);
return computationStatus;
} catch (ServiceException e) {
logger.error(e.getLocalizedMessage());
logger.error(e.getLocalizedMessage(), e);
throw e;
} catch (Throwable e) {
logger.error("Error in getComputationStatus: "
+ e.getLocalizedMessage());
e.printStackTrace();
logger.error("Error in getComputationStatus: " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
@Override
public void deleteItem(ItemDescription itemDescription)
throws ServiceException {
public void deleteItem(ItemDescription itemDescription) throws ServiceException {
try {
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(httpRequest);
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
logger.debug("DeleteItem(): " + itemDescription);
StorageUtil.deleteItem(serviceCredentials.getUserName(),
itemDescription.getId());
StorageUtil.deleteItem(serviceCredentials.getUserName(), itemDescription.getId());
return;
} catch (ServiceException e) {
logger.error(e.getLocalizedMessage());
logger.error(e.getLocalizedMessage(), e);
throw e;
} catch (Throwable e) {
logger.error(e.getLocalizedMessage(), e);
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
@Override
public TableItemSimple retrieveTableInformation(Item item)
throws ServiceException {
public TableItemSimple retrieveTableInformation(Item item) throws ServiceException {
try {
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(httpRequest);
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
logger.debug("retrieveTableInformation(): " + item);
TableReader tableReader = new TableReader(serviceCredentials, item);
TableItemSimple tableItemSimple = tableReader.getTableItemSimple();
return tableItemSimple;
} catch (ServiceException e) {
logger.error(e.getLocalizedMessage());
logger.error(e.getLocalizedMessage(), e);
throw e;
} catch (Throwable e) {
logger.error(e.getLocalizedMessage(), e);
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
@ -259,131 +216,106 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
public DataMinerWorkArea getDataMinerWorkArea() throws ServiceException {
try {
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(httpRequest);
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
logger.debug("getDataMinerWorkArea()");
DataMinerWorkAreaManager dataMinerWorkAreaManager = new DataMinerWorkAreaManager(
serviceCredentials);
DataMinerWorkAreaManager dataMinerWorkAreaManager = new DataMinerWorkAreaManager(serviceCredentials);
return dataMinerWorkAreaManager.getDataMinerWorkArea();
} catch (ServiceException e) {
logger.error(e.getLocalizedMessage());
logger.error(e.getLocalizedMessage(), e);
throw e;
} catch (Throwable e) {
logger.error(e.getLocalizedMessage(), e);
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
@Override
public String getPublicLink(ItemDescription itemDescription)
throws ServiceException {
public String getPublicLink(ItemDescription itemDescription) throws ServiceException {
try {
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(httpRequest);
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
logger.debug("GetPublicLink(): " + itemDescription);
String link = StorageUtil.getPublicLink(
serviceCredentials.getUserName(), itemDescription.getId());
String link = StorageUtil.getPublicLink(serviceCredentials.getUserName(), itemDescription.getId());
return link;
} catch (ServiceException e) {
logger.error(e.getLocalizedMessage());
logger.error(e.getLocalizedMessage(), e);
throw e;
} catch (Throwable e) {
logger.error(e.getLocalizedMessage(), e);
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
@Override
public String cancelComputation(ComputationId computationId)
throws ServiceException {
public String cancelComputation(ComputationId computationId) throws ServiceException {
try {
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(httpRequest);
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
logger.debug("CancelComputation(): " + computationId);
SClient smClient = SessionUtil.getSClient(httpRequest,
serviceCredentials);
SClient smClient = SessionUtil.getSClient(httpRequest, serviceCredentials);
String result = smClient.cancelComputation(computationId);
// SessionUtil.putSClient(session, smClient);
return result;
} catch (ServiceException e) {
logger.error(e.getLocalizedMessage());
logger.error(e.getLocalizedMessage(), e);
throw e;
} catch (Throwable e) {
logger.error(e.getLocalizedMessage(), e);
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
@Override
public OutputData getOutputDataByComputationId(ComputationId computationId)
throws ServiceException {
public OutputData getOutputDataByComputationId(ComputationId computationId) throws ServiceException {
try {
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(httpRequest);
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
Log.debug("getOutputDataByComputationId: " + computationId);
SClient smClient = SessionUtil.getSClient(httpRequest,
serviceCredentials);
OutputData outputData = smClient
.getOutputDataByComputationId(computationId);
SClient smClient = SessionUtil.getSClient(httpRequest, serviceCredentials);
OutputData outputData = smClient.getOutputDataByComputationId(computationId);
Log.debug("OutputData: " + outputData);
return outputData;
} catch (ServiceException e) {
logger.error(e.getLocalizedMessage());
logger.error(e.getLocalizedMessage(), e);
throw e;
} catch (Throwable e) {
logger.error("Error retrieving output by computation id: "
+ e.getLocalizedMessage());
e.printStackTrace();
logger.error("Error retrieving output by computation id: " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
@Override
public ComputationData getComputationData(ItemDescription itemDescription)
throws ServiceException {
public ComputationData getComputationData(ItemDescription itemDescription) throws ServiceException {
try {
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(httpRequest);
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
logger.debug("OutputDataByComputationItemt(): " + itemDescription);
Map<String, String> properties = StorageUtil.getProperties(
serviceCredentials.getUserName(), itemDescription.getId());
Map<String, String> properties = StorageUtil.getProperties(serviceCredentials.getUserName(),
itemDescription.getId());
logger.debug("Properties: " + properties);
SClient smClient = SessionUtil.getSClient(httpRequest,
serviceCredentials);
SClient smClient = SessionUtil.getSClient(httpRequest, serviceCredentials);
ComputationData computationData = smClient
.getComputationDataByComputationProperties(properties);
ComputationData computationData = smClient.getComputationDataByComputationProperties(properties);
return computationData;
} catch (ServiceException e) {
logger.error(e.getLocalizedMessage());
logger.error(e.getLocalizedMessage(), e);
throw e;
} catch (Throwable e) {
logger.error("Error retrieving output by item: "
+ e.getLocalizedMessage());
e.printStackTrace();
logger.error("Error retrieving output by item: " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage());
}
}
@Override
public String cancelComputation(ItemDescription itemDescription)
throws ServiceException {
public String cancelComputation(ItemDescription itemDescription) throws ServiceException {
try {
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(httpRequest);
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
logger.debug("CancelComputation(): " + itemDescription);
String compId = itemDescription.getName();
if (compId == null) {
@ -391,24 +323,21 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
} else {
int lastIndexUnd = compId.lastIndexOf("_");
if (lastIndexUnd == -1) {
throw new ServiceException("Invalid Computation Id: "
+ compId);
throw new ServiceException("Invalid Computation Id: " + compId);
} else {
compId = compId.substring(lastIndexUnd + 1);
}
}
ComputationId computationId = new ComputationId();
computationId.setId(compId);
SClient smClient = SessionUtil.getSClient(httpRequest,
serviceCredentials);
SClient smClient = SessionUtil.getSClient(httpRequest, serviceCredentials);
String result = smClient.cancelComputation(computationId);
return result;
} catch (ServiceException e) {
logger.error(e.getLocalizedMessage());
logger.error(e.getLocalizedMessage(), e);
throw e;
} catch (Throwable e) {
logger.error(e.getLocalizedMessage(), e);
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage(), e);
}
}