dataminer-pool-manager/src/main/java/org/gcube/dataanalysis/dataminer/poolmanager/rest/RestPoolManager.java

141 lines
4.5 KiB
Java

package org.gcube.dataanalysis.dataminer.poolmanager.rest;
***REMOVED***
***REMOVED***
import org.gcube.dataanalysis.dataminer.poolmanager.datamodel.Algorithm;
import org.gcube.dataanalysis.dataminer.poolmanager.service.DataminerPoolManager;
import org.gcube.dataanalysis.dataminer.poolmanager.util.AlgorithmBuilder;
***REMOVED***
***REMOVED***
import org.tmatesoft.svn.core.SVNException;
import javax.ws.rs.*;
***REMOVED***
import java.net.MalformedURLException;
***REMOVED***
import java.net.UnknownHostException;
***REMOVED***
import java.util.Set;
@Path("/")
public class RestPoolManager implements PoolManager {
private static final Logger LOGGER = LoggerFactory.getLogger(RestPoolManager.class);
private DataminerPoolManager service = new DataminerPoolManager();
***REMOVED***TODO: for all methods accept also a callback url to send the log.
@GET
@Path("/algorithm/stage")
@Produces("text/plain")
public String stageAlgorithm(String algorithmPackageURL) throws IOException, InterruptedException {
Algorithm algo = AlgorithmBuilder.create(algorithmPackageURL);
return this.service.stageAlgorithm(algo);
***REMOVED***
@GET
@Path("/algorithm/add")
@Produces("text/plain")
public String publishAlgorithm(String algorithmPackageURL, String targetVREToken) throws IOException, InterruptedException {
Algorithm algo = AlgorithmBuilder.create(algorithmPackageURL);
return this.service.publishAlgorithm(algo, targetVREToken);
***REMOVED***
/*
* /scopes/<scope> POST ***REMOVED*** add an algorithm to all dataminers in the scope
* /hosts/<hostname> POST ***REMOVED*** add an algorithm to the given host
*/
@GET
@Path("/log")
@Produces("text/plain")
public String getLogById(@QueryParam("logUrl") String logUrl) throws IOException {
***REMOVED*** TODO Auto-generated method stub
LOGGER.debug("Returning Log =" + logUrl);
return service.getScriptFromURL(service.getURLfromWorkerLog(logUrl));
***REMOVED***
@Override
public Algorithm extractAlgorithm(String url) throws IOException {
***REMOVED*** TODO Auto-generated method stub
return null;
***REMOVED***
public static void main(String[] args) throws IOException, InterruptedException, SVNException {
***REMOVED*** System.out.println(System.getProperty("user.home")+File.separator+"/gcube/dataminer-pool-manager");
***REMOVED*** ProxySelector.setDefault(new
***REMOVED*** PropertiesBasedProxySelector("/home/ngalante/.proxy-settings"));
ScopeProvider.instance.set("/d4science.research-infrastructures.eu/gCubeApps/RPrototypingLab");
***REMOVED***SecurityTokenProvider.instance.set("3a23bfa4-4dfe-44fc-988f-194b91071dd2-843339462");
RestPoolManager a = new RestPoolManager();
***REMOVED***a.stageAlgorithm("http:***REMOVED***data.d4science.org/MnovRjZIdGV5WlB0WXE5NVNaZnRoRVg0SU8xZWpWQlFHbWJQNStIS0N6Yz0");
a.publishAlgorithm("http:***REMOVED***data.d4science.org/MnovRjZIdGV5WlB0WXE5NVNaZnRoRVg0SU8xZWpWQlFHbWJQNStIS0N6Yz0", "3a23bfa4-4dfe-44fc-988f-194b91071dd2-843339462");
***REMOVED*** PoolManager aa = new DataminerPoolManager();
***REMOVED*** System.out.println(aa.getAlgoById("ICHTHYOP_MODEL_ONE_BY_ONE@3141d3aa-5f93-409f-b6f8-9fae0a6c0ee3"));
***REMOVED*** System.out.println(aa.getAlgoFromIs());
***REMOVED***
@Override
public void getLogId(Algorithm algo, String vre) {
***REMOVED*** TODO Auto-generated method stub
***REMOVED***
@Override
public String getScriptFromURL(URL logId) throws IOException {
***REMOVED*** TODO Auto-generated method stub
return null;
***REMOVED***
@Override
public URL getURLfromWorkerLog(String logUrl) throws MalformedURLException, UnknownHostException {
***REMOVED*** TODO Auto-generated method stub
return null;
***REMOVED***
@Override
public void addAlgToIs(Algorithm algo) {
***REMOVED*** TODO Auto-generated method stub
***REMOVED***
@Override
public Set<Algorithm> getAlgoFromIs() {
***REMOVED*** TODO Auto-generated method stub
return null;
***REMOVED***
@Override
public List<String> updateSVN(String file, List<String> ldep) throws SVNException {
***REMOVED*** TODO Auto-generated method stub
return null;
***REMOVED***
@Override
public String addAlgorithmToHost(Algorithm algo, String host, boolean test)
throws IOException, InterruptedException {
***REMOVED*** TODO Auto-generated method stub
return null;
***REMOVED***
@Override
public String addAlgorithmToVRE(Algorithm algo, String vre, boolean test)
throws IOException, InterruptedException {
***REMOVED*** TODO Auto-generated method stub
return null;
***REMOVED***
***REMOVED***