/** * */ package org.gcube.informationsystem.collector.testsuite; import java.net.URL; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import org.gcube.informationsystem.collector.stubs.DeleteProfileParams; import org.gcube.informationsystem.collector.stubs.XMLCollectionAccessPortType; import org.gcube.informationsystem.collector.stubs.holders.VoidTypeHolder; import org.gcube.informationsystem.collector.stubs.service.XMLCollectionAccessServiceAddressingLocator; /** * * DIS-IC client testsuite class *
    *
  1. to compile: javac -classpath MYPATH/org_diligentproject_informationservice_disic_stubs.jar:$CLASSPATH testsuite/Client.java * *
  2. to run (make sure that the DIS-IC stub classes are in your CLASSPATH): *
* * * @author manuele simi * * @version 1.0 July 2006 * * @link http://www.diligentproject.com */ public class Client { public Client() { } /** * * @param file the file that contains the query * @return a String with the file content * @throws IOException */ protected static String readFile(String file) throws IOException { BufferedReader f = new BufferedReader(new FileReader(file)); String line; StringBuffer xml = new StringBuffer(); while ((line = f.readLine()) != null) xml.append(line + " "); f.close(); return xml.toString(); } /** * @param args * 0 - the URI of an active DIS-IC service 1 - the file that * contains the query to execute */ public static void main(String[] args) { XMLCollectionAccessServiceAddressingLocator locator = new XMLCollectionAccessServiceAddressingLocator(); String uri = args[1]; try { URL dis_ic_url = new URL(uri); XMLCollectionAccessPortType ic = locator.getXMLCollectionAccessPortTypePort(dis_ic_url); if (args[0].equalsIgnoreCase("delete")) { ic.deleteResource(args[2]); } if (args[0].equalsIgnoreCase("deleteAllRPs")) { ic.deleteAllRPs(new VoidTypeHolder()); } if (args[0].equalsIgnoreCase("deleteprofile")) { DeleteProfileParams prof = new DeleteProfileParams(); prof.setID(args[2]); prof.setProfileType(args[3]); ic.deleteProfile(prof); } if (args[0].equalsIgnoreCase("query")) { String query = Client.readFile(args[2]); String resp = ic.executeXQuery(query); System.out.println(resp); } if (args[0].equalsIgnoreCase("dispose")) { ic.dispose(new VoidTypeHolder()); } if (args[0].equalsIgnoreCase("initialize")) { ic.initialize(new VoidTypeHolder()); } } catch (Exception e) { e.printStackTrace(); } }// end main }