package org.gcube.informationsystem.collector.stubs.testsuite.xmlcollectionaccess; import java.net.URL; import java.rmi.RemoteException; import org.gcube.common.core.contexts.GCUBERemotePortTypeContext; import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.utils.logging.GCUBEClientLog; import org.gcube.informationsystem.collector.stubs.DocumentNotFoundFaultType; import org.gcube.informationsystem.collector.stubs.GetResourceCriteria; import org.gcube.informationsystem.collector.stubs.XMLCollectionAccessPortType; import org.gcube.informationsystem.collector.stubs.service.XMLCollectionAccessServiceLocator; /** * Tester for GetResource operation of the * gcube/informationsystem/collector/XMLCollectionAccess portType * * @author Manuele Simi (ISTI-CNR) * */ public class GetResourceTester { private static GCUBEClientLog logger = new GCUBEClientLog(GetResourceTester.class); /** * @param args */ public static void main(String[] args) { if (args.length != 4) { logger.fatal("Usage: GetResourceTester "); return; } final String portTypeURI = "http://" + args[0] + ":" + args[1] + "/wsrf/services/gcube/informationsystem/collector/XMLCollectionAccess"; XMLCollectionAccessPortType port = null; try { port = new XMLCollectionAccessServiceLocator().getXMLCollectionAccessPortTypePort(new URL(portTypeURI)); port = GCUBERemotePortTypeContext.getProxy(port, GCUBEScope.getScope(args[2])); } catch (Exception e) { logger.error("",e); } logger.info("Submitting the request..."); String resource; try { GetResourceCriteria criteria = new GetResourceCriteria(); criteria.setID(args[3]); resource = port.getResource(criteria); logger.info("Retrieved resource: \n" + resource); } catch (DocumentNotFoundFaultType e) { logger.error("",e); } catch (RemoteException e) { logger.error("",e); } } }