Displaying differences for changeset
 
display as  

jenkins-build.xml

@@ -47,16 +47,16 @@
         <tstamp>
             <format property="time.now" pattern="yyyy-MM-dd HH:mm"/>
         </tstamp>
-        <replaceregexp match="(.*)\$version(.*)\$(.*)" replace="\1$version: ${hg.version.full}, built at: ${time.now} by ${user.name}$\3" flags="g">
+        <replaceregexp match="(.*)\$version(.*)\$(.*)" replace="\1$version: ${hg.version.full}, built at ${time.now} by ${user.name}$\3" flags="g">
             <fileset dir="." includes="**/Config.java"/>
-            <fileset dir="." includes="**/csip-conf*.json"/>
+            <fileset dir="." includes="**/csip-*.json"/>
         </replaceregexp>
     </target>
     
     <target name="-create-versioned-war">
         <basename property="war.base" file="${dist.war}" suffix=".war"/>
         <move file="${dist.war}" tofile="${dist.dir}/${war.base}##${hg.version.short}.war"/>
-        <echo file="dist/version.txt">${hg.version.short}</echo>
+        <echo file="${dist.dir}/version.txt">${hg.version.short}</echo>
         <echo>Created: ${war.base}##${hg.version.short}.war</echo>
     </target>
             

src/csip/CatalogService.java

@@ -52,11 +52,11 @@
         try {
             Registry r = Config.registry();
             String host = Services.toPublicURL(uriInfo.getRequestUri()).toString();
-            for (int i = 0; i < r.getServiceCount(); i++) {
+            for (Class<?> c : r.getServices()) {
                 JSONObject m = new JSONObject();
-                String url = host + "/" + r.getServicePath(i);
-                m.put(ModelDataService.KEY_NAME, r.getServiceName(i));
-                m.put(ModelDataService.KEY_DESC, r.getServiceDescription(i));
+                String url = host + "/" + r.getServicePath(c);
+                m.put(ModelDataService.KEY_NAME, r.getServiceName(c));
+                m.put(ModelDataService.KEY_DESC, r.getServiceDescription(c));
                 m.put(ModelDataService.KEY_URL, url);
                 o.put(m);
             }

src/csip/Config.java

@@ -35,6 +35,7 @@
 import com.mongodb.gridfs.GridFS;
 import com.mongodb.gridfs.GridFSDBFile;
 import com.mongodb.gridfs.GridFSInputFile;
+import com.sun.javafx.scene.control.skin.VirtualFlow;
 import csip.ModelDataService.Task;
 import csip.utils.Binaries;
 import java.io.ByteArrayInputStream;
@@ -104,7 +105,7 @@
         /* 
          The CSIP version
          */
-        put("csip.version", "$version$");
+        put("csip.version", "$version: 2.1.10 dec2e8c6030c 2016-03-30 od, built at 2016-03-31 20:57 by od$");
 
         /*
          * The runtime architecture. 
@@ -292,8 +293,8 @@
 
     public static class Registry {
 
-        List<Class<?>> s = new ArrayList<>();
         String context;
+        List<Class<?>> s;
         Set<Class<?>> regServ;
 
 
@@ -308,16 +309,24 @@
 
 
         public void register(Set<Class<?>> service) {
-            for (Class<?> c : service) {
-                if (!s.contains(c)
-                        && (c.getCanonicalName().startsWith("m.") // model service
+            if (regServ != null) {
+                return;
+            }
+            regServ = service;
+            s = new ArrayList<>();
+
+            service.forEach(c -> {
+                if ((c.getCanonicalName().startsWith("m.") // model service
                         || c.getCanonicalName().startsWith("d."))) { // data service
-                    LOG.info("Register: " + c.getName());
+                    LOG.info("Register service: " + c.getName());
                     s.add(c);
                     callStaticMethodIfExist(c, "onContextInit");
                 }
-            }
-            regServ = service;
+            });
+            Collections.sort(s, (Class<?> o1, Class<?> o2)
+                    -> getServiceName(o1).compareTo(getServiceName(o2)));
+
+            LOG.info(">>> Registered " + service.size() + " CSIP services.");
         }
 
 
@@ -325,13 +334,12 @@
             if (regServ == null) {
                 return;
             }
-            for (Class<?> c : regServ) {
-                if (s.contains(c)) {
-                    LOG.info("Unregister service " + c);
-                    s.remove(c);
-                    callStaticMethodIfExist(c, "onContextDestroy");
-                }
-            }
+            regServ = null;
+            s.forEach(c -> {
+                LOG.info("Unregister service " + c);
+                callStaticMethodIfExist(c, "onContextDestroy");
+            });
+            s.clear();
         }
 
 
@@ -348,30 +356,25 @@
         }
 
 
-        void clear() {
-            s.clear();
+        List<Class<?>> getServices() {
+            return s;
         }
 
 
-        int getServiceCount() {
-            return s.size();
-        }
-
-
-        String getServicePath(int i) {
-            Path p = (Path) s.get(i).getAnnotation(Path.class);
+        String getServicePath(Class<?> i) {
+            Path p = (Path) i.getAnnotation(Path.class);
             return (p == null) ? "" : p.value();
         }
 
 
-        String getServiceName(int i) {
-            Name p = (Name) s.get(i).getAnnotation(Name.class);
+        String getServiceName(Class<?> i) {
+            Name p = (Name) i.getAnnotation(Name.class);
             return (p == null) ? "" : p.value();
         }
 
 
-        String getServiceDescription(int i) {
-            Description p = (Description) s.get(i).getAnnotation(Description.class);
+        String getServiceDescription(Class<?> i) {
+            Description p = (Description) i.getAnnotation(Description.class);
             return (p == null) ? "" : p.value();
         }
     }

src/csip/ControlService.java

@@ -163,17 +163,23 @@
     }
 
 
+    static void updateConfig(Properties p, String key, String value) {
+    }
+
+
     static String updateConfig(String inputObj) throws JSONException {
         Properties p = Config.getProperties();
         Collection<Config.PostgresChunk> pcs = Config.getPostgresChunks();
-
         synchronized (p) {
             try {
                 JSONObject o = new JSONObject(inputObj);
                 Iterator i = o.keys();
                 while (i.hasNext()) {
                     String key = i.next().toString();
-                    LOG.info("update: " + key + " = " + o.getString(key));
+                    if (key.trim().equals("#") || key.trim().equals("//") || key.toLowerCase().startsWith("note")) {
+                        continue;
+                    }
+                    LOG.info(" " + key + " = " + o.getString(key));
 
                     // pg dbs go into the list
                     if ((key.length() > 4) && (key.startsWith("pgdb")) && (Integer.parseInt(key.substring(4))) > 0) {

src/csip/ModelDataService.java

@@ -475,6 +475,8 @@
             return process0();
         };
     }
+
+
     /**
      * Process logic of the service.
      * @return null if the process ended successfully, the error message
@@ -498,10 +500,10 @@
             } else {
                 postProcess();
             }
+            return null;
         } catch (Throwable E) {
             return E;
         }
-        return null;
     }
 
 
@@ -515,7 +517,6 @@
         } catch (Throwable E) {
             return E;
         }
-//        return null;
     }
 
 
@@ -2206,8 +2207,6 @@
             processOptions();
             LOG = new SessionLogger(getResultsDir(), getServicePath(), getSUID());
         }
-
-//        Config.getLoggingStore().setupHandler(LOG, tz);
         if (LOG.isLoggable(Level.INFO)) {
             LOG.info("path: " + getServicePath());
             LOG.info("from: " + req.getRemoteAddr() + "," + req.getRemoteHost() + "," + req.getRemoteUser());
@@ -2222,7 +2221,6 @@
             LOG.info("context: " + req.getContextPath());
             LOG.info("x-forwarded-for:" + req.getHeader("X-Forwarded-For"));
         }
-
         req_remoteIp = req.getHeader("X-Forwarded-For");
         if (req_remoteIp == null) {
             req_remoteIp = req.getRemoteAddr();

src/csip/QueryService.java

@@ -49,7 +49,6 @@
 import javax.ws.rs.client.ClientBuilder;
 import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.ResponseBuilder;
 import org.codehaus.jettison.json.JSONObject;
 
 /**
@@ -219,7 +218,7 @@
                 // try to find the file.
                 ModelSession session = Config.getSessionStore().getSession(suid);
                 if (session == null) {
-                    return Response.ok(JSONUtils.error("suid unknown").toString(), MediaType.APPLICATION_JSON).build();
+                    return Response.ok(JSONUtils.error("suid not found: " + suid).toString(), MediaType.APPLICATION_JSON).build();
                 }
                 // but the file should be here, avoid infinite loop here.
                 if (session.getNodeIP().equals(Services.LOCAL_IP_ADDR)) {
@@ -402,11 +401,11 @@
                     StreamingOutput o = (StreamingOutput) out.getEntity();
                     return toString(o);
                 }
-                return "{ error: \" not found:" + file + "\"}";
+                return JSONUtils.error("not found: " + suid).toString();
             }
             return JSONUtils.error("suid unknown: " + suid).toString();
         } catch (Exception E) {
-            return JSONUtils.error("suid unknown " + E.getMessage()).toString();
+            return JSONUtils.error("exception fetching suid: " + suid + ", problem: " + E.getMessage()).toString();
         }
     }
 

src/csip/ServletContextHooks.java

@@ -36,22 +36,22 @@
 @WebListener
 public class ServletContextHooks implements ServletContextListener {
 
+    static Logger l = Logger.getLogger(ServletContextHooks.class.getName());
+
+
     /**
      * Apply an initial config if present.
      *
      * @param ctx
      */
-    private void applyConfig(ServletContext ctx) {
-        InputStream is = ctx.getResourceAsStream("/META-INF/csip-conf.json");
+    private void applyConfig(ServletContext ctx, String file) {
+        InputStream is = ctx.getResourceAsStream(file);
         if (is != null) {
             try {
-                String s = IOUtils.toString(is);
-                Logger.getLogger(ServletContextHooks.class.getName()).info("Using bundled context config in 'META-INF/csip-conf.json'");
-                String newConf = ControlService.updateConfig(s);
-                Logger.getLogger(ServletContextHooks.class.getName()).info("Service configuration:");
-                Logger.getLogger(ServletContextHooks.class.getName()).info(newConf);
+                l.info("Apply bundled context config '" + file + "'");
+                ControlService.updateConfig(IOUtils.toString(is));
             } catch (IOException | JSONException ex) {
-                ex.printStackTrace(System.out);
+                ex.printStackTrace(System.err);
             }
         }
     }
@@ -60,14 +60,16 @@
     @Override
     public void contextInitialized(ServletContextEvent e) {
         Config.startup(e.getServletContext());
-        Logger.getLogger(ServletContextHooks.class.getName()).info("CSIP Context Created: " + e.getServletContext().getContextPath());
-        applyConfig(e.getServletContext());
+        applyConfig(e.getServletContext(), "/WEB-INF/csip-defaults.json");
+        applyConfig(e.getServletContext(), "/META-INF/csip-conf.json");
+        l.info("CSIP Context Created: " + e.getServletContext().getContextPath());
     }
 
 
     @Override
     public void contextDestroyed(ServletContextEvent e) {
         Config.shutdown(e.getServletContext());
-        Logger.getLogger(ServletContextHooks.class.getName()).info("CSIP Context Destroyed: " + e.getServletContext().getContextPath());
+        l.info("CSIP Context Destroyed: " + e.getServletContext().getContextPath());
     }
+
 }