[MOBY-guts] biomoby commit

Eddie Kawas kawas at pub.open-bio.org
Tue May 31 18:13:13 UTC 2005


kawas
Tue May 31 14:13:13 EDT 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority
In directory pub.open-bio.org:/tmp/cvs-serv6385/org/biomoby/client/ui/graphical/servlet/lsid/authority

Modified Files:
	MobyAuthority.java LSIDDataLookup.java 
Log Message:
Updated property file usage and improved some logic to (Hopefully) make code more portable. Eddie

moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority MobyAuthority.java,1.1,1.2 LSIDDataLookup.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority/MobyAuthority.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority/MobyAuthority.java	2005/04/07 16:42:26	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority/MobyAuthority.java	2005/05/31 18:13:13	1.2
@@ -1,6 +1,9 @@
-
 package org.biomoby.client.ui.graphical.servlet.lsid.authority;
 
+import java.util.Properties;
+
+import org.biomoby.registry.properties.MobyProperties;
+
 import com.ibm.lsid.ExpiringResponse;
 import com.ibm.lsid.LSID;
 import com.ibm.lsid.LSIDException;
@@ -20,19 +23,14 @@
  */
 
 /**
- * @author Eddie Kawas
- *         <p>
- *         Created for
- *         <p>
- *         This class was created to ...
- *         <p>
- *         For questions, comments, or bugs
- *         <p>
- *         email me at edward.kawas at gmail.com
+ * @author Eddie Kawas <p> Created for <p> This class was created to ... <p> For
+ *         questions, comments, or bugs <p> email me at edward.kawas at gmail.com
  */
 public class MobyAuthority extends SimpleAuthority {
     private LSIDDataLookup lookup = null;
 
+    private Properties properties = MobyProperties.PROPERTIES();
+
     public LSIDMetadataPort[] getMetadataLocations(LSID lsid, String url) {
 
         if (lookup == null)
@@ -48,7 +46,13 @@
         if (lsType == LSIDDataLookup.UNKNOWN)
             return null;
 
-        return new LSIDMetadataPort[] { new SOAPLocation("BioMOBYSOAPPort","http://mobycentral.cbr.nrc.ca:8090/authority/metadata"), new HTTPLocation("BioMOBYHTTPPort","mobycentral.cbr.nrc.ca",8090, "/authority/metadata" ) };
+        return new LSIDMetadataPort[] {
+                new SOAPLocation("BioMOBYSOAPPort", "http://"
+                        + properties.getProperty("lsid_domain") + ":"
+                        + properties.getProperty("lsid_port")
+                        + "/authority/metadata"),
+                new HTTPLocation("BioMOBYHTTPPort", properties.getProperty("lsid_domain"),
+                        Integer.parseInt(properties.getProperty("lsid_port")), "/authority/metadata") };
     }
 
     public LSIDDataPort[] getDataLocations(LSID lsid, String url) {
@@ -56,24 +60,29 @@
     }
 
     /*
-     *  (non-Javadoc)
+     * (non-Javadoc)
+     * 
      * @see com.ibm.lsid.server.LSIDAuthorityService#getAvailableServices(com.ibm.lsid.server.LSIDRequestContext)
      */
-    public ExpiringResponse getAvailableServices(LSIDRequestContext ctx) throws LSIDServerException {
+    public ExpiringResponse getAvailableServices(LSIDRequestContext ctx)
+            throws LSIDServerException {
         LSID lsid = ctx.getLsid();
-		String url = ctx.getReqUrl();
-		try {
-			LSIDWSDLWrapper wsdl = new LSIDWSDLWrapper(lsid);
-			LSIDMetadataPort[] metaLocs = getMetadataLocations(lsid,url);
-			if (metaLocs != null)
-				for (int i = 0; i < metaLocs.length; ++i) {
-					wsdl.setMetadataLocation(metaLocs[i]);
-				}
-			return new ExpiringResponse(wsdl.toString(),getExpiration());
-		} catch (LSIDException e) {
-			throw new LSIDServerException(e, e.getErrorCode(), "Simple Authority Error in getAvailableOperations(" + lsid + "): ");
-		}
+        String url = ctx.getReqUrl();
+        try {
+            LSIDWSDLWrapper wsdl = new LSIDWSDLWrapper(lsid);
+            LSIDMetadataPort[] metaLocs = getMetadataLocations(lsid, url);
+            if (metaLocs != null)
+                for (int i = 0; i < metaLocs.length; ++i) {
+                    wsdl.setMetadataLocation(metaLocs[i]);
+                }
+            return new ExpiringResponse(wsdl.toString(), getExpiration());
+        } catch (LSIDException e) {
+            throw new LSIDServerException(e, e.getErrorCode(),
+                    "Simple Authority Error in getAvailableOperations(" + lsid
+                            + "): ");
+        }
     }
+
     /*
      * (non-Javadoc)
      * 
@@ -83,4 +92,4 @@
             throws LSIDServerException {
         lookup = new LSIDDataLookup();
     }
-}
\ No newline at end of file
+}

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority/LSIDDataLookup.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority/LSIDDataLookup.java	2005/04/07 16:42:26	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority/LSIDDataLookup.java	2005/05/31 18:13:13	1.2
@@ -18,9 +18,11 @@
 package org.biomoby.client.ui.graphical.servlet.lsid.authority;
 import java.io.IOException;
 import java.util.HashMap;
+import java.util.Properties;
 
 import org.biomoby.client.rdf.builder.RDFConfigure;
 import org.biomoby.client.rdf.builder.ServiceInstanceRDF;
+import org.biomoby.registry.properties.MobyProperties;
 
 import com.ibm.lsid.LSID;
 import com.ibm.lsid.server.LSIDServerException;
@@ -43,6 +45,12 @@
 
     public static final int MOBY_PREDICATE = 6;
     
+    private Properties mobycentral = MobyProperties.SERVICE_INSTANCE_PROPERTIES();
+    private Properties mobyobject = MobyProperties.OBJECT_PROPERTIES();
+    private Properties mobyservice = MobyProperties.SERVICE_PROPERTIES();
+    private Properties mobynamespace = MobyProperties.NAMESPACE_PROPERTIES();
+    private Properties mobyrelationship = MobyProperties.RELATIONSHIP_PROPERTIES();
+    
     /**
      * 0 - object
      * 1 - namespace
@@ -64,15 +72,15 @@
         int result = UNKNOWN;
         System.err.println(lsid.toString());
         String authority = lsid.getAuthority().getAuthority();
-        if (!authority.equals("biomoby.org")) {
-            throw new LSIDServerException("Error in lsidType - Unknown LSID: " + lsid.getLsid());
-        }
 
         if (ver != null || (ver != null && ver.length() != 0))
             return UNKNOWN;
 
-        if (ns.equalsIgnoreCase("namespacetype")) {
+        if (ns.equalsIgnoreCase(mobynamespace.getProperty("lsid_namespace"))) {
             if (lsidLookup[1] == null) {
+                if (!authority.equals(mobynamespace.getProperty("lsid_authority"))) {
+                    throw new LSIDServerException("Error in lsidType - Unknown LSID: " + lsid.getLsid());
+                }
                 try {
                     lsidLookup[1] = new RDFConfigure(RDFConfigure.URI_NAMESPACE);
                 } catch (IOException e) {
@@ -82,8 +90,11 @@
             if (lsidLookup[1].objectExists(lsid.getObject()))
                 result = NAMESPACE_TYPE;
         }
-        else if (ns.equalsIgnoreCase("objectclass")) {
+        else if (ns.equalsIgnoreCase(mobyobject.getProperty("lsid_namespace"))) {
             if (lsidLookup[0] == null) {
+                if (!authority.equals(mobyobject.getProperty("lsid_authority"))) {
+                    throw new LSIDServerException("Error in lsidType - Unknown LSID: " + lsid.getLsid());
+                }
                 try {
                     lsidLookup[0] = new RDFConfigure(RDFConfigure.URI_OBJECT);
                 } catch (IOException e) {
@@ -93,8 +104,11 @@
             if (lsidLookup[0].objectExists(lsid.getObject()))    
                 result = OBJECT_CLASS;
         }
-        else if (ns.equalsIgnoreCase("servicetype")) {
+        else if (ns.equalsIgnoreCase(mobyservice.getProperty("lsid_namespace"))) {
             if (lsidLookup[2] == null) {
+                if (!authority.equals(mobyservice.getProperty("lsid_authority"))) {
+                    throw new LSIDServerException("Error in lsidType - Unknown LSID: " + lsid.getLsid());
+                }
                 try {
                     lsidLookup[2] = new RDFConfigure(RDFConfigure.URI_SERVICE);
                 } catch (IOException e) {
@@ -117,11 +131,14 @@
             return UNKNOWN;
             
         }
-        else if (ns.equalsIgnoreCase("serviceinstance")) {
+        else if (ns.equalsIgnoreCase(mobycentral.getProperty("lsid_namespace"))) {
             String str = lsid.getObject();
             // make sure that the service instance is in the form
             // domain,serviceInstanceName
             if (lsidLookup[3] == null) {
+                if (!authority.equals(mobycentral.getProperty("lsid_authority"))) {
+                    throw new LSIDServerException("Error in lsidType - Unknown LSID: " + lsid.getLsid());
+                }
                 try {
                     lsidLookup[3] = new RDFConfigure(RDFConfigure.URI_ServiceINSTANCE);
                 } catch (IOException e) {




More information about the MOBY-guts mailing list