Skip to Content.
Sympa Menu

perfsonar-dev - r1720 - branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType

Subject: perfsonar development work

List archive

r1720 - branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType


Chronological Thread 
  • From:
  • To:
  • Subject: r1720 - branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType
  • Date: Fri, 27 Oct 2006 14:22:14 -0400

Author: yi
Date: 2006-10-27 14:22:13 -0400 (Fri, 27 Oct 2006)
New Revision: 1720

Modified:

branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSAction.java

branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanup.java

branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSDeregisterAction.java

branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGenericRegisterAction.java

branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSLookupAction.java

branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSRegisterAction.java

branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/XmlTypeLSServiceEngine.java
Log:

BDB API Updates

-Yi



Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSAction.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSAction.java
2006-10-27 17:55:26 UTC (rev 1719)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSAction.java
2006-10-27 18:22:13 UTC (rev 1720)
@@ -20,7 +20,6 @@
import org.perfsonar.service.commons.exceptions.RequestException;
import org.perfsonar.service.commons.exceptions.SystemException;
import org.perfsonar.service.commons.storage.StorageManager;
-import
org.perfsonar.service.commons.storage.xmldb.bdbxml.BerkeleyDbXmlStorageManager;

/**
* Generic class for all LS actions performed by XmlTypeLSServiceEngine
@@ -31,11 +30,6 @@
public abstract class LSAction {

// --------------------------------------------------------------
Constants
-
- /**
- * BDB store container
- */
- protected static final String LS_STORE_CONTAINER =
BerkeleyDbXmlStorageManager.BDBXML_DEFAULT_CONTAINER;

/**
* The name of the store collection (containing LS data/metadata
@@ -54,6 +48,11 @@
*/
protected static final String LS_STORE_CONTROL_COLLECTION_TYPE =
"LSStore-control";

+ /**
+ * BDB container
+ */
+ public final static String LS_STORE_CONTAINER = LS_STORE_COLLECTION_TYPE
+ ".dbxml";
+ public final static String LS_STORE_CONTROL_CONTAINER =
LS_STORE_CONTROL_COLLECTION_TYPE + ".dbxml";

/**
* The name of the cache collection (containing summarized LS
data/metadata)

Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanup.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanup.java
2006-10-27 17:55:26 UTC (rev 1719)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSCleanup.java
2006-10-27 18:22:13 UTC (rev 1720)
@@ -8,6 +8,8 @@
import org.perfsonar.service.commons.exceptions.SystemException;
import org.perfsonar.service.commons.storage.StorageManager;
import org.perfsonar.service.commons.storage.xmldb.XmlDbResult;
+import
org.perfsonar.service.commons.storage.xmldb.bdbxml.BerkeleyDbXmlStorageManager;
+import
org.perfsonar.service.commons.storage.xmldb.exist.xmlrpc.ExistDbXmlrpcXmlStorageManager;


/**
@@ -137,6 +139,10 @@
//generate XQuery that removes data
//removes data from THESE schemas (LSStore,
LSStore-control, LSCache)

+
+ if (xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager)
+ {
+
String query = "";
query = XQUERY_UPDATE_DECLARE +
"for $md in
/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE + "' or @type='" +
@@ -145,15 +151,26 @@
XQUERY_UPDATE_DELETE + "$md";

xmlStorageManager.fetch(query); //XQuery

-
+
query = "";
query = XQUERY_UPDATE_DECLARE +
"for $d in
/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE + "' or @type='" +
LS_CACHE_COLLECTION_TYPE + "' or @type='" +
LS_STORE_CONTROL_COLLECTION_TYPE +

"']/nmwg:data[@metadataIdRef='"
+ keys[i] + "'] return " +
XQUERY_UPDATE_DELETE + "$d";
- xmlStorageManager.fetch(query); //XQuery

-
+ xmlStorageManager.fetch(query); //XQuery
+
+ }
+ else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
+ {
+ String xPath =
"/nmwg:metadata[@id=\""
+ keys[i] +"\"]";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).delete(LS_STORE_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).delete(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+ xPath =
"/nmwg:data[@metadataIdRef=\""
+ keys[i] +"\"]";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).delete(LS_STORE_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).delete(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+ }
+
} //if

} //else
@@ -184,6 +201,7 @@
protected String[] getMetadataKeys(StorageManager xmlStorageManager)
throws SystemException, RequestException, DataFormatException {

+
String query =
"declare namespace nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +

"data(/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE + "' or @type='" +
@@ -191,9 +209,26 @@

XmlDbResult edbres = (XmlDbResult)xmlStorageManager.fetch(query);
String[] res = (String[])edbres.getResultAsStringArray();
-
- return res;
-
+
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ {
+ query =
+ "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+
"data(/nmwg:store[@type='"+LS_STORE_COLLECTION_TYPE+"']/nmwg:metadata/@id)";
+ XmlDbResult edbres =
(XmlDbResult)xmlStorageManager.fetch(query);
+ String[] res = (String[])edbres.getResultAsStringArray();
+ return res;
+ }
+ else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
+ {
+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+
"data(collection(\""+LS_STORE_CONTAINER+"\")/nmwg:metadata/@id)";
+ XmlDbResult edbres =
(XmlDbResult)xmlStorageManager.fetch(query);
+ String[] res = (String[])edbres.getResultAsStringArray();
+ return res;
+ }
+ else
+ throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
}


@@ -204,17 +239,34 @@
String key,
String parameterName, StorageManager xmlStorageManager)
throws SystemException, RequestException,
DataFormatException {
+
+ String query;
+ String[] resArray;

- String query =
- "declare namespace nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
-
"/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE +
-
"']/nmwg:metadata[@id='"
+ key +
-
"']/nmwg:parameters/nmwg:parameter[@name='"
+
- parameterName+"']/text()";
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ {
+ query =
+ "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+
"/nmwg:store[@type='"+LS_STORE_CONTROL_COLLECTION_TYPE+
+
"']/nmwg:metadata[@id='"+key+
+
"']/nmwg:parameters/nmwg:parameter[@name='"+
+ parameterName+"']/text()";
+ XmlDbResult edbres =
(XmlDbResult)xmlStorageManager.fetch(query);
+ resArray = (String[])edbres.getResultAsStringArray();
+ }
+ else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
+ {
+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+
"collection(\""+LS_STORE_CONTROL_CONTAINER+"\")" +
+
"/nmwg:metadata[@id=\""+key+"\"]"
+
+
"/nmwg:parameters/nmwg:parameter[@name=\""+parameterName+"\"]/text()";
+ XmlDbResult edbres =
(XmlDbResult)xmlStorageManager.fetch(query);
+ resArray = (String[])edbres.getResultAsStringArray();
+ }
+ else
+ throw new SystemException("error.common.storage.xmldb.query",
"No database exists");
+

- XmlDbResult edbres = (XmlDbResult)xmlStorageManager.fetch(query);
- String[] resArray = (String[])edbres.getResultAsStringArray();
-
try {
String result = resArray[0];
return result.trim();

Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSDeregisterAction.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSDeregisterAction.java
2006-10-27 17:55:26 UTC (rev 1719)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSDeregisterAction.java
2006-10-27 18:22:13 UTC (rev 1720)
@@ -2,7 +2,6 @@

import org.ggf.ns.nmwg.base.v2_0.*;
import org.perfsonar.service.commons.exceptions.DataFormatException;
-import org.perfsonar.service.commons.exceptions.PerfSONARException;
import org.perfsonar.service.commons.exceptions.RequestException;
import org.perfsonar.service.commons.exceptions.SystemException;
import org.perfsonar.service.commons.storage.StorageManager;
@@ -67,6 +66,7 @@
// Prepare query
String query;
String[] queryResults;
+ XmlDbResult edbres;
int countMetadataRemoved = 0;
int countDataRemoved =0;

@@ -77,20 +77,19 @@
{
query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; "+

"data(/nmwg:store/nmwg:data[@metadataIdRef='"+keyValue+"']/@id)";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ queryResults = (String[])edbres.getResultAsStringArray();
}
else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
{
- query =
- "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
-
"data(collection(\""+LS_STORE_CONTAINER+"\")/nmwg:store/nmwg:data[@metadataIdRef=\""+keyValue+"\"]/@id)";

+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+
"data(collection(\""+LS_STORE_CONTAINER+"\")/nmwg:data[@metadataIdRef=\""+keyValue+"\"]/@id)";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ queryResults = (String[])edbres.getResultAsStringArray();
}
else
- query = "";
+ throw new SystemException("error.common.storage.xmldb.query",
"No database exists");

-
- XmlDbResult edbres = (XmlDbResult)xmlStorageManager.fetch(query);
- queryResults = (String[])edbres.getResultAsStringArray();
-
if (queryResults!=null) {

countDataRemoved = edbres.getCount();
@@ -118,7 +117,8 @@
}
else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
{
-
((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteElement(XQUERY_UPDATE_DECLARE,

"/nmwg:store/nmwg:data[@metadataIdRef=\""
+ keyValue +"\"]");
+ String xPath =
"/nmwg:data[@metadataIdRef=\""
+ keyValue +"\"]";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteDocument(LS_STORE_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
}
}

@@ -129,19 +129,19 @@
{
query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; "+

"data(/nmwg:store/nmwg:metadata[@id='"+keyValue+"']/@id)";
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query); //XQuery
+ queryResults = (String[])edbres.getResultAsStringArray();
}
else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
{
- query =
- "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
-
"data(collection(\""+LS_STORE_CONTAINER+"\")/nmwg:store/nmwg:metadata[@id=\""+keyValue+"\"]/@id)";

+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+
"data(collection(\""+LS_STORE_CONTAINER+"\")/nmwg:metadata[@id=\""+keyValue+"\"]/@id)";

+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ queryResults = (String[])edbres.getResultAsStringArray();
}
else
- query = "";
+ throw new SystemException("error.common.storage.xmldb.query",
"No database exists");

- edbres = (XmlDbResult)xmlStorageManager.fetch(query); //XQuery
- queryResults = (String[])edbres.getResultAsStringArray();
-
if (queryResults!=null) {

countMetadataRemoved = edbres.getCount();
@@ -168,7 +168,9 @@
}
else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
{
-
((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteElement(XQUERY_UPDATE_DECLARE,

"/nmwg:store/nmwg:metadata[@id=\""
+ keyValue +"\"]");
+ String xPath =
"/nmwg:metadata[@id=\""
+ keyValue +"\"]";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteDocument(LS_STORE_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteDocument(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
}
}


Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGenericRegisterAction.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGenericRegisterAction.java
2006-10-27 17:55:26 UTC (rev 1719)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSGenericRegisterAction.java
2006-10-27 18:22:13 UTC (rev 1720)
@@ -81,18 +81,45 @@
logger.debug("LSGenericRegisterAction: remove parameter ["+
parameterName+"] for key ["+key+"]");

- remove = XQUERY_UPDATE_DECLARE +
- "for $p in
/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE +
-
"']/nmwg:metadata[@id='"
+ key +
"']/nmwg:parameters/nmwg:parameter[@name='"
+
- parameterName + "'] return " + XQUERY_UPDATE_DELETE + "$p";

- xmlStorageManager.fetch(remove); //XQuery
-
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ {
+ remove = XQUERY_UPDATE_DECLARE +
+ "for $p in
/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE +
+
"']/nmwg:metadata[@id='"
+ key +
"']/nmwg:parameters/nmwg:parameter[@name='"
+
+ parameterName + "'] return " +
XQUERY_UPDATE_DELETE + "$p";
+ xmlStorageManager.fetch(remove); //XQuery
+ }
+ else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
+ {
+ String xPath =
"/nmwg:metadata[@id=\""
+ key +"\"]" +
+
"/nmwg:parameters/nmwg:parameter[@name=\""
+ parameterName + "\"]";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).delete(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+ }
+
//check if metadata empty
+ String query;
+ XmlDbResult res;
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ {
+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+
"data(/nmwg:store[@type='"+LS_STORE_CONTROL_COLLECTION_TYPE+"']/nmwg:metadata[@id='"+key+"']/@id)";
+ res = (XmlDbResult)xmlStorageManager.fetch(query);
+ }
+ else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
+ {
+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+
"data(collection(\""+LS_STORE_CONTROL_CONTAINER+"\")/nmwg:metadata[@id=\""+key+"\"]/@id)";
+ res = (XmlDbResult)xmlStorageManager.fetch(query);
+ }
+ else
+ throw new SystemException("error.common.storage.xmldb.query",
"No database exists");

+
String query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +

"data(/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"+key+"']/@id)";

XmlDbResult res = (XmlDbResult)xmlStorageManager.fetch(query);
+
int resnum = res.getCount();

//metadata empty -> remove it
@@ -101,12 +128,19 @@
logger.debug("LSGenericRegisterAction: metadata block for key
["+key
+"] remained empty, delete it");

- remove = XQUERY_UPDATE_DECLARE +
- "for $md in
/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE +
-
"']/nmwg:metadata[@id='"
+ key + "'] return " +
- XQUERY_UPDATE_DELETE + "$md";

- xmlStorageManager.fetch(remove); //XQuery
-
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ {
+ remove = XQUERY_UPDATE_DECLARE +
+ "for $md in
/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE +
+
"']/nmwg:metadata[@id='"
+ key + "'] return " +
+ XQUERY_UPDATE_DELETE + "$md";

+ xmlStorageManager.fetch(remove); //XQuery
+ }
+ else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
+ {
+ String xPath =
"/nmwg:metadata[@id=\""
+ key +"\"]";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteDocument(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+ }
}

} //remove parameter
@@ -135,79 +169,145 @@

String query = null;
int resnum = 0;
+ XmlDbResult res;

//check if there is control metadata for such key
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ {
+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+
"data(/nmwg:store[@type='"+LS_STORE_CONTROL_COLLECTION_TYPE+"']/nmwg:metadata[@id='"+key+"']/@id)";
+ res = (XmlDbResult)xmlStorageManager.fetch(query);
+ }
+ else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
+ {
+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+
"data(collection(\""+LS_STORE_CONTROL_CONTAINER+"\")/nmwg:metadata[@id=\""+key+"\"]/@id)";

+ res = (XmlDbResult)xmlStorageManager.fetch(query);
+ }
+ else
+ throw new SystemException("error.common.storage.xmldb.query",
"No database exists");

+
query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +

"data(/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"+key+"']/@id)";

XmlDbResult res = (XmlDbResult)xmlStorageManager.fetch(query);
+
resnum = res.getCount();

//if there is no control metadata, put it
- if (resnum==0) {
-
+ if (resnum==0) {
logger.debug("LSGenericRegisterAction: setParameter: no control
metadata, put metadata+parameters");
-
- String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
- insert = insert + " <nmwg:metadata id=\"" + key + "\">\n" +
- " <nmwg:parameters
id=\"control-parameters\">\n" +
- " </nmwg:parameters>\n" +
- " </nmwg:metadata>\n into
/nmwg:store[@type='"
+
- LS_STORE_CONTROL_COLLECTION_TYPE + "']";
- xmlStorageManager.fetch(insert);
+
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ {
+ String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
+ insert = insert + " <nmwg:metadata id=\"" + key +
"\">\n" +
+ " <nmwg:parameters
id=\"control-parameters\">\n" +
+ " </nmwg:parameters>\n" +
+ " </nmwg:metadata>\n into
/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE + "']";
+ xmlStorageManager.fetch(insert);
+ }
+ else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
+ {
+ String insertData = "<nmwg:metadata id=\"" + key +
"\" xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";>\n" +
+ " <nmwg:parameters
id=\"control-parameters\">\n" +
+ "
</nmwg:parameters>\n" +
+ "</nmwg:metadata>\n";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insertDocument(LS_STORE_CONTROL_CONTAINER,
insertData);
+ }
+ }
+ else {
+ //if there is the metadata, check if it has a parameters block

- } else {
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ {
+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+
"data(/nmwg:store[@type='"+LS_STORE_CONTROL_COLLECTION_TYPE+"']/nmwg:metadata[@id='"+key+"']/nmwg:parameters/@id)";
+ res = (XmlDbResult)xmlStorageManager.fetch(query);
+ }
+ else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
+ {
+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+
"data(collection(\""+LS_STORE_CONTROL_CONTAINER+"\")/nmwg:metadata[@id=\""+key+"\"]/nmwg:parameters/@id)";
+ res = (XmlDbResult)xmlStorageManager.fetch(query);
+ }
+ else
+ throw new
SystemException("error.common.storage.xmldb.query", "No database exists");

- //if there is the metadata, check if it has a parameters block
- query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
-
"data(/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"+
- key+"']/nmwg:parameters/@id)";

- res = (XmlDbResult)xmlStorageManager.fetch(query);
+
resnum = res.getCount();

if (resnum==0) {
-
- logger.debug("LSGenericRegisterAction: setParameter: no
parameters, put parameters");
-
- //put parameters
-
- String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
- insert = insert + " <nmwg:parameters
id=\"control-parameters\">\n" +
- " </nmwg:parameters>\n into
/nmwg:store[@type='"
+
- LS_STORE_CONTROL_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"
+
- key + "']";
- xmlStorageManager.fetch(insert);
-
- }
-
+ // put parameters
+ if (xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager)
+ {
+ String insert = XQUERY_UPDATE_DECLARE +
XQUERY_UPDATE_INSERT;
+ insert = insert + " <nmwg:parameters
id=\"control-parameters\">\n" +
+ " </nmwg:parameters>\n
into
/nmwg:store[@type='"
+
+ LS_STORE_CONTROL_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"
+ key + "']";
+ xmlStorageManager.fetch(insert);
+ }
+ else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
+ {
+ String xPath =
"/nmwg:metadata[@id='"
+ key + "']";
+ String insertData = "<nmwg:parameters
id=\"control-parameters\">\n" +
+
"</nmwg:parameters>\n";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insert(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath, insertData);
+ }
+ }
}

//check if there is parameter inside metadata
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ {
+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+
"/nmwg:store[@type='"+LS_STORE_CONTROL_COLLECTION_TYPE+"']/nmwg:metadata[@id='"+key+"']/nmwg:parameters/nmwg:parameter[@name='"+parameterName+"']";
+ res = (XmlDbResult)xmlStorageManager.fetch(query);
+ }
+ else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
+ {
+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+
"collection(\""+LS_STORE_CONTROL_CONTAINER+"\")/nmwg:metadata[@id=\""+key+"\"]/nmwg:parameters/nmwg:parameter[@name=\""+parameterName+"\"]";
+ res = (XmlDbResult)xmlStorageManager.fetch(query);
+ }
+ else
+ throw new SystemException("error.common.storage.xmldb.query",
"No database exists");

+
query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +

"/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"+key+

"']/nmwg:parameters/nmwg:parameter[@name='"+parameterName+"']";

res = (XmlDbResult)xmlStorageManager.fetch(query);
+
resnum = res.getCount();

if (resnum==0) {

//if there is no such parameter, put new one
-
logger.debug("LSGenericRegisterAction: Set parameter
["+parameterName+
"] not found, " +
"insert new parameter ["+key+"]");

- String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
- insert = insert + "<nmwg:parameter name=\"" + parameterName +
"\">" +
- parameterValue + "</nmwg:parameter> into
/nmwg:store[@type='"
+
- LS_STORE_CONTROL_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"
+
- key + "']/nmwg:parameters";
- xmlStorageManager.fetch(insert);
-
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ {
+ String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
+ insert = insert + "<nmwg:parameter name=\"" +
parameterName + "\">" +
+ parameterValue + "</nmwg:parameter>
into
/nmwg:store[@type='"
+
+ LS_STORE_CONTROL_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"
+
+ key + "']/nmwg:parameters";
+ xmlStorageManager.fetch(insert);
+ }
+ else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
+ {
+ String xPath =
"/nmwg:metadata[@id=\""
+ key + "\"]/nmwg:parameters";
+ String insertData = "<nmwg:parameter name=\"" +
parameterName + "\" xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";>"
+ + parameterValue
+ + "</nmwg:parameter>";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insert(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath, insertData);
+ }
} else {

//otherwise update it
@@ -215,13 +315,21 @@
logger.debug("LSGenericRegisterAction: Set parameter ["
+parameterName+"] found," +
"update existing one");
-
- String update = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_VALUE;
- update = update +
"/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE +
-
"']/nmwg:metadata[@id='"
+ key +
-
"']/nmwg:parameters/nmwg:parameter[@name='"
+ parameterName +
- "'] with " + parameterValue;
- xmlStorageManager.fetch(update);
+
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ {
+ String update = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_VALUE;
+ update = update +
"/nmwg:store[@type='"
+ LS_STORE_CONTROL_COLLECTION_TYPE +
+
"']/nmwg:metadata[@id='"
+ key +
+
"']/nmwg:parameters/nmwg:parameter[@name='"
+ parameterName +
+ "'] with " + parameterValue;
+ xmlStorageManager.fetch(update);
+ }
+ else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
+ {
+ String xPath =
"/nmwg:metadata[@id=\""
+ key +
"\"]/nmwg:parameters/nmwg:parameter[@name=\""
+ parameterName + "\"]";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).update(LS_STORE_CONTROL_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath, parameterValue);
+ }
}

} //set parameter
@@ -234,29 +342,29 @@

try {
String query;
+ XmlDbResult res;

if (xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager)
{
query =
"declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +

"data(/nmwg:store[@type='"+LS_STORE_COLLECTION_TYPE+"']/nmwg:metadata[@id='"+key+"']/@id)";

+ res = (XmlDbResult)xmlStorageManager.fetch(query);
}
else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
{
- query =
- "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
-
"data(doc(\""+LS_STORE_CONTAINER+"/"+LS_STORE_COLLECTION_TYPE+"\")/nmwg:store/nmwg:metadata[@id=\""+key+"\"]/@id)";

+ query = "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +
+
"data(collection(\""+LS_STORE_CONTAINER+"\")/nmwg:metadata[@id=\""+key+"\"]/@id)";

+ res = (XmlDbResult)xmlStorageManager.fetch(query);
}
else
- query = "";
+ throw new
SystemException("error.common.storage.xmldb.query", "No database exists");

String query =
"declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; " +

"data(/nmwg:store[@type='"+
LS_STORE_COLLECTION_TYPE + "' or @type='" +
LS_CACHE_COLLECTION_TYPE +
"']/nmwg:metadata[@id='"+key+"']/@id)";


- XmlDbResult res = (XmlDbResult)xmlStorageManager.fetch(query);
-
int resnum = res.getCount();

if (resnum>0)

Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSLookupAction.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSLookupAction.java
2006-10-27 17:55:26 UTC (rev 1719)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSLookupAction.java
2006-10-27 18:22:13 UTC (rev 1720)
@@ -3,12 +3,12 @@
import org.ggf.ns.nmwg.base.v2_0.*;
import org.perfsonar.commons.util.XMLUtils;
import org.perfsonar.service.commons.exceptions.DataFormatException;
-import org.perfsonar.service.commons.exceptions.PerfSONARException;
import org.perfsonar.service.commons.exceptions.RequestException;
import org.perfsonar.service.commons.exceptions.SystemException;
import org.perfsonar.service.commons.storage.StorageManager;
import org.perfsonar.service.commons.storage.xmldb.XmlDbResult;
-import
org.perfsonar.service.commons.storage.xmldb.exist.rest.ExistDbHTTPAccess;
+import
org.perfsonar.service.commons.storage.xmldb.bdbxml.BerkeleyDbXmlStorageManager;
+import
org.perfsonar.service.commons.storage.xmldb.exist.xmlrpc.ExistDbXmlrpcXmlStorageManager;

/**
* LOOKUP Action
@@ -144,8 +144,19 @@
///////////////////////////////////////////////////////////////

/* XQuery */
- XmlDbResult edbres = (XmlDbResult)xmlStorageManager.fetch(query);
- results = (String[])edbres.getResultAsStringArray();
+ XmlDbResult edbres;
+ if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
+ {
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
+ {
+ edbres = (XmlDbResult)xmlStorageManager.fetch(query);
+ results = (String[])edbres.getResultAsStringArray();
+ }
+ else
+ throw new SystemException("error.common.storage.xmldb.query",
"No database exists");

///////////////////////////////////////////////////////////////


Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSRegisterAction.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSRegisterAction.java
2006-10-27 17:55:26 UTC (rev 1719)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSRegisterAction.java
2006-10-27 18:22:13 UTC (rev 1720)
@@ -325,7 +325,9 @@
//check if there is metadata with the same key:
//if so, check if you're allowed to update data (to remove them)
//throw exception if you're not allowed
+
if(checkIfKeyIsRegistered(keyValue,xmlStorageManager)) {
+

logger.debug("LSRegisterAction: Key is already " +
"registered in DB (metadata), allow_update="+
@@ -334,19 +336,32 @@
if (allowReplaceIfAlreadyRegistered) {

logger.debug("LSRegisterAction: old data will be replaced by
new set of data");
+
+ if (xmlStorageManager instanceof
ExistDbXmlrpcXmlStorageManager)
+ {
+ String remove = XQUERY_UPDATE_DECLARE +
+ "for $md in
/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE +
+
"']/nmwg:metadata[@id='"
+ keyValue + "'] return " +
+ XQUERY_UPDATE_DELETE
+ "$md";
+ xmlStorageManager.fetch(remove); //XQuery
+
+ remove = "";
+ remove = XQUERY_UPDATE_DECLARE +
+ "for $d in
/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE +
+
"']/nmwg:data[@metadataIdRef='"
+ keyValue + "'] return " +
+ XQUERY_UPDATE_DELETE + "$d";
+ xmlStorageManager.fetch(remove); //XQuery
+ }
+ else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
+ {
+ String xPath =
"/nmwg:metadata[@id=\""
+ keyValue +"\"]";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteDocument(LS_STORE_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+ xPath =
"/nmwg:data[@metadataIdRef=\""
+ keyValue +"\"]";
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).deleteDocument(LS_STORE_CONTAINER,
XQUERY_UPDATE_DECLARE, xPath);
+ }

- String remove = XQUERY_UPDATE_DECLARE +
- "for $md in
/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE +
-
"']/nmwg:metadata[@id='"
+ keyValue + "'] return " +
- XQUERY_UPDATE_DELETE + "$md";
- xmlStorageManager.fetch(remove); //XQuery
-
- remove = "";
- remove = XQUERY_UPDATE_DECLARE +
- "for $d in
/nmwg:store[@type='"
+ LS_STORE_COLLECTION_TYPE +
-
"']/nmwg:data[@metadataIdRef='"
+ keyValue + "'] return " +
- XQUERY_UPDATE_DELETE + "$d";
- xmlStorageManager.fetch(remove); //XQuery
+
+
} else {
String m = "LSRegisterAction: Can't replace data";
logger.error(m);
@@ -356,7 +371,6 @@
}
else {

-
//summary data always gets updated (don't look at the conf file info)

logger.debug("LSRegisterAction: old data summary data is always
replaced");
@@ -380,31 +394,28 @@
//change metadata id
requestMetadata.setId(accessPoint);

-<<<<<<< .mine
-
//make sure we update the store vs the cache
- String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
- insert = insert + XMLUtils.serializeXML(requestMetadata) + " into
/nmwg:store[@type='";
- if(summaryParam == null) {
- insert = insert + LS_STORE_COLLECTION_TYPE + "']";
- }
- else {
- insert = insert + LS_CACHE_COLLECTION_TYPE + "']";
- }
- xmlStorageManager.fetch(insert);
-=======
if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
{
- String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
- insert = insert + XMLUtils.serializeXML(requestMetadata) + "
into
/nmwg:store[@type='"
+
- LS_STORE_COLLECTION_TYPE + "']";
- xmlStorageManager.fetch(insert);
+
+
+ String insert = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
+ insert = insert + XMLUtils.serializeXML(requestMetadata) + " into
/nmwg:store[@type='";
+ if(summaryParam == null) {
+ insert = insert + LS_STORE_COLLECTION_TYPE + "']";
+ }
+ else {
+ insert = insert + LS_CACHE_COLLECTION_TYPE + "']";
+ }
+ xmlStorageManager.fetch(insert);
+
+
}
else if (xmlStorageManager instanceof BerkeleyDbXmlStorageManager)
{
-
((BerkeleyDbXmlStorageManager)xmlStorageManager).insertElement(XQUERY_UPDATE_DECLARE,
LS_STORE_COLLECTION_TYPE, "/nmwg:store",
XMLUtils.serializeXML(requestMetadata));
+ String insertData = XMLUtils.serializeXML(requestMetadata);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insertDocument(LS_STORE_CONTAINER,
insertData);
}
->>>>>>> .r1691

//Prepare XQuery data

@@ -435,20 +446,9 @@
//Prepare XQuery for Data
//fill updateData structure

-<<<<<<< .mine
-=======
+
if (xmlStorageManager instanceof ExistDbXmlrpcXmlStorageManager)
{
- String insert2 = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
- insert2 = insert2 + XMLUtils.serializeXML(requestData) +
" into
/nmwg:store[@type='"
+
- LS_STORE_COLLECTION_TYPE + "']";
- xmlStorageManager.fetch(insert2);
- }
- else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
- {
-
((BerkeleyDbXmlStorageManager)xmlStorageManager).insertElement(XQUERY_UPDATE_DECLARE,
LS_STORE_COLLECTION_TYPE, "/nmwg:store", XMLUtils.serializeXML(requestData));
- }
->>>>>>> .r1691

//make sure we update the store vs the cache
String insert2 = XQUERY_UPDATE_DECLARE + XQUERY_UPDATE_INSERT;
@@ -459,8 +459,17 @@
else {
insert2 = insert2 + LS_CACHE_COLLECTION_TYPE + "']";
}
- xmlStorageManager.fetch(insert2);
+ xmlStorageManager.fetch(insert2);
+
+
+ }
+ else if (xmlStorageManager instanceof
BerkeleyDbXmlStorageManager)
+ {
+ String insertData =
XMLUtils.serializeXML(requestData);
+
((BerkeleyDbXmlStorageManager)xmlStorageManager).insertDocument(LS_STORE_CONTAINER,
insertData);
+ }

+
datanum++;
}


Modified:
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/XmlTypeLSServiceEngine.java
===================================================================
---
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/XmlTypeLSServiceEngine.java
2006-10-27 17:55:26 UTC (rev 1719)
+++
branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType/XmlTypeLSServiceEngine.java
2006-10-27 18:22:13 UTC (rev 1720)
@@ -18,7 +18,6 @@
import org.perfsonar.service.commons.storage.xmldb.XmlDbStorageManager;
import
org.perfsonar.service.commons.storage.xmldb.bdbxml.BerkeleyDbXmlStorageManager;
import org.perfsonar.service.commons.storage.xmldb.exist.ExistDbFactory;
-import org.perfsonar.service.commons.storage.xmldb.XmlDbConstants;

/**
* ServiceEngine class for LookupService. (The heart of the LookupService)
@@ -36,6 +35,9 @@

// -------------------------------------------------------------
Constants

+ /**
+ * Service database type: "eXist or BDB"
+ */
private static final String SERVICE_DATABASE_TYPE = "BDB";

/**
@@ -265,7 +267,8 @@


protected static XmlDbStorageManager getStorageManager(String type)
throws SystemException
- {
+ {
+ // generate the corresponding database manager based on the database
type
if (SERVICE_DATABASE_TYPE == "eXist")
{
XmlDbDataRepository dataRepository =



  • r1720 - branches/yi-udel/perfsonar/src/org/perfsonar/service/lookupService/xmlType, svnlog, 10/27/2006

Archive powered by MHonArc 2.6.16.

Top of Page