[MOBY-guts] biomoby commit
Eddie Kawas
kawas at pub.open-bio.org
Thu Mar 23 19:10:32 UTC 2006
kawas
Thu Mar 23 14:10:31 EST 2006
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier
In directory pub.open-bio.org:/tmp/cvs-serv11688/org/biomoby/registry/rdfagent/verifier
Modified Files:
MobyServiceComparator.java Processor.java
Log Message:
updated the agent so that if a modified service doesnt have an updated revision, then the agent will not update the service.
moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier MobyServiceComparator.java,1.3,1.4 Processor.java,1.14,1.15
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/MobyServiceComparator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/MobyServiceComparator.java 2006/03/15 17:57:07 1.3
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/MobyServiceComparator.java 2006/03/23 19:10:31 1.4
@@ -5,6 +5,7 @@
import java.util.Map;
import org.biomoby.shared.MobyData;
+import org.biomoby.shared.MobyException;
import org.biomoby.shared.MobyNamespace;
import org.biomoby.shared.MobyPrimaryDataSet;
import org.biomoby.shared.MobyPrimaryDataSimple;
@@ -21,25 +22,25 @@
*
* <pre>
* <code>
- * // create 2 services and do stuff with them
- * MobyService service1 = new MobyService();
- * MobyService service2 = new MobyService();
- *
- * ...
- *
- * // now use the MobyServiceComparator class
- * MobyServiceComparator c = new MobyServiceComparator();
- * if (c.areServicesDifferent(service1, service2)) {
- * // print out the differences
- * System.out.println(c.getDifferences());
- * } else {
- * System.out.println("The 2 services are identical");
- * }
+ * // create 2 services and do stuff with them
+ * MobyService service1 = new MobyService();
+ * MobyService service2 = new MobyService();
+ *
+ * ...
*
- * // lets check if the inputs and outputs for service 1 are valid
- * if (c.areInputsOutputsForServiceValid(service1)) {
- * System.out.println("The inputs/outputs are valid!");
- * }
+ * // now use the MobyServiceComparator class
+ * MobyServiceComparator c = new MobyServiceComparator();
+ * if (c.areServicesDifferent(service1, service2)) {
+ * // print out the differences
+ * System.out.println(c.getDifferences());
+ * } else {
+ * System.out.println("The 2 services are identical");
+ * }
+ *
+ * // lets check if the inputs and outputs for service 1 are valid
+ * if (c.areInputsOutputsForServiceValid(service1)) {
+ * System.out.println("The inputs/outputs are valid!");
+ * }
* </code>
* </pre>
*
@@ -53,7 +54,7 @@
/**
* Constructor
- *
+ *
*/
public MobyServiceComparator() {
init();
@@ -73,8 +74,7 @@
* @return true if the service signatures are not equal, false otherwise.
* For services that are null, true is always returned.
*/
- public boolean areServicesDifferent(MobyService service1,
- MobyService service2) {
+ public boolean areServicesDifferent(MobyService service1, MobyService service2) {
init();
if (service1 == null || service2 == null)
return true;
@@ -87,23 +87,21 @@
// compare the name - usually different if using this class stand
// alone
if (!service1.getName().equals(service2.getName())) {
- addDifference("Service1 has name " + service1.getName()
- + " which is different from " + service2.getName() + ".");
+ addDifference("Service1 has name " + service1.getName() + " which is different from "
+ + service2.getName() + ".");
isDifferent = true;
}
// compare authorities
if (!service1.getAuthority().equals(service2.getAuthority())) {
addDifference("Service1 has authority " + service1.getAuthority()
- + " which is different from " + service2.getAuthority()
- + ".");
+ + " which is different from " + service2.getAuthority() + ".");
isDifferent = true;
}
// compare authoritative
if (service1.isAuthoritative() != service2.isAuthoritative()) {
- addDifference("Service1 is "
- + (service1.isAuthoritative() ? "" : "not ")
+ addDifference("Service1 is " + (service1.isAuthoritative() ? "" : "not ")
+ "authoritative while service2 is"
+ (service2.isAuthoritative() ? "." : " not."));
isDifferent = true;
@@ -112,46 +110,34 @@
// compare category
if (!service1.getCategory().equals(service2.getCategory())) {
addDifference("Service1 has category " + service1.getCategory()
- + " which is different from " + service2.getCategory()
- + ".");
+ + " which is different from " + service2.getCategory() + ".");
isDifferent = true;
}
// compare descriptions
if (!service1.getDescription().equals(service2.getDescription())) {
- addDifference("Service1 has description "
- + service1.getDescription() + " which is different from "
- + service2.getDescription() + ".");
- isDifferent = true;
- }
-
- // compare lsids
- if (!service1.getLSID().equals(service2.getLSID())) {
- addDifference("Service1 has LSID "
- + service1.getLSID() + " which is different from "
- + service2.getLSID() + ".");
+ addDifference("Service1 has description " + service1.getDescription()
+ + " which is different from " + service2.getDescription() + ".");
isDifferent = true;
}
// compare email
if (!service1.getEmailContact().equals(service2.getEmailContact())) {
- addDifference("Service1 has contact address "
- + service1.getEmailContact() + " which is different from "
- + service2.getEmailContact() + ".");
+ addDifference("Service1 has contact address " + service1.getEmailContact()
+ + " which is different from " + service2.getEmailContact() + ".");
isDifferent = true;
}
// compare signature url
if (!service1.getSignatureURL().equals(service2.getSignatureURL())) {
- addDifference("Service1 has signature url "
- + service1.getSignatureURL() + " which is different from "
- + service2.getSignatureURL() + ".");
+ addDifference("Service1 has signature url " + service1.getSignatureURL()
+ + " which is different from " + service2.getSignatureURL() + ".");
isDifferent = true;
}
// compare type
if (!service1.getType().equals(service2.getType())) {
- addDifference("Service1 has type " + service1.getType()
- + " which is different from " + service2.getType() + ".");
+ addDifference("Service1 has type " + service1.getType() + " which is different from "
+ + service2.getType() + ".");
isDifferent = true;
}
@@ -203,30 +189,25 @@
MobyPrimaryDataSet set1 = (MobyPrimaryDataSet) data1;
MobyPrimaryDataSet set2 = (MobyPrimaryDataSet) data2;
- Map collectionInputs1 = getMapFromCollection(set1
- .getElements());
- Map collectionInputs2 = getMapFromCollection(set2
- .getElements());
- for (Iterator collectionInputIt = collectionInputs1
- .keySet().iterator(); collectionInputIt.hasNext();) {
+ Map collectionInputs1 = getMapFromCollection(set1.getElements());
+ Map collectionInputs2 = getMapFromCollection(set2.getElements());
+ for (Iterator collectionInputIt = collectionInputs1.keySet().iterator(); collectionInputIt
+ .hasNext();) {
String inputKey = (String) collectionInputIt.next();
if (collectionInputs2.containsKey(inputKey)) {
MobyPrimaryDataSimple colData1 = (MobyPrimaryDataSimple) collectionInputs1
.get(inputKey);
MobyPrimaryDataSimple colData2 = (MobyPrimaryDataSimple) collectionInputs2
.remove(inputKey);
-
-
+
if (colData1.getDataType().getName().equals(
colData2.getDataType().getName())) {
// check the namespaces if of the same type
- Map namespaces1 = getMapFromMobyNamespace(colData1
- .getNamespaces());
- Map namespaces2 = getMapFromMobyNamespace(colData2
- .getNamespaces());
- for (Iterator nsIt = namespaces1.keySet()
- .iterator(); nsIt.hasNext();) {
+ Map namespaces1 = getMapFromMobyNamespace(colData1.getNamespaces());
+ Map namespaces2 = getMapFromMobyNamespace(colData2.getNamespaces());
+ for (Iterator nsIt = namespaces1.keySet().iterator(); nsIt
+ .hasNext();) {
String nsKey = (String) nsIt.next();
// remove it from namespaces2
if (namespaces2.remove(nsKey) == null) {
@@ -240,95 +221,76 @@
}
}
// now go through what is left in namespaces2
- for (Iterator nsIt = namespaces2.keySet()
- .iterator(); nsIt.hasNext();) {
+ for (Iterator nsIt = namespaces2.keySet().iterator(); nsIt
+ .hasNext();) {
String nsKey = (String) nsIt.next();
// namespae2 was different -> key not in it
- addDifference("A collection "
- + (isInput ? "input" : "output")
+ addDifference("A collection " + (isInput ? "input" : "output")
+ " for service2 had the additional namespace: "
+ nsKey);
isDifferent = true;
}
} else {
// different object types
- addDifference("Service1 had an "
- + (isInput ? "input" : "output")
+ addDifference("Service1 had an " + (isInput ? "input" : "output")
+ " in a collection of type "
+ colData1.getDataType().getName()
+ " while service2 had an "
- + (isInput ? "input" : "output")
- + " of type "
+ + (isInput ? "input" : "output") + " of type "
+ colData2.getDataType().getName()
- + ". Both had an articlename of "
- + inputKey + ".");
+ + ". Both had an articlename of " + inputKey + ".");
isDifferent = true;
}
} else {
addDifference("Service1 had a collection "
- + (isInput ? "input" : "output")
- + " named " + inputKey
+ + (isInput ? "input" : "output") + " named " + inputKey
+ " while service2 did not.");
isDifferent = true;
}
}
- for (Iterator collectionInputIt = collectionInputs2
- .keySet().iterator(); collectionInputIt.hasNext();) {
- addDifference("Service2 had a collection "
- + (isInput ? "input" : "output") + " named "
- + (String) collectionInputIt.next()
+ for (Iterator collectionInputIt = collectionInputs2.keySet().iterator(); collectionInputIt
+ .hasNext();) {
+ addDifference("Service2 had a collection " + (isInput ? "input" : "output")
+ + " named " + (String) collectionInputIt.next()
+ " while service1 did not.");
isDifferent = true;
}
} else if (data1 instanceof MobyPrimaryDataSimple) {
// check for same object type
- if (((MobyPrimaryDataSimple) data1).getDataType().getName()
- .equals(
- ((MobyPrimaryDataSimple) data2)
- .getDataType().getName())) {
+ if (((MobyPrimaryDataSimple) data1).getDataType().getName().equals(
+ ((MobyPrimaryDataSimple) data2).getDataType().getName())) {
// check the namespaces if of the same type
Map namespaces1 = getMapFromMobyNamespace(((MobyPrimaryDataSimple) data1)
.getNamespaces());
Map namespaces2 = getMapFromMobyNamespace(((MobyPrimaryDataSimple) data2)
.getNamespaces());
- //FIXME not parsing correctly - missing namespaces
- for (Iterator nsIt = namespaces1.keySet().iterator(); nsIt
- .hasNext();) {
+ for (Iterator nsIt = namespaces1.keySet().iterator(); nsIt.hasNext();) {
String nsKey = (String) nsIt.next();
// remove it from namespaces2
if (namespaces2.remove(nsKey) == null) {
// namespae2 was different -> key not in it
- addDifference("An "
- + (isInput ? "input" : "output")
- + " for service2 did not have the namespace "
- + nsKey + ".");
+ addDifference("An " + (isInput ? "input" : "output")
+ + " for service2 did not have the namespace " + nsKey + ".");
isDifferent = true;
}
}
// now go through what is left in namespaces2
- for (Iterator nsIt = namespaces2.keySet().iterator(); nsIt
- .hasNext();) {
+ for (Iterator nsIt = namespaces2.keySet().iterator(); nsIt.hasNext();) {
String nsKey = (String) nsIt.next();
// namespae2 was different -> key not in it
- addDifference("An "
- + (isInput ? "input" : "output")
- + " for service2 had the additional namespace: "
- + nsKey);
+ addDifference("An " + (isInput ? "input" : "output")
+ + " for service2 had the additional namespace: " + nsKey);
isDifferent = true;
}
} else {
// different object types
- addDifference("Service1 had an "
- + (isInput ? "input" : "output")
+ addDifference("Service1 had an " + (isInput ? "input" : "output")
+ " of type "
- + ((MobyPrimaryDataSimple) data1).getDataType()
- .getName()
- + " while service2 had an "
- + (isInput ? "input" : "output")
+ + ((MobyPrimaryDataSimple) data1).getDataType().getName()
+ + " while service2 had an " + (isInput ? "input" : "output")
+ " of type "
- + ((MobyPrimaryDataSimple) data2).getDataType()
- .getName()
+ + ((MobyPrimaryDataSimple) data2).getDataType().getName()
+ ". Both had an articlename of " + key + ".");
isDifferent = true;
}
@@ -337,52 +299,39 @@
MobySecondaryData secondary1 = (MobySecondaryData) data1;
MobySecondaryData secondary2 = (MobySecondaryData) data2;
- if (secondary1.getDataType().equals(
- secondary2.getDataType())) {
+ if (secondary1.getDataType().equals(secondary2.getDataType())) {
// compare maximums
- if (secondary1.getMaximumValue() != secondary2
- .getMaximumValue()) {
+ if (secondary1.getMaximumValue() != secondary2.getMaximumValue()) {
addDifference("Service1 had a secondary input maxinmum value "
+ secondary1.getMaximumValue()
+ " while service2 had a secondary input maximum value of "
+ secondary2.getMaximumValue()
- + ". Both had an articlename of "
- + key
- + ".");
+ + ". Both had an articlename of " + key + ".");
isDifferent = true;
}
// compare minimums
- if (secondary1.getMinimumValue() != secondary2
- .getMinimumValue()) {
+ if (secondary1.getMinimumValue() != secondary2.getMinimumValue()) {
addDifference("Service1 had a secondary input mininmum value of "
+ secondary1.getMinimumValue()
+ " while service2 had a secondary input minimum value of "
+ secondary2.getMinimumValue()
- + ". Both had an articlename of "
- + key
- + ".");
+ + ". Both had an articlename of " + key + ".");
isDifferent = true;
}
// compare defaults
- if (!secondary1.getDefaultValue().equals(
- secondary2.getDefaultValue())) {
+ if (!secondary1.getDefaultValue().equals(secondary2.getDefaultValue())) {
addDifference("Service1 had a secondary input default value of "
+ secondary1.getDefaultValue()
+ " while service2 had a secondary input default value of "
+ secondary2.getDefaultValue()
- + ". Both had an articlename of "
- + key
- + ".");
+ + ". Both had an articlename of " + key + ".");
isDifferent = true;
}
// compare allowable values
- Map allowable1 = getMapStrings(secondary1
- .getAllowedValues());
- Map allowable2 = getMapStrings(secondary2
- .getAllowedValues());
- for (Iterator nsIt = allowable1.keySet().iterator(); nsIt
- .hasNext();) {
+ Map allowable1 = getMapStrings(secondary1.getAllowedValues());
+ Map allowable2 = getMapStrings(secondary2.getAllowedValues());
+ for (Iterator nsIt = allowable1.keySet().iterator(); nsIt.hasNext();) {
String valueKey = (String) nsIt.next();
// remove it from namespaces2
if (allowable2.remove(valueKey) == null) {
@@ -394,8 +343,7 @@
}
// now iterate through secondary2
// now go through what is left in namespaces2
- for (Iterator nsIt = allowable2.keySet().iterator(); nsIt
- .hasNext();) {
+ for (Iterator nsIt = allowable2.keySet().iterator(); nsIt.hasNext();) {
String valueKey = (String) nsIt.next();
// namespae2 was different -> key not in it
addDifference("A secondary input for service2 had the additional allowable value: "
@@ -408,8 +356,8 @@
addDifference("Service1 had a secondary input of type "
+ secondary1.getDataType()
+ " while service2 had a secondary input of type "
- + secondary2.getDataType()
- + ". Both had an articlename of " + key + ".");
+ + secondary2.getDataType() + ". Both had an articlename of " + key
+ + ".");
isDifferent = true;
}
@@ -419,8 +367,7 @@
}
} else {
// no -> record difference
- addDifference("Service1 had an "
- + (isInput ? "input" : "output") + " named " + key
+ addDifference("Service1 had an " + (isInput ? "input" : "output") + " named " + key
+ " while service2 did not.");
isDifferent = true;
@@ -429,9 +376,8 @@
// now look through the second map for any new types
// record them
for (Iterator it = dataMap2.keySet().iterator(); it.hasNext();) {
- addDifference("Service2 had an " + (isInput ? "input" : "output")
- + " named " + (String) it.next()
- + " while service1 did not.");
+ addDifference("Service2 had an " + (isInput ? "input" : "output") + " named "
+ + (String) it.next() + " while service1 did not.");
isDifferent = true;
}
}
@@ -482,6 +428,29 @@
return true;
}
+ /**
+ * <b>PRE:</b> <em>Service1 and service2 are describe the same service instance
+ * otherwise an exception is raised</em>
+ *
+ * @param service1
+ * a moby service instance
+ * @param service2
+ * another moby service instance
+ * @return true if the lsid revisions are different, false otherwise.
+ * @throws MobyException
+ * if the services describe different service 'instances'
+ */
+ public boolean areLsidVersionsDifferent(MobyService service1, MobyService service2)
+ throws MobyException {
+ if (!service1.getUniqueName().equals(service2.getUniqueName()))
+ throw new MobyException(
+ "You cannot LSID revision numbers if the services are not describing the same 'instance'.");
+ if (!service1.getLSID().equals(service2.getLSID())) {
+ return true;
+ }
+ return false;
+ }
+
private Map getMapFromMobyNamespace(MobyNamespace[] datas) {
HashMap map = new HashMap();
for (int i = 0; i < datas.length; i++) {
@@ -504,7 +473,7 @@
* newline
*/
private void addDifference(String difference) {
- buffer.append("\t" +difference + System.getProperty("line.separator"));
+ buffer.append("\t" + difference + System.getProperty("line.separator"));
}
/**
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Processor.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Processor.java 2006/03/15 17:56:26 1.14
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Processor.java 2006/03/23 19:10:31 1.15
@@ -62,8 +62,7 @@
Map servicesProcessed = new HashMap();
// create a vector of process services
Vector extraServices = new Vector();
- for (Iterator keyIterator = serviceMap.keySet().iterator(); keyIterator
- .hasNext();) {
+ for (Iterator keyIterator = serviceMap.keySet().iterator(); keyIterator.hasNext();) {
String key = (String) keyIterator.next();
if (extraServices.contains(key)) {
@@ -76,42 +75,35 @@
// process bad signatures once, try to remove the service
if (badURLs.containsKey(signatureURL)) {
- Log.warning("The signature url, " + signatureURL
- + ", has already been" + newline
- + " processed and was invalid"
+ Log.warning("The signature url, " + signatureURL + ", has already been"
+ + newline + " processed and was invalid"
+ " for one reason or another.");
- removeInvalidSignatureURLServiceFromRegistry(
- registryService, central,
- "The service has an invalid signature url.",
- ((Integer) badURLs.get(signatureURL)).intValue());
+ removeInvalidSignatureURLServiceFromRegistry(registryService, central,
+ "The service has an invalid signature url.", ((Integer) badURLs
+ .get(signatureURL)).intValue());
continue;
}
if (signatureURL.trim().equals("")) {
if (!ignoreNulls) {
- processNullSignatureURLs(registryService,
- "Null signature URL.", central);
+ processNullSignatureURLs(registryService, "Null signature URL.", central);
continue;
} else {
// warn about the null url
- Log
- .warning("Service, ("
- + registryService.getUniqueName()
- + "), contains a NULL signature url and"
- + newline
- + " could have been removed, "
- + "but you have chosen to ignore these services.");
- processNullSignatureURLs(registryService,
- "Null signature URL.", central);
+ Log.warning("Service, (" + registryService.getUniqueName()
+ + "), contains a NULL signature url and" + newline
+ + " could have been removed, "
+ + "but you have chosen to ignore these services.");
+ processNullSignatureURLs(registryService, "Null signature URL.", central);
continue;
}
} else {
// non null signature url
SignatureURLConnection connection = new SignatureURLConnection();
MobyService[] rdfServices = null;
-
+
// only process signature urls once
if (signatureURLsProcessed.containsKey(signatureURL))
continue;
@@ -119,17 +111,14 @@
signatureURLsProcessed.put(signatureURL, "");
rdfServices = connection.extractServicesFromURL(signatureURL);
-
+
if (rdfServices == null) {
// add the url to the bad list so that the hitlist
// doesnt grow by the number of services at the service
// description location
- badURLs.put(signatureURL, connection.getBadUrlMap()
- .get(signatureURL));
+ badURLs.put(signatureURL, connection.getBadUrlMap().get(signatureURL));
// rdf is missing
- removeInvalidSignatureURLService(
- registryService,
- central,
+ removeInvalidSignatureURLService(registryService, central,
"The signature url was missing, or the rdf document was invalid.",
connection);
continue;
@@ -140,19 +129,17 @@
// this would happen if a url contained rdf but not
// current rdf
- badURLs.put(signatureURL, connection.getBadUrlMap()
- .get(signatureURL));
+ badURLs.put(signatureURL, connection.getBadUrlMap().get(signatureURL));
// no services found in the document
- removeInvalidSignatureURLService(
- registryService,
- central,
- "given, " + signatureURL
- + ", no service was found called "
- + registryService.getUniqueName() + ".",
- connection);
+ removeInvalidSignatureURLService(registryService, central, "given, "
+ + signatureURL + ", no service was found called "
+ + registryService.getUniqueName() + ".", connection);
continue;
} else {
for (int i = 0; i < rdfServices.length; i++) {
+ // TODO compare service LSIDs if revision is
+ // different, then process service, otherwise ignore
+ // it
boolean rdfInvalid = false;
// iterate over the services in the array
String rdfKey = rdfServices[i].getAuthority() + ","
@@ -160,23 +147,19 @@
MobyServiceComparator comparator = new MobyServiceComparator();
if (key.equals(rdfKey)) {
// we have a matching service
- if (!comparator
- .areInputsOutputsForServiceValid(rdfServices[i])) {
+ if (!comparator.areInputsOutputsForServiceValid(rdfServices[i])) {
Log
.warning("The service, "
+ rdfKey
+ ", contained in the RDF is not a valid service."
+ newline
+ "\tIt may have inputs or outputs that do not conform to the Moby API.");
- Log
- .info("The service "
- + rdfKey
- + " was ignored as it was invalid.");
+ Log.info("The service " + rdfKey
+ + " was ignored as it was invalid.");
rdfInvalid = true;
}
- if (!comparator
- .areInputsOutputsForServiceValid(registryService)) {
+ if (!comparator.areInputsOutputsForServiceValid(registryService)) {
if (!rdfInvalid) {
// a valid rdf service will replace the
// invalid registry one.
@@ -198,8 +181,7 @@
+ "Note that a valid version of this service was found in the RDF document.");
// do this iff we removed the service
if (code == 200) {
- addServiceToRegistry(
- rdfServices[i], central);
+ addServiceToRegistry(rdfServices[i], central);
}
continue;
} else {
@@ -225,28 +207,40 @@
// if the rdf is not invalid and the services
// are different
if (!rdfInvalid
- && comparator
- .areServicesDifferent(
- registryService,
- rdfServices[i])) {
- String differences = comparator
- .getDifferences();
- processModifiedServices(central,
- rdfServices[i], registryService,
- differences);
- /*
- * Log.info("The service " + rdfKey + " has
- * changed." + newline + "Changes are: " +
- * newline + comparator.getDifferences());
- * int code =
- * removeChangedServiceFromRegistry(
- * registryService, central,
- * comparator.getDifferences()); // do this
- * iff we removed the first service if (code ==
- * 200) {
- * addServiceToRegistry(rdfServices[i],
- * central); }
- */
+ && comparator.areServicesDifferent(registryService,
+ rdfServices[i])) {
+ boolean areLSIDsDifferent = false;
+ try {
+ areLSIDsDifferent = comparator.areLsidVersionsDifferent(
+ rdfServices[i], registryService);
+ } catch (MobyException e) {
+ // TODO log and skip this service
+ // because the lsids describe different
+ // services
+ Log.exception(this.getClass().getName(),
+ "processRegistryServices(Map, Central)", e);
+ Log.severe("The LSIDs describe different services."
+ + newline + e.getLocalizedMessage());
+ Log.info("The service " + rdfServices[i].getUniqueName()
+ + " and the service "
+ + registryService.getUniqueName()
+ + " have lsids that describe different services.");
+
+ }
+
+ if (areLSIDsDifferent) {
+ String differences = comparator.getDifferences();
+ processModifiedServices(central, rdfServices[i],
+ registryService, differences);
+ } else {
+ Log.info("The service " + rdfServices[i].getUniqueName()
+ + " and the service " + newline
+ + registryService.getUniqueName()
+ + " have the same LSID (and revision) " + newline
+ + "and due to this, the agent chose not " + newline
+ + "to update the service. Please modify " + newline
+ + "the LSID revision for your service.");
+ }
continue;
}
} else {
@@ -255,18 +249,15 @@
MobyService existingRegistryService = (MobyService) serviceMap
.get(rdfKey);
extraServices.add(rdfKey);
- if (!comparator
- .areInputsOutputsForServiceValid(rdfServices[i])) {
+ if (!comparator.areInputsOutputsForServiceValid(rdfServices[i])) {
Log
.warning("The service, "
+ rdfKey
+ ", contained in the RDF is not a valid service. "
+ newline
+ "\tIt may have inputs or outputs that do not conform to the Moby API.");
- Log
- .info("The service "
- + rdfKey
- + " was ignored as it was invalid.");
+ Log.info("The service " + rdfKey
+ + " was ignored as it was invalid.");
rdfInvalid = true;
}
if (!comparator
@@ -294,8 +285,7 @@
// do this iff we removed the
// service
if (code == 200) {
- addServiceToRegistry(
- rdfServices[i], central);
+ addServiceToRegistry(rdfServices[i], central);
}
continue;
} else {
@@ -320,47 +310,64 @@
}
if (!rdfInvalid
&& comparator.areServicesDifferent(
- existingRegistryService,
- rdfServices[i])) {
- String differences = comparator
- .getDifferences();
- processModifiedServices(central,
- rdfServices[i],
- existingRegistryService,
- differences);
-
- /*
- * Log.info("The service " + rdfKey + "
- * has changed." + newline + "Changes
- * are: " + newline +
- * comparator.getDifferences()); int
- * code =
- * removeChangedServiceFromRegistry(
- * existingRegistryService, central,
- * comparator .getDifferences()); if
- * (code == 200) { addServiceToRegistry(
- * rdfServices[i], central); }
- */
+ existingRegistryService, rdfServices[i])) {
+
+ boolean areLSIDsDifferent = false;
+ try {
+ areLSIDsDifferent = comparator
+ .areLsidVersionsDifferent(rdfServices[i],
+ existingRegistryService);
+ } catch (MobyException e) {
+ // TODO log and skip this service
+ // because the lsids describe
+ // different services
+ Log.exception(this.getClass().getName(),
+ "processRegistryServices(Map, Central)", e);
+ Log.severe("The LSIDs describe different services."
+ + newline + e.getLocalizedMessage());
+ Log
+ .info("The service "
+ + rdfServices[i].getUniqueName()
+ + " and the service "
+ + existingRegistryService
+ .getUniqueName()
+ + " have lsids that describe different services.");
+
+ }
+
+ if (areLSIDsDifferent) {
+ String differences = comparator.getDifferences();
+ processModifiedServices(central, rdfServices[i],
+ existingRegistryService, differences);
+ } else {
+ Log.info("The service "
+ + rdfServices[i].getUniqueName()
+ + " and the service " + newline
+ + existingRegistryService.getUniqueName()
+ + " have the same LSID (and revision) "
+ + newline
+ + "and due to this, the agent chose not "
+ + newline
+ + "to update the service. Please modify "
+ + newline
+ + "the LSID revision for your service.");
+ }
continue;
}
} else {
// new service found!
- Log.info("New service found. Service: "
- + rdfKey);
- addNewServiceToRegistry(rdfServices[i],
- central);
+ Log.info("New service found. Service: " + rdfKey);
+ addNewServiceToRegistry(rdfServices[i], central);
}
}
} // end for loop rdfInvalid now false
// check if their were any invalid services in the rdf
if (connection.getInvalidServicesFoundInRDF().size() > 0) {
- for (Iterator it = connection
- .getInvalidServicesFoundInRDF().iterator(); it
+ for (Iterator it = connection.getInvalidServicesFoundInRDF().iterator(); it
.hasNext();) {
- removeInvalidServiceFromRegistry((MobyService) it
- .next());
+ removeInvalidServiceFromRegistry((MobyService) it.next());
}
}
@@ -394,16 +401,13 @@
registryServices[0].setSignatureURL(url);
registryServices = central.findService(registryServices[0]);
for (int i = 0; i < registryServices.length; i++) {
- foundServices.put(registryServices[i].getUniqueName(),
- registryServices[i]);
+ foundServices.put(registryServices[i].getUniqueName(), registryServices[i]);
}
} catch (MobyException e) {
//
- Log.exception(this.getClass().getName(),
- "processServicesFromURL(String, Central)", e);
- Log
- .severe("There was a problem comunicating with the registry. The url: "
- + url + " was not processed.");
+ Log.exception(this.getClass().getName(), "processServicesFromURL(String, Central)", e);
+ Log.severe("There was a problem comunicating with the registry. The url: " + url
+ + " was not processed.");
return;
}
@@ -413,37 +417,23 @@
// empty
for (Iterator it = foundServices.keySet().iterator(); it.hasNext();) {
String uniqueName = (String) it.next();
- MobyService service = (MobyService) foundServices
- .get(uniqueName);
- removeMissingServiceFromRegistry(
- service,
- central,
- "The RDF document located at: "
- + url
- + " was unreachable. Removing those services that "
- + "were said to be located there.");
+ MobyService service = (MobyService) foundServices.get(uniqueName);
+ removeMissingServiceFromRegistry(service, central, "The RDF document located at: "
+ + url + " was unreachable. Removing those services that "
+ + "were said to be located there.");
}
return;
} else if (rdfServices.length == 0) {
- Log
- .warning("Unable to retrieve the services from "
- + url
- + "."
- + newline
- + "All services described by that location will be removed.");
+ Log.warning("Unable to retrieve the services from " + url + "." + newline
+ + "All services described by that location will be removed.");
// iterate over foundServices and remove any services b/c rdf was
// empty
for (Iterator it = foundServices.keySet().iterator(); it.hasNext();) {
String uniqueName = (String) it.next();
- MobyService service = (MobyService) foundServices
- .get(uniqueName);
- removeMissingServiceFromRegistry(
- service,
- central,
- "The RDF document located at: "
- + url
- + " was unreachable. Removing those services that "
- + "were said to be located there.");
+ MobyService service = (MobyService) foundServices.get(uniqueName);
+ removeMissingServiceFromRegistry(service, central, "The RDF document located at: "
+ + url + " was unreachable. Removing those services that "
+ + "were said to be located there.");
}
return;
} else {
@@ -454,14 +444,11 @@
MobyService rdfService = rdfServices[i];
rdfService.setSignatureURL(url);
MobyService registryService = null;
-
// rdf had extra service
if (!foundServices.containsKey(rdfService.getUniqueName())) {
- Log
- .info("Unable to find a service in the registry that matches ("
- + rdfService.getUniqueName() + ").");
- MobyService[] ms = new MobyService[] { new MobyService(
- rdfService.getName()) };
+ Log.info("Unable to find a service in the registry that matches ("
+ + rdfService.getUniqueName() + ").");
+ MobyService[] ms = new MobyService[] { new MobyService(rdfService.getName()) };
ms[0].setAuthority(rdfService.getAuthority());
try {
@@ -469,9 +456,8 @@
} catch (MobyException e) {
Log.exception(this.getClass().getName(),
"processServicesFromURL(String, Central)", e);
- Log
- .severe("There was a problem comunicating with "
- + "the registry while checking for service existance.");
+ Log.severe("There was a problem comunicating with "
+ + "the registry while checking for service existance.");
ms = null;
}
@@ -488,24 +474,21 @@
}
// registry and rdf had a similar service - start comparing
- Log
- .info("Found a service in the registry that matches the one in the RDF ..."
- + newline + "Comparing them ...");
- registryService = (MobyService) foundServices.remove(rdfService
- .getUniqueName());
+ Log.info("Found a service in the registry that matches the one in the RDF ..."
+ + newline + "Comparing them ...");
+ registryService = (MobyService) foundServices.remove(rdfService.getUniqueName());
if (!comparator.areInputsOutputsForServiceValid(rdfService)) {
// service in rdf is invalid
Log.warning("The service, " + rdfService.getUniqueName()
- + ", contained in the RDF is not a valid service."
- + newline + "\tIt may have inputs or outputs that"
+ + ", contained in the RDF is not a valid service." + newline
+ + "\tIt may have inputs or outputs that"
+ " do not conform to the Moby API.");
Log.info("The service " + rdfService.getUniqueName()
+ " was ignored as it was invalid.");
isRDFValid = false;
}
- if (!comparator
- .areInputsOutputsForServiceValid(registryService)) {
+ if (!comparator.areInputsOutputsForServiceValid(registryService)) {
// service in registry is invalid
if (isRDFValid) {
// a valid rdf service will replace
@@ -540,8 +523,7 @@
+ ", is not a valid service. This service was found in the registry."
+ newline
+ "\tIt may have inputs or outputs that do not conform to the Moby API."
- + newline
- + "\tThis service is going to be removed.");
+ + newline + "\tThis service is going to be removed.");
removeInvalidChangedServiceFromRegistry(
registryService,
central,
@@ -552,24 +534,46 @@
}
}
- if (isRDFValid
- && comparator.areServicesDifferent(rdfService,
- registryService)) {
+ if (isRDFValid && comparator.areServicesDifferent(rdfService, registryService)) {
+ // TODO compare lsid revisions, if different process
+ // service, otherwise dont!
// services differ - remove registry srvc and add rdf svrc
- String differences = comparator.getDifferences();
- processModifiedServices(central, rdfService,
- registryService, differences);
+ boolean areLSIDsDifferent = false;
+ try {
+ areLSIDsDifferent = comparator.areLsidVersionsDifferent(rdfService,
+ registryService);
+ } catch (MobyException e) {
+ // TODO log and skip this service because the lsids
+ // describe different services
+ Log.exception(this.getClass().getName(),
+ "processRegistryServices(Map, Central)", e);
+ Log.severe("The LSIDs describe different services." + newline
+ + e.getLocalizedMessage());
+ Log.info("The service " + rdfService.getUniqueName() + " and the service "
+ + registryService.getUniqueName()
+ + " have lsids that describe different services.");
+
+ }
+ if (areLSIDsDifferent) {
+ String differences = comparator.getDifferences();
+ processModifiedServices(central, rdfService, registryService, differences);
+ } else {
+ Log.info("The service " + rdfService.getUniqueName() + " and the service "
+ + newline + registryService.getUniqueName()
+ + " have the same LSID (and revision) " + newline
+ + "and due to this, the agent chose not " + newline
+ + "to update the service. Please modify " + newline
+ + "the LSID revision for your service.");
+ }
continue;
}
}
// iterate over foundServices and remove any services left
for (Iterator it = foundServices.keySet().iterator(); it.hasNext();) {
String uniqueName = (String) it.next();
- MobyService service = (MobyService) foundServices
- .get(uniqueName);
+ MobyService service = (MobyService) foundServices.get(uniqueName);
removeMissingServiceFromRegistry(service, central,
- "Service was not found in the RDF document located at: "
- + url);
+ "Service was not found in the RDF document located at: " + url);
}
}
}
@@ -578,14 +582,14 @@
* @param central @param rdfService @param registryService @param
* differences
*/
- private void processModifiedServices(Central central,
- MobyService rdfService, MobyService registryService,
- String differences) {
- Log.info("The service " + rdfService.getUniqueName() + " has changed."
- + newline + "Changes are: " + newline + differences);
+ private void processModifiedServices(Central central, MobyService rdfService,
+ MobyService registryService, String differences) {
+ Log.info("The service " + rdfService.getUniqueName() + " has changed." + newline
+ + "Changes are: " + newline + differences);
if (enableServiceUpdates) {
- int code = removeChangedServiceFromRegistry(registryService,
- central, differences);
+ // TODO keep track of the revision on the new service - change the
+ // revision to the one in the document
+ int code = removeChangedServiceFromRegistry(registryService, central, differences);
if (code == 200) {
if (addServiceToRegistry(rdfService, central)) {
// service was added
@@ -608,35 +612,29 @@
}
}
} else {
- Log
- .info("The service "
- + rdfService.getUniqueName()
- + " was found to be modified."
- + newline
- + "Since you have disabled service updates, the registry was not updated.");
+ Log.info("The service " + rdfService.getUniqueName() + " was found to be modified."
+ + newline
+ + "Since you have disabled service updates, the registry was not updated.");
}
}
- private void processNullSignatureURLs(MobyService service, String string,
- Central central) {
+ private void processNullSignatureURLs(MobyService service, String string, Central central) {
// create and optionally save the report
Report report = new Report(Constants.ADMIN_NAME, Constants.ADMIN_EMAIL,
Constants.REGISTRY_REMOVAL_ENDPOINT, true);
- report.addToReport("\tThe service: " + service.getAuthority() + ","
- + service.getName() + " generated the following error:");
+ report.addToReport("\tThe service: " + service.getAuthority() + "," + service.getName()
+ + " generated the following error:");
report.addToReport("\t\t" + string);
- String rdf = ServiceInstanceRDF.findService(service.getAuthority(),
- service.getName(), central.getRegistryEndpoint(), central
- .getRegistryNamespace());
+ String rdf = ServiceInstanceRDF.findService(service.getAuthority(), service.getName(),
+ central.getRegistryEndpoint(), central.getRegistryNamespace());
report.addToReport("");
report.addToReport("Your service had the following RDF document:");
report.addToReport(rdf);
if (Constants.REPORT_ENABLE) {
Log.info("Saving the report");
- report.saveReport(Constants.REPORT_DIRECTORY, service
- .getAuthority()
- + "_" + service.getName() + ".rtf");
+ report.saveReport(Constants.REPORT_DIRECTORY, service.getAuthority() + "_"
+ + service.getName() + ".rtf");
}
if (sendMailOnNull) {
@@ -646,18 +644,13 @@
// remove service only if we arent ignoring them
if (!ignoreNulls) {
// remove the null signature url service
- Log.info("Service, (" + service.getName() + ", "
- + service.getAuthority()
+ Log.info("Service, (" + service.getName() + ", " + service.getAuthority()
+ "), contains a NULL signature url and will be removed.");
- CentralAdmin centralAdmin = new CentralAdmin(
- Constants.REGISTRY_REMOVAL_ENDPOINT,
- Constants.REGISTRY_REMOVAL_URI,
- Constants.REGISTRY_REMOVAL_USERNAME,
- Constants.REGISTRY_REMOVAL_PASSWORD,
- Constants.REGISTRY_KEYPHRASE);
- int code = centralAdmin.deleteService(service.getName(), service
- .getAuthority());
+ CentralAdmin centralAdmin = new CentralAdmin(Constants.REGISTRY_REMOVAL_ENDPOINT,
+ Constants.REGISTRY_REMOVAL_URI, Constants.REGISTRY_REMOVAL_USERNAME,
+ Constants.REGISTRY_REMOVAL_PASSWORD, Constants.REGISTRY_KEYPHRASE);
+ int code = centralAdmin.deleteService(service.getName(), service.getAuthority());
processCentralAdminCode(code);
}
}
@@ -668,24 +661,18 @@
*/
private void sendMail(MobyService service, Report report) {
if (useSMTP) {
- Log.info("Sending the report to " + service.getEmailContact()
- + " (SMTP).");
+ Log.info("Sending the report to " + service.getEmailContact() + " (SMTP).");
Mailer mailer = new Mailer();
- if (!mailer.sendSMTPMail(Constants.SMTP_SERVER,
- Constants.SMTP_LOGIN, Constants.SMTP_PSWD, service
- .getEmailContact(), "Agent report regarding: "
- + service.getName(), report.getReport(),
- Constants.ADMIN_EMAIL)) {
- Log
- .warning("Agent told to use SMTP mail, but failed. Attempting to use 'mail'");
+ if (!mailer.sendSMTPMail(Constants.SMTP_SERVER, Constants.SMTP_LOGIN,
+ Constants.SMTP_PSWD, service.getEmailContact(), "Agent report regarding: "
+ + service.getName(), report.getReport(), Constants.ADMIN_EMAIL)) {
+ Log.warning("Agent told to use SMTP mail, but failed. Attempting to use 'mail'");
}
} else {
- Log.info("Sending the report to " + service.getEmailContact()
- + " ('mail').");
+ Log.info("Sending the report to " + service.getEmailContact() + " ('mail').");
Mailer mailer = new Mailer();
- if (!mailer.sendMail(service.getEmailContact(),
- "Agent report regarding: " + service.getName(), report
- .getReport())) {
+ if (!mailer.sendMail(service.getEmailContact(), "Agent report regarding: "
+ + service.getName(), report.getReport())) {
Log.warning("Agent failed to send mail using 'mail'");
}
}
@@ -695,9 +682,8 @@
* adds a service that was modified or registered incorrectly.
*/
private boolean addServiceToRegistry(MobyService service, Central central) {
- Log.info("Agent will attempt to add the Service " + service.getName()
- + ", " + service.getAuthority() + " ) " + newline
- + "to the registry.");
+ Log.info("Agent will attempt to add the Service " + service.getName() + ", "
+ + service.getAuthority() + " ) " + newline + "to the registry.");
return registerService(service, central);
}
@@ -706,9 +692,8 @@
*/
private void addNewServiceToRegistry(MobyService service, Central central) {
Log.info("A new service was found in an RDF document." + newline
- + "\tThe service is called: " + service.getName()
- + " under the authority: " + service.getAuthority() + "."
- + newline
+ + "\tThe service is called: " + service.getName() + " under the authority: "
+ + service.getAuthority() + "." + newline
+ "Attempting to register the service with mobycentral.");
registerService(service, central);
@@ -721,41 +706,33 @@
*/
private boolean registerService(MobyService service, Central central) {
- if (service.getSignatureURL().trim().equals("")
- && !Constants.REGISTRY_IGNORE_NULL) {
- Log.info("The service, (" + service.getName() + ","
- + service.getAuthority() + "), was *not* registered "
- + newline + "since it has a NULL signature URL.");
+ if (service.getSignatureURL().trim().equals("") && !Constants.REGISTRY_IGNORE_NULL) {
+ Log.info("The service, (" + service.getName() + "," + service.getAuthority()
+ + "), was *not* registered " + newline + "since it has a NULL signature URL.");
return false;
}
try {
central.registerService(service);
} catch (MobyException e) {
- Log.exception(this.getClass().getName(),
- "addNewServiceToRegistry(MobyService)", e);
+ Log.exception(this.getClass().getName(), "addNewServiceToRegistry(MobyService)", e);
Log.severe("Communication with the registry failed." + newline
+ e.getLocalizedMessage());
- Log.info("service " + service.getName() + ", "
- + service.getAuthority()
+ Log.info("service " + service.getName() + ", " + service.getAuthority()
+ " has not been added to the registry.");
return false;
} catch (NoSuccessException e) {
- Log.exception(this.getClass().getName(),
- "addNewServiceToRegistry(MobyService)", e);
+ Log.exception(this.getClass().getName(), "addNewServiceToRegistry(MobyService)", e);
Log.severe("There was no success with registration." + newline
+ e.getLocalizedMessage());
- Log.info("service " + service.getName() + ", "
- + service.getAuthority()
+ Log.info("service " + service.getName() + ", " + service.getAuthority()
+ " has not been added to the registry.");
return false;
} catch (PendingCurationException e) {
- Log.exception(this.getClass().getName(),
- "addNewServiceToRegistry(MobyService)", e);
- Log.severe("The service may be registered later pending curation."
- + newline + e.getLocalizedMessage());
- Log.info("service " + service.getName() + ", "
- + service.getAuthority()
+ Log.exception(this.getClass().getName(), "addNewServiceToRegistry(MobyService)", e);
+ Log.severe("The service may be registered later pending curation." + newline
+ + e.getLocalizedMessage());
+ Log.info("service " + service.getName() + ", " + service.getAuthority()
+ " has not *yet* been added to the registry.");
return false;
}
@@ -768,45 +745,38 @@
/*
* remove a changed service
*/
- private int removeChangedServiceFromRegistry(MobyService service,
- Central central, String changes) {
+ private int removeChangedServiceFromRegistry(MobyService service, Central central,
+ String changes) {
// create and optionally save the report
- Report report = new Report(Constants.ADMIN_NAME,Constants.ADMIN_EMAIL, Constants.REGISTRY_REMOVAL_ENDPOINT, false);
- report.addToReport("\tThe service: " + service.getAuthority() + ","
- + service.getName() + " has been modified.");
+ Report report = new Report(Constants.ADMIN_NAME, Constants.ADMIN_EMAIL,
+ Constants.REGISTRY_REMOVAL_ENDPOINT, false);
+ report.addToReport("\tThe service: " + service.getAuthority() + "," + service.getName()
+ + " has been modified.");
report.addToReport("\t\tThe following changes have been found:");
report.addToReport(Utils.format(changes, 3));
report.addToReport("");
- report
- .addToReport("\t\tNote: Service1 is the service found in the registry, while "
- + newline
- + "\t\t Service2 is the one found by HTTP getting the signatureURL.");
+ report.addToReport("\t\tNote: Service1 is the service found in the registry, while "
+ + newline + "\t\t Service2 is the one found by HTTP getting the signatureURL.");
report.addToReport("");
if (Constants.REPORT_ENABLE) {
Log.info("Saving the report");
- report.saveReport(Constants.REPORT_DIRECTORY, service
- .getAuthority()
- + "_" + service.getName() + ".rtf");
+ report.saveReport(Constants.REPORT_DIRECTORY, service.getAuthority() + "_"
+ + service.getName() + ".rtf");
}
if (sendMailOnChanged) {
sendMail(service, report);
}
- Log.info("Service, (" + service.getName() + ", "
- + service.getAuthority()
+ Log.info("Service, (" + service.getName() + ", " + service.getAuthority()
+ "), was modified and will be updated.");
- CentralAdmin centralAdmin = new CentralAdmin(
- Constants.REGISTRY_REMOVAL_ENDPOINT,
- Constants.REGISTRY_REMOVAL_URI,
- Constants.REGISTRY_REMOVAL_USERNAME,
- Constants.REGISTRY_REMOVAL_PASSWORD,
- Constants.REGISTRY_KEYPHRASE);
- int code = centralAdmin.deleteService(service.getName(), service
- .getAuthority());
+ CentralAdmin centralAdmin = new CentralAdmin(Constants.REGISTRY_REMOVAL_ENDPOINT,
+ Constants.REGISTRY_REMOVAL_URI, Constants.REGISTRY_REMOVAL_USERNAME,
+ Constants.REGISTRY_REMOVAL_PASSWORD, Constants.REGISTRY_KEYPHRASE);
+ int code = centralAdmin.deleteService(service.getName(), service.getAuthority());
processCentralAdminCode(code);
return code;
}
@@ -814,13 +784,14 @@
/*
* remove a changed service
*/
- private int removeInvalidChangedServiceFromRegistry(MobyService service,
- Central central, String changes) {
+ private int removeInvalidChangedServiceFromRegistry(MobyService service, Central central,
+ String changes) {
// create and optionally save the report
- Report report = new Report(Constants.ADMIN_NAME,Constants.ADMIN_EMAIL, Constants.REGISTRY_REMOVAL_ENDPOINT, true);
- report.addToReport("\tThe service: " + service.getAuthority() + ","
- + service.getName() + " has been found to be invalid.");
+ Report report = new Report(Constants.ADMIN_NAME, Constants.ADMIN_EMAIL,
+ Constants.REGISTRY_REMOVAL_ENDPOINT, true);
+ report.addToReport("\tThe service: " + service.getAuthority() + "," + service.getName()
+ + " has been found to be invalid.");
report.addToReport("\t\tThe following changes have been found:");
report.addToReport(Utils.format(changes, 3));
@@ -828,9 +799,8 @@
if (Constants.REPORT_ENABLE) {
Log.info("Saving the report");
- report.saveReport(Constants.REPORT_DIRECTORY, service
- .getAuthority()
- + "_" + service.getName() + ".rtf");
+ report.saveReport(Constants.REPORT_DIRECTORY, service.getAuthority() + "_"
+ + service.getName() + ".rtf");
}
if (sendMailOnInvalid) {
@@ -839,14 +809,10 @@
Log.info("Attempting to remove service, (" + service.getName() + ", "
+ service.getAuthority() + ").");
- CentralAdmin centralAdmin = new CentralAdmin(
- Constants.REGISTRY_REMOVAL_ENDPOINT,
- Constants.REGISTRY_REMOVAL_URI,
- Constants.REGISTRY_REMOVAL_USERNAME,
- Constants.REGISTRY_REMOVAL_PASSWORD,
- Constants.REGISTRY_KEYPHRASE);
- int code = centralAdmin.deleteService(service.getName(), service
- .getAuthority());
+ CentralAdmin centralAdmin = new CentralAdmin(Constants.REGISTRY_REMOVAL_ENDPOINT,
+ Constants.REGISTRY_REMOVAL_URI, Constants.REGISTRY_REMOVAL_USERNAME,
+ Constants.REGISTRY_REMOVAL_PASSWORD, Constants.REGISTRY_KEYPHRASE);
+ int code = centralAdmin.deleteService(service.getName(), service.getAuthority());
processCentralAdminCode(code);
return code;
}
@@ -857,15 +823,15 @@
private void removeInvalidServiceFromRegistry(MobyService service) {
// create and optionally save the report
- Report report = new Report(Constants.ADMIN_NAME,Constants.ADMIN_EMAIL, Constants.REGISTRY_REMOVAL_ENDPOINT, true);
- report.addToReport("\tThe service: " + service.getAuthority() + ","
- + service.getName() + " has been found to be invalid.");
+ Report report = new Report(Constants.ADMIN_NAME, Constants.ADMIN_EMAIL,
+ Constants.REGISTRY_REMOVAL_ENDPOINT, true);
+ report.addToReport("\tThe service: " + service.getAuthority() + "," + service.getName()
+ + " has been found to be invalid.");
report.addToReport("");
if (Constants.REPORT_ENABLE) {
Log.info("Saving the report");
- report.saveReport(Constants.REPORT_DIRECTORY, service
- .getAuthority()
- + "_" + service.getName() + ".rtf");
+ report.saveReport(Constants.REPORT_DIRECTORY, service.getAuthority() + "_"
+ + service.getName() + ".rtf");
}
if (sendMailOnInvalid) {
sendMail(service, report);
@@ -873,16 +839,12 @@
// only remove if we enable deregistration
if (enableDeregistration) {
- Log.info("Attempting to remove service, (" + service.getName()
- + ", " + service.getAuthority() + ").");
- CentralAdmin centralAdmin = new CentralAdmin(
- Constants.REGISTRY_REMOVAL_ENDPOINT,
- Constants.REGISTRY_REMOVAL_URI,
- Constants.REGISTRY_REMOVAL_USERNAME,
- Constants.REGISTRY_REMOVAL_PASSWORD,
- Constants.REGISTRY_KEYPHRASE);
- int code = centralAdmin.deleteService(service.getName(), service
- .getAuthority());
+ Log.info("Attempting to remove service, (" + service.getName() + ", "
+ + service.getAuthority() + ").");
+ CentralAdmin centralAdmin = new CentralAdmin(Constants.REGISTRY_REMOVAL_ENDPOINT,
+ Constants.REGISTRY_REMOVAL_URI, Constants.REGISTRY_REMOVAL_USERNAME,
+ Constants.REGISTRY_REMOVAL_PASSWORD, Constants.REGISTRY_KEYPHRASE);
+ int code = centralAdmin.deleteService(service.getName(), service.getAuthority());
processCentralAdminCode(code);
}
@@ -892,49 +854,42 @@
/*
* remove a bad service (invalid, no signature rdf, etc)
*/
- private void removeInvalidSignatureURLService(MobyService service,
- Central central, String reason, SignatureURLConnection connection) {
+ private void removeInvalidSignatureURLService(MobyService service, Central central,
+ String reason, SignatureURLConnection connection) {
int count = 0;
// create and optionally save the report
- Report report = new Report(Constants.ADMIN_NAME,Constants.ADMIN_EMAIL, Constants.REGISTRY_REMOVAL_ENDPOINT, true);
- report.addToReport("\tThe service: " + service.getAuthority() + ","
- + service.getName() + " generated the following error:");
+ Report report = new Report(Constants.ADMIN_NAME, Constants.ADMIN_EMAIL,
+ Constants.REGISTRY_REMOVAL_ENDPOINT, true);
+ report.addToReport("\tThe service: " + service.getAuthority() + "," + service.getName()
+ + " generated the following error:");
report.addToReport("\t\t" + reason);
- String rdf = ServiceInstanceRDF.findService(service.getAuthority(),
- service.getName(), central.getRegistryEndpoint(), central
- .getRegistryNamespace());
+ String rdf = ServiceInstanceRDF.findService(service.getAuthority(), service.getName(),
+ central.getRegistryEndpoint(), central.getRegistryNamespace());
report.addToReport("");
report.addToReport("Your service had the following RDF document:");
report.addToReport(rdf);
if (Constants.REPORT_ENABLE) {
Log.info("Saving the report");
- report.saveReport(Constants.REPORT_DIRECTORY, service
- .getAuthority()
- + "_" + service.getName() + ".rtf");
+ report.saveReport(Constants.REPORT_DIRECTORY, service.getAuthority() + "_"
+ + service.getName() + ".rtf");
}
if (!service.getSignatureURL().equals("")) {
- if (connection.getBadUrlMap()
- .containsKey(service.getSignatureURL())) {
- count = ((Integer) connection.getBadUrlMap().get(
- service.getSignatureURL())).intValue();
+ if (connection.getBadUrlMap().containsKey(service.getSignatureURL())) {
+ count = ((Integer) connection.getBadUrlMap().get(service.getSignatureURL()))
+ .intValue();
}
}
if (enableDeregistration) {
if (count >= errorLimit) {
- Log.info("Attempting to remove the service "
- + service.getName() + ", " + service.getAuthority()
- + "." + newline + "\tRemoved because " + reason);
-
- CentralAdmin centralAdmin = new CentralAdmin(
- Constants.REGISTRY_REMOVAL_ENDPOINT,
- Constants.REGISTRY_REMOVAL_URI,
- Constants.REGISTRY_REMOVAL_USERNAME,
- Constants.REGISTRY_REMOVAL_PASSWORD,
- Constants.REGISTRY_KEYPHRASE);
- int code = centralAdmin.deleteService(service.getName(),
- service.getAuthority());
+ Log.info("Attempting to remove the service " + service.getName() + ", "
+ + service.getAuthority() + "." + newline + "\tRemoved because " + reason);
+
+ CentralAdmin centralAdmin = new CentralAdmin(Constants.REGISTRY_REMOVAL_ENDPOINT,
+ Constants.REGISTRY_REMOVAL_URI, Constants.REGISTRY_REMOVAL_USERNAME,
+ Constants.REGISTRY_REMOVAL_PASSWORD, Constants.REGISTRY_KEYPHRASE);
+ int code = centralAdmin.deleteService(service.getName(), service.getAuthority());
processCentralAdminCode(code);
}
if (sendMailOnInvalid) {
@@ -948,43 +903,37 @@
* remove a bad service (invalid, no signature rdf, etc). this method is
* used when a signature url was already found to contain a bad service.
*/
- private void removeInvalidSignatureURLServiceFromRegistry(
- MobyService service, Central central, String reason, int count) {
+ private void removeInvalidSignatureURLServiceFromRegistry(MobyService service, Central central,
+ String reason, int count) {
// create and optionally save the report
- Report report = new Report(Constants.ADMIN_NAME,Constants.ADMIN_EMAIL, Constants.REGISTRY_REMOVAL_ENDPOINT,true );
- report.addToReport("\tThe service: " + service.getAuthority() + ","
- + service.getName() + " generated the following error:");
+ Report report = new Report(Constants.ADMIN_NAME, Constants.ADMIN_EMAIL,
+ Constants.REGISTRY_REMOVAL_ENDPOINT, true);
+ report.addToReport("\tThe service: " + service.getAuthority() + "," + service.getName()
+ + " generated the following error:");
report.addToReport("\t\t" + reason);
- String rdf = ServiceInstanceRDF.findService(service.getAuthority(),
- service.getName(), central.getRegistryEndpoint(), central
- .getRegistryNamespace());
+ String rdf = ServiceInstanceRDF.findService(service.getAuthority(), service.getName(),
+ central.getRegistryEndpoint(), central.getRegistryNamespace());
report.addToReport("");
report.addToReport("Your service had the following RDF document:");
report.addToReport(rdf);
if (Constants.REPORT_ENABLE) {
Log.info("Saving the report");
- report.saveReport(Constants.REPORT_DIRECTORY, service
- .getAuthority()
- + "_" + service.getName() + ".rtf");
+ report.saveReport(Constants.REPORT_DIRECTORY, service.getAuthority() + "_"
+ + service.getName() + ".rtf");
}
if (enableDeregistration) {
if (count >= errorLimit) {
- Log.info("Service " + service.getName() + ", "
- + service.getAuthority() + " has been removed."
- + newline + "\tRemoved because " + reason + newline
+ Log.info("Service " + service.getName() + ", " + service.getAuthority()
+ + " has been removed." + newline + "\tRemoved because " + reason + newline
+ "The agent has made " + count
+ " attempts to resolve and correctly parse the"
+ " service description url.");
- CentralAdmin centralAdmin = new CentralAdmin(
- Constants.REGISTRY_REMOVAL_ENDPOINT,
- Constants.REGISTRY_REMOVAL_URI,
- Constants.REGISTRY_REMOVAL_USERNAME,
- Constants.REGISTRY_REMOVAL_PASSWORD,
- Constants.REGISTRY_KEYPHRASE);
- int code = centralAdmin.deleteService(service.getName(),
- service.getAuthority());
+ CentralAdmin centralAdmin = new CentralAdmin(Constants.REGISTRY_REMOVAL_ENDPOINT,
+ Constants.REGISTRY_REMOVAL_URI, Constants.REGISTRY_REMOVAL_USERNAME,
+ Constants.REGISTRY_REMOVAL_PASSWORD, Constants.REGISTRY_KEYPHRASE);
+ int code = centralAdmin.deleteService(service.getName(), service.getAuthority());
processCentralAdminCode(code);
}
if (sendMailOnInvalid) {
@@ -998,39 +947,33 @@
* remove a bad service (invalid, no signature rdf, etc). this method is
* used when a signature url was already found to contain a bad service.
*/
- private void removeMissingServiceFromRegistry(MobyService service,
- Central central, String reason) {
+ private void removeMissingServiceFromRegistry(MobyService service, Central central,
+ String reason) {
// create and optionally save the report
- Report report = new Report(Constants.ADMIN_NAME,Constants.ADMIN_EMAIL, Constants.REGISTRY_REMOVAL_ENDPOINT, true);
- report.addToReport("\tThe service: " + service.getAuthority() + ","
- + service.getName() + " generated the following error:");
+ Report report = new Report(Constants.ADMIN_NAME, Constants.ADMIN_EMAIL,
+ Constants.REGISTRY_REMOVAL_ENDPOINT, true);
+ report.addToReport("\tThe service: " + service.getAuthority() + "," + service.getName()
+ + " generated the following error:");
report.addToReport("\t\t" + reason);
- String rdf = ServiceInstanceRDF.findService(service.getAuthority(),
- service.getName(), central.getRegistryEndpoint(), central
- .getRegistryNamespace());
+ String rdf = ServiceInstanceRDF.findService(service.getAuthority(), service.getName(),
+ central.getRegistryEndpoint(), central.getRegistryNamespace());
report.addToReport("");
report.addToReport("Your service had the following RDF document:");
report.addToReport(rdf);
if (Constants.REPORT_ENABLE) {
Log.info("Saving the report");
- report.saveReport(Constants.REPORT_DIRECTORY, service
- .getAuthority()
- + "_" + service.getName() + ".rtf");
+ report.saveReport(Constants.REPORT_DIRECTORY, service.getAuthority() + "_"
+ + service.getName() + ".rtf");
}
if (enableDeregistration) {
- Log.info("Service " + service.getName() + ", "
- + service.getAuthority() + " has been removed." + newline
- + "\tRemoved because " + reason + newline);
-
- CentralAdmin centralAdmin = new CentralAdmin(
- Constants.REGISTRY_REMOVAL_ENDPOINT,
- Constants.REGISTRY_REMOVAL_URI,
- Constants.REGISTRY_REMOVAL_USERNAME,
- Constants.REGISTRY_REMOVAL_PASSWORD,
- Constants.REGISTRY_KEYPHRASE);
- int code = centralAdmin.deleteService(service.getName(), service
- .getAuthority());
+ Log.info("Service " + service.getName() + ", " + service.getAuthority()
+ + " has been removed." + newline + "\tRemoved because " + reason + newline);
+
+ CentralAdmin centralAdmin = new CentralAdmin(Constants.REGISTRY_REMOVAL_ENDPOINT,
+ Constants.REGISTRY_REMOVAL_URI, Constants.REGISTRY_REMOVAL_USERNAME,
+ Constants.REGISTRY_REMOVAL_PASSWORD, Constants.REGISTRY_KEYPHRASE);
+ int code = centralAdmin.deleteService(service.getName(), service.getAuthority());
processCentralAdminCode(code);
if (sendMailOnInvalid) {
@@ -1044,8 +987,7 @@
boolean bool = false;
switch (code) {
case 101: {
- Log
- .warning("Central admin didnt receive an service provider authority");
+ Log.warning("Central admin didnt receive an service provider authority");
bool = false;
}
break;
@@ -1065,8 +1007,7 @@
}
break;
case 404: {
- Log
- .severe("Oddly enough, the service wasnt found in the registry!?!");
+ Log.severe("Oddly enough, the service wasnt found in the registry!?!");
bool = false;
}
break;
@@ -1094,8 +1035,7 @@
}
break;
case 508: {
- Log
- .severe("The url and/or uri for the Central Admin service were invalid.");
+ Log.severe("The url and/or uri for the Central Admin service were invalid.");
bool = false;
}
@@ -1126,55 +1066,44 @@
p = new ServiceInstanceParser(url);
rdfServices = p.getMobyServicesFromRDF();
} catch (MobyException e) {
- sb
- .append("Exception from processServicesFromUrlTEST(String, Central)"
- + e.getLocalizedMessage() + newline);
- Log.exception(this.getClass().getName(),
- "processServicesFromUrlTEST(String, Central)", e);
+ sb.append("Exception from processServicesFromUrlTEST(String, Central)"
+ + e.getLocalizedMessage() + newline);
+ Log.exception(this.getClass().getName(), "processServicesFromUrlTEST(String, Central)",
+ e);
return sb.toString();
}
if (p != null) {
if (rdfServices == null) {
- Log
- .warning("Unable to retrieve the services from " + url
- + ".");
+ Log.warning("Unable to retrieve the services from " + url + ".");
sb
.append("There was a problem extracting the services. Perhaps the rdf is invalid."
+ newline);
return sb.toString();
} else if (rdfServices.length == 0) {
if (p.isRDFValid()) {
- Log.info("Unable to retrieve any services from " + url
- + "." + newline
+ Log.info("Unable to retrieve any services from " + url + "." + newline
+ "Most likely cause is that there were none.");
- sb.append("Unable to retrieve any services from " + url
- + "." + newline
+ sb.append("Unable to retrieve any services from " + url + "." + newline
+ "Most likely cause is that there were none.");
} else {
- Log.info("Unable to retrieve any services from " + url
- + "." + newline + "Some of the problems are: "
- + Utils.format(p.getErrors(), 2));
- sb.append("Unable to retrieve any services from " + url
- + "." + newline + "Some of the problems are: "
- + Utils.format(p.getErrors(), 2));
+ Log.info("Unable to retrieve any services from " + url + "." + newline
+ + "Some of the problems are: " + Utils.format(p.getErrors(), 2));
+ sb.append("Unable to retrieve any services from " + url + "." + newline
+ + "Some of the problems are: " + Utils.format(p.getErrors(), 2));
}
return sb.toString();
} else {
- Log.info("Found the following services in the RDF located at "
- + url);
- sb.append("Found the following services in the RDF located at "
- + url + newline);
+ Log.info("Found the following services in the RDF located at " + url);
+ sb.append("Found the following services in the RDF located at " + url + newline);
for (int i = 0; i < rdfServices.length; i++) {
MobyService serv = rdfServices[i];
MobyServiceComparator comparator = new MobyServiceComparator();
if (!comparator.areInputsOutputsForServiceValid(serv)) {
- Log.info(Utils.format("Invalid service found: "
- + serv.getUniqueName(), 2));
- sb.append(Utils.format("Invalid service found: "
- + serv.getUniqueName(), 2)
+ Log.info(Utils.format("Invalid service found: " + serv.getUniqueName(), 2));
+ sb.append(Utils.format("Invalid service found: " + serv.getUniqueName(), 2)
+ newline);
} else {
Log.info(Utils.format(serv, 2));
More information about the MOBY-guts
mailing list