Modified ISClientRequester class in order to create valid request for TM-Plugins

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/rmp-common-library@73717 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Valentina Marioli 2013-04-19 17:06:39 +00:00
parent 9c47d53f1c
commit 99212351a7
7 changed files with 47 additions and 33 deletions

View File

@ -1,27 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
<classpathentry kind="output" path="war/WEB-INF/classes"/>
</classpath>

View File

@ -31,12 +31,12 @@
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>

View File

@ -1,5 +1,4 @@
#Fri Dec 28 17:26:46 CET 2012
eclipse.preferences.version=1
entryPointModules=
filesCopiedToWebInfLib=
filesCopiedToWebInfLib=gwt-servlet.jar
gwtCompileSettings=PGd3dC1jb21waWxlLXNldHRpbmdzPjxsb2ctbGV2ZWw+SU5GTzwvbG9nLWxldmVsPjxvdXRwdXQtc3R5bGU+T0JGVVNDQVRFRDwvb3V0cHV0LXN0eWxlPjxleHRyYS1hcmdzPjwhW0NEQVRBW11dPjwvZXh0cmEtYXJncz48dm0tYXJncz48IVtDREFUQVstWG14NTEybV1dPjwvdm0tYXJncz48ZW50cnktcG9pbnQtbW9kdWxlPm9yZy5nY3ViZS5yZXNvdXJjZW1hbmFnZW1lbnQuc3VwcG9ydC5SZXNvdXJjZV9zdXBwb3J0PC9lbnRyeS1wb2ludC1tb2R1bGU+PC9nd3QtY29tcGlsZS1zZXR0aW5ncz4\=

View File

@ -1,4 +1,4 @@
#Wed Dec 19 12:49:25 CET 2012
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8

View File

@ -500,7 +500,6 @@ public class ISClientRequester {
}
List<XMLResult> results = client.execute(isQuery, queryScope);
List<String> retval = new Vector<String>();
//ServerConsole.trace(LOG_PREFIX, "Retrieved (" + retval.size() + ") Resource for ID: " + resID);
@ -531,9 +530,10 @@ public class ISClientRequester {
Map<String, GenericResourcePlugin> retval = new HashMap<String, GenericResourcePlugin>();
gonext: for (XMLResult plugin : results) {
//System.out.println(plugin.toString());
try {
for (String entry : plugin.evaluate("/CMPlugins/Plugin/Entry")) {
Document doc = ScopeManager.getDocumentGivenXML(entry);
String name = doc.getElementsByTagName("name").item(0).getFirstChild().getNodeValue();
_log.trace("[LOAD-PLUGIN] found: *** name " + name);
@ -635,9 +635,10 @@ public class ISClientRequester {
HashMap<String, ArrayList<TMPluginFormField>> retval = new HashMap<String, ArrayList<TMPluginFormField>>();
gonext: for (XMLResult plugin : results) {
//System.out.println(plugin.toString());
try {
for (String entry : plugin.evaluate("/TMPlugins/Plugin/Entry")) {
String requestName = null;
boolean foundRequest = false;
Document doc = ScopeManager.getDocumentGivenXML(entry);
String name = doc.getElementsByTagName("name").item(0).getFirstChild().getNodeValue();
_log.trace("[LOAD-PLUGIN] found: *** name " + name);
@ -655,6 +656,7 @@ public class ISClientRequester {
NodeList params = doc.getElementsByTagName("param");
ArrayList<TMPluginFormField> formFields = new ArrayList<TMPluginFormField>();
for (int i = 0; i < params.getLength(); i++) {
NodeList paramTree = params.item(i).getChildNodes();
@ -664,22 +666,31 @@ public class ISClientRequester {
for (int j = 0; j < paramTree.getLength(); j++) {
if (paramTree.item(j).getNodeName().equals("param-name")) {
paramName = paramTree.item(j).getFirstChild().getNodeValue();
if (paramName.compareTo("requestSample") == 0) {
foundSample = true;
foundRequest = true;
}
}
if (paramTree.item(j).getNodeName().equals("param-definition") && foundSample) {
xmlToParse = paramTree.item(j).getFirstChild().getNodeValue();
xmlToParse = xmlToParse.replaceAll("&lt;", "<");
xmlToParse = xmlToParse.replaceAll("&gt;", "<");
//System.out.println("toParse:" + xmlToParse);
foundSample = false;
requestName = getRequestName(xmlToParse);
formFields = getPluginFormFromXml(xmlToParse);
}
}
// if (params.getLength()>1)
retval.put(name + ":" + requestName, formFields);
}
if (foundRequest == false){
retval.put(name, formFields);
}
}
} catch (RuntimeException e) {
continue gonext;
@ -688,6 +699,21 @@ public class ISClientRequester {
return retval;
}
/**
* get Request Name
*
*
* @param xmlToParse
* @return the list
*/
private static String getRequestName(String xmlToParse) {
Document doc = ScopeManager.getDocumentGivenXML(xmlToParse);
return doc.getDocumentElement().getNodeName();
}
/**
* parses the following and return the list to generate the form automatically
*
@ -708,7 +734,9 @@ public class ISClientRequester {
private static ArrayList<TMPluginFormField> getPluginFormFromXml(String xmlToParse) {
ArrayList<TMPluginFormField> toReturn = new ArrayList<TMPluginFormField>();
Document doc = ScopeManager.getDocumentGivenXML(xmlToParse);
Node root = doc.getElementsByTagName("speciesRequest").item(0);
// Node root = doc.getElementsByTagName("request").item(0);
Node root = doc.getDocumentElement();
NodeList children = root.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
String label = children.item(i).getNodeName();

View File

@ -123,7 +123,8 @@ public class GenericResourcePlugin implements Serializable, IsSerializable {
private String description = null;
private String type = null;
private List<Field> params = new Vector<Field>();
private String namespace = "xmlns:ns4=\"http://gcube-system.org/namespaces/contentmanagement/contentmanager/oaiplugin\"";
// private String namespace = null;
private String namespace = "xmlns:ns4=\"http://gcube-system.org/namespaces/data/oaiplugin\"";
/**

Binary file not shown.