Skip to Content.
Sympa Menu

perfsonar-dev - r1930 - trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType

Subject: perfsonar development work

List archive

r1930 - trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType


Chronological Thread 
  • From:
  • To:
  • Subject: r1930 - trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType
  • Date: Wed, 17 Jan 2007 10:28:40 -0500

Author: mac
Date: 2007-01-17 10:28:39 -0500 (Wed, 17 Jan 2007)
New Revision: 1930

Modified:

trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSAction.java

trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSRegisterAction.java
Log:
Bugs reported by Michael Michalis found in registration and update actions
were fixed.
Now registration fails if there is no accessPoint, no serviceType or no
serviceName (those are mandatory) or they're empty.
Some code was restructured.


Modified:
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSAction.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSAction.java
2007-01-17 15:12:11 UTC (rev 1929)
+++
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSAction.java
2007-01-17 15:28:39 UTC (rev 1930)
@@ -173,7 +173,7 @@
//don't finish parsing, there may still be other
//parameters

- }catch (RuntimeException ex) {
+ } catch (RuntimeException ex) {
logger.warn("XmlTypeLSServiceEngine: error while " +
"parsing parameters from Key");
}

Modified:
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSRegisterAction.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSRegisterAction.java
2007-01-17 15:12:11 UTC (rev 1929)
+++
trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType/LSRegisterAction.java
2007-01-17 15:28:39 UTC (rev 1930)
@@ -78,25 +78,17 @@
throw new SystemException("error.ls.no_metadata", m);
}

- //get accessPoint from Metadata - obligatory element
+ //get accessPoint from Metadata - obligatory element
+ //if it's empty or null SystemException will be thrown
+ String accessPoint = getAccessPoint(requestMetadata);
+
+ //check other mandatory elements, dont care about results
+ //if they're empty or null SystemException will be thrown
+ getServiceName(requestMetadata);
+ getServiceType(requestMetadata);

- String accessPoint = null;
- try {
- accessPoint = ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
- requestMetadata.getSubject()).getService().
- getAccessPoint().getAccessPoint();
-
- accessPoint = accessPoint.trim();
-
- } catch (RuntimeException e) {
- logger.debug("LSRegisterAction: no accessPoint");
- }
-
- //Try to get Key from Metadata
-
-
- String keyValue = getKeyFromMetadata(requestMetadata, LS_KEY);
-
+ //Try to get Key from Metadata
+ String keyValue = getKeyFromMetadata(requestMetadata, LS_KEY);

if (keyValue != null) keyValue = keyValue.trim(); //TODO: trim is
temporary

logger.debug("LSRegisterAction: LS key=["+keyValue+"]");
@@ -111,7 +103,6 @@
if (keyValue == null) { //REGISTER

//let the key value be accesspoint
-
logger.debug("LSRegisterAction: key = accessPoint");

keyValue = accessPoint;
@@ -133,9 +124,8 @@
}

//remove key element from metadata
- requestMetadata.setKey(null);
+ requestMetadata.setKey(null);

-
}

// check keyValue again, it may be accessPoint now
@@ -147,11 +137,9 @@
}


-
//========check data========


-
//Get all Data elements, suppose they all belong to metadata
//(data map is created in the constructor of Message, so Null Ptr
Exc
//won't be thrown!)
@@ -275,7 +263,12 @@
//put metadata
update.append(updateMeta);

- logger.debug("LSRegisterAction: "+((removeUpdate!=null)?"remove old
entries":"")+", insert metadata and ["+updateData.length+"] data elements");
+ logger.debug("LSRegisterAction: "+
+ ((removeUpdate!=null)?
+ "remove old entries"
+ :
+ "") + ", insert metadata and ["
+ + updateData.length+"] data elements");

for (int i=0; i<updateData.length; i++) {
update.append(updateData[i]);
@@ -320,6 +313,80 @@
}


+ /**
+ * Returns serviceType from metadata or throws SystemException if null
or empty
+ * @param requestMetadata
+ * @return service type
+ * @throws SystemException if null or empty
+ */
+ protected String getServiceType(Metadata requestMetadata) throws
SystemException {
+ //service type
+ String serviceType = null;
+ try {
+ serviceType = ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
+ requestMetadata.getSubject()).getService().
+ getServiceType().getServiceType().trim();
+ if (serviceType.equals("")) throw new RuntimeException("empty");
+ } catch (RuntimeException e) {
+ String m="LSRegisteraction: No serviceType in request -
"+e.getMessage();
+ logger.error(m);
+ throw new SystemException("error.ls.no_service_type", m);

+ }
+ return serviceType;
+ }
+
+
+ /**
+ * Returns serviceName from metadata or throws SystemException if null
or empty
+ * @param requestMetadata
+ * @return service Name
+ * @throws SystemException if null or empty
+ */
+ protected String getServiceName(Metadata requestMetadata) throws
SystemException {
+// service name
+ String serviceName = null;
+ try {
+ serviceName = ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
+ requestMetadata.getSubject()).getService().
+ getServiceName().getServiceName().trim();
+ if (serviceName.equals("")) throw new RuntimeException("empty");
+ } catch (RuntimeException e) {
+ String m="LSRegisteraction: No serviceName in request -
"+e.getMessage();
+ logger.error(m);
+ throw new SystemException("error.ls.no_service_name", m);

+ }
+ return serviceName;
+ }
+
+
+ /**
+ * Returns accessPoint from metadata or throws SystemException if null
or empty
+ * @param requestMetadata
+ * @return access point
+ * @throws SystemException if null or empty
+ */
+ protected String getAccessPoint(Metadata requestMetadata)
+ throws SystemException {
+ String accessPoint = null;
+ try {
+
+ accessPoint = ((org.ggf.ns.nmwg.tools.org.perfsonar.v1_0.Subject)
+ requestMetadata.getSubject()).getService().
+ getAccessPoint().getAccessPoint();
+ accessPoint = accessPoint.trim(); //trim
+ if (accessPoint.equals("")) throw new RuntimeException("empty");
+
+ } catch (RuntimeException e) {
+ String m="LSRegisteraction: No access_point in request -
"+e.getMessage();
+ logger.error(m);
+ throw new SystemException("error.ls.no_access_point", m);

+ }
+
+ return accessPoint;
+
+ }
+
+
// -------------------------------------------------------- Private
methods





  • r1930 - trunk/perfsonar/src/org/perfsonar/service/lookupService/xmlType, svnlog, 01/17/2007

Archive powered by MHonArc 2.6.16.

Top of Page