Displaying differences for changeset
 
display as  

src/csip/ArchiveService.java

@@ -52,7 +52,7 @@
     @Produces(MediaType.APPLICATION_OCTET_STREAM)
     @Path("download/{suid}")
     public Response downloadArchive(@Context UriInfo uriInfo, @Context HttpServletRequest req, @PathParam("suid") final String suid) {
-        Config.checkRemoteAccessACL(req);
+        Utils.checkRemoteAccessACL(req);
         if (!Config.isArchiveEnabled()) {
             String o = JSONUtils.error("archive disabled").toString();
             return Response.status(404).entity(o).type(MediaType.APPLICATION_JSON).build();
@@ -63,7 +63,7 @@
                 byte[] b = Config.getArchiveStore().getFile(suid, "files-" + suid + ".zip");
                 if (b != null) {
                     String ext = ".zip";
-                    if (Arrays.equals(Config.ArchiveStore.ARCHIVE_TOO_BIG.getBytes(), b)) {
+                    if (Arrays.equals(ArchiveStore.ARCHIVE_TOO_BIG.getBytes(), b)) {
                         ext = ".txt";
                     }
                     return Response.ok(QueryService.output(b)).header("Content-Disposition", "attachment; filename=archive-" + suid + ext).build();
@@ -81,7 +81,7 @@
     @Produces(MediaType.APPLICATION_JSON)
     @Path("remove/{suid}")
     public String removeArchive(@Context UriInfo uriInfo, @Context HttpServletRequest req, @PathParam("suid") final String suid) {
-        Config.checkRemoteAccessACL(req);
+        Utils.checkRemoteAccessACL(req);
         try {
             if (!Config.isArchiveEnabled()) {
                 return JSONUtils.error("archive disabled. ").toString();
@@ -102,7 +102,7 @@
     @Produces(MediaType.APPLICATION_JSON)
     @Path("clean")
     public String clean(@Context UriInfo uriInfo, @Context HttpServletRequest req) throws JSONException {
-        Config.checkRemoteAccessACL(req);
+        Utils.checkRemoteAccessACL(req);
 
         if (!Config.isArchiveEnabled()) {
             return JSONUtils.error("archive disabled. ").toString();

src/csip/CatalogService.java

@@ -11,7 +11,7 @@
  */
 package csip;
 
-import csip.Config.Registry;
+import csip.Registry;
 import csip.utils.JSONUtils;
 import csip.utils.Services;
 import csip.utils.SimpleCache;
@@ -50,7 +50,7 @@
     public String getJSONCatalog(@Context UriInfo uriInfo) {
         LOG.log(Level.INFO, "HTTP/GET {0}", uriInfo.getRequestUri().toString());
 
-        return cat.get(Config.registry(), (Registry r) -> {
+        return cat.get(Config.getRegistry(), (Registry r) -> {
             JSONArray o = new JSONArray();
             try {
                 String host = Services.toPublicURL(uriInfo.getRequestUri()).toString();

src/csip/Config.java

@@ -11,60 +11,16 @@
  */
 package csip;
 
-import com.mongodb.BasicDBObject;
-import com.mongodb.DB;
-import com.mongodb.DBCollection;
-import com.mongodb.DBCursor;
-import com.mongodb.DBObject;
-import com.mongodb.MongoClient;
-import com.mongodb.MongoClientURI;
-import com.mongodb.WriteResult;
-import com.mongodb.client.FindIterable;
-import com.mongodb.client.MongoCollection;
-import com.mongodb.client.MongoDatabase;
-import com.mongodb.client.model.UpdateOptions;
-import com.mongodb.client.result.DeleteResult;
-import com.mongodb.client.result.UpdateResult;
-import com.mongodb.gridfs.GridFS;
-import com.mongodb.gridfs.GridFSDBFile;
-import com.mongodb.gridfs.GridFSInputFile;
 import csip.ModelDataService.Task;
 import csip.utils.Binaries;
 import csip.utils.SimpleCache;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.locks.ReentrantLock;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.Path;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-import javax.xml.bind.DatatypeConverter;
-import oms3.annotations.Description;
-import oms3.annotations.Name;
-import org.apache.commons.net.util.SubnetUtils;
-import org.bson.Document;
-import org.codehaus.jettison.json.JSONException;
-import org.codehaus.jettison.json.JSONObject;
 
 /**
  * Global properties, changeable at runtime.
@@ -72,24 +28,23 @@
  * @author od
  */
 public class Config {
-    
+
     private static final Properties p = new Properties();
     private static final Properties allProps = new Properties();
-    
+
     private static final LinkedList<PostgresChunk> pcs = new LinkedList<>();
     private static final List<Task> tasks = Collections.synchronizedList(new ArrayList<Task>());
     //
     //
     private static ArchiveStore archive;
     private static SessionStore session;
-//    private static AccessLogStore logstore;
     private static ResultStore resultStore;
 
     //
     private static ExecutorService exec;
     private static Timer timer;
     private static final Registry reg = new Registry();
-    private static final Logger LOG = Logger.getLogger(Config.class.getName());
+    static final Logger LOG = Logger.getLogger(Config.class.getName());
 
     //
     public static final String CSIP_VERSION = "csip.version";
@@ -123,24 +78,28 @@
     public static final String CSIP_SNAPSHOT = "csip.snapshot";
     public static final String CSIP_KEEPWORKSPACE = "csip.keepworkspace";
     public static final String CSIP_JDBC_CHECKVALID = "csip.jdbc.checkvalid";
-    
+
+    // values for session/archive/result    
+    public static final String MONGODB = "mongodb";
+    public static final String LOCAL = "local";
+    public static final String SQL = "sql";
     public static final String NONE = "none";
-    
-    
+
+
     public static Map<Object, Object> properties() {
         return Collections.unmodifiableMap(p);
     }
 
     // 
     static SimpleCache<File, ReentrantLock> wsFileLocks = new SimpleCache<>();
-    
-    
+
+
     static {
 
         /* 
          The CSIP version
          */
-        put(CSIP_VERSION, "$version: 2.1.179 5b6bb423bd93 2017-04-17 od, built at 2017-04-20 09:18 by od$");
+        put(CSIP_VERSION, "$version: 2.1.180 8d161c806793 2017-04-20 od, built at 2017-04-21 11:40 by od$");
 
         /*
          * The runtime architecture. 
@@ -164,7 +123,7 @@
          The backend to use for session management. valid choices are 
          "mongodb", "sql", "local". 
          */
-        put(CSIP_SESSION_BACKEND, "local");
+        put(CSIP_SESSION_BACKEND, LOCAL);
 
 
         /*
@@ -311,1048 +270,60 @@
 
         // internal
         put("vm.port", "8080");
-        
+
         update();
     }
-    
+
 
     public static void register(Set<Class<?>> service) {
-        registry().register(service);
+        getRegistry().register(service);
     }
 
+
     /**
-     *
+     * @return @deprecated use register() instead.
      */
-    public static class Registry {
-        
-        String context;
-        List<Class<?>> s;
-        Set<Class<?>> regServ;
-        
-        
-        void setContext(String context) {
-            this.context = context;
-        }
-        
-        
-        String getContext() {
-            return context;
-        }
-        
-        
-        public void register(Set<Class<?>> 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 service " + c);
-                    s.add(c);
-                    callStaticMethodIfExist(c, "onContextInit");
-                }
-            });
-            Collections.sort(s, (Class<?> o1, Class<?> o2)
-                    -> getServiceName(o1).compareTo(getServiceName(o2)));
-            LOG.info(">>>>>>>> Registered " + s.size() + " CSIP services.");
-        }
-        
-        
-        public void unregister() {
-            if (regServ == null) {
-                return;
-            }
-            regServ = null;
-            s.forEach(c -> {
-                LOG.info("Unregister service " + c);
-                callStaticMethodIfExist(c, "onContextDestroy");
-            });
-            s.clear();
-        }
-        
-        
-        static void callStaticMethodIfExist(Class c, String method) {
-            try {
-                Method m = c.getMethod(method);
-                m.invoke(null);
-                LOG.info("Found and Invoked '" + method + "' in: " + c);
-            } catch (NoSuchMethodException ex) {
-                return; // no problem
-            } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
-                LOG.log(Level.SEVERE, null, ex);
-            }
-        }
-        
-        
-        List<Class<?>> getServices() {
-            return s;
-        }
-        
-        
-        String getServicePath(Class<?> i) {
-            Path p = (Path) i.getAnnotation(Path.class);
-            return (p == null) ? "" : p.value();
-        }
-        
-        
-        String getServiceName(Class<?> i) {
-            Name p = (Name) i.getAnnotation(Name.class);
-            return (p == null) ? "" : p.value();
-        }
-        
-        
-        String getServiceDescription(Class<?> i) {
-            Description p = (Description) i.getAnnotation(Description.class);
-            return (p == null) ? "" : p.value();
-        }
-    }
-    
-    
+    @Deprecated
     public static Registry registry() {
         return reg;
     }
 
-    /**
-     * session store.
-     */
-    interface SessionStore {
 
-        /**
-         * Set a model session.
-         *
-         * @param suid
-         * @param session
-         * @throws Exception
-         */
-        void setSession(String suid, ModelSession session) throws Exception;
-
-
-        /**
-         * Get a model session
-         * @param suid
-         * @return the model session
-         * @throws Exception
-         */
-        ModelSession getSession(String suid) throws Exception;
-        
-        
-        boolean hasSession(String suid) throws Exception;
-
-
-        /**
-         * Remove a model session.
-         *
-         * @param suid
-         */
-        void removeSession(String suid);
-
-
-        /**
-         * Shutdown the session store
-         * @throws Exception
-         */
-        void shutdown() throws Exception;
-
-
-        /**
-         *
-         * @param skip the number of keys to skip
-         * @param limit the number of keys to return (0) means all
-         * @param sortby the 'field' to sort by.
-         * @param sortAscending true if sort is ascending, false otherwise.
-         * @return the keys.
-         */
-        Set<String> keys(int skip, int limit, String sortby, boolean sortAscending);
-
-
-        /**
-         * Get the number of elements.
-         * @return the number of elements.
-         */
-        long getCount();
-
-
-        /**
-         * Ping the store.
-         *
-         * @throws Exception if something is wrong.
-         */
-        void ping() throws Exception;
+    static Registry getRegistry() {
+        return reg;
     }
 
-    /**
-     * Archive Store
-     */
-    interface ArchiveStore {
-        
-        static String ARCHIVE_TOO_BIG = "the archive was too big to store.";
-        
-        
-        void archiveSession(String sid, ModelArchive ma, File f) throws Exception;
-        
-        
-        ModelArchive getArchive(String suid) throws Exception;
-        
-        
-        boolean hasArchive(String suid) throws Exception;
-        
-        
-        void removeArchive(String suid);
-        
-        
-        byte[] getFile(String suid, String filename) throws Exception;
-        
-        
-        void shutdown() throws Exception;
 
-
-        /**
-         * Get the number of elements.
-         * @return the number of elements
-         */
-        long getCount();
-        
-        
-        Set<String> keys(int skip, int limit, String sortby, boolean sortAsc);
-        
-        ArchiveStore NONE = new ArchiveStore() {
-            Set<String> keys = new HashSet<>();
-            
-            
-            @Override
-            public void archiveSession(String sid, ModelArchive ma, File f) throws Exception {
-            }
-            
-            
-            @Override
-            public ModelArchive getArchive(String suid) throws Exception {
-                return null;
-            }
-            
-            
-            @Override
-            public void removeArchive(String suid) {
-            }
-            
-            
-            @Override
-            public byte[] getFile(String suid, String filename) throws Exception {
-                return null;
-            }
-            
-            
-            @Override
-            public void shutdown() throws Exception {
-            }
-            
-            
-            @Override
-            public Set<String> keys(int skip, int limit, String sortby, boolean sortAsc) {
-                return keys;
-            }
-            
-            
-            @Override
-            public long getCount() {
-                return keys.size();
-            }
-            
-            
-            @Override
-            public boolean hasArchive(String suid) throws Exception {
-                return false;
-            }
-        };
-        
-    }
-    
-    interface ResultStore {
-
-        /**
-         *
-         * @param request
-         * @return the result json.
-         * @throws Exception
-         */
-        String getResult(String request);
-
-
-        /**
-         * Returns hash
-         * @param digest
-         * @param results
-         * @throws Exception
-         */
-        void putResult(String digest, String results);
-
-
-        /**
-         * Get the digest.
-         * @param request
-         * @return the sha1 digest.
-         */
-        default String getDigest(String request) {
-            request = request.replace(" ", "").replace("\n", "").replace("\t", "");
-            try {
-                return DatatypeConverter.printHexBinary(
-                        MessageDigest.getInstance("SHA1").digest(request.getBytes("UTF-8"))).toLowerCase();
-            } catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) {
-                return null;
-            }
-        }
-
-
-        /**
-         * Purge the results.
-         */
-        void purge();
-
-
-        /**
-         * Shut down the resource
-         * @throws Exception
-         */
-        default void shutdown() throws Exception {
-        }
-        
-        ResultStore NONE = new ResultStore() {
-            
-            @Override
-            public String getResult(String request) {
-                return null;
-            }
-            
-            
-            @Override
-            public void putResult(String digest, String results) {
-            }
-            
-            
-            @Override
-            public String getDigest(String request) {
-                return null;
-            }
-            
-            
-            @Override
-            public void purge() {
-            }
-            
-        };
-        
+    static boolean isArchiveEnabled() {
+        return !getString(CSIP_ARCHIVE_BACKEND, NONE).equals(NONE);
     }
 
-    /**
-     *
-     */
-    static class MongoResultStore implements ResultStore {
-        
-        MongoClient mongo;
-        MongoDatabase db;
-        static final String RESULTS = "results";
-        
-        
-        MongoResultStore(String uri) {
-            MongoClientURI u = new MongoClientURI(uri);
-            String dbname = u.getDatabase();
-            if (dbname == null) {
-                dbname = "csip";
-            }
-            mongo = new MongoClient(u);
-            db = mongo.getDatabase(dbname);
-            LOG.info("Connected to mongo result store : " + uri);
-        }
-        
-        
-        @Override
-        public synchronized String getResult(String digest) {
-            FindIterable<Document> r = db.getCollection(RESULTS).find(new Document("_id", digest));
-            Document o = r.first();
-            if (o != null) {
-                return o.getString("result");
-            } else {
-                LOG.warning("No previous result for : " + digest);
-                return null;
-            }
-        }
-        
-        
-        @Override
-        public synchronized void putResult(String digest, String result) {
-            Document doc = new Document();
-            doc.append("_id", digest);
-            doc.append("result", result);
-            
-            UpdateOptions opt = new UpdateOptions();
-            opt.upsert(true);
-            MongoCollection<Document> c = db.getCollection(RESULTS);
-            c.replaceOne(new Document("_id", digest), doc, opt);
-            
-            LOG.info("put result: " + digest + " " + doc.toJson());
-        }
-        
-        
-        @Override
-        public synchronized void purge() {
-            db.getCollection(RESULTS).drop();
-        }
-        
-        
-        @Override
-        public void shutdown() throws Exception {
-            mongo.close();
-        }
-    }
 
-    /**
-     * This is a local session store. One instance only, no failover.
-     */
-    private static class LocalStore implements SessionStore {
-        
-        Map<String, ModelSession> m = Collections.synchronizedMap(new HashMap<String, ModelSession>());
-        
-        
-        public LocalStore() {
-            LOG.info("Using local session store.");
-        }
-        
-        
-        @Override
-        public void shutdown() throws Exception {
-            m.clear();
-        }
-        
-        
-        @Override
-        public void setSession(String key, ModelSession session) throws Exception {
-            m.put(key, session);
-        }
-        
-        
-        @Override
-        public ModelSession getSession(String key) throws Exception {
-            return m.get(key);
-        }
-        
-        
-        @Override
-        public void removeSession(String key) {
-            m.remove(key);
-        }
-        
-        
-        @Override
-        public Set<String> keys(int skip, int limit, String sortby, boolean sortAscending) {
-            return m.keySet();
-        }
-        
-        
-        @Override
-        public long getCount() {
-            return m.size();
-        }
-        
-        
-        @Override
-        public void ping() {
-            if (m == null) {
-                throw new NullPointerException("Illegal hashtable store.");
-            }
-        }
-        
-        
-        @Override
-        public boolean hasSession(String suid) throws Exception {
-            return m.containsKey(suid);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class SQLSessionStore implements SessionStore {
-        
-        static final String jdbc_session_id = "jdbc_session";
-        
-        SessionLogger l = new SessionLogger(null, "SQLSessionLog", "");
-        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
-        boolean isMSSQL = false;
-        
-        
-        SQLSessionStore(String url) {
-            Map<String, String> m = new HashMap<>();
-            m.put("defaultAutoCommit", "true");
-            Binaries.addToJDBCPool(jdbc_session_id, url, m);
-            
-            createTableIfNeeded();
-        }
-        
-        
-        @Override
-        public synchronized void setSession(String suid, ModelSession session) throws Exception {
-            try (Connection c = Binaries.getConnection(jdbc_session_id, l)) {
-                try (Statement st = c.createStatement()) {
-                    String[] a = session.getAttachments();
-                    String att = String.join(",", a);
-                    String sql = null;
-                    if (hasSession(suid)) {
-                        sql = "UPDATE csip_sessions SET tst='" + session.getTstamp()
-                                + "', exp='" + session.getExpDate()
-                                + "', srv='" + session.getService()
-                                + "', sta='" + session.getStatus()
-                                + "', nip='" + session.getNodeIP()
-                                + "', rip='" + session.getReqIP()
-                                + "', cpu=" + (session.getCputime().isEmpty() ? -1 : Integer.parseInt(session.getCputime()))
-                                + ",  pro='" + (session.getProgress() == null ? "" : session.getProgress())
-                                + "', att='" + att + "';";
-                    } else {
-                        sql = "INSERT INTO csip_sessions(suid,tst,exp,srv,sta,nip,rip,cpu,pro,att) VALUES('"
-                                + suid + "','"
-                                + session.getTstamp() + "','"
-                                + session.getExpDate() + "','"
-                                + session.getService() + "','"
-                                + session.getStatus() + "','"
-                                + session.getNodeIP() + "','"
-                                + session.getReqIP() + "','"
-                                + (session.getCputime().isEmpty() ? -1 : Integer.parseInt(session.getCputime())) + "','"
-                                + (session.getProgress() == null ? "" : session.getProgress()) + "','" + att + "');";
-                    }
-                    l.info("setSession() " + sql);
-                    st.executeUpdate(sql);
-                }
-            } catch (SQLException | ServiceException ex) {
-                l.log(Level.SEVERE, null, ex);
-                LOG.log(Level.SEVERE, null, ex);
-            }
-        }
-        
-        
-        @Override
-        public synchronized ModelSession getSession(String suid) throws Exception {
-            try (Connection c = Binaries.getConnection(jdbc_session_id, l)) {
-                try (Statement st = c.createStatement()) {
-                    String sql = "SELECT tst,exp,srv,sta,nip,rip,cpu,pro,att FROM csip_sessions WHERE suid='" + suid + "';";
-                    l.info("getSession() " + sql);
-                    ResultSet rs = st.executeQuery(sql);
-                    rs.next();
-                    
-                    ModelSession s = new ModelSession();
-                    s.setTstamp(rs.getString(1));
-                    s.setExpDate(rs.getString(2));
-                    s.setService(rs.getString(3));
-                    s.setStatus(rs.getString(4));
-                    s.setNodeIP(rs.getString(5));
-                    s.setReqIP(rs.getString(6));
-                    int cpu = rs.getInt(7);
-                    s.setCputime(cpu == -1 ? "" : Integer.toString(cpu));
-                    String pro = rs.getString(8);
-                    s.setProgress(pro.equals("") ? null : pro);
-                    String att = rs.getString(9);
-                    s.setAttachments(att.isEmpty() ? ModelSession.NO_ATTACHMENTS : att.split(","));
-                    return s;
-                }
-            } catch (SQLException | ServiceException ex) {
-                l.log(Level.SEVERE, null, ex);
-                LOG.log(Level.SEVERE, null, ex);
-            }
-            return null;
-        }
-        
-        
-        @Override
-        public synchronized boolean hasSession(String suid) throws Exception {
-            try (Connection c = Binaries.getConnection(jdbc_session_id, l)) {
-                try (Statement st = c.createStatement()) {
-                    String sql = "SELECT suid FROM csip_sessions WHERE suid = '" + suid + "';";
-                    l.info("hasSession() " + sql);
-                    ResultSet rs = st.executeQuery(sql);
-                    return rs.next();
-                }
-            } catch (SQLException | ServiceException ex) {
-                l.log(Level.SEVERE, null, ex);
-                LOG.log(Level.SEVERE, null, ex);
-            }
-            return false;
-        }
-        
-        
-        @Override
-        public void removeSession(String suid) {
-            try (Connection c = Binaries.getConnection(jdbc_session_id, l)) {
-                try (Statement st = c.createStatement()) {
-                    String sql = "DELETE FROM csip_sessions WHERE suid='" + suid + "';";
-                    l.info("removeSession() " + sql);
-                    st.executeUpdate(sql);
-                }
-            } catch (SQLException | ServiceException ex) {
-                l.log(Level.SEVERE, null, ex);
-                LOG.log(Level.SEVERE, null, ex);
-            }
-        }
-        
-        
-        @Override
-        public void shutdown() throws Exception {
-            // should shut down at the end.
-        }
-        
-        
-        @Override
-        public synchronized Set<String> keys(int skip, int limit, String sortby, boolean sortAsc) {
-            if (sortby == null) {
-                sortby = "tst";
-                sortAsc = false;
-            }
-            Set<String> keys = new LinkedHashSet<>();
-            try (Connection c = Binaries.getConnection(jdbc_session_id, l)) {
-                try (Statement st = c.createStatement()) {
-                    String sql = isMSSQL
-                            ? "SELECT suid FROM csip_sessions ORDER BY " + sortby + " OFFSET " + skip + " ROWS FETCH NEXT " + limit + " ROWS ONLY;"
-                            : "SELECT suid FROM csip_sessions ORDER BY " + sortby + " LIMIT " + limit + " OFFSET " + skip + ";";
-                    l.info("keys() " + sql);
-                    ResultSet rs = st.executeQuery(sql);
-                    while (rs.next()) {
-                        keys.add(rs.getString(1));
-                    }
-                }
-            } catch (SQLException | ServiceException ex) {
-                l.log(Level.SEVERE, null, ex);
-                LOG.log(Level.SEVERE, null, ex);
-            }
-            return keys;
-        }
-        
-        
-        @Override
-        public synchronized long getCount() {
-            try (Connection c = Binaries.getConnection(jdbc_session_id, l)) {
-                try (Statement st = c.createStatement()) {
-                    String sql = "SELECT COUNT(*) FROM csip_sessions;";
-                    l.info("getCount() " + sql);
-                    ResultSet rs = st.executeQuery(sql);
-                    rs.next();
-                    return rs.getLong(1);
-                }
-            } catch (SQLException | ServiceException ex) {
-                l.log(Level.SEVERE, null, ex);
-                LOG.log(Level.SEVERE, null, ex);
-            }
-            return -1;
-        }
-        
-        
-        @Override
-        public void ping() throws Exception {
-        }
-        
-        
-        private void createTableIfNeeded() {
-            try (Connection c = Binaries.getConnection(jdbc_session_id, l)) {
-                String driver = c.getMetaData().getDriverName();
-                l.info("Driver name: " + driver);
-                isMSSQL = driver.contains("Microsoft");
-                try (Statement st = c.createStatement()) {
-                    // mssql
-                    String sql = isMSSQL
-                            ? "if not exists (select * from sysobjects where name='csip_sessions' and xtype='U')"
-                            + " BEGIN CREATE TABLE csip_sessions ("
-                            + "  suid VARCHAR(64) primary key,"
-                            + "  tst  VARCHAR(64),"
-                            + "  exp  VARCHAR(64),"
-                            + "  srv  VARCHAR(64),"
-                            + "  sta  VARCHAR(64),"
-                            + "  nip  VARCHAR(64),"
-                            + "  rip  VARCHAR(64),"
-                            + "  cpu  INTEGER,"
-                            + "  pro  VARCHAR(64),"
-                            + "  att  VARCHAR(64)"
-                            + ") END;"
-                            //
-                            : "CREATE TABLE IF NOT EXISTS csip_sessions ("
-                            + "  suid VARCHAR(64) primary key,"
-                            + "  tst  VARCHAR(64),"
-                            + "  exp  VARCHAR(64),"
-                            + "  srv  VARCHAR(64),"
-                            + "  sta  VARCHAR(64),"
-                            + "  nip  VARCHAR(64),"
-                            + "  rip  VARCHAR(64),"
-                            + "  cpu  INTEGER,"
-                            + "  pro  VARCHAR(64),"
-                            + "  att  VARCHAR(64)"
-                            + ");";
-                    l.info("createTable() " + sql);
-                    st.execute(sql);
-                    l.info("created Table. ");
-                }
-            } catch (SQLException | ServiceException ex) {
-                l.severe("ERROR: connecting to session store, check connection string or database setup. need r/w SQL access.");
-                l.log(Level.SEVERE, null, ex);
-                LOG.log(Level.SEVERE, null, ex);
-            }
-        }
-    }
-
-    /**
-     *
-     */
-    private static class MongoDBSessionStore implements SessionStore {
-        
-        MongoClient mongo;
-        MongoDatabase db;
-        static final String coll = "session";
-        
-        
-        MongoDBSessionStore(String uri) {
-            MongoClientURI u = new MongoClientURI(uri);
-            String dbname = u.getDatabase();
-            if (dbname == null) {
-                dbname = "csip";
-            }
-            mongo = new MongoClient(u);
-            db = mongo.getDatabase(dbname);
-            LOG.info("Connected to mongo session csip store : " + uri);
-        }
-        
-        
-        @Override
-        public synchronized void setSession(String suid, ModelSession session) throws Exception {
-            Document doc = new Document();
-            doc.append("_id", suid)
-                    .append("tst", session.getTstamp())
-                    .append("exp", session.getExpDate())
-                    .append("srv", session.getService())
-                    .append("sta", session.getStatus())
-                    .append("nip", session.getNodeIP())
-                    .append("rip", session.getReqIP())
-                    .append("cpu", session.getCputime().isEmpty() ? -1 : Integer.parseInt(session.getCputime()))
-                    .append("pro", session.getProgress() == null ? ""
-                            : session.getProgress());
-            
-            String[] a = session.getAttachments();
-            doc.append("att", String.join(",", a));
-            
-            UpdateOptions opt = new UpdateOptions();
-            opt.upsert(true);
-            MongoCollection<Document> c = db.getCollection(coll);
-            c.replaceOne(new Document("_id", suid), doc, opt);
-            LOG.info("added: " + suid + " " + doc.toJson());
-        }
-        
-        
-        @Override
-        public synchronized ModelSession getSession(String suid) throws Exception {
-            FindIterable<Document> r = db.getCollection(coll).find(new Document("_id", suid));
-            Document o = r.first();
-            if (o != null) {
-                // Build our document and add all the fields
-                ModelSession s = new ModelSession();
-                s.setTstamp(o.get("tst", String.class));
-                s.setExpDate(o.get("exp", String.class));
-                s.setService(o.get("srv", String.class));
-                s.setStatus(o.get("sta", String.class));
-                s.setNodeIP(o.get("nip", String.class));
-                s.setReqIP(o.get("rip", String.class));
-                int cpu = o.get("cpu", Integer.class);
-                s.setCputime(cpu == -1 ? "" : Integer.toString(cpu));
-                s.setProgress((o.get("pro", String.class)).equals("") ? null : (o.get("pro", String.class)));
-                String l = o.get("att", String.class);
-                s.setAttachments(l.isEmpty() ? ModelSession.NO_ATTACHMENTS : l.split(","));
-                return s;
-            } else {
-                LOG.warning("Unable get session : " + suid + " as record already exists!!!");
-                return null;
-            }
-        }
-        
-        
-        @Override
-        public synchronized boolean hasSession(String suid) throws Exception {
-            return db.getCollection(coll).count(new Document("_id", suid)) == 1;
-        }
-        
-        
-        @Override
-        public synchronized void removeSession(String suid) {
-            DeleteResult r = db.getCollection(coll).deleteOne(new Document("_id", suid));
-            if (r.getDeletedCount() != 1) {
-                throw new RuntimeException("Not deleted: " + suid);
-            }
-        }
-        
-        
-        @Override
-        public synchronized void shutdown() throws Exception {
-            mongo.close();
-        }
-        
-        
-        @Override
-        public synchronized Set<String> keys(int skip, int limit, String sortby, boolean sortAsc) {
-            if (sortby == null) {
-                sortby = "tst";
-                sortAsc = false;
-            }
-            Document sort = new Document(sortby, sortAsc ? 1 : -1);
-            Set<String> l = new LinkedHashSet<>();
-            MongoCollection<Document> c = db.getCollection(coll);
-            for (Document doc : c.find().sort(sort).skip(skip).limit(limit)) {
-                l.add(doc.get("_id", String.class));
-            }
-            return l;
-        }
-        
-        
-        @Override
-        public synchronized long getCount() {
-            return db.getCollection(coll).count();
-        }
-        
-        
-        @Override
-        public void ping() throws Exception {
-            MongoCollection<Document> c = db.getCollection(coll + "_test");
-            
-            String id = "test_id_1234";
-
-            // insert document
-            Document doc = new Document("_id", id);
-            UpdateOptions opt = new UpdateOptions();
-            opt.upsert(true);
-            UpdateResult res = c.replaceOne(new Document("_id", id), doc, opt);
-            LOG.info("added " + res);
-            // find it.
-            FindIterable<Document> d = c.find(new Document("_id", id));
-            Document o = d.first();
-            if (o == null) {
-                throw new Exception("Not found: " + id);
-            }
-            if (!id.equals(o.getString("_id"))) {
-                throw new Exception("Id not found: " + id);
-            }
-            LOG.info("found " + o);
-
-            // remove it.
-            DeleteResult r = c.deleteOne(new Document("_id", id));
-            if (r.getDeletedCount() != 1) {
-                throw new Exception("Not deleted: " + id);
-            }
-            LOG.info("deleted " + r);
-            c.drop();
-        }
-    }
-
-    /**
-     *
-     */
-    private static class MongoDBArchive implements ArchiveStore {
-        
-        MongoClient mongo;
-        String dbname;
-        static final String fsColl = "fs";
-        
-        
-        MongoDBArchive(String uri) {
-            // "mongodb://user:pass@host:port/db"
-            MongoClientURI u = new MongoClientURI(uri);
-            dbname = u.getDatabase();
-            if (dbname == null) {
-                dbname = "csip";
-            }
-            mongo = new MongoClient(u);
-            LOG.info("Connected to archive csip store : " + uri);
-        }
-        
-        
-        public synchronized void removeAll() {
-            DB db = mongo.getDB(dbname);
-
-            //Let's store the standard data in regular collection
-            DBCollection collection = db.getCollection(fsColl);
-            collection.remove((new BasicDBObject()));
-
-            // remove all file in the bucket
-            GridFS fileStore = new GridFS(db, fsColl);
-            fileStore.remove((DBObject) null);
-        }
-        
-        
-        @Override
-        public synchronized void archiveSession(String sid, ModelArchive ma, File f) throws Exception {
-            DB db = mongo.getDB(dbname);
-
-            //Let's store the standard data in regular collection
-            DBCollection collection = db.getCollection(fsColl);
-            
-            String max = getString(CSIP_ARCHIVE_MAX_FILE_SIZE);
-            long limit = Binaries.parseByteSize(max);
-            
-            String filename = null;
-            long filesize = 0;
-            InputStream is = null;
-            
-            if (f.length() <= limit) {
-                filename = f.getName();
-                filesize = f.length();
-                is = new FileInputStream(f);
-            } else {
-                filename = sid + ".txt";
-                filesize = ARCHIVE_TOO_BIG.length();
-                is = new ByteArrayInputStream(ARCHIVE_TOO_BIG.getBytes());
-            }
-
-            // Let's query to ensure ID does not already exist in Mongo
-            // if it does, we will alert the user
-            BasicDBObject query = new BasicDBObject("_id", sid);
-            DBCursor cursor = collection.find(query);
-            if (!cursor.hasNext()) {
-                // Build our document and add all the fields
-                BasicDBObject doc = new BasicDBObject();
-                doc.append("_id", sid);
-                doc.append("service", ma.getService());
-                doc.append("status", ma.getStatus());
-                doc.append("ctime", ma.getCtime());
-                doc.append("etime", ma.getEtime());
-                doc.append("req_ip", ma.getReqIP());
-                doc.append("filename", "files-" + filename);
-                doc.append("filelength", filesize);
-
-                //insert the document into the collection
-                collection.insert(doc);
-
-                // Now let's store the binary file data using filestore GridFS 
-                GridFS fileStore = new GridFS(db, fsColl);
-                GridFSInputFile file = fileStore.createFile(is);
-                file.setId(sid);
-                file.setFilename("files-" + filename);
-                file.save();
-            } else {
-                LOG.warning("Unable to archive record with ID: " + sid + " as record already exists!!!");
-            }
-        }
-        
-        
-        @Override
-        public synchronized ModelArchive getArchive(String suid) throws Exception {
-            DB db = mongo.getDB(dbname);
-            DBCollection collection = db.getCollection(fsColl);
-            
-            BasicDBObject findQuery = new BasicDBObject("_id", suid);
-            DBObject doc = collection.findOne(findQuery);
-            if (doc != null) {
-                ModelArchive ma = new ModelArchive(
-                        doc.get("ctime").toString(),
-                        doc.get("etime").toString(),
-                        doc.get("service").toString(),
-                        doc.get("status").toString(),
-                        doc.get("req_ip").toString());
-                return ma;
-            }
-            return null;
-        }
-        
-        
-        @Override
-        public synchronized void removeArchive(String suid) {
-            DB db = mongo.getDB(dbname);
-            DBCollection collection = db.getCollection(fsColl);
-            BasicDBObject q = new BasicDBObject("_id", suid);
-            WriteResult res = collection.remove(q);
-            
-            GridFS fileStore = new GridFS(db, fsColl);
-            fileStore.remove(q);
-        }
-        
-        
-        @Override
-        public synchronized byte[] getFile(String suid, String filename) throws Exception {
-            DB db = mongo.getDB(dbname);
-            GridFS fileStore = new GridFS(db, fsColl);
-            BasicDBObject query = new BasicDBObject("_id", suid);
-            GridFSDBFile gridFile = fileStore.findOne(query);
-            if (gridFile != null) {
-                ByteArrayOutputStream out = new ByteArrayOutputStream();
-                gridFile.writeTo(out);
-                return out.toByteArray();
-            }
-            return null;
-        }
-        
-        
-        @Override
-        public synchronized void shutdown() throws Exception {
-            mongo.close();
-        }
-        
-        
-        @Override
-        public synchronized long getCount() {
-            DB db = mongo.getDB(dbname);
-            return db.getCollection(fsColl).count();
-        }
-
-
-        // new keys implementation.
-        public synchronized Set<String> keys(int skip, int limit, String sortby, boolean sortAsc) {
-            if (sortby == null) {
-                sortby = "ctime";
-                sortAsc = false;
-            }
-            BasicDBObject sort = new BasicDBObject(sortby, sortAsc ? 1 : -1);
-            Set<String> l = new LinkedHashSet<>();
-            
-            DB db = mongo.getDB(dbname);
-            DBCollection c = db.getCollection(fsColl);
-            DBCursor cursor = c.find().sort(sort).skip(skip).limit(limit);
-            while (cursor.hasNext()) {
-                DBObject o = cursor.next();
-                l.add(o.get("_id").toString());
-            }
-            return l;
-        }
-        
-        
-        @Override
-        public synchronized boolean hasArchive(String suid) throws Exception {
-            DB db = mongo.getDB(dbname);
-            DBCollection c = db.getCollection(fsColl);
-            return c.count(new BasicDBObject("_id", suid)) == 1;
-        }
-    }
-    
-    
-    static boolean isArchiveEnabled() {
-        return !getString("csip.archive.backend", NONE).equals(NONE);
-    }
-    
-    
     static boolean isResultStoreEnabled() {
         return !getString(CSIP_RESULTSTORE_BACKEND, NONE).equals(NONE);
     }
-    
-    
+
+
     static synchronized SessionStore getSessionStore() {
         if (session == null) {
             String uri = null;
             switch (getString(CSIP_SESSION_BACKEND)) {
-                case "mongodb":
+                case MONGODB:
                     uri = getString(CSIP_SESSION_MONGODB_URI);
                     if (uri == null) {
                         throw new RuntimeException("missing uri configuration entry 'csip.session.mongodb.uri'");
                     }
-                    session = new MongoDBSessionStore(uri);
+                    session = new MongoSessionStore(uri);
                     break;
-                case "sql":
+                case SQL:
                     uri = getString("csip.session.sql.uri");
                     if (uri == null) {
                         throw new RuntimeException("missing uri configuration entry 'csip.session.sql.uri'");
                     }
                     session = new SQLSessionStore(uri);
                     break;
-                case "local":
-                    session = new LocalStore();
+                case LOCAL:
+                    session = new LocalSessionStore();
                     break;
                 default:
                     throw new RuntimeException("unknown session backend: " + getString(CSIP_SESSION_BACKEND));
@@ -1360,20 +331,20 @@
         }
         return session;
     }
-    
-    
+
+
     static synchronized ArchiveStore getArchiveStore() {
         if (archive == null) {
             if (!isArchiveEnabled()) {
                 archive = ArchiveStore.NONE;
             } else {
                 switch (getString(CSIP_ARCHIVE_BACKEND)) {
-                    case "mongodb":
+                    case MONGODB:
                         String uri = getString(CSIP_ARCHIVE_MONGODB_URI);
                         if (uri == null) {
                             throw new RuntimeException("missing uri configuration entry 'csip.archive.mongodb.uri'");
                         }
-                        archive = new MongoDBArchive(uri);
+                        archive = new MongoArchiveStore(uri);
                         break;
                     case NONE:
                         archive = ArchiveStore.NONE;
@@ -1385,15 +356,15 @@
         }
         return archive;
     }
-    
-    
+
+
     static synchronized ResultStore getResultStore() {
         if (resultStore == null) {
             if (!isResultStoreEnabled()) {
                 resultStore = ResultStore.NONE;
             } else {
                 switch (getString(CSIP_RESULTSTORE_BACKEND)) {
-                    case "mongodb":
+                    case MONGODB:
                         resultStore = new MongoResultStore(getString(CSIP_RESULTSTORE_MONGODB_URI));
                         break;
                     case NONE:
@@ -1406,24 +377,24 @@
         }
         return resultStore;
     }
-    
-    
+
+
     static synchronized Timer getTimer() {
         if (timer == null) {
             timer = new Timer();
         }
         return timer;
     }
-    
-    
+
+
     static synchronized ExecutorService getExecutorService() {
         if (exec == null) {
             exec = Executors.newCachedThreadPool();
         }
         return exec;
     }
-    
-    
+
+
     static List<ModelDataService.Task> getModelTasks() {
         return tasks;
     }
@@ -1434,8 +405,7 @@
      *
      * @param context
      */
-    static void startup(ServletContext context) {
-        reg.setContext(context.getContextPath());
+    static void startup() {
     }
 
 
@@ -1444,13 +414,13 @@
      *
      * @param context
      */
-    static void shutdown(ServletContext context) {
+    static void shutdown() {
         for (ModelDataService.Task t : tasks) {
             t.cancel();
         }
-        
+
         reg.unregister();
-        
+
         if (exec != null) {
             LOG.info("Shutting down ExecutorService");
             exec.shutdownNow();
@@ -1463,7 +433,7 @@
             }
             session = null;
         }
-        
+
         if (archive != null) {
             try {
                 archive.shutdown();
@@ -1472,7 +442,7 @@
             }
             archive = null;
         }
-        
+
         if (resultStore != null) {
             try {
                 resultStore.shutdown();
@@ -1484,7 +454,7 @@
         if (timer != null) {
             timer.cancel();
         }
-        
+
         Binaries.shutdownJDBC();
     }
 
@@ -1495,123 +465,92 @@
     static void update() {
         rehashProperties();
     }
-    
-    
+
+
     static public Collection<PostgresChunk> getPostgresChunks() {
         return pcs;
     }
-    
-    
+
+
     public static boolean hasProperty(String key) {
         return allProps.containsKey(key);
     }
-    
-    
+
+
     public static boolean isString(String key, String str) {
         String s = getString(key);
         return (s != null) && s.equals(str);
     }
-    
-    
+
+
     public static String getString(String key, String def) {
         return getP(key, def);
     }
-    
-    
+
+
     public static String getString(String key) {
         return getP(key, null);
     }
-    
-    
+
+
     public static boolean getBoolean(String key, boolean def) {
         return Boolean.parseBoolean(getP(key, Boolean.toString(def)));
     }
-    
-    
+
+
     public static boolean getBoolean(String key) {
         return Boolean.parseBoolean(getP(key, "false"));
     }
-    
-    
+
+
     public static int getInt(String key, int def) {
         return Integer.parseInt(getP(key, Integer.toString(def)));
     }
-    
-    
+
+
     public static int getInt(String key) {
         return Integer.parseInt(getP(key, "0"));
     }
-    
-    
+
+
     public static long getLong(String key, long def) {
         return Long.parseLong(getP(key, Long.toString(def)));
     }
-    
-    
+
+
     public static long getLong(String key) {
         return Long.parseLong(getP(key, "0L"));
     }
-    
-    
+
+
     public static double getDouble(String key, double def) {
         return Double.parseDouble(getP(key, Double.toString(def)));
     }
-    
-    
+
+
     public static double getDouble(String key) {
         return Double.parseDouble(getP(key, "0.0"));
     }
-    
-    
+
+
     private static String getP(String key, String def) {
-        return resolve(allProps.getProperty(key, def));
+        return Utils.resolve(allProps.getProperty(key, def));
     }
-    
-    
+
+
     static Properties getProperties() {
         return p;
     }
-    
-    
+
+
     static Properties getMergedProperties() {
         return allProps;
     }
-    
-    
+
+
     private static void put(String key, String value) {
         p.setProperty(key, value);
     }
-    
-    
-    public static void main(String[] args) {
-//        System.out.println(System.getenv());
-        String a = resolve("${test.port} abc ${java.home} ///${PATH}/// def ${csip.bin.dir}");
-        System.out.println(a);
-        
-        String b = "d".replace("___", "-").replace("__", ".");
-        System.out.println(b);
-    }
-
-
-    /**
-     * Resolve a string with system and CSIP properties.
-     *
-     * @param str the string to resolve
-     * @return the resolved string.
-     */
-    public static String resolve(String str) {
-        if (str == null) {
-            return null;
-        }
-        if (!str.contains("${")) {
-            return str;
-        }
-        String res = resolve0(str, allProps, new HashSet<>());
-        if (res.contains("${")) {
-            LOG.warning("Resolving one or more varariables failed in: " + res);
-        }
-        return res;
-    }
 
 
     /**
@@ -1622,7 +561,6 @@
         allProps.clear();
         allProps.putAll(Config.properties());
         allProps.putAll(System.getProperties());
-        
         Map<String, String> env = System.getenv();
         for (String key : env.keySet()) {
             String newKey = key.replace("___", "-").replace("__", ".");
@@ -1630,165 +568,4 @@
         }
     }
 
-
-    /**
-     * property substitution in a string.
-     *
-     * @param str
-     * @return
-     */
-    private static String resolve0(String str, Properties prop, Set<String> keys) {
-        int idx = 0;
-        while (idx < str.length()) {
-            int start = str.indexOf("${", idx);
-            int end = str.indexOf("}", idx);
-            if (start == -1 || end == -1 || end < start) {
-                break;
-            }
-            String key = str.substring(start + 2, end);
-            if (keys.contains(key)) {
-                System.err.println("Circular property reference: " + key);
-                break;
-            }
-            String val = prop.getProperty(key);
-            if (val != null) {
-                keys.add(key);
-                val = resolve0(val, prop, keys);
-                keys.remove(key);
-                str = str.replace("${" + key + "}", val);
-                idx = start + val.length();
-            } else {
-                idx = start + key.length() + 3;
-            }
-        }
-        return str;
-    }
-    
-    
-    static void checkRemoteAccessACL(HttpServletRequest req) {
-        String reqIp = req.getHeader("X-Forwarded-For");
-        if (reqIp == null) {
-            reqIp = req.getRemoteAddr();
-        }
-        if (!checkRemoteAccessACL(reqIp)) {
-            LOG.log(Level.WARNING, req.getMethod() + " " + req.getRequestURI() + ", denied for " + reqIp);
-            throw new WebApplicationException(Response.Status.UNAUTHORIZED);
-        }
-        LOG.log(Level.INFO, req.getMethod() + " " + req.getRequestURI() + ", OK for " + reqIp);
-    }
-    
-    
-    static boolean checkRemoteAccessACL(String ip) {
-        // default is "localhost" only.
-        String acls = Config.getString(CSIP_REMOTE_ACL, "127.0.0.1/32");
-        String[] acl = acls.split("\\s+");
-        for (String sn : acl) {
-            if (sn.indexOf('/') == -1) {
-                if (sn.equals(ip)) {
-                    return true;
-                }
-            } else {
-                if (isInSubnet(ip, sn)) {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-    
-    
-    static boolean isInSubnet(String ip, String subnet) {
-        try {
-            SubnetUtils utils = new SubnetUtils(subnet);
-            utils.setInclusiveHostCount(true);
-            return utils.getInfo().isInRange(ip);
-        } catch (Exception E) {
-            LOG.log(Level.WARNING, "Invalid Subnet: " + subnet, E);
-            return false;
-        }
-    }
-    
-    public static class PostgresChunk {
-        
-        String name;
-        double minLong;
-        double maxLong;
-        Connection[] connections;
-        int currentConnection;
-        
-        
-        public PostgresChunk(String name, double minLong, double maxLong) {
-            this.name = name;
-            this.minLong = minLong;
-            this.maxLong = maxLong;
-        }
-        
-        
-        public boolean equals(Object obj) {
-            return this.name.equals(((PostgresChunk) obj).getName());
-        }
-        
-        
-        public String getName() {
-            return name;
-        }
-        
-        
-        public double getMinLong() {
-            return minLong;
-        }
-        
-        
-        public double getMaxLong() {
-            return maxLong;
-        }
-        
-        
-        public void setConnections(Connection[] connections) {
-            this.connections = connections;
-        }
-        
-        
-        public Connection[] getConnections() {
-            return connections;
-        }
-        
-        
-        public void connectionInc() {
-            currentConnection++;
-        }
-        
-        
-        public int getCurrentConnectionIdx() {
-            return currentConnection;
-        }
-        
-        
-        public void setCurrentConnectionIdx(int currentConnection) {
-            this.currentConnection = currentConnection;
-        }
-        
-        
-        public Connection getCurrentConnection() {
-            if ((connections != null) && (connections.length >= currentConnection)) {
-                return connections[currentConnection];
-            } else {
-                return null;
-            }
-        }
-        
-        
-        public JSONObject getJSON() {
-            try {
-                JSONObject pgchunk = new JSONObject();
-                pgchunk.put("name", name);
-                pgchunk.put("minLong", minLong);
-                pgchunk.put("maxLong", maxLong);
-                return pgchunk;
-            } catch (JSONException jse) {
-                LOG.warning("Error creating JSON representation of a db chunk object");
-            }
-            return new JSONObject();
-        }
-    }
 }

src/csip/ContextConfig.java

@@ -213,8 +213,8 @@
 
     private void init(InputStream is, String file) {
         try {
+            LOG.info("Context configuration: '" + file + "'");
             String ftype = file.substring(file.lastIndexOf('.'));
-            LOG.info("Context configuration: '" + file + "'");
             switch (ftype) {
                 case ".yaml":
                     fromYaml(is);
@@ -230,7 +230,7 @@
             }
         } catch (ScannerException E) {
             LOG.log(Level.WARNING, "Ignoring config, Error:\n" + E.getMessage());
-        } catch (IOException | JSONException E) {
+        } catch (Exception E) {
             LOG.log(Level.WARNING, "Ignoring config, Error:\n" + E);
         } finally {
             try {
@@ -272,15 +272,9 @@
         if (!yaml.containsKey(KEY_CONFIG)) {
             throw new RuntimeException("Missing: 'Config: ...', ignoring.");
         }
-        Map<String, String> c = (Map) yaml.get(KEY_CONFIG);
-        c.keySet().forEach((key) -> {
-            conf.put(key, c.get(key));
-        });
+        conf.putAll((Map) yaml.get(KEY_CONFIG));
         if (yaml.containsKey(KEY_SERVICES)) {
-            List<String> s = (List) yaml.get(KEY_SERVICES);
-            s.forEach((s1) -> {
-                services.add(s1);
-            });
+            services.addAll((List) yaml.get(KEY_SERVICES));
         }
     }
 

src/csip/ControlService.java

@@ -11,7 +11,6 @@
  */
 package csip;
 
-import csip.Config.SessionStore;
 import csip.utils.*;
 import java.io.*;
 import java.text.DateFormat;
@@ -49,7 +48,7 @@
     @Path("clean")
     @Produces(MediaType.APPLICATION_JSON)
     public String getClean(@Context UriInfo uriInfo, @Context HttpServletRequest req) throws JSONException, Exception {
-        Config.checkRemoteAccessACL(req);
+        Utils.checkRemoteAccessACL(req);
 
         SessionStore s = Config.getSessionStore();
         Set<String> keys = s.keys(0, Integer.MAX_VALUE, null, true);
@@ -89,7 +88,7 @@
     @Produces(MediaType.APPLICATION_JSON)
     @Path("clean/{suid}")
     public String remove(@Context UriInfo uriInfo, @Context HttpServletRequest req, @PathParam("suid") String suid) throws Exception {
-        Config.checkRemoteAccessACL(req);
+        Utils.checkRemoteAccessACL(req);
 
         ModelSession session = Config.getSessionStore().getSession(suid);
         JSONObject o = new JSONObject();
@@ -137,7 +136,7 @@
     @Path("conf")
     @Produces(MediaType.APPLICATION_JSON)
     public String getJSON(@Context UriInfo uriInfo, @Context HttpServletRequest req) throws JSONException {
-        Config.checkRemoteAccessACL(req);
+        Utils.checkRemoteAccessACL(req);
 
         Properties p = Config.getMergedProperties();
         Map<Object, Object> m = new TreeMap<>();
@@ -152,11 +151,11 @@
         }
 
         JSONObject theconfig = new JSONObject(m);
-        Collection<Config.PostgresChunk> pcs = Config.getPostgresChunks();
+        Collection<PostgresChunk> pcs = Config.getPostgresChunks();
         // Add PGChunks to output if they exist...
         if ((pcs != null) && (pcs.size() > 0)) {
             int i = 1;
-            for (Config.PostgresChunk ch : pcs) {
+            for (PostgresChunk ch : pcs) {
                 theconfig.put("pgdb" + i, ch.getJSON());
                 i++;
             }
@@ -203,7 +202,7 @@
 
     static String updateConfig(String inputObj) throws JSONException {
         Properties p = Config.getProperties();
-        Collection<Config.PostgresChunk> pcs = Config.getPostgresChunks();
+        Collection<PostgresChunk> pcs = Config.getPostgresChunks();
         synchronized (p) {
             try {
                 JSONObject o = new JSONObject(inputObj);
@@ -221,7 +220,7 @@
                         String name = pgsvr.getString("name");
                         double minLong = pgsvr.getDouble("minLong");
                         double maxLong = pgsvr.getDouble("maxLong");
-                        Config.PostgresChunk newchunk = new Config.PostgresChunk(name, minLong, maxLong);
+                        PostgresChunk newchunk = new PostgresChunk(name, minLong, maxLong);
                         if (!pcs.contains(newchunk)) {
                             pcs.add(newchunk);
                         } else {
@@ -246,7 +245,7 @@
         // Add PGChunks to output if they exist...
         if ((pcs != null) && (pcs.size() > 0)) {
             int i = 1;
-            for (Config.PostgresChunk ch : pcs) {
+            for (PostgresChunk ch : pcs) {
                 theconfig.put("pgdb" + i, ch.getJSON());
                 i++;
             }
@@ -267,7 +266,7 @@
     @Consumes(MediaType.APPLICATION_JSON)
     public String putJSON(@Context UriInfo uriInfo, @Context HttpServletRequest req, String inputObj) throws JSONException {
         LOG.log(Level.INFO, "HTTP/POST {0}", uriInfo.getRequestUri().toString() + " " + inputObj);
-        Config.checkRemoteAccessACL(req);
+        Utils.checkRemoteAccessACL(req);
         return updateConfig(inputObj);
     }
 

src/csip/ModelArchive.java

@@ -11,16 +11,12 @@
  */
 package csip;
 
-import java.io.Serializable;
-
 /**
  * A model session for
  *
  * @author Olaf David
  */
-public class ModelArchive implements Serializable {
-
-    private static final long serialVersionUID = 6774562822981820371L;
+class ModelArchive {
 
     String service;
     String status;
@@ -29,11 +25,7 @@
     String req_ip;
 
 
-    public ModelArchive() {
-    }
-
-
-    public ModelArchive(String ctime, String etime, String service, String status, String req_ip) {
+    ModelArchive(String ctime, String etime, String service, String status, String req_ip) {
         this.ctime = ctime;
         this.etime = etime;
         this.service = service;
@@ -42,54 +34,53 @@
     }
 
 
-    public String getReqIP() {
+    String getReqIP() {
         return req_ip;
     }
 
 
-    public void setReqIP(String req_ip) {
+    void setReqIP(String req_ip) {
         this.req_ip = req_ip;
     }
 
 
-    public String getStatus() {
+    String getStatus() {
         return status;
     }
 
 
-    public void setStatus(String status) {
+    void setStatus(String status) {
         this.status = status;
     }
 
 
-    public String getService() {
+    String getService() {
         return service;
     }
 
 
-    public void setService(String service) {
+    void setService(String service) {
         this.service = service;
     }
 
 
-    public String getCtime() {
+    String getCtime() {
         return ctime;
     }
 
 
-    public void setCtime(String ctime) {
+    void setCtime(String ctime) {
         this.ctime = ctime;
     }
 
 
-    public void setEtime(String etime) {
+    void setEtime(String etime) {
         this.etime = etime;
     }
 
 
-    public String getEtime() {
+    String getEtime() {
         return etime;
     }
-    
 
 }

src/csip/ModelDataService.java

@@ -20,7 +20,7 @@
 import static csip.Config.CSIP_SNAPSHOT;
 import static csip.Config.CSIP_TIMEZONE;
 import static csip.Config.CSIP_VERSION;
-import csip.Config.ResultStore;
+import csip.ResultStore;
 import csip.annotations.*;
 
 import csip.utils.*;
@@ -2569,7 +2569,7 @@
                                         Date now = new Date();
                                         Date expDate = Dates.futureDate(now, 31536000); // 1 year expiration 
                                         ModelArchive ma = new ModelArchive(df.format(now), df.format(expDate), getRequestURL(), ms.getStatus(), ms.getReqIP());
-                                        Config.ArchiveStore as = Config.getArchiveStore();
+                                        ArchiveStore as = Config.getArchiveStore();
                                         if (as.hasArchive(suid)) {
                                             as.removeArchive(suid);
                                         }
@@ -2667,7 +2667,7 @@
                                     Date expDate = Dates.futureDate(now, Dates.getDurationSec("csip.archive.ttl"));
                                     ModelArchive ma = new ModelArchive(df.format(now), df.format(expDate), getRequestURL(), ms.getStatus(), ms.getReqIP());
 
-                                    Config.ArchiveStore as = Config.getArchiveStore();
+                                    ArchiveStore as = Config.getArchiveStore();
                                     if (as.hasArchive(suid)) {
                                         as.removeArchive(suid);
                                     }

src/csip/ModelSession.java

@@ -11,19 +11,15 @@
  */
 package csip;
 
-import java.io.Serializable;
-
 /**
  * A model session
  *
  * @author Olaf David
  */
-public class ModelSession implements Serializable {
+class ModelSession {
 
     static final String[] NO_ATTACHMENTS = new String[]{};
 
-    private static final long serialVersionUID = -8509383077607102371L;
-
     String service;
     String status;
     String ip;
@@ -36,11 +32,11 @@
     boolean report = false;
 
 
-    public ModelSession() {
+    ModelSession() {
     }
 
 
-    public ModelSession(String tstamp, String exp_date, String service,
+    ModelSession(String tstamp, String exp_date, String service,
             String status, String node_ip, String cputime,
             String req_ip, String[] attachments, boolean report, String progress) {
         this.tstamp = tstamp;
@@ -56,102 +52,102 @@
     }
 
 
-    public void setProgress(String progress) {
+    void setProgress(String progress) {
         this.progress = progress;
     }
 
 
-    public String getProgress() {
+    String getProgress() {
         return progress;
     }
 
 
-    public String getNodeIP() {
+    String getNodeIP() {
         return ip;
     }
 
 
-    public void setNodeIP(String ip) {
+    void setNodeIP(String ip) {
         this.ip = ip;
     }
 
 
-    public String getReqIP() {
+    String getReqIP() {
         return req_ip;
     }
 
 
-    public void setReqIP(String req_ip) {
+    void setReqIP(String req_ip) {
         this.req_ip = req_ip;
     }
 
 
-    public String getStatus() {
+    String getStatus() {
         return status;
     }
 
 
-    public void setStatus(String status) {
+    void setStatus(String status) {
         this.status = status;
     }
 
 
-    public String getService() {
+    String getService() {
         return service;
     }
 
 
-    public void setService(String service) {
+    void setService(String service) {
         this.service = service;
     }
 
 
-    public String getTstamp() {
+    String getTstamp() {
         return tstamp;
     }
 
 
-    public void setTstamp(String tstamp) {
+    void setTstamp(String tstamp) {
         this.tstamp = tstamp;
     }
 
 
-    public String getExpDate() {
+    String getExpDate() {
         return exp_date;
     }
 
 
-    public void setExpDate(String exp_date) {
+    void setExpDate(String exp_date) {
         this.exp_date = exp_date;
     }
 
 
-    public String getCputime() {
+    String getCputime() {
         return cputime;
     }
 
 
-    public void setCputime(String cputime) {
+    void setCputime(String cputime) {
         this.cputime = cputime;
     }
 
 
-    public String[] getAttachments() {
+    String[] getAttachments() {
         return attachments;
     }
 
 
-    public void setAttachments(String[] attachments) {
+    void setAttachments(String[] attachments) {
         this.attachments = attachments;
     }
 
 
-    public boolean hasReport() {
+    boolean hasReport() {
         return report;
     }
 
 
-    public void setReport(boolean report) {
+    void setReport(boolean report) {
         this.report = report;
     }
 }

src/csip/QueryService.java

@@ -11,8 +11,6 @@
  */
 package csip;
 
-import csip.Config.ArchiveStore;
-import csip.Config.SessionStore;
 import static csip.Config.getString;
 import csip.annotations.Resource;
 import csip.annotations.ResourceType;
@@ -66,55 +64,41 @@
     static final Logger LOG = Logger.getLogger(QueryService.class.getName());
 
 
-//    @GET
-//    @Path("status")
-//    @Produces(MediaType.APPLICATION_JSON)
-//    public String getStatus(@Context UriInfo uriInfo) throws Exception {
-//        LOG.log(Level.INFO, "HTTP/GET {0}", uriInfo.getRequestUri().toString());
-//
-//        int running = 0;
-//        int finished = 0;
-//        int cancelled = 0;
-//        int failed = 0;
-//
-//        Config.SessionStore s = Config.getSessionStore();
-//        for (String id : s.keys(0, Integer.MAX_VALUE, null, false)) {
-//            ModelSession v = s.getSession(id);
-//            if (v == null) {
-//                continue;  // this should not happen
-//            }
-//            String st = v.getStatus();
-//            if (st.equals(ModelDataService.RUNNING)) {
-//                running++;
-//            } else if (st.equals(ModelDataService.FAILED)) {
-//                failed++;
-//            } else if (st.equals(ModelDataService.CANCELED)) {
-//                cancelled++;
-//            } else if (st.equals(ModelDataService.FINISHED)) {
-//                finished++;
-//            }
-//        }
-//        JSONObject o = new JSONObject();
-//        o.put("running", running);
-//        o.put("failed", failed);
-//        o.put("canceled", cancelled);
-//        o.put("finished", finished);
-//        return o.toString(2);
-//    }
-    public static String humanReadableByteCount(long bytes, boolean si) {
-        int unit = si ? 1000 : 1024;
-        if (bytes < unit) {
-            return bytes + " B";
-        }
-        int exp = (int) (Math.log(bytes) / Math.log(unit));
-        String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i");
-        return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
-    }
-
-
-    public static void main(String[] args) throws UnknownHostException {
-        System.out.println(Config.isInSubnet("101.2.228.68", "101.2.228.0/8"));
-    }
+    //    @GET
+    //    @Path("status")
+    //    @Produces(MediaType.APPLICATION_JSON)
+    //    public String getStatus(@Context UriInfo uriInfo) throws Exception {
+    //        LOG.log(Level.INFO, "HTTP/GET {0}", uriInfo.getRequestUri().toString());
+    //
+    //        int running = 0;
+    //        int finished = 0;
+    //        int cancelled = 0;
+    //        int failed = 0;
+    //
+    //        Config.SessionStore s = Config.getSessionStore();
+    //        for (String id : s.keys(0, Integer.MAX_VALUE, null, false)) {
+    //            ModelSession v = s.getSession(id);
+    //            if (v == null) {
+    //                continue;  // this should not happen
+    //            }
+    //            String st = v.getStatus();
+    //            if (st.equals(ModelDataService.RUNNING)) {
+    //                running++;
+    //            } else if (st.equals(ModelDataService.FAILED)) {
+    //                failed++;
+    //            } else if (st.equals(ModelDataService.CANCELED)) {
+    //                cancelled++;
+    //            } else if (st.equals(ModelDataService.FINISHED)) {
+    //                finished++;
+    //            }
+    //        }
+    //        JSONObject o = new JSONObject();
+    //        o.put("running", running);
+    //        o.put("failed", failed);
+    //        o.put("canceled", cancelled);
+    //        o.put("finished", finished);
+    //        return o.toString(2);
+    //    }
 
 
     /**
@@ -129,7 +113,7 @@
     @Path("r")
     @Consumes(MediaType.TEXT_PLAIN)
     public String r(@Context HttpServletRequest req, String arg) throws Exception {
-        Config.checkRemoteAccessACL(req);
+        Utils.checkRemoteAccessACL(req);
         @Resource(file = "bash", type = ResourceType.REFERENCE, id = "_")
         class _C_ {
         }
@@ -156,7 +140,7 @@
     @Path("check")
     @Produces(MediaType.APPLICATION_JSON)
     public String getCheck(@Context HttpServletRequest req) throws JSONException, Exception {
-        Config.checkRemoteAccessACL(req);
+        Utils.checkRemoteAccessACL(req);
 
         JSONObject o = new JSONObject();
         File work = new File(Config.getString("csip.work.dir"));
@@ -164,18 +148,18 @@
 
         o.put("node.address", Services.LOCAL_IP_ADDR);
         o.put("cpus", Runtime.getRuntime().availableProcessors());
-        o.put("memory.free", humanReadableByteCount(Runtime.getRuntime().freeMemory(), true));
-        o.put("memory.max", humanReadableByteCount(Runtime.getRuntime().maxMemory(), true));
-        o.put("memory.total", humanReadableByteCount(Runtime.getRuntime().totalMemory(), true));
+        o.put("memory.free", Utils.humanReadableByteCount(Runtime.getRuntime().freeMemory(), true));
+        o.put("memory.max", Utils.humanReadableByteCount(Runtime.getRuntime().maxMemory(), true));
+        o.put("memory.total", Utils.humanReadableByteCount(Runtime.getRuntime().totalMemory(), true));
         o.put("work.dir", work.toString());
         o.put("work.exists", work.exists());
         o.put("work.canread", work.canRead());
         o.put("work.canexecute", work.canExecute());
         o.put("work.canwrite", work.canWrite());
         o.put("work.canwrite", work.canWrite());
-        o.put("work.usable.mb", humanReadableByteCount(work.getUsableSpace(), true));
-        o.put("work.free.mb", humanReadableByteCount(work.getFreeSpace(), true));
-        o.put("work.total.mb", humanReadableByteCount(work.getTotalSpace(), true));
+        o.put("work.usable.mb", Utils.humanReadableByteCount(work.getUsableSpace(), true));
+        o.put("work.free.mb", Utils.humanReadableByteCount(work.getFreeSpace(), true));
+        o.put("work.total.mb", Utils.humanReadableByteCount(work.getTotalSpace(), true));
 
         File res = new File(Config.getString("csip.results.dir"));
         res.mkdirs();
@@ -184,9 +168,9 @@
         o.put("result.canread", res.canRead());
         o.put("result.canexecute", res.canExecute());
         o.put("result.canwrite", res.canWrite());
-        o.put("result.usable.mb", humanReadableByteCount(res.getUsableSpace(), true));
-        o.put("result.free.mb", humanReadableByteCount(res.getFreeSpace(), true));
-        o.put("result.total.mb", humanReadableByteCount(res.getTotalSpace(), true));
+        o.put("result.usable.mb", Utils.humanReadableByteCount(res.getUsableSpace(), true));
+        o.put("result.free.mb", Utils.humanReadableByteCount(res.getFreeSpace(), true));
+        o.put("result.total.mb", Utils.humanReadableByteCount(res.getTotalSpace(), true));
 
 //        DateFormat df = Dates.newISOFormat();
 //        String now = df.format(new Date());

src/csip/ReportService.java

@@ -29,7 +29,6 @@
 import csip.utils.JSONUtils;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.client.Client;
 import javax.ws.rs.client.ClientBuilder;
 import javax.ws.rs.client.WebTarget;

src/csip/ServletContextHooks.java

@@ -32,7 +32,7 @@
     @Override
     public void contextInitialized(ServletContextEvent e) {
         ServletContext ctx = e.getServletContext();
-        Config.startup(ctx);
+        Config.startup();
 
         ContextConfig cc = new ContextConfig();
 
@@ -46,7 +46,7 @@
         // Tomcat/conf folder as <context>.yaml
         cc.load(new File(System.getProperty("catalina.home") + File.separatorChar + "conf" + ctx.getContextPath() + ".yaml"));
 
-        // webapp folder
+        // webapp folder configuration files
         cc.load(ctx, ".json");
         cc.load(ctx, ".properties");
         cc.load(ctx, ".yaml");
@@ -54,14 +54,14 @@
         if (!cc.getConfig().isEmpty()) {
             ControlService.updateConfig(cc.getConfig());
         }
-        
+
         l.info("CSIP Context Created: " + ctx.getContextPath());
     }
 
 
     @Override
     public void contextDestroyed(ServletContextEvent e) {
-        Config.shutdown(e.getServletContext());
+        Config.shutdown();
         l.info("CSIP Context Destroyed: " + e.getServletContext().getContextPath());
     }
 }

src/csip/Sweeper.java

@@ -35,7 +35,7 @@
     @Override
     public void run() {
         // remove all file locks for the workspace
-        for (File key : new ArrayList<File>(Config.wsFileLocks.keySet())) {
+        for (File key : new ArrayList<>(Config.wsFileLocks.keySet())) {
             if (key.toString().startsWith(resultsDir.toString())) {
                 Config.wsFileLocks.remove(key);
             }

src/csip/UIService.java

@@ -11,8 +11,6 @@
  */
 package csip;
 
-import csip.Config.ArchiveStore;
-import csip.Config.SessionStore;
 import csip.utils.*;
 import java.net.URI;
 import java.text.DateFormat;
@@ -147,7 +145,7 @@
             @QueryParam("order") String order)
             throws Exception {
 
-        Config.checkRemoteAccessACL(req);
+        Utils.checkRemoteAccessACL(req);
 
         URI uri = u.getBaseUri();
         String path = uri.getPath();
@@ -271,7 +269,7 @@
             @DefaultValue("d") @QueryParam("order") String order) // descending order
             throws Exception {
 
-        Config.checkRemoteAccessACL(req);
+        Utils.checkRemoteAccessACL(req);
 
         if (!Config.isArchiveEnabled()) {
             return "<html><body>Archive not enabled.</body></html>";
@@ -357,7 +355,7 @@
     @Path("conf")
     @Produces(MediaType.TEXT_HTML)
     public String getHtml(@Context UriInfo u,  @Context HttpServletRequest req) throws JSONException {
-        Config.checkRemoteAccessACL(req);
+        Utils.checkRemoteAccessACL(req);
 
         Properties p = Config.getMergedProperties();
         Map<Object, Object> m = new TreeMap<>(p);
@@ -373,11 +371,11 @@
         }
 
         // Add chunk DBs if applicable
-        Collection<Config.PostgresChunk> pcs = Config.getPostgresChunks();
+        Collection<PostgresChunk> pcs = Config.getPostgresChunks();
         // Add PGChunks to output if they exist...
         if ((pcs != null) && (pcs.size() > 0)) {
             int i = 1;
-            for (Config.PostgresChunk ch : pcs) {
+            for (PostgresChunk ch : pcs) {
                 o.append("<b>pgdb" + i + "</b>: " + ch.getJSON().toString() + "<br>");
                 i++;
             }

src/csip/utils/Binaries.java

@@ -17,6 +17,7 @@
 import csip.Executable;
 import csip.ServiceException;
 import csip.SessionLogger;
+import csip.Utils;
 import csip.annotations.Resource;
 import csip.annotations.ResourceType;
 import java.io.BufferedInputStream;
@@ -88,7 +89,7 @@
         Connection getConnection(SessionLogger logger) throws ServiceException {
             try {
                 // probe for configuration change.
-                String res_url = Config.resolve(url);
+                String res_url = Utils.resolve(url);
                 if (datasource == null || !res_url.equals(resolved_url)) {
                     //Close previous datasource if it exists
                     if (datasource != null) {
@@ -373,7 +374,7 @@
             return null;
         }
         File csip_home = new File(Config.getString(CSIP_DIR));
-        file = Config.resolve(file);
+        file = Utils.resolve(file);
         if (file.endsWith("zip") && resource.type() == ResourceType.ARCHIVE) {
             return new File(csip_home, file.substring(0, file.indexOf('.')));
         }
@@ -583,7 +584,7 @@
             return null;
         }
 
-        file = Config.resolve(file);
+        file = Utils.resolve(file);
         File executable;
         if (resource.type() == ResourceType.REFERENCE) {
             executable = new File(file);
@@ -733,7 +734,7 @@
      */
     @Deprecated()
     public static File unpackResource(String name, File file_or_folder) throws IOException {
-        name = Config.resolve(name);
+        name = Utils.resolve(name);
 
         URL u = Binaries.class.getResource(name);
         if (u == null) {
@@ -780,7 +781,7 @@
      */
     public static File unpackResource0(Resource r, File file_or_folder, SessionLogger LOG) throws IOException {
         String name = r.file();
-        name = Config.resolve(name);
+        name = Utils.resolve(name);
 
         LOG.info("accessing resource : " + name);
 
@@ -835,7 +836,7 @@
      */
     @Deprecated
     public static File unpackResourceAbsolute(String name, String newName) throws IOException {
-        name = Config.resolve(name);
+        name = Utils.resolve(name);
         URL u = Binaries.class.getResource(name);
         if (u == null) {
             throw new IllegalArgumentException("No such resource " + name);
@@ -942,7 +943,7 @@
             }
             String t[] = s.trim().split("\\s*=\\s*");
             if (t.length == 2) {
-                m.put(t[0], Config.resolve(t[1]));
+                m.put(t[0], Utils.resolve(t[1]));
             }
         }
         return m;

src/csip/utils/Services.java

@@ -29,10 +29,8 @@
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.TimeZone;
 import java.util.UUID;
 import java.util.concurrent.ArrayBlockingQueue;
@@ -48,8 +46,6 @@
 import java.util.concurrent.TimeUnit;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-import javax.servlet.ServletContext;
-import javax.ws.rs.Path;
 import javax.ws.rs.client.Client;
 import javax.ws.rs.client.ClientBuilder;
 import javax.ws.rs.client.Entity;
@@ -62,7 +58,6 @@
 import org.apache.commons.compress.archivers.ArchiveStreamFactory;
 import org.apache.commons.compress.compressors.CompressorException;
 import org.apache.commons.compress.compressors.CompressorStreamFactory;
-import org.apache.commons.io.FileUtils;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;