perfsonar-dev - perfsonar: r2355 - trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/storage/exist
Subject: perfsonar development work
List archive
perfsonar: r2355 - trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/storage/exist
Chronological Thread
- From:
- To:
- Subject: perfsonar: r2355 - trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/storage/exist
- Date: Wed, 25 Apr 2007 09:29:40 -0400
Author: mac
Date: 2007-04-25 09:29:39 -0400 (Wed, 25 Apr 2007)
New Revision: 2355
Modified:
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/storage/exist/ExistHTTPDataStorage.java
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/storage/exist/XQueryExistDAOImpl.java
Log:
Some small changes (I guess they haven't been commited before)
Modified:
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/storage/exist/ExistHTTPDataStorage.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/storage/exist/ExistHTTPDataStorage.java
2007-04-25 13:00:42 UTC (rev 2354)
+++
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/storage/exist/ExistHTTPDataStorage.java
2007-04-25 13:29:39 UTC (rev 2355)
@@ -31,6 +31,7 @@
DataCredential credential) throws SystemException {
try {
+
httpAccess.sendPUTRequest(
collection,
xmlDocument,
@@ -40,7 +41,7 @@
} catch (Exception ex) {
throw new SystemException(
"error.common.storage.xmldb.open",
- "XUpdate by HTTP failed. "
+ "PUT HTTP request of resource ["+collection+"] failed."
+ "Could not connect to eXist via pure http, "
+ " nested exception was: "+
ex.getClass()+" : "+ex.getMessage());
@@ -63,7 +64,7 @@
} catch (Exception ex) {
throw new SystemException(
"error.common.storage.xmldb.open",
- "XUpdate by HTTP failed. "
+ "DELETE HTTP request of resource ["+collection+"]
failed. "
+ "Could not connect to eXist via pure http, "
+ " nested exception was: "+
ex.getClass()+" : "+ex.getMessage());
Modified:
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/storage/exist/XQueryExistDAOImpl.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/storage/exist/XQueryExistDAOImpl.java
2007-04-25 13:00:42 UTC (rev 2354)
+++
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/storage/exist/XQueryExistDAOImpl.java
2007-04-25 13:29:39 UTC (rev 2355)
@@ -5,9 +5,6 @@
import org.perfsonar.commons.util.XMLUtils;
import org.perfsonar.service.commons.exceptions.PerfSONARException;
import org.perfsonar.service.commons.storage.xmldb.XmlDbResult;
-import org.perfsonar.service.lookupService.xmlType.storage.DataCredential;
-import org.perfsonar.service.lookupService.xmlType.storage.LookupServiceDAO;
-import org.perfsonar.service.lookupService.xmlType.storage.XMLDataStorage;
/**
* Implementation of LookupServiceDAO:
@@ -17,7 +14,7 @@
* @author Maciej Glowiak
*
*/
-public class XQueryExistDAOImpl implements LookupServiceDAO {
+public class XQueryExistDAOImpl extends CommonExistDAOImpl {
//
---------------------------------------------------------------constants
@@ -31,17 +28,8 @@
// ------------------------------------------------------instance
variables
- private XMLDataStorage dataStorage;
- private String dataCollection;
- private DataCredential dataCredential;
-
- //-------------------------------------------------------------
Constructor
-
public XQueryExistDAOImpl() {
-
- dataStorage = new ExistHTTPDataStorage();
- //parameters = new HashMap();
-
+ super();
}
// --------------------------------------------------------- Public
methods
@@ -67,7 +55,7 @@
xmls[i] +
UPDATE_INTO +
UPDATE_LSSTORE;
- dataStorage.performXQuery(xquery, dataCollection,
dataCredential);
+ getDataStorage().performXQuery(xquery,
getDataCollection(), getDataCredential());
}
}
@@ -81,42 +69,11 @@
UPDATE_REMOVE;
//remove by xquery
- XmlDbResult res = dataStorage.performXQuery(xquery, dataCollection,
dataCredential);
+ XmlDbResult res = getDataStorage().performXQuery(xquery,
getDataCollection(), getDataCredential());
return res.getCount();
}
- /**
- * Returns pair of numbers separated by space: "#M #D" where #M is number
- * of metadata blocks with specific metadataId, #D is number of related
- * data blocks (metadataIdRef=metadataId)
- * @param metadataId
- * @return
- * @throws PerfSONARException
- */
- public String countLookupInfo(String metadataId) throws
PerfSONARException {
-
- String xquery =
- DECLARE_NMWG_NAMESPACE +
- "concat(" +
-
"count(/nmwg:store[@type='"+LS_STORE_COLLECTION_TYPE+"']/nmwg:metadata[@id='"+metadataId+"']),
" +
- "' ', " +
-
"count(/nmwg:store[@type='"+LS_STORE_COLLECTION_TYPE+"']/nmwg:data[@metadataIdRef='"+metadataId+"']))";
-
- //remove by xquery
- XmlDbResult res = dataStorage.performXQuery(xquery, dataCollection,
dataCredential);
- return res.getResultAsString(); //return "M D" where
M is count(metadata), D is count(data)
- }
-
-
- public boolean isLookupInfo(String metadataId) throws PerfSONARException
{
-
- String result = countLookupInfo(metadataId);
- return !("0 0".equals(result));
-
- }
-
-
public int cleanupLookupInfo(long timestamp, long defaultInterval)
throws PerfSONARException {
String xquery =
@@ -141,40 +98,13 @@
System.out.println("---\n"+xquery+"\n---\n");
- /*XmlDbResult res =*/ dataStorage.performXQuery(xquery,
dataCollection, dataCredential);
+ /*XmlDbResult res =*/ getDataStorage().performXQuery(xquery,
getDataCollection(), getDataCredential());
return -1;
}
- /**
- * Returns control parameter, if not present, null value will be
returned.
- */
- public String getControlParameter(String metadataId, String parameter)
- throws PerfSONARException {
-
- String xquery =
- DECLARE_NMWG_NAMESPACE +
-
-
"data(/nmwg:store[@type='"+
- LS_STORE_CONTROL_COLLECTION_TYPE+
-
"']/nmwg:metadata[@id='"+
- metadataId+
-
"']/nmwg:parameters/nmwg:parameter[@name='"+parameter+"']/@value)";
-
- //remove by xquery
- XmlDbResult res = dataStorage.performXQuery(xquery, dataCollection,
dataCredential);
-
- String result = null;
- if (res.getCount()>0) result=res.getResultAsStringArray()[0];
- //if not present null will be returned
-
- return result;
-
- }
-
-
public void setControlParameter(String metadataId, String parameter,
String value) throws PerfSONARException {
String xquery =
@@ -210,7 +140,7 @@
"return $command \n";
//put
- dataStorage.performXQuery(xquery, dataCollection,
dataCredential);
+ getDataStorage().performXQuery(xquery, getDataCollection(),
getDataCredential());
} //set parameter
@@ -242,68 +172,13 @@
"for $i in $o return update delete $i\n";
//remove
- dataStorage.performXQuery(xquery, dataCollection, dataCredential);
+ getDataStorage().performXQuery(xquery, getDataCollection(),
getDataCredential());
}
- public String[] performXQuery(String xquery) throws
PerfSONARException {
-
- XmlDbResult res = dataStorage.performXQuery(xquery, dataCollection,
dataCredential);
- return res.getResultAsStringArray();
-
- }
-
- // -------------------------------------------------------- DAO methods
-
-
- public void setDAOParameter(String param, String value) {
- //parameters.put(param, value);
- //unused
- }
-
- public String getDAOParameter(String param) {
-
- return "";
- //return parameters.get(param);
- //unused
-
- }
-
- public void setDataCredential(DataCredential dc) {
-
- this.dataCredential = dc;
-
- }
-
- public void setDataCollection(String dc) {
-
- this.dataCollection = dc;
-
- }
-
-
- public boolean isDBCollection(String collection) throws
PerfSONARException {
-
- String xquery =
- DECLARE_NMWG_NAMESPACE +
- "
count(/nmwg:store[@type='"+collection+"'])";
- XmlDbResult res = dataStorage.performXQuery(xquery, dataCollection,
dataCredential);
- int result = Integer.parseInt(res.getResultAsString());
- return (result>0);
- }
-
-
- public boolean isDBConnectivity() throws PerfSONARException {
-
- String xquery = "fn:current-dateTime()";
- dataStorage.performXQuery(xquery, dataCollection, dataCredential);
- return true;
-
- }
-
- protected String getRemoveLookupInfoXQueryPart(String metadataId) {
+ protected String getRemoveLookupInfoXQueryPart(String metadataId) {
return
// a set of ()
"(" +
- perfsonar: r2355 - trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/storage/exist, svnlog, 04/25/2007
Archive powered by MHonArc 2.6.16.