106 lines
3.7 KiB
Java
106 lines
3.7 KiB
Java
/**
|
|
*
|
|
*/
|
|
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
|
|
* <ol>
|
|
* <li> <b>to compile</b>: javac -classpath MYPATH/org_diligentproject_informationservice_disic_stubs.jar:$CLASSPATH testsuite/Client.java
|
|
*
|
|
* <li> <b>to run</b> (make sure that the DIS-IC stub classes are in your CLASSPATH):
|
|
* </ol>
|
|
* <ul>
|
|
* <li> DELETE ALL RPs: java -classpath MYPATH//org_diligentproject_informationservice_disic_stubs.jar:$CLASSPATH testsuite/Client deleteAllRPs http://MYHOST:MYPORT/wsrf/services/diligentproject/informationservice/disic/DISICService
|
|
*
|
|
* <li> DELETE A PROFILE: java -classpath MYPATH//org_diligentproject_informationservice_disic_stubs.jar:$CLASSPATH testsuite/Client deleteprofile http://MYHOST:MYPORT/wsrf/services/diligentproject/informationservice/disic/DISICService <PROFILE ID> <PROFILE TYPE>
|
|
* (allowed type are: "DHN", "RI", "SERVICE", "CS", "CSInstance", "Collection", "gLiteResource"
|
|
* <li> DELETE A RESOURCE: java -classpath MYPATH//lib/org_diligentproject_informationservice_disic_stubs.jar:$CLASSPATH testsuite/Client delete http://MYHOST:MYPORT/wsrf/services/diligentproject/informationservice/disic/DISICService <RESOURCE_ID>
|
|
*
|
|
* <li> SEND A QUERY: java -classpath ./build/lib/org_diligentproject_informationservice_disic_stubs.jar:$CLASSPATH testsuite/Client query http://MYHOST:MYPORT/wsrf/services/diligentproject/informationservice/disic/DISICService <xquery-file>
|
|
* </ul>
|
|
*
|
|
* @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
|
|
}
|