perfsonar-dev - perfsonar: r2480 - in trunk/perfsonar/src/org/perfsonar/client/commons: requests/lookupService xquery xquery/lookupService
Subject: perfsonar development work
List archive
perfsonar: r2480 - in trunk/perfsonar/src/org/perfsonar/client/commons: requests/lookupService xquery xquery/lookupService
Chronological Thread
- From:
- To:
- Subject: perfsonar: r2480 - in trunk/perfsonar/src/org/perfsonar/client/commons: requests/lookupService xquery xquery/lookupService
- Date: Fri, 29 Jun 2007 10:39:03 -0400
Author: mac
Date: 2007-06-29 10:39:03 -0400 (Fri, 29 Jun 2007)
New Revision: 2480
Added:
trunk/perfsonar/src/org/perfsonar/client/commons/requests/lookupService/EchoRequestGenerator.java
trunk/perfsonar/src/org/perfsonar/client/commons/requests/lookupService/LSDeregisterRequestGenerator.java
trunk/perfsonar/src/org/perfsonar/client/commons/requests/lookupService/LSKeepaliveRequestGenerator.java
trunk/perfsonar/src/org/perfsonar/client/commons/xquery/lookupService/GenericXQueryExpression.java
Removed:
trunk/perfsonar/src/org/perfsonar/client/commons/xquery/lookupService/LookupInformationXQueryExpression.java
trunk/perfsonar/src/org/perfsonar/client/commons/xquery/lookupService/XQueryExpressionImpl.java
Modified:
trunk/perfsonar/src/org/perfsonar/client/commons/requests/lookupService/LSQueryRequestGenerator.java
trunk/perfsonar/src/org/perfsonar/client/commons/xquery/XQueryExpression.java
Log:
Client API for LS. Requests generators and generic XQuery expression
genereator
Added:
trunk/perfsonar/src/org/perfsonar/client/commons/requests/lookupService/EchoRequestGenerator.java
Property changes on:
trunk/perfsonar/src/org/perfsonar/client/commons/requests/lookupService/EchoRequestGenerator.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added:
trunk/perfsonar/src/org/perfsonar/client/commons/requests/lookupService/LSDeregisterRequestGenerator.java
Property changes on:
trunk/perfsonar/src/org/perfsonar/client/commons/requests/lookupService/LSDeregisterRequestGenerator.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added:
trunk/perfsonar/src/org/perfsonar/client/commons/requests/lookupService/LSKeepaliveRequestGenerator.java
Property changes on:
trunk/perfsonar/src/org/perfsonar/client/commons/requests/lookupService/LSKeepaliveRequestGenerator.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified:
trunk/perfsonar/src/org/perfsonar/client/commons/requests/lookupService/LSQueryRequestGenerator.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/client/commons/requests/lookupService/LSQueryRequestGenerator.java
2007-06-26 19:46:42 UTC (rev 2479)
+++
trunk/perfsonar/src/org/perfsonar/client/commons/requests/lookupService/LSQueryRequestGenerator.java
2007-06-29 14:39:03 UTC (rev 2480)
@@ -4,228 +4,168 @@
*/
package org.perfsonar.client.commons.requests.lookupService;
-//import org.perfsonar.service.commons.exceptions.SystemException;
-//import org.w3c.dom.Document;
-//import org.w3c.dom.Element;
-//import org.w3c.dom.Node;
+import org.ggf.ns.nmwg.base.v2_0.Data;
+import org.ggf.ns.nmwg.base.v2_0.EventType;
+import org.ggf.ns.nmwg.base.v2_0.Message;
+import org.ggf.ns.nmwg.base.v2_0.Metadata;
+import
org.ggf.ns.nmwg.tools.org.perfsonar.service.lookup.xquery.v1_0.Subject;
+import org.perfsonar.client.commons.requests.RequestGenerator;
+import org.perfsonar.service.commons.exceptions.PerfSONARException;
-
/**
* @author Maciej Glowiak
*
- * This class can generate simple LSQueryRequest as a DOM document
(org.w3c.dom)
+ * This class can generate simple LSQueryRequest as a Message element
* The only parameter you must set is "query"
- *
- * It can be set by constructor:
- *
- * new LSQueryRequestGenerator("xquery expression");
- * or:
- * setParameter(QUERY, "xquery expression");
- * or:
- * setQuery("xquery expression");
- *
- * Optional parameter is QUERY_TYPE:
- *
- * It can be set by constructor:
- *
- * new LSQueryRequestGenerator("xquery expression",
- * "service.lookup.xquery");
- * or:
- * setParameter(QUERY_TYPE, "service.lookup.xquery");
- * or:
- * setQueryType("service.lookup.xquery");
- *
*/
-public class LSQueryRequestGenerator {/*extends RequestGeneratorImpl {
-//
-//
-// // -------------------------------------------------------------
Constants
-//
-//
-// /**
-// * Default query type to LS (characteristic element)
-// */
-// private static final String DEFAULT_QUERY_TYPE =
"service.lookup.xquery";
-//
-//
-// /**
-// * Parameter that contains query type (characteristic)
-// */
-// private static final String QUERY_TYPE = "queryType";
-//
-//
-// /**
-// * Parameter that contains query (subject)
-// */
-// private static final String QUERY = "query";
-//
-//
-// // ------------------------------------------------------------ Static
code
-//
-//
-// /**
-// * Sets query and query type
-// */
-// public LSQueryRequestGenerator(String query, String queryType) {
+public class LSQueryRequestGenerator implements RequestGenerator {
+
+ // --------------------------------------------------------------
Constants
+
+ /**
+ * Default query type to LS (eventType element)
+ */
+ private static final String DEFAULT_QUERY_TYPE = "service.lookup.xquery";
+
+ /**
+ * Message Type
+ */
+ private static final String MESSAGE_TYPE = "LSQueryRequest";
+
+ // ----------------------------------------------------- Instance
variables
+
+ /**
+ * metadata Id
+ */
+ private String metaId = "query-metadata";
+
+ /**
+ * data Id
+ */
+ private String dataId = "query-trigger";
+
+ /**
+ * Query Type - eventType
+ */
+ private String queryType = DEFAULT_QUERY_TYPE;
+
+ /**
+ * Default query
+ */
+ private String query = "";
+
+ // --------------------------------------------------- Public
constructors
+
+ /**
+ * Sets query and query type
+ */
+ public LSQueryRequestGenerator(String query, String queryType) {
+
+ super();
+ setQuery(query);
+ setQueryType(queryType);
+
+ }
+
+
+ /**
+ * Sets query. Query type is set to default - see: DEFAULT_QUERY_TYPE
+ * @param query
+ */
+ public LSQueryRequestGenerator(String query) {
+
+ super();
+ setQuery(query);
+ setQueryType(DEFAULT_QUERY_TYPE);
+
+ }
+
+ // ------------------------------------------- public methods
+
+ /**
+ * generates Request as Message
+ */
+ public Message generateRequestMessage() throws PerfSONARException {
+
+ Message message = new Message();
+ message.setType(MESSAGE_TYPE);
+
+ Metadata meta = new Metadata();
+ meta.setId(metaId);
+
+ Subject subject = new Subject();
+ subject.setId("query");
+ subject.setSubject(query );
+ meta.setSubject(subject);
+
+ EventType evt = new EventType();
+ evt.setId("query-type");
+ evt.setEventType(queryType);
+ meta.setEventType(evt);
+
+ Data data = new Data();
+ data.setId(dataId);
+ data.setMetadataIdRef(metaId);
+
+ message.setMetadata(meta);
+ message.setData(data);
+
+ return message;
+ }
+
+
+ public String getDataId() {
+ return dataId;
+ }
+
+
+ public void setDataId(String dataId) {
+ this.dataId = dataId;
+ }
+
+
+ public String getMetaId() {
+ return metaId;
+ }
+
+
+ public void setMetaId(String metaId) {
+ this.metaId = metaId;
+ }
+
+
+ public String getQuery() {
+ return query;
+ }
+
+
+ public void setQuery(String query) {
+ this.query = query;
+ }
+
+
+ public String getQueryType() {
+ return queryType;
+ }
+
+
+ public void setQueryType(String queryType) {
+ this.queryType = queryType;
+ }
+
+
+ // -------------- TEST
---------------------------------------------------
+
+// public static void main(String[] args) throws PerfSONARException {
//
-// super();
-// setQuery(query);
-// setQueryType(queryType);
-//
-// }
-//
-//
-// /**
-// * Sets query. Query type is set to default - see: DEFAULT_QUERY_TYPE
-// * @param query
-// */
-// public LSQueryRequestGenerator(String query) {
-//
-// super();
-// setQuery(query);
-// setQueryType(DEFAULT_QUERY_TYPE);
-//
-// }
-//
-//
-// // --------------------------------------------------------- Public
methods
-//
-//
-// public Document generateRequest() throws SystemException {
-//
-// //Create document
-// Document document;
-// try {
-// document = createEmptyDocument();
-// } catch (Exception e) {
-// throw new SystemException(
-// "DOM Document creation error: "+e.getMessage());
-// }
-//
-// //create message
-// Element message = createMessageElement(
-// document, "anId", "LSQueryRequest");
-//
-// //add namespaces to message
-// message.setAttribute("xmlns",getNamespaceUri("perfsonar"));
-//
message.setAttribute("xmlns:perfsonar",getNamespaceUri("perfsonar"));
-// message.setAttribute("xmlns:nmwg",getNamespaceUri("nmwg"));
-// message.setAttribute("xmlns:ls",getNamespaceUri("ls"));
-//
message.setAttribute("xmlns:psservice",getNamespaceUri("psservice"));
-// message.setAttribute("xmlns:xquery",getNamespaceUri("xquery"));
-//
-// //create metadata
-// Element metadata = document.createElementNS(
-// getNamespaceUri("perfsonar"), "metadata");
-// metadata.setPrefix("perfsonar");
-// metadata.setAttribute("id", "meta1");
-//
-// //create subject
-// Element subject = document.createElementNS(
-// getNamespaceUri("xquery"), "subject");
-// subject.setPrefix("xquery");
-// subject.setAttribute("id", "subject1");
-// Node queryText = document.createTextNode( getQuery() );
-// subject.appendChild( queryText );
-//
-// //create characteristic
-// Element characteristic = document.createElementNS(
-// getNamespaceUri("nmwg"), "characteristic");
-// subject.setPrefix("xquery");
-// Node characteristicText = document.createTextNode(
-// getQueryType());
-// characteristic.appendChild(characteristicText);
-//
-// //build LSQueryRequest document with created elements
-//
-// message.appendChild(metadata);
-// metadata.appendChild(subject);
-// metadata.appendChild(characteristic);
-// document.appendChild(message);
-//
-// //return document
-//
-// return document;
-//
-// }
-//
-//
-// /**
-// * Set query for LSQueryRequest
-// * Can be set by:
-// * setParameter(QUERY, query);
-// * @param query
-// */
-// public void setQuery(String query) {
-//
-// setParameter(QUERY, query);
-//
-// }
-//
-//
-// /**
-// * Set query and type of query for LSQueryRequest.
-// * Can be set by:
-// * setParameter(QUERY, query);
-// * setParameter(QUERY_TYPE, queryType);
-// * @param query
-// * @param queryType
-// */
-// public void setQuery(String query, String queryType) {
-//
-// setParameter(QUERY, query);
-// setParameter(QUERY_TYPE, queryType);
-//
-// }
-//
-//
-// /**
-// * Return query
-// * @return
-// */
-// public String getQuery() {
-//
-// return getParameter(QUERY);
-//
-// }
-//
-//
-// /**
-// * Set query type for LSQueryRequest
-// * Can be set by:
-// * setParameter(QUERY_TYPE, queryType);
-// */
-// public void setQueryType(String queryType) {
-//
-// setParameter(QUERY_TYPE, queryType);
-//
-// }
-//
-// /**
-// * Return query type
-// * @return
-// */
-// public String getQueryType() {
-//
-// return getParameter(QUERY_TYPE);
-//
-// }
-//
-//
-///*
-//
-// // -------------- TEST
---------------------------------------------------
-//
-// public static void main(String[] args) throws SystemException {
-//
// LSQueryRequestGenerator request =
// new LSQueryRequestGenerator("Q U E R Y");
//
-// Document doc = request.generateRequest();
-// System.out.println(serializeDocument(doc));
+// String msgtxt =
XMLUtils.serializeXML(request.generateRequestMessage());
+// System.out.println(msgtxt);
//
// }
-//*/
-//
+
+
} //LSQueryRequestGenerator
Modified:
trunk/perfsonar/src/org/perfsonar/client/commons/xquery/XQueryExpression.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/client/commons/xquery/XQueryExpression.java
2007-06-26 19:46:42 UTC (rev 2479)
+++
trunk/perfsonar/src/org/perfsonar/client/commons/xquery/XQueryExpression.java
2007-06-29 14:39:03 UTC (rev 2480)
@@ -7,38 +7,53 @@
/**
* @author Maciej Glowiak
+ *
* XQuery expression. Can generate specific XQuery expression string
*
*/
public interface XQueryExpression {
/**
- * Method returns XQuery expression
- * @return
+ * The name of the store collection (containing LS data/metadata
*/
- public String generateExpression();
+ public static final String LS_STORE_COLLECTION_TYPE = "LSStore";
/**
- * Adds a condition to XQuery "where" clause: "xpath = value"
- * @param xpath
- * @param value
+ * The name of the control collection of LS
*/
- public void addCondition(String xpath, String value);
+ public static final String LS_STORE_CONTROL_COLLECTION_TYPE =
"LSStore-control";
+ public final static String DECLARE_NMWG_NAMESPACE =
+ "declare namespace nmwg='http://ggf.org/ns/nmwg/base/2.0/'; \n";
+
/**
- * Returns previously stored condition
- * @param xpath
- * @return
+ * Namespaces declaration for perfSONAR
*/
- public String getCondition(String xpath);
+ public final static String XQUERY_DECLARE_NAMESPACES =
+ "declare namespace
perfsonar='http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/'; \n"+
+ DECLARE_NMWG_NAMESPACE +
+ "declare namespace
psservice='http://ggf.org/ns/nmwg/tools/org/perfsonar/service/1.0/'; \n"+
+ "declare namespace nmwgt='http://ggf.org/ns/nmwg/topology/2.0/';
\n"+
+ "declare namespace
netutil='http://ggf.org/ns/nmwg/characteristic/utilization/2.0/'; \n";
+
+ public static final String SERVICE_TYPE = "psservice:serviceType";
+ public static final String SERVICE_NAME = "psservice:serviceName";
+ public static final String ACCESS_POINT = "psservice:accessPoint";
+
+ public static final String SERVICE_DESCRIPTION =
"psservice:serviceDescription";
+ public static final String ORGANIZATION_NAME =
"psservice:organization_name";
+ public static final String SERVICE_VERSION =
"psservice:serviceVersion";
+ public static final String CONTACT_EMAIL = "psservice:contact_email";
+ public static final String EVENT_TYPE = "nmwg:eventType";
/**
- * Removes previously stored condition
- * @param xpath
+ * Method returns XQuery expression
+ * @return
*/
- public void removeCondition(String xpath);
+ public String generateExpression();
+
} //XQueryExpression
Added:
trunk/perfsonar/src/org/perfsonar/client/commons/xquery/lookupService/GenericXQueryExpression.java
Property changes on:
trunk/perfsonar/src/org/perfsonar/client/commons/xquery/lookupService/GenericXQueryExpression.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted:
trunk/perfsonar/src/org/perfsonar/client/commons/xquery/lookupService/LookupInformationXQueryExpression.java
Deleted:
trunk/perfsonar/src/org/perfsonar/client/commons/xquery/lookupService/XQueryExpressionImpl.java
- perfsonar: r2480 - in trunk/perfsonar/src/org/perfsonar/client/commons: requests/lookupService xquery xquery/lookupService, svnlog, 06/29/2007
Archive powered by MHonArc 2.6.16.