perfsonar-dev - perfsonar: r5384 - in branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice: . registerService
Subject: perfsonar development work
List archive
perfsonar: r5384 - in branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice: . registerService
Chronological Thread
- From:
- To:
- Subject: perfsonar: r5384 - in branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice: . registerService
- Date: Tue, 8 Dec 2009 08:06:37 -0500
Author: trzaszcz
Date: 2009-12-08 08:06:37 -0500 (Tue, 08 Dec 2009)
New Revision: 5384
Added:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/AbstractRegisterServiceEngine.java
Removed:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSGenericRegisterServiceEngine.java
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSCleanupServiceEngine.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSDeregisterServiceEngine.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSDiscoveryAction.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSKeepaliveServiceEngine.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSQueryAction.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSQueryServiceEngine.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registerService/LSRegisterServiceHelper.java
Log:
refactoring
Added:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/AbstractRegisterServiceEngine.java
Property changes on:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/AbstractRegisterServiceEngine.java
___________________________________________________________________
Name: svn:executable
+ *
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSCleanupServiceEngine.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSCleanupServiceEngine.java
2009-12-08 12:22:03 UTC (rev 5383)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSCleanupServiceEngine.java
2009-12-08 13:06:37 UTC (rev 5384)
@@ -17,7 +17,7 @@
*
*/
//TODO: refactor this class - remove LSGenericRegisterServiceEngine - it is
not ServiceEngine - this class supports only for CleanupScheduleAction !
-public class LSCleanupServiceEngine extends LSGenericRegisterServiceEngine {
+public class LSCleanupServiceEngine extends GenericLSServiceEngine {
private final Logger logger =
Logger.getLogger(LSKeepaliveServiceEngine.class.getName());
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSDeregisterServiceEngine.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSDeregisterServiceEngine.java
2009-12-08 12:22:03 UTC (rev 5383)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSDeregisterServiceEngine.java
2009-12-08 13:06:37 UTC (rev 5384)
@@ -15,7 +15,7 @@
* @author Maciej Glowiak,Slawomir Trzaszczka
*
*/
-public class LSDeregisterServiceEngine extends
LSGenericRegisterServiceEngine {
+public class LSDeregisterServiceEngine extends GenericLSServiceEngine {
private final Logger logger = Logger
.getLogger(LSDeregisterServiceEngine.class);
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSDiscoveryAction.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSDiscoveryAction.java
2009-12-08 12:22:03 UTC (rev 5383)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSDiscoveryAction.java
2009-12-08 13:06:37 UTC (rev 5384)
@@ -16,7 +16,7 @@
/**
* Discovery action (LS Query / Discovery)
*
- * @author Maciej Glowiak
+ * @author Maciej Glowiak, Slawomir Trzaszczka
*
*/
public class LSDiscoveryAction {
Deleted:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSGenericRegisterServiceEngine.java
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSKeepaliveServiceEngine.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSKeepaliveServiceEngine.java
2009-12-08 12:22:03 UTC (rev 5383)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSKeepaliveServiceEngine.java
2009-12-08 13:06:37 UTC (rev 5384)
@@ -10,25 +10,17 @@
/**
* KEEPALIVE - register/keepalive Action
*
- * @author Maciej Glowiak
- * Trzaszcz
+ * @author Maciej Glowiak, Slawomir Trzaszcz
*
*/
-public class LSKeepaliveServiceEngine extends LSGenericRegisterServiceEngine
{
+public class LSKeepaliveServiceEngine extends AbstractRegisterServiceEngine {
- // --------------------------------------------------------------
Constants
- private static final Logger logger = Logger
- .getLogger(LSKeepaliveServiceEngine.class.getName());
+ private final Logger logger =
Logger.getLogger(LSKeepaliveServiceEngine.class);
-
- // ------------------------------------------------------------
Constructor
-
public LSKeepaliveServiceEngine() throws PerfSONARException {
-
super();
-
}
@@ -113,4 +105,4 @@
return requestMetadata;
}
-} // LSKeepaliveAction
+}
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSQueryAction.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSQueryAction.java
2009-12-08 12:22:03 UTC (rev 5383)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSQueryAction.java
2009-12-08 13:06:37 UTC (rev 5384)
@@ -18,8 +18,7 @@
*/
public class LSQueryAction {
- private static final Logger logger =
Logger.getLogger(LSQueryAction.class
- .getName());
+ private final Logger logger = Logger.getLogger(LSQueryAction.class);
private LookupServiceDAO dao;
@@ -31,36 +30,17 @@
ServiceMessage serviceResponse, Message message,
Element subject,
String lsOutput) throws PerfSONARException {
- // native vs escaped
- // <nmwg:parameter name="lsOutput">native</nmwg:parameter>
- // if not null check if different from "escaped"
- // if (lsOutput!=null) {
- // if (!"escaped".equals(lsOutput)) {
- // String m =
- // "This version of LS supports only [escaped] results of
xquery (by default). You used ["+lsOutput+"] value.";
- // logger.error(m);
- // throw new
PerfSONARException("error/ls/output_not_accepted",m);
- // }
- // }
-
// get subject query
String query = subject.getText();
logger.debug("Query=[" + query + "]");
- // TEMPORARY
- // convert query, change > = ">", < = "<".
- // query = convertEntitiesToCharacters(query);
-
// Performing XQuery operation on the database
logger.debug("Perform query");
- /* ------------- XQuery ------------- */
XMLDBResult results = dao.performXQuery(query);
- /* ------------- XQuery ------------- */
-
logger
.debug("Got [" + results.getElementsCount()
+ "] results from DB");
@@ -103,22 +83,6 @@
}
- /*
- * public String convertEntitiesToCharacters(String input) {
- *
- * String output = input;
- *
- * //< output = input.replaceAll("\\<\\;", "<"); //> output =
- * output.replaceAll("\\>\\;", ">"); //& output =
- * output.replaceAll("\\&\\;", "&"); //' output =
- * output.replaceAll("\\&apos\\;", "'"); //" output =
- * output.replaceAll("\\"\\;", "\"");
- *
- * return output;
- *
- * }
- */
-
private Element createDatumElement(){
Element el=new Element("datum", "psservice",
"http://ggf.org/ns/nmwg/tools/org/perfsonar/service/1.0/");
@@ -126,4 +90,4 @@
}
-} // LS
+}
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSQueryServiceEngine.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSQueryServiceEngine.java
2009-12-08 12:22:03 UTC (rev 5383)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSQueryServiceEngine.java
2009-12-08 13:06:37 UTC (rev 5384)
@@ -1,9 +1,12 @@
package org.perfsonar.service.lookupservice;
+import java.util.Collection;
+
import org.apache.log4j.Logger;
import org.perfsonar.base2.service.exceptions.PerfSONARException;
import org.perfsonar.base2.service.requesthandler.ServiceMessage;
import org.perfsonar.base2.xml.Element;
+import org.perfsonar.base2.xml.nmwg.EventType;
import org.perfsonar.base2.xml.nmwg.Message;
import org.perfsonar.base2.xml.nmwg.Metadata;
import org.perfsonar.base2.xml.nmwg.Parameters;
@@ -11,20 +14,17 @@
/**
* LS Query Action
*
- * @author Maciej Glowiak
+ * @author Maciej Glowiak, Slawomir Trzaszczka
*
*/
public class LSQueryServiceEngine extends GenericLSServiceROEngine {
- // --------------------------------------------------------------
Constants
+ private final Logger logger =
Logger.getLogger(LSQueryServiceEngine.class);
- private static final Logger logger = Logger
- .getLogger(LSQueryServiceEngine.class.getName());
-
/**
* Supported query types, eventType (e.g. "xquery")
*/
- private String[] queryEventTypes = {
+ private final String[] queryEventTypes = {
"service.lookup.xpath", // DEPRECATED
"service.lookup.xquery", // DEPRECATED
"http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/xquery/1.0",
@@ -32,18 +32,12 @@
"http://ogf.org/ns/nmwg/tools/org/perfsonar/service/lookup/discovery/xquery/2.0",
"http://ogf.org/ns/nmwg/tools/org/perfsonar/service/lookup/query/xquery/2.0",
};
- private String[] discoveryEventTypes = {
"http://ogf.org/ns/nmwg/tools/org/perfsonar/service/lookup/discovery/summary/2.0",
};
+ private final String[] discoveryEventTypes = {
"http://ogf.org/ns/nmwg/tools/org/perfsonar/service/lookup/discovery/summary/2.0"};
public LSQueryServiceEngine() throws PerfSONARException {
super();
}
- // ----------------------------------------------------- instance
variables
-
- // -----------------------------------------------------------
Constructor
-
- // --------------------------------------------------------- Public
methods
-
public void takeAction(ServiceMessage serviceRequest,
ServiceMessage serviceResponse) throws
PerfSONARException {
@@ -67,33 +61,42 @@
Metadata m = (Metadata) e;
// try to get event type
- try {
- eventType =
m.getFirstEventType().getEventType();
+ EventType et = m.getFirstEventType();
+ Collection<Element> subjectElement =
m.getChildren("subject");
+
+ if (et == null) {
+ // if there is no eventType
+ String message = "EventType not
found, unknown or not supported";
+ logger.debug(message);
+ throw new
PerfSONARException("error/no_event_type", message);
+ } else if (subjectElement == null ||
subjectElement.size() != 1) {
+ // if there is no subject
+ String message = "Subject not found";
+ logger.debug(message);
+ throw new
PerfSONARException("error/no_subject", message);
+ } else {
+ // subject and eventTypes occur -
process
+ eventType = et.getEventType();
logger.debug("Found eventType
[+eventType+]");
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- // try to get subject
- try {
- subject =
m.getChildren("subject").iterator().next();
+ // try to get subject
+ subject =
subjectElement.iterator().next();
metadataWithSubject = m;
logger.debug("Found subject
(namespace "
+
subject.getNamespacePrefix() + ")");
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- // try to get parameters
- Parameters parameters = m
-
.getParameters("http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/xquery/1.0/");
- if (parameters!=null &&
parameters.getChildren("parameters") != null) {
- lsOutput =
parameters.getFirstParameter("lsOutput")
- .getValue();
- logger.debug("Found lsOutput
parameter [" + lsOutput + "]");
+ // try to get parameters
+ Parameters parameters = m
+
.getParameters("http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/xquery/1.0/");
+ if (parameters != null
+ &&
parameters.getChildren("parameters") != null) {
+ lsOutput =
parameters.getFirstParameter("lsOutput")
+ .getValue();
+ logger.debug("Found lsOutput
parameter [" + lsOutput
+ + "]");
+ }
}
-
}
}
@@ -110,23 +113,23 @@
logger.debug("EventType [" + eventType
+ "] accepted, taking LSDiscovery
action");
LSDiscoveryAction discovery = new
LSDiscoveryAction(dao); // process
-
// DISCOVERY
- logger.debug("!!!!!!!!! subject:" + subject);
+ logger.debug("subject:" + subject);
discovery.performAction(serviceRequest,
serviceResponse,
requestMessage, metadataWithSubject,
subject);
} else {
- String m = "Event Type [" + eventType
- + "] not found, unknown or not
supported";
- logger.error(m);
- throw new PerfSONARException("error/no_event_type",
m);
+ throw new PerfSONARException("error/unsupported query
message",
+ "Unsupported query message");
}
}
private boolean eventTypeInArray(String needle, String[] haystack) {
+
+ // TODO: this piece of code occurs somewhere in code ...
+
for (String h : haystack) {
if (h.equals(needle))
return true;
@@ -144,4 +147,4 @@
return eventTypeInArray(queryType, queryEventTypes);
}
-} // LSLookupAction
+}
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registerService/LSRegisterServiceHelper.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registerService/LSRegisterServiceHelper.java
2009-12-08 12:22:03 UTC (rev 5383)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registerService/LSRegisterServiceHelper.java
2009-12-08 13:06:37 UTC (rev 5384)
@@ -15,7 +15,7 @@
import org.perfsonar.base2.xml.nmwg.Parameter;
import org.perfsonar.base2.xml.nmwg.Parameters;
import org.perfsonar.base2.xml.nmwg.Subject;
-import org.perfsonar.service.lookupservice.LSGenericRegisterServiceEngine;
+import org.perfsonar.service.lookupservice.AbstractRegisterServiceEngine;
import org.perfsonar.service.lookupservice.LSRegisterServiceEngine;
import org.perfsonar.service.lookupservice.registration.LsTTLParameterStatus;
import org.perfsonar.service.lookupservice.storage.LookupServiceDAO;
@@ -30,7 +30,7 @@
*
*/
public abstract class LSRegisterServiceHelper extends
- LSGenericRegisterServiceEngine {
+ AbstractRegisterServiceEngine {
protected static final Logger logger = Logger
.getLogger(LSRegisterServiceEngine.class.getName());
- perfsonar: r5384 - in branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice: . registerService, svnlog, 12/08/2009
Archive powered by MHonArc 2.6.16.