Search in sources :

Example 1 with AdminDBTopLevel

use of cbit.vcell.modeldb.AdminDBTopLevel in project vcell by virtualcell.

the class VcmlOmexConverter method parseArgsAndConvert.

public static void parseArgsAndConvert(String[] args) throws IOException {
    File input = null;
    try {
        // TODO: handle if it's not valid PATH
        input = new File(args[1]);
    } catch (Exception e1) {
        e1.printStackTrace();
    }
    args = parseArgs(args);
    // if (bHasDataOnly) {
    try {
        conFactory = DatabaseService.getInstance().createConnectionFactory();
        adminDbTopLevel = new AdminDBTopLevel(conFactory);
    } catch (SQLException e) {
        System.err.println("\n\n\n=====>>>>EXPORT FAILED: connection to database failed");
        e.printStackTrace();
    }
    // }
    VCInfoContainer vcic;
    try {
        vcic = adminDbTopLevel.getPublicOracleVCInfoContainer(false);
        if (vcic != null) {
            User user = vcic.getUser();
            BioModelInfo[] bioModelInfos = vcic.getBioModelInfos();
            // int count = 0;
            for (BioModelInfo bi : bioModelInfos) {
                // if(bi.getPublicationInfos() != null && bi.getPublicationInfos().length > 0) {
                // // let's see what has PublicationInfo
                // System.out.println(bi.getVersion().getName());
                // count++;
                // }
                // build the biomodel id / biomodel info map
                String biomodelId = "biomodel_" + bi.getVersion().getVersionKey();
                String biomodelName = bi.getVersion().getName();
                // String biomodelId2 = "biomodel_" + bi.getModelKey();
                bioModelInfoMap.put(biomodelId, bi);
                bioModelInfoMap2.put(biomodelName, bi);
            }
        // System.out.println("User: " + user.getName() + "   count published biomodels: " + count);
        }
    } catch (SQLException | DataAccessException e1) {
        System.err.println("\n\n\n=====>>>>EXPORT FAILED: failed to retrieve metadata");
        e1.printStackTrace();
    }
    System.out.println("Found " + bioModelInfoMap.size() + " public BioNodelInfo objects");
    if (input != null && input.isDirectory()) {
        FilenameFilter filterVcmlFiles = (f, name) -> name.endsWith(".vcml");
        // jusr a list of vcml names, like biomodel-185577495.vcml, ...
        String[] inputFiles = input.list(filterVcmlFiles);
        if (inputFiles == null) {
            System.err.println("No VCML files found in the directory `" + input + "`");
        }
        // full directory name, like C:\TEMP\biomodel\omex\native
        String outputDir = args[3];
        CLIStandalone.writeSimErrorList(outputDir, "hasDataOnly is " + bHasDataOnly);
        CLIStandalone.writeSimErrorList(outputDir, "makeLogsOnly is " + bMakeLogsOnly);
        // assert inputFiles != null;
        for (String inputFile : inputFiles) {
            File file = new File(input, inputFile);
            System.out.println(" ============== start: " + inputFile);
            args[1] = file.toString();
            cliHandler = new CLIHandler(args);
            try {
                if (inputFile.endsWith(".vcml")) {
                    boolean isCreated = vcmlToOmexConversion(outputDir);
                    if (isCreated) {
                        System.out.println("Combine archive created for file(s) `" + input + "`");
                    } else {
                        System.err.println("Failed converting VCML to OMEX archive for `" + input + "`");
                    }
                } else {
                    System.err.println("No VCML files found in the directory `" + input + "`");
                }
            } catch (Exception e) {
                // e.printStackTrace(System.err);
                System.out.println("\n\n\n=====>>>>EXPORT FAILED: " + inputFile + "\n\n\n");
                CLIStandalone.writeDetailedErrorList(outputDir, inputFile + ",   " + e.getMessage());
            // System.exit(1);
            }
        }
    } else {
        try {
            assert input != null;
            if (input.toString().endsWith(".vcml")) {
                cliHandler = new CLIHandler(args);
                boolean isCreated = vcmlToOmexConversion(null);
                if (isCreated)
                    System.out.println("Combine archive created for `" + input + "`");
                else
                    System.err.println("Failed converting VCML to OMEX archive for `" + input + "`");
            } else
                System.err.println("No input files found in the directory `" + input + "`");
        } catch (Exception e) {
            // e.printStackTrace();
            System.out.println("\n\n\n=====>>>>EXPORT FAILED: " + input + "\n\n\n");
        // System.exit(1);
        }
    }
}
Also used : User(org.vcell.util.document.User) Arrays(java.util.Arrays) Enumeration(java.util.Enumeration) Date(java.util.Date) Graph(org.openrdf.model.Graph) XmlUtil(cbit.util.xml.XmlUtil) PropertyVetoException(java.beans.PropertyVetoException) SEDMLExporter(org.vcell.sedml.SEDMLExporter) Version(org.vcell.util.document.Version) Vector(java.util.Vector) RDFFormat(org.openrdf.rio.RDFFormat) XmlHelper(cbit.vcell.xml.XmlHelper) Map(java.util.Map) PublicationInfo(org.vcell.util.document.PublicationInfo) FieldDataIdentifierSpec(cbit.vcell.field.FieldDataIdentifierSpec) RDF(org.openrdf.model.vocabulary.RDF) SimulationJobStatusPersistent(cbit.vcell.server.SimulationJobStatusPersistent) Simulation(cbit.vcell.solver.Simulation) CLIHandler(org.vcell.cli.CLIHandler) Literal(org.openrdf.model.Literal) ValueFactory(org.openrdf.model.ValueFactory) DefaultNameSpaces(org.sbpax.schemas.util.DefaultNameSpaces) Set(java.util.Set) PubMet(org.vcell.sedml.PubMet) XMLSource(cbit.vcell.xml.XMLSource) FileNotFoundException(java.io.FileNotFoundException) FieldUtilities(cbit.vcell.field.FieldUtilities) BioPAX3(org.sbpax.schemas.BioPAX3) List(java.util.List) KnownFormats(org.sbml.libcombine.KnownFormats) OntUtil(org.sbpax.schemas.util.OntUtil) Expression(cbit.vcell.parser.Expression) FilenameUtils(org.apache.commons.io.FilenameUtils) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) Statement(org.openrdf.model.Statement) HashGraph(org.sbpax.impl.HashGraph) MathModelInfo(org.vcell.util.document.MathModelInfo) FilenameFilter(java.io.FilenameFilter) BioModelInfo(org.vcell.util.document.BioModelInfo) ValueFactoryImpl(org.openrdf.model.impl.ValueFactoryImpl) SBPAX3Util(org.sbpax.schemas.util.SBPAX3Util) SimpleDateFormat(java.text.SimpleDateFormat) ArrayUtils(org.apache.commons.lang3.ArrayUtils) HashMap(java.util.HashMap) FieldFunctionArguments(cbit.vcell.field.FieldFunctionArguments) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) ConnectionFactory(org.vcell.db.ConnectionFactory) DatabaseService(org.vcell.db.DatabaseService) SQLException(java.sql.SQLException) VCInfoContainer(org.vcell.util.document.VCInfoContainer) Calendar(java.util.Calendar) SimulationInfo(cbit.vcell.solver.SimulationInfo) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) GeometryInfo(cbit.vcell.geometry.GeometryInfo) XmlParseException(cbit.vcell.xml.XmlParseException) OutputStreamWriter(java.io.OutputStreamWriter) URI(org.openrdf.model.URI) NativeLoader(cbit.vcell.util.NativeLoader) LinkedHashSet(java.util.LinkedHashSet) Value(org.openrdf.model.Value) RDFHandlerException(org.openrdf.rio.RDFHandlerException) BioModel(cbit.vcell.biomodel.BioModel) ResourceUtil(cbit.vcell.resource.ResourceUtil) BufferedWriter(java.io.BufferedWriter) AdminDBTopLevel(cbit.vcell.modeldb.AdminDBTopLevel) FileOutputStream(java.io.FileOutputStream) FieldDataDBOperationDriver(cbit.vcell.field.db.FieldDataDBOperationDriver) IOException(java.io.IOException) PropertyLoader(cbit.vcell.resource.PropertyLoader) OWL(org.openrdf.model.vocabulary.OWL) DataAccessException(org.vcell.util.DataAccessException) BNode(org.openrdf.model.BNode) File(java.io.File) SolverDescription(cbit.vcell.solver.SolverDescription) Variable(cbit.vcell.math.Variable) KeyValue(org.vcell.util.document.KeyValue) Resource(org.eclipse.jetty.util.resource.Resource) Paths(java.nio.file.Paths) CLIStandalone(org.vcell.cli.CLIStandalone) SesameRioUtil(org.sbpax.util.SesameRioUtil) CombineArchive(org.sbml.libcombine.CombineArchive) AdminDBTopLevel(cbit.vcell.modeldb.AdminDBTopLevel) User(org.vcell.util.document.User) SQLException(java.sql.SQLException) BioModelInfo(org.vcell.util.document.BioModelInfo) CLIHandler(org.vcell.cli.CLIHandler) PropertyVetoException(java.beans.PropertyVetoException) FileNotFoundException(java.io.FileNotFoundException) SQLException(java.sql.SQLException) XmlParseException(cbit.vcell.xml.XmlParseException) RDFHandlerException(org.openrdf.rio.RDFHandlerException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) FilenameFilter(java.io.FilenameFilter) VCInfoContainer(org.vcell.util.document.VCInfoContainer) File(java.io.File) DataAccessException(org.vcell.util.DataAccessException)

Example 2 with AdminDBTopLevel

use of cbit.vcell.modeldb.AdminDBTopLevel in project vcell by virtualcell.

the class SimulationDispatcher method main.

/**
 * Starts the application.
 * @param args an array of command-line arguments
 */
public static void main(java.lang.String[] args) {
    OperatingSystemInfo.getInstance();
    if (args.length != 3 && args.length != 0) {
        System.out.println("Missing arguments: " + VCellServices.class.getName() + " [sshHost sshUser sshKeyFile] ");
        System.exit(1);
    }
    try {
        PropertyLoader.loadProperties(REQUIRED_SERVICE_PROPERTIES);
        HtcProxy htcProxy = SlurmProxy.creatCommandService(args);
        int serviceOrdinal = 99;
        VCMongoMessage.serviceStartup(ServiceName.dispatch, new Integer(serviceOrdinal), args);
        // //
        // // JMX registration
        // //
        // MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        // mbs.registerMBean(new VCellServiceMXBeanImpl(), new ObjectName(VCellServiceMXBean.jmxObjectName));
        ServiceInstanceStatus serviceInstanceStatus = new ServiceInstanceStatus(VCellServerID.getSystemServerID(), ServiceType.DISPATCH, serviceOrdinal, ManageUtils.getHostName(), new Date(), true);
        ConnectionFactory conFactory = DatabaseService.getInstance().createConnectionFactory();
        KeyFactory keyFactory = conFactory.getKeyFactory();
        DatabaseServerImpl databaseServerImpl = new DatabaseServerImpl(conFactory, keyFactory);
        AdminDBTopLevel adminDbTopLevel = new AdminDBTopLevel(conFactory);
        SimulationDatabase simulationDatabase = new SimulationDatabaseDirect(adminDbTopLevel, databaseServerImpl, true);
        VCMessagingService vcMessagingService_int = new VCMessagingServiceActiveMQ();
        String jmshost_int = PropertyLoader.getRequiredProperty(PropertyLoader.jmsIntHostInternal);
        int jmsport_int = Integer.parseInt(PropertyLoader.getRequiredProperty(PropertyLoader.jmsIntPortInternal));
        vcMessagingService_int.setConfiguration(new ServerMessagingDelegate(), jmshost_int, jmsport_int);
        VCMessagingService vcMessagingService_sim = new VCMessagingServiceActiveMQ();
        String jmshost_sim = PropertyLoader.getRequiredProperty(PropertyLoader.jmsSimHostInternal);
        int jmsport_sim = Integer.parseInt(PropertyLoader.getRequiredProperty(PropertyLoader.jmsSimPortInternal));
        vcMessagingService_sim.setConfiguration(new ServerMessagingDelegate(), jmshost_sim, jmsport_sim);
        SimulationDispatcher simulationDispatcher = new SimulationDispatcher(htcProxy, vcMessagingService_int, vcMessagingService_sim, serviceInstanceStatus, simulationDatabase, false);
        simulationDispatcher.init();
    } catch (Throwable e) {
        lg.error("uncaught exception initializing SimulationDispatcher: " + e.getLocalizedMessage(), e);
        System.exit(1);
    }
}
Also used : ServerMessagingDelegate(cbit.vcell.message.server.ServerMessagingDelegate) AdminDBTopLevel(cbit.vcell.modeldb.AdminDBTopLevel) HtcProxy(cbit.vcell.message.server.htc.HtcProxy) VCMessagingService(cbit.vcell.message.VCMessagingService) Date(java.util.Date) VCellServices(cbit.vcell.message.server.combined.VCellServices) ConnectionFactory(org.vcell.db.ConnectionFactory) ServiceInstanceStatus(cbit.vcell.message.server.ServiceInstanceStatus) DatabaseServerImpl(cbit.vcell.modeldb.DatabaseServerImpl) VCMessagingServiceActiveMQ(cbit.vcell.message.jms.activeMQ.VCMessagingServiceActiveMQ) KeyFactory(org.vcell.db.KeyFactory)

Example 3 with AdminDBTopLevel

use of cbit.vcell.modeldb.AdminDBTopLevel in project vcell by virtualcell.

the class VCellServices method main.

/**
 * Starts the application.
 * @param args an array of command-line arguments
 */
public static void main(java.lang.String[] args) {
    OperatingSystemInfo.getInstance();
    if (args.length != 3 && args.length != 0) {
        System.out.println("Missing arguments: " + VCellServices.class.getName() + " [sshHost sshUser sshKeyFile] ");
        System.exit(1);
    }
    try {
        PropertyLoader.loadProperties(REQUIRED_SERVICE_PROPERTIES);
        ResourceUtil.setNativeLibraryDirectory();
        new LibraryLoaderThread(false).start();
        PythonSupport.verifyInstallation(new PythonPackage[] { PythonPackage.VTK, PythonPackage.THRIFT });
        HtcProxy htcProxy = SlurmProxy.creatCommandService(args);
        int serviceOrdinal = 0;
        VCMongoMessage.serviceStartup(ServiceName.dispatch, new Integer(serviceOrdinal), args);
        // //
        // // JMX registration
        // //
        // MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        // mbs.registerMBean(new VCellServiceMXBeanImpl(), new ObjectName(VCellServiceMXBean.jmxObjectName));
        ServiceInstanceStatus serviceInstanceStatus = new ServiceInstanceStatus(VCellServerID.getSystemServerID(), ServiceType.MASTER, serviceOrdinal, ManageUtils.getHostName(), new Date(), true);
        ConnectionFactory conFactory = DatabaseService.getInstance().createConnectionFactory();
        KeyFactory keyFactory = conFactory.getKeyFactory();
        DatabaseServerImpl databaseServerImpl = new DatabaseServerImpl(conFactory, keyFactory);
        AdminDBTopLevel adminDbTopLevel = new AdminDBTopLevel(conFactory);
        SimulationDatabase simulationDatabase = new SimulationDatabaseDirect(adminDbTopLevel, databaseServerImpl, true);
        String cacheSize = PropertyLoader.getRequiredProperty(PropertyLoader.simdataCacheSizeProperty);
        long maxMemSize = Long.parseLong(cacheSize);
        Cachetable cacheTable = new Cachetable(MessageConstants.MINUTE_IN_MS * 20, maxMemSize);
        DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(cacheTable, new File(PropertyLoader.getRequiredProperty(PropertyLoader.primarySimDataDirInternalProperty)), new File(PropertyLoader.getProperty(PropertyLoader.secondarySimDataDirInternalProperty, PropertyLoader.getRequiredProperty(PropertyLoader.primarySimDataDirInternalProperty))));
        ExportServiceImpl exportServiceImpl = new ExportServiceImpl();
        // add dataJobListener
        DataServerImpl dataServerImpl = new DataServerImpl(dataSetControllerImpl, exportServiceImpl);
        VCMessagingService vcMessagingService_int = new VCMessagingServiceActiveMQ();
        String jmshost_int = PropertyLoader.getRequiredProperty(PropertyLoader.jmsIntHostInternal);
        int jmsport_int = Integer.parseInt(PropertyLoader.getRequiredProperty(PropertyLoader.jmsIntPortInternal));
        vcMessagingService_int.setConfiguration(new ServerMessagingDelegate(), jmshost_int, jmsport_int);
        VCMessagingService vcMessagingService_sim = new VCMessagingServiceActiveMQ();
        String jmshost_sim = PropertyLoader.getRequiredProperty(PropertyLoader.jmsSimHostInternal);
        int jmsport_sim = Integer.parseInt(PropertyLoader.getRequiredProperty(PropertyLoader.jmsSimPortInternal));
        vcMessagingService_sim.setConfiguration(new ServerMessagingDelegate(), jmshost_sim, jmsport_sim);
        VCellServices vcellServices = new VCellServices(htcProxy, vcMessagingService_int, vcMessagingService_sim, serviceInstanceStatus, databaseServerImpl, dataServerImpl, simulationDatabase);
        dataSetControllerImpl.addDataJobListener(vcellServices);
        exportServiceImpl.addExportListener(vcellServices);
        vcellServices.init();
    } catch (Throwable e) {
        e.printStackTrace(System.out);
    }
}
Also used : Cachetable(cbit.vcell.simdata.Cachetable) DataServerImpl(cbit.vcell.simdata.DataServerImpl) ServerMessagingDelegate(cbit.vcell.message.server.ServerMessagingDelegate) AdminDBTopLevel(cbit.vcell.modeldb.AdminDBTopLevel) HtcProxy(cbit.vcell.message.server.htc.HtcProxy) SimulationDatabase(cbit.vcell.message.server.dispatcher.SimulationDatabase) VCMessagingService(cbit.vcell.message.VCMessagingService) LibraryLoaderThread(cbit.vcell.resource.LibraryLoaderThread) Date(java.util.Date) ConnectionFactory(org.vcell.db.ConnectionFactory) SimulationDatabaseDirect(cbit.vcell.message.server.dispatcher.SimulationDatabaseDirect) ServiceInstanceStatus(cbit.vcell.message.server.ServiceInstanceStatus) DatabaseServerImpl(cbit.vcell.modeldb.DatabaseServerImpl) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) ExportServiceImpl(cbit.vcell.export.server.ExportServiceImpl) VCMessagingServiceActiveMQ(cbit.vcell.message.jms.activeMQ.VCMessagingServiceActiveMQ) File(java.io.File) KeyFactory(org.vcell.db.KeyFactory)

Example 4 with AdminDBTopLevel

use of cbit.vcell.modeldb.AdminDBTopLevel in project vcell by virtualcell.

the class ServerManageConsole method main.

/**
 * main entrypoint - starts the part when it is run as an application
 * @param args java.lang.String[]
 */
public static void main(java.lang.String[] args) {
    try {
        if (args.length == 2 && args[0].equals("-password")) {
            ServerManageConsole.commandLineAdminPassword = args[1];
        }
        PropertyLoader.loadProperties();
        javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
        ConnectionFactory conFactory = DatabaseService.getInstance().createConnectionFactory();
        KeyFactory keyFactory = conFactory.getKeyFactory();
        DatabaseServerImpl databaseServerImpl = new DatabaseServerImpl(conFactory, keyFactory);
        AdminDBTopLevel adminDbTopLevel = new AdminDBTopLevel(conFactory);
        ServerManageConsole aServerManageConsole = new ServerManageConsole(adminDbTopLevel, databaseServerImpl);
        aServerManageConsole.addWindowListener(new java.awt.event.WindowAdapter() {

            public void windowClosing(java.awt.event.WindowEvent e) {
                System.exit(0);
            }
        });
        java.awt.Insets insets = aServerManageConsole.getInsets();
        aServerManageConsole.setSize(aServerManageConsole.getWidth() + insets.left + insets.right, aServerManageConsole.getHeight() + insets.top + insets.bottom);
        aServerManageConsole.setLocation(200, 200);
        aServerManageConsole.setVisible(true);
    } catch (Throwable exception) {
        System.err.println("Exception occurred in main() of javax.swing.JFrame");
        exception.printStackTrace(System.out);
    }
}
Also used : RemoteProxyVCellConnectionFactory(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory) ConnectionFactory(org.vcell.db.ConnectionFactory) AdminDBTopLevel(cbit.vcell.modeldb.AdminDBTopLevel) DatabaseServerImpl(cbit.vcell.modeldb.DatabaseServerImpl) KeyFactory(org.vcell.db.KeyFactory)

Example 5 with AdminDBTopLevel

use of cbit.vcell.modeldb.AdminDBTopLevel in project vcell by virtualcell.

the class VCellApiMain method main.

/**
 * @param args
 */
public static void main(String[] args) {
    try {
        if (args.length != 2) {
            System.out.println("usage: VCellApiMain javascriptDir port");
            System.exit(1);
        }
        File javascriptDir = new File(args[0]);
        if (!javascriptDir.isDirectory()) {
            throw new RuntimeException("javascriptDir '" + args[0] + "' is not a directory");
        }
        // don't validate
        PropertyLoader.loadProperties();
        lg.debug("properties loaded");
        String portString = args[1];
        // was hard-coded at 8080
        Integer port = null;
        try {
            port = Integer.parseInt(portString);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            throw new RuntimeException("failed to parse port argument '" + portString + "'", e);
        }
        lg.trace("connecting to database");
        lg.trace("oracle factory (next)");
        ConnectionFactory conFactory = DatabaseService.getInstance().createConnectionFactory();
        KeyFactory keyFactory = conFactory.getKeyFactory();
        lg.trace("database impl (next)");
        DatabaseServerImpl databaseServerImpl = new DatabaseServerImpl(conFactory, keyFactory);
        lg.trace("local db server (next)");
        LocalAdminDbServer localAdminDbServer = new LocalAdminDbServer(conFactory, keyFactory);
        lg.trace("admin db server (next)");
        AdminDBTopLevel adminDbTopLevel = new AdminDBTopLevel(conFactory);
        lg.trace("messaging service (next)");
        VCMessagingService vcMessagingService_int = VCellServiceHelper.getInstance().loadService(VCMessagingService.class);
        VCMessagingDelegate delegate = new VCMessagingDelegate() {

            @Override
            public void onTraceEvent(String string) {
                if (lg.isTraceEnabled())
                    lg.trace("onTraceEvent(): " + string);
            }

            @Override
            public void onRpcRequestSent(VCRpcRequest vcRpcRequest, UserLoginInfo userLoginInfo, VCMessage vcRpcRequestMessage) {
                if (lg.isTraceEnabled())
                    lg.trace("onRpcRequestSent(): " + vcRpcRequest.getMethodName());
            }

            @Override
            public void onRpcRequestProcessed(VCRpcRequest vcRpcRequest, VCMessage rpcVCMessage) {
                if (lg.isTraceEnabled())
                    lg.trace("onRpcRequestProcessed(): " + vcRpcRequest.getMethodName());
            }

            @Override
            public void onMessageSent(VCMessage message, VCDestination desintation) {
                if (lg.isTraceEnabled())
                    lg.trace("onMessageSent(): " + message);
            }

            @Override
            public void onMessageReceived(VCMessage vcMessage, VCDestination vcDestination) {
                if (lg.isTraceEnabled())
                    lg.trace("onMessageReceived(): " + vcMessage);
            }

            @Override
            public void onException(Exception e) {
                lg.error(e.getMessage(), e);
            }
        };
        String jmshost_int = PropertyLoader.getRequiredProperty(PropertyLoader.jmsIntHostInternal);
        int jmsport_int = Integer.parseInt(PropertyLoader.getRequiredProperty(PropertyLoader.jmsIntPortInternal));
        vcMessagingService_int.setConfiguration(delegate, jmshost_int, jmsport_int);
        lg.trace("rest database service (next)");
        RestDatabaseService restDatabaseService = new RestDatabaseService(databaseServerImpl, localAdminDbServer, vcMessagingService_int);
        lg.trace("rest event service (next)");
        RestEventService restEventService = new RestEventService(vcMessagingService_int);
        lg.trace("use verifier (next)");
        UserVerifier userVerifier = new UserVerifier(adminDbTopLevel);
        lg.trace("mongo (next)");
        VCMongoMessage.enabled = true;
        VCMongoMessage.serviceStartup(ServiceName.unknown, port, args);
        System.out.println("setting up server configuration");
        lg.trace("register engine (next)");
        Engine.register(true);
        WadlComponent component = new WadlComponent();
        // Server httpServer = component.getServers().add(Protocol.HTTP, 80);
        // Server httpsServer = component.getServers().add(Protocol.HTTPS, 443);
        // Client httpsClient = component.getClients().add(Protocol.HTTPS);
        // Client httpClient = component.getClients().add(Protocol.HTTP);
        lg.trace("adding FILE protcol");
        @SuppressWarnings("unused") Client httpClient = component.getClients().add(Protocol.FILE);
        lg.trace("adding CLAP protcol");
        @SuppressWarnings("unused") Client clapClient = component.getClients().add(Protocol.CLAP);
        lg.trace("adding CLAP https");
        File keystorePath = new File(PropertyLoader.getRequiredProperty(PropertyLoader.vcellapiKeystoreFile));
        String keystorePassword = PropertyLoader.getSecretValue(PropertyLoader.vcellapiKeystorePswd, PropertyLoader.vcellapiKeystorePswdFile);
        try {
            // 
            // keystorePassword may be encrypted with dbPassword, if it is decypt it.
            // 
            String dbPassword = PropertyLoader.getSecretValue(PropertyLoader.dbPasswordValue, PropertyLoader.dbPasswordFile);
            SecretKeyFactory kf = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
            SecretKey key = kf.generateSecret(new PBEKeySpec(dbPassword.toCharArray()));
            Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");
            pbeCipher.init(Cipher.DECRYPT_MODE, key, new PBEParameterSpec(new byte[] { 32, 11, 55, 121, 01, 42, 89, 11 }, 20));
            keystorePassword = new String(pbeCipher.doFinal(DatatypeConverter.parseBase64Binary(keystorePassword)));
        } catch (Exception e) {
            System.out.println("password unhashing didn't work - trying clear text password");
            e.printStackTrace();
        }
        Server httpsServer = component.getServers().add(Protocol.HTTPS, port);
        Series<Parameter> parameters = httpsServer.getContext().getParameters();
        parameters.add("keystorePath", keystorePath.toString());
        parameters.add("keystorePassword", keystorePassword);
        parameters.add("keystoreType", "JKS");
        parameters.add("keyPassword", keystorePassword);
        parameters.add("disabledCipherSuites", "SSL_RSA_WITH_3DES_EDE_CBC_SHA " + "SSL_DHE_RSA_WITH_DES_CBC_SHA " + "SSL_DHE_DSS_WITH_DES_CBC_SHA");
        parameters.add("enabledCipherSuites", "TLS_DHE_DSS_WITH_AES_128_CBC_SHA " + "TLS_DHE_RSA_WITH_AES_128_CBC_SHA " + "TLS_RSA_WITH_AES_128_CBC_SHA " + "TLS_DHE_DSS_WITH_AES_256_CBC_SHA " + "TLS_DHE_RSA_WITH_AES_256_CBC_SHA " + "TLS_RSA_WITH_AES_256_CBC_SHA");
        lg.trace("create config");
        Configuration templateConfiguration = new Configuration();
        templateConfiguration.setObjectWrapper(new DefaultObjectWrapper());
        // lg.trace("verify python installation");
        // PythonSupport.verifyInstallation(new PythonPackage[] { PythonPackage.COPASI, PythonPackage.LIBSBML, PythonPackage.THRIFT });
        // 
        // lg.trace("start Optimization Service");
        lg.trace("create app");
        boolean bIgnoreHostProblems = true;
        boolean bIgnoreCertProblems = true;
        User testUser = localAdminDbServer.getUser(TEST_USER);
        // lookup hashed auth credentials in database.
        UserInfo testUserInfo = localAdminDbServer.getUserInfo(testUser.getID());
        HealthService healthService = new HealthService(restEventService, "localhost", port, bIgnoreCertProblems, bIgnoreHostProblems, testUserInfo.userid, testUserInfo.digestedPassword0);
        AdminService adminService = new AdminService(adminDbTopLevel, databaseServerImpl);
        RpcService rpcService = new RpcService(vcMessagingService_int);
        WadlApplication app = new VCellApiApplication(restDatabaseService, userVerifier, rpcService, restEventService, adminService, templateConfiguration, healthService, javascriptDir);
        lg.trace("attach app");
        component.getDefaultHost().attach(app);
        System.out.println("component start()");
        lg.trace("start component");
        component.start();
        System.out.println("component ended.");
        lg.trace("component started");
        lg.trace("start VCell Health Monitoring service");
        healthService.start();
    } catch (Exception e) {
        lg.error(e.getMessage(), e);
    }
}
Also used : PBEKeySpec(javax.crypto.spec.PBEKeySpec) WadlComponent(org.restlet.ext.wadl.WadlComponent) User(org.vcell.util.document.User) AdminService(org.vcell.rest.admin.AdminService) Server(org.restlet.Server) LocalAdminDbServer(cbit.vcell.modeldb.LocalAdminDbServer) Configuration(freemarker.template.Configuration) VCMessagingDelegate(cbit.vcell.message.VCMessagingDelegate) UserInfo(org.vcell.util.document.UserInfo) VCMessagingService(cbit.vcell.message.VCMessagingService) ConnectionFactory(org.vcell.db.ConnectionFactory) VCDestination(cbit.vcell.message.VCDestination) VCMessage(cbit.vcell.message.VCMessage) HealthService(org.vcell.rest.health.HealthService) DatabaseServerImpl(cbit.vcell.modeldb.DatabaseServerImpl) RestDatabaseService(org.vcell.rest.server.RestDatabaseService) Client(org.restlet.Client) SecretKeyFactory(javax.crypto.SecretKeyFactory) SecretKeyFactory(javax.crypto.SecretKeyFactory) KeyFactory(org.vcell.db.KeyFactory) PBEParameterSpec(javax.crypto.spec.PBEParameterSpec) AdminDBTopLevel(cbit.vcell.modeldb.AdminDBTopLevel) DefaultObjectWrapper(freemarker.template.DefaultObjectWrapper) VCRpcRequest(cbit.vcell.message.VCRpcRequest) SecretKey(javax.crypto.SecretKey) RestEventService(org.vcell.rest.events.RestEventService) WadlApplication(org.restlet.ext.wadl.WadlApplication) RpcService(org.vcell.rest.rpc.RpcService) LocalAdminDbServer(cbit.vcell.modeldb.LocalAdminDbServer) Parameter(org.restlet.data.Parameter) Cipher(javax.crypto.Cipher) UserLoginInfo(org.vcell.util.document.UserLoginInfo) File(java.io.File)

Aggregations

AdminDBTopLevel (cbit.vcell.modeldb.AdminDBTopLevel)7 DatabaseServerImpl (cbit.vcell.modeldb.DatabaseServerImpl)6 ConnectionFactory (org.vcell.db.ConnectionFactory)6 KeyFactory (org.vcell.db.KeyFactory)5 File (java.io.File)4 VCMessagingService (cbit.vcell.message.VCMessagingService)3 DataSetControllerImpl (cbit.vcell.simdata.DataSetControllerImpl)3 Date (java.util.Date)3 ExportServiceImpl (cbit.vcell.export.server.ExportServiceImpl)2 VCMessagingServiceActiveMQ (cbit.vcell.message.jms.activeMQ.VCMessagingServiceActiveMQ)2 ServerMessagingDelegate (cbit.vcell.message.server.ServerMessagingDelegate)2 ServiceInstanceStatus (cbit.vcell.message.server.ServiceInstanceStatus)2 SimulationDatabaseDirect (cbit.vcell.message.server.dispatcher.SimulationDatabaseDirect)2 HtcProxy (cbit.vcell.message.server.htc.HtcProxy)2 Cachetable (cbit.vcell.simdata.Cachetable)2 User (org.vcell.util.document.User)2 XmlUtil (cbit.util.xml.XmlUtil)1 BioModel (cbit.vcell.biomodel.BioModel)1 FieldDataIdentifierSpec (cbit.vcell.field.FieldDataIdentifierSpec)1 FieldFunctionArguments (cbit.vcell.field.FieldFunctionArguments)1