perfsonar-dev - perfsonar: r5327 - in trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient: data/implementation data/topology level1 level2 xml
Subject: perfsonar development work
List archive
perfsonar: r5327 - in trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient: data/implementation data/topology level1 level2 xml
Chronological Thread
- From:
- To:
- Subject: perfsonar: r5327 - in trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient: data/implementation data/topology level1 level2 xml
- Date: Mon, 26 Oct 2009 10:30:40 -0400
Author: krzjed
Date: 2009-10-26 10:30:40 -0400 (Mon, 26 Oct 2009)
New Revision: 5327
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/implementation/EventTypeImpl.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/implementation/LookupServiceImpl.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/implementation/ServiceImpl.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/ClassContainer.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/HandlersManager.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/SpecificTopologyElementHandler.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/TopologyElementHandlerFactory.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/UnknownTopologyElement.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/UnknownTopologyElementHandler.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/UriNameContainer.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/LsTopologyQuery.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level2/Level2Impl.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/DiscoverySAXHandler.java
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/ResponseParser.java
Log:
Code javadoced
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/implementation/EventTypeImpl.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/implementation/EventTypeImpl.java
2009-10-26 08:40:00 UTC (rev 5326)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/implementation/EventTypeImpl.java
2009-10-26 14:30:40 UTC (rev 5327)
@@ -2,13 +2,31 @@
import org.perfsonar.lsclient.data.EventType;
+/**
+ *
{@link
EventType} implementation
+ *
+ * @author krzjed (PSNC)
+ *
+ */
public class EventTypeImpl implements EventType {
+ /**
+ * Event type value
+ */
private String value;
+ /**
+ * Constructor
+ */
public EventTypeImpl() {
}
+ /**
+ * Constructor
+ *
+ * @param value
+ * event type set
+ */
public EventTypeImpl(String value) {
this.value = value;
}
@@ -35,6 +53,9 @@
return true;
}
+ /**
+ * Getter for value
+ */
public String getValue() {
return this.value;
}
@@ -52,10 +73,18 @@
return result;
}
+ /**
+ * Setter for value
+ */
public void setValue(String value) {
this.value = value;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
@Override
public String toString() {
return value;
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/implementation/LookupServiceImpl.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/implementation/LookupServiceImpl.java
2009-10-26 08:40:00 UTC (rev 5326)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/implementation/LookupServiceImpl.java
2009-10-26 14:30:40 UTC (rev 5327)
@@ -2,11 +2,27 @@
import java.net.URI;
-public class LookupServiceImpl extends ServiceImpl{
+import org.perfsonar.lsclient.data.LookupService;
+/**
+ *
{@link
LookupService} implementation
+ *
+ * @author krzjed (PSNC
+ * */
+public class LookupServiceImpl extends ServiceImpl {
+
+ /**
+ * Constructor
+ */
public LookupServiceImpl() {
}
+ /**
+ * Setter for endpoint URI
+ *
+ * @param endPoint
+ * to set
+ */
public LookupServiceImpl(URI endPoint) {
super(endPoint);
}
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/implementation/ServiceImpl.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/implementation/ServiceImpl.java
2009-10-26 08:40:00 UTC (rev 5326)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/implementation/ServiceImpl.java
2009-10-26 14:30:40 UTC (rev 5327)
@@ -6,7 +6,15 @@
import org.perfsonar.lsclient.data.LookupService;
import org.perfsonar.lsclient.data.Service;
-public class ServiceImpl implements AuthorativeLookupservice {
+/**
+ *
+ * Implementation of
{@link
Service}
+ *
+ * @author krzjed (PSNC)
+ *
+ */
+public class ServiceImpl implements AuthorativeLookupservice,
+ Comparable<Service> {
private AuthorativeLookupservice authorativeLookupService;
private String contactEmail;
@@ -26,19 +34,36 @@
public ServiceImpl() {
}
+ /**
+ * Constructor
+ *
+ * @param endPoint
+ * - endpoint URL of service
+ */
public ServiceImpl(URI endPoint) {
this.endPoint = endPoint;
}
+ /**
+ * Comparating method
+ */
public int compareTo(LookupService o) {
return endPoint.compareTo(o.getEndPoint());
}
+ /**
+ * Comparating method
+ */
public int compareTo(Service arg0) {
return this.endPoint.toString()
.compareTo(arg0.getEndPoint().toString());
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
@Override
public boolean equals(Object obj) {
if (this == obj)
@@ -56,14 +81,23 @@
return true;
}
+ /**
+ * Getter
+ */
public AuthorativeLookupservice getAuthorativeLookupService() {
return this.authorativeLookupService;
}
+ /**
+ * Getter
+ */
public String getContactEmail() {
return contactEmail;
}
+ /**
+ * Getter
+ */
public String getDescription() {
return this.description;
}
@@ -72,22 +106,39 @@
return this.endPoint;
}
+ /**
+ * Getter
+ */
public String getName() {
return this.name;
}
+ /**
+ * Getter
+ */
public String getOrganization() {
return this.organization;
}
+ /**
+ * Getter
+ */
public String getType() {
return type;
}
+ /**
+ * Getter
+ */
public String getVersion() {
return version;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
@Override
public int hashCode() {
final int prime = 31;
@@ -97,39 +148,68 @@
return result;
}
+ /**
+ * Setter
+ */
public void setAuthorativeLookupService(
AuthorativeLookupservice authorativeLookupService) {
this.authorativeLookupService = authorativeLookupService;
}
+ /**
+ * Setter
+ */
public void setContactEmail(String contactEmail) {
this.contactEmail = contactEmail;
}
+ /**
+ * Setter
+ */
public void setDescription(String description) {
this.description = description;
}
+ /**
+ * Setter
+ */
public void setEndPoint(URI endPoint) {
this.endPoint = endPoint;
}
+ /**
+ * Setter
+ */
public void setName(String name) {
this.name = name;
}
+ /**
+ * Setter
+ */
public void setOrganization(String organization) {
this.organization = organization;
}
+ /**
+ * Setter
+ */
public void setType(String type) {
this.type = type;
}
+ /**
+ * Setter
+ */
public void setVersion(String version) {
this.version = version;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
@Override
public String toString() {
return String.valueOf(endPoint);
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/ClassContainer.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/ClassContainer.java
2009-10-26 08:40:00 UTC (rev 5326)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/ClassContainer.java
2009-10-26 14:30:40 UTC (rev 5327)
@@ -1,19 +1,52 @@
package org.perfsonar.ri.lsclient.data.topology;
+/**
+ * Class for storing class object of
{@link
SpecificTopologyElementHandler}
+ * implementation
+ *
+ * @author krzjed (PSNC)
+ *
+ */
class ClassContainer {
+ /**
+ * Class object of
{@link
SpecificTopologyElementHandler} implementation
+ */
private Class<? extends SpecificTopologyElementHandler> handlerClass;
+
+ /**
+ * Priority (if handler exists in
{@link
HandlersManager} and there is given
+ * new one that has higher value old one is replaced by new)
+ */
private int priority;
+ /**
+ * Constructor
+ *
+ * @param priority
+ * - priority of handler class
+ * @param handlerClass
+ * - class object of handler
+ */
public ClassContainer(int priority,
Class<? extends SpecificTopologyElementHandler> handlerClass) {
this.priority = priority;
this.handlerClass = handlerClass;
}
+ /**
+ * Return handler class
+ *
+ * @return handler class
+ */
public Class<? extends SpecificTopologyElementHandler> getHandlerClass()
{
return handlerClass;
}
+ /**
+ * Returns priority of the class
+ *
+ * @return priority of the class
+ */
public int getPriority() {
return priority;
}
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/HandlersManager.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/HandlersManager.java
2009-10-26 08:40:00 UTC (rev 5326)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/HandlersManager.java
2009-10-26 14:30:40 UTC (rev 5327)
@@ -5,30 +5,69 @@
import org.apache.log4j.Logger;
+/**
+ * Class maintaining handlers
+ *
+ * @author krzjed (PSNC)
+ *
+ */
public class HandlersManager {
+ /**
+ * Singleton instance
+ */
private static HandlersManager manager = new HandlersManager();
+ /**
+ * Adds handler class
({@link
SpecificTopologyElementHandler} implemantation
+ * with
{@link
Handler} annotation)
+ *
+ * @param handlerClass
+ * class to add
+ */
public static void addHandlerClass(
Class<? extends SpecificTopologyElementHandler> handlerClass) {
getInstance().addHandlerClassToMap(handlerClass);
}
+ /**
+ * Removes all handlers
+ */
public static void clearHandlers() {
getInstance().clearHandlersMap();
}
+ /**
+ * Returns instance
+ *
+ * @return instance
+ */
static HandlersManager getInstance() {
return manager;
}
+ /**
+ * Map containing handlers
+ */
private Map<UriNameContainer, ClassContainer> handlerMap = new
HashMap<UriNameContainer, ClassContainer>();
+ /**
+ * Log4j logger
+ */
protected Logger logger = Logger.getLogger(this.getClass());
+ /**
+ * Constructor
+ */
private HandlersManager() {
}
+ /**
+ * Adds handler class to map
+ *
+ * @param handlerClass
+ * handler class to add
+ */
void addHandlerClassToMap(
Class<? extends SpecificTopologyElementHandler> handlerClass) {
synchronized (this) {
@@ -55,12 +94,24 @@
}
}
+ /**
+ * Removes all handlers from map
+ */
void clearHandlersMap() {
synchronized (this) {
handlerMap.clear();
}
}
+ /**
+ * Returns handler class for given uri and tag name
+ *
+ * @param uri
+ * namespace of tag
+ * @param name
+ * name of tag
+ * @return handler class for given uri and tag name
+ */
Class<? extends SpecificTopologyElementHandler> getHandlerClass(String
uri,
String name) {
synchronized (this) {
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/SpecificTopologyElementHandler.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/SpecificTopologyElementHandler.java
2009-10-26 08:40:00 UTC (rev 5326)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/SpecificTopologyElementHandler.java
2009-10-26 14:30:40 UTC (rev 5327)
@@ -16,6 +16,7 @@
* <ul>
* <li>Inherit this class
* <li>Have annotation
{@link
Handler}
+ * <li>Have constructor with
{@link
Attributes} parameter
* </ul>
*
* @author krzjed (PSNC)
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/TopologyElementHandlerFactory.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/TopologyElementHandlerFactory.java
2009-10-26 08:40:00 UTC (rev 5326)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/TopologyElementHandlerFactory.java
2009-10-26 14:30:40 UTC (rev 5327)
@@ -54,6 +54,23 @@
constructor);
}
+ /**
+ * Creates instance with given constructor
+ *
+ * @param uri
+ * namespace uri of opening tag
+ * @param name
+ * local name of opening tag
+ * @param qName
+ * qualified name of openning tag
+ * @param attributes
+ * attributes of tag
+ * @param namespaces
+ * namespaces opened before tag
+ * @param constructor
+ * constructor of tag handler
+ * @return
{@link
SpecificTopologyElementHandler} instance
+ */
private static SpecificTopologyElementHandler createInstance(String uri,
String name, String qName, Attributes attributes,
Map<String, String> namespaces,
@@ -83,6 +100,14 @@
}
}
+ /**
+ * Retrieves constructor from class
+ *
+ * @param handlerClass
+ * class to retrieve constructor from
+ * @return Constructor of
{@link
SpecificTopologyElementHandler}
+ * specialization
+ */
private static Constructor<? extends SpecificTopologyElementHandler>
retrieveConstructor(
Class<? extends SpecificTopologyElementHandler> handlerClass) {
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/UnknownTopologyElement.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/UnknownTopologyElement.java
2009-10-26 08:40:00 UTC (rev 5326)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/UnknownTopologyElement.java
2009-10-26 14:30:40 UTC (rev 5327)
@@ -12,13 +12,29 @@
*/
public class UnknownTopologyElement extends GenericTopologyElement {
+ /**
+ * Urn-formatted (http://code.google.com/p/perfsonar-ps/wiki/URNs) id of
+ * Topology Element
+ */
private String id = "";
+ /**
+ * XML document containing Topology Element information
+ */
private String xmlDescription;
+ /**
+ * Constructor
+ */
UnknownTopologyElement() {
}
+ /**
+ * Getter for Urn-formatted
+ * (http://code.google.com/p/perfsonar-ps/wiki/URNs) id
+ *
+ * @return Topology Element ID
+ */
public String getId() {
return id;
}
@@ -39,14 +55,32 @@
return null;
}
+ /**
+ * Getter for XML document containing Topology Element information
+ *
+ * @return XML document containing Topology Element information
+ */
public String getXmlDescription() {
return xmlDescription;
}
+ /**
+ * Setter for Urn-formatted
+ * (http://code.google.com/p/perfsonar-ps/wiki/URNs) id
+ *
+ * @param id
+ * Topology Element ID
+ */
void setId(String id) {
this.id = id;
}
+ /**
+ * Setter for XML document containing Topology Element information
+ *
+ * @param xmlDescription
+ * XML document containing Topology Element information
+ */
void setXmlDescription(String xmlDescription) {
this.xmlDescription = xmlDescription;
}
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/UnknownTopologyElementHandler.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/UnknownTopologyElementHandler.java
2009-10-26 08:40:00 UTC (rev 5326)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/UnknownTopologyElementHandler.java
2009-10-26 14:30:40 UTC (rev 5327)
@@ -25,6 +25,20 @@
private Map<String, String> localNamespaces = new HashMap<String,
String>();
+ /**
+ * Constructor
+ *
+ * @param uri
+ * namespace uri of opening tag
+ * @param name
+ * local name of opening tag
+ * @param qName
+ * qualified name of openning tag
+ * @param attributes
+ * attributes of tag
+ * @param namespaces
+ * namespaces opened before tag
+ */
public UnknownTopologyElementHandler(String uri, String name, String
qName,
Attributes attributes, Map<String, String> namespaces) {
this.qName = qName;
@@ -49,6 +63,13 @@
element.setId(id);
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.perfsonar.ri.lsclient.data.topology.SpecificTopologyElementHandler
+ * #getTopologyElements()
+ */
@Override
public Set<GenericTopologyElement> getTopologyElements() {
if (!finished) {
@@ -64,17 +85,36 @@
return set;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ *
org.xml.sax.helpers.DefaultHandler#startPrefixMapping(java.lang.String,
+ * java.lang.String)
+ */
@Override
public void startPrefixMapping(String prefix, String uri)
throws SAXException {
localNamespaces.put(prefix, uri);
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.xml.sax.helpers.DefaultHandler#endPrefixMapping(java.lang.String)
+ */
@Override
public void endPrefixMapping(String prefix) throws SAXException {
localNamespaces.remove(prefix);
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String,
+ * java.lang.String, java.lang.String, org.xml.sax.Attributes)
+ */
@Override
public void startElement(String uri, String localName, String name,
Attributes attributes) throws SAXException {
@@ -97,6 +137,12 @@
xmlBuilder.append(">");
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String,
+ * java.lang.String, java.lang.String)
+ */
@Override
public void endElement(String uri, String localName, String name)
throws SAXException {
@@ -105,6 +151,11 @@
xmlBuilder.append(">");
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
+ */
@Override
public void characters(char[] ch, int start, int length)
throws SAXException {
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/UriNameContainer.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/UriNameContainer.java
2009-10-26 08:40:00 UTC (rev 5326)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/data/topology/UriNameContainer.java
2009-10-26 14:30:40 UTC (rev 5327)
@@ -1,14 +1,33 @@
package org.perfsonar.ri.lsclient.data.topology;
+/**
+ * Container for namespace uri and name of tag
+ *
+ * @author krzjed
+ *
+ */
class UriNameContainer {
private String name;
private String uri;
+ /**
+ * Constructor
+ *
+ * @param name
+ * local name of tag
+ * @param uri
+ * namespace uri
+ */
protected UriNameContainer(String name, String uri) {
this.name = name;
this.uri = uri;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
@Override
public boolean equals(Object obj) {
if (this == obj)
@@ -31,6 +50,11 @@
return true;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
@Override
public int hashCode() {
final int prime = 31;
@@ -40,6 +64,11 @@
return result;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
@Override
public String toString() {
return "[" + uri + ":" + name + "]";
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/LsTopologyQuery.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/LsTopologyQuery.java
2009-10-26 08:40:00 UTC (rev 5326)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level1/LsTopologyQuery.java
2009-10-26 14:30:40 UTC (rev 5327)
@@ -6,56 +6,60 @@
import org.perfsonar.lsclient.data.ServiceType;
import org.perfsonar.lsclient.data.TopologyElement;
+
public abstract class LsTopologyQuery {
- protected final String topologyElementCondition;
- protected final String eventTypeCondition;
+ protected final String topologyElementCondition;
+ protected final String eventTypeCondition;
- public LsTopologyQuery(Set<TopologyElement> elements, Set<EventType>
eventTypes, Set<ServiceType> type) {
- topologyElementCondition =
getTopologyElementCondition(elements);
- eventTypeCondition = getEventTypeCondition(eventTypes);
- }
+ public LsTopologyQuery(Set<TopologyElement> elements,
+ Set<EventType> eventTypes, Set<ServiceType> type) {
+ topologyElementCondition = getTopologyElementCondition(elements);
+ eventTypeCondition = getEventTypeCondition(eventTypes);
+ }
- private String getTopologyElementCondition(Set<TopologyElement>
elements) {
- if(elements == null || !elements.isEmpty()) {
- return "true()";
- }
-
- // TODO ??
- return "true()";
- }
+ private String getTopologyElementCondition(Set<TopologyElement>
elements) {
+ if (elements == null || !elements.isEmpty()) {
+ return "true()";
+ }
- private String getEventTypeCondition(Set<EventType> eventTypes) {
- if(eventTypes == null || eventTypes.isEmpty()) {
- return "true()";
- }
-
- StringBuilder condition = new StringBuilder();
- boolean first = true;
- for(EventType eventType : eventTypes) {
- if(!first) {
- condition.append(" or ");
- }
-
condition.append("nmwg:metadata/nmwg:parameters/nmwg:parameter/@value='");
- condition.append(eventType.getValue());
- condition.append("'");
- first = false;
- }
-
- return condition.toString();
- }
+ // TODO ??
+ return "true()";
+ }
- @Override
- public String toString() {
- String selectIds =
"/nmwg:store[@type=\'LSStore\']/nmwg:data["+eventTypeCondition+"]/@metadataIdRef";
- return
- "declare namespace
perfsonar=\"http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/\"; \n" +
- "declare namespace nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";
\n" +
- "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" +
- "declare namespace
summary=\"http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/summarization/2.0/\";
\n" +
- "\n" +
-
"/nmwg:store[@type='LSStore']/nmwg:metadata[@id
= " + selectIds + "]/perfsonar:subject/psservice:service";
- }
+ private String getEventTypeCondition(Set<EventType> eventTypes) {
+ if (eventTypes == null || eventTypes.isEmpty()) {
+ return "true()";
+ }
+
+ StringBuilder condition = new StringBuilder();
+ boolean first = true;
+ for (EventType eventType : eventTypes) {
+ if (!first) {
+ condition.append(" or ");
+ }
+ condition
+
.append("nmwg:metadata/nmwg:parameters/nmwg:parameter/@value='");
+ condition.append(eventType.getValue());
+ condition.append("'");
+ first = false;
+ }
+
+ return condition.toString();
+ }
+
+ @Override
+ public String toString() {
+ String selectIds =
"/nmwg:store[@type=\'LSStore\']/nmwg:data["
+ + eventTypeCondition + "]/@metadataIdRef";
+ return "declare namespace
perfsonar=\"http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/\"; \n"
+ + "declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; \n"
+ + "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"
+ + "declare namespace
summary=\"http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/summarization/2.0/\";
\n"
+ + "\n"
+ +
"/nmwg:store[@type='LSStore']/nmwg:metadata[@id
= "
+ + selectIds + "]/perfsonar:subject/psservice:service";
+ }
}
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level2/Level2Impl.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level2/Level2Impl.java
2009-10-26 08:40:00 UTC (rev 5326)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/level2/Level2Impl.java
2009-10-26 14:30:40 UTC (rev 5327)
@@ -2,7 +2,6 @@
import org.perfsonar.lsclient.Level0LsClientInterface;
import org.perfsonar.lsclient.Level1LsClientInterface;
-import org.perfsonar.lsclient.Level2LsClientInterface;
import org.perfsonar.lsclient.helpers.AbstractLevel2;
public class Level2Impl extends AbstractLevel2 {
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/DiscoverySAXHandler.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/DiscoverySAXHandler.java
2009-10-26 08:40:00 UTC (rev 5326)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/DiscoverySAXHandler.java
2009-10-26 14:30:40 UTC (rev 5327)
@@ -4,6 +4,7 @@
import java.net.URISyntaxException;
import org.apache.log4j.Logger;
+import org.perfsonar.lsclient.data.Service;
import org.perfsonar.ri.lsclient.data.implementation.ServiceImpl;
import org.perfsonar.ri.lsclient.handlers.ServiceHandler;
import org.perfsonar.ri.lsclient.lsinfo.Namespaces;
@@ -11,26 +12,86 @@
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
+/**
+ * Class for parsing Discovery Response
+ *
+ * @author krzjed
+ *
+ */
public class DiscoverySAXHandler extends DefaultHandler {
+ /**
+ * Object for handling newly parsed
{@link
Service} instance
+ */
private ServiceHandler handler;
+ /**
+ * Parsing is in data tag
+ */
private boolean inData;
+ /**
+ * Parsing is in metadata tag (in data tag)
+ */
private boolean inMetadata;
+ /**
+ * Parsing is in subject tag
+ */
private boolean inSubject;
+ /**
+ * Parsing is in service tag
+ */
private boolean inService;
+ /**
+ * Parsing is in service name tag
+ */
private boolean inName;
+ /**
+ * Parsing is in access point tag
+ */
private boolean inAccessPoint;
+ /**
+ * Parsing is in type tag
+ */
private boolean inType;
+ /**
+ * Parsing is in description tag
+ */
private boolean inDescription;
+ /**
+ * Parsing is in version tag
+ */
private boolean inVersion;
+ /**
+ * Parsing is in organization tag
+ */
private boolean inOrganization;
+ /**
+ * Parsing is in email tag
+ */
private boolean inEmail;
+ /**
+ *
{@link
Service} currently being parsed
+ */
private ServiceImpl service;
+ /**
+ * Logger
+ */
protected Logger logger = Logger.getLogger(this.getClass());
+ /**
+ * Constructor
+ *
+ * @param handler
+ * for parsed
{@link
Service} instances
+ */
public DiscoverySAXHandler(ServiceHandler handler) {
this.handler = handler;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String,
+ * java.lang.String, java.lang.String, org.xml.sax.Attributes)
+ */
@Override
public void startElement(String uri, String localName, String name,
Attributes attributes) throws SAXException {
@@ -54,6 +115,9 @@
}
}
+ /**
+ * Tag inside Service tag opened
+ */
public void startServiceElement(String uri, String localName, String
name,
Attributes attributes) throws SAXException {
if (uri.equals(Namespaces.PSSERVICE) &&
localName.equals("serviceName")) {
@@ -79,6 +143,12 @@
}
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String,
+ * java.lang.String, java.lang.String)
+ */
@Override
public void endElement(String uri, String localName, String name)
throws SAXException {
@@ -99,6 +169,9 @@
}
}
+ /**
+ * Tag inside Service tag closed
+ */
public void endServiceElement(String uri, String localName, String name)
{
if (inName && uri.equals(Namespaces.PSSERVICE)
&& localName.equals("serviceName")) {
@@ -128,6 +201,11 @@
}
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
+ */
@Override
public void characters(char[] ch, int start, int length)
throws SAXException {
Modified:
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/ResponseParser.java
===================================================================
---
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/ResponseParser.java
2009-10-26 08:40:00 UTC (rev 5326)
+++
trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient/xml/ResponseParser.java
2009-10-26 14:30:40 UTC (rev 5327)
@@ -8,8 +8,10 @@
import javax.xml.parsers.SAXParserFactory;
import org.perfsonar.lsclient.LsQueryException;
+import org.perfsonar.lsclient.data.Service;
import org.perfsonar.ri.lsclient.handlers.ServiceHandler;
import org.perfsonar.ri.lsclient.handlers.ServiceMeasurementMetadataHandler;
+import org.perfsonar.ri.lsclient.level1.DiscoveryQuery;
import org.xml.sax.SAXException;
/**
@@ -26,7 +28,7 @@
* @param is
* stream containing response
* @param metadataHandler
- * object handling newly parsed
+ * object for handling newly parsed
*
{@link
ServiceMeasurementMetadata}
* @throws ParserConfigurationException
* Sax problems
@@ -58,6 +60,22 @@
}
}
+ /**
+ * Parses
{@link
DiscoveryQuery} result
+ *
+ * @param is
+ * stream containing response
+ * @param serviceHandlerobject
+ * for handling newly parsed
{@link
Service}s
+ * @throws ParserConfigurationException
+ * Sax problems
+ * @throws SAXException
+ * Sax problems
+ * @throws LsQueryException
+ * when problems with executing query occurs
+ * @throws IOException
+ * Connection to LS problems
+ */
public static void parseDiscoveryResponse(InputStream is,
ServiceHandler serviceHandler) throws
ParserConfigurationException,
SAXException, IOException, LsQueryException {
- perfsonar: r5327 - in trunk/ps-mdm-lsclient-impl/src/main/java/org/perfsonar/ri/lsclient: data/implementation data/topology level1 level2 xml, svnlog, 10/26/2009
Archive powered by MHonArc 2.6.16.