Search in sources :

Example 26 with Services

use of org.structr.core.Services in project structr by structr.

the class StructrUiTest method start.

@BeforeClass
public static void start() throws Exception {
    final long timestamp = System.currentTimeMillis();
    basePath = "/tmp/structr-test-" + timestamp + "-" + System.nanoTime();
    Settings.Services.setValue("NodeService HttpService SchemaService DirectoryWatchService");
    Settings.ConnectionUrl.setValue(Settings.TestingConnectionUrl.getValue());
    // example for new configuration setup
    Settings.BasePath.setValue(basePath);
    Settings.DatabasePath.setValue(basePath + "/db");
    Settings.FilesPath.setValue(basePath + "/files");
    Settings.RelationshipCacheSize.setValue(1000);
    Settings.NodeCacheSize.setValue(1000);
    Settings.SuperUserName.setValue("superadmin");
    Settings.SuperUserPassword.setValue("sehrgeheim");
    Settings.ApplicationTitle.setValue("structr unit test app" + timestamp);
    Settings.ApplicationHost.setValue(host);
    Settings.HttpPort.setValue(httpPort);
    Settings.Servlets.setValue("JsonRestServlet WebSocketServlet HtmlServlet");
    Settings.NodeCacheSize.setValue(10000);
    Settings.RelationshipCacheSize.setValue(10000);
    // Settings.LogSchemaOutput.setValue(true);
    final Services services = Services.getInstance();
    // wait for service layer to be initialized
    do {
        try {
            Thread.sleep(100);
        } catch (Throwable t) {
        }
    } while (!services.isInitialized());
    securityContext = SecurityContext.getSuperUserInstance();
    app = StructrApp.getInstance(securityContext);
    graphDbCommand = app.command(GraphDatabaseCommand.class);
}
Also used : Services(org.structr.core.Services) GraphDatabaseCommand(org.structr.core.graph.GraphDatabaseCommand) BeforeClass(org.junit.BeforeClass)

Example 27 with Services

use of org.structr.core.Services in project structr by structr.

the class StructrApiModuleTest method startSystem.

@BeforeClass
public static void startSystem() {
    final Date now = new Date();
    final long timestamp = now.getTime();
    basePath = "/tmp/structr-test-" + timestamp;
    Settings.Services.setValue("NodeService LogService SchemaService HttpService");
    Settings.ConnectionUrl.setValue(Settings.TestingConnectionUrl.getValue());
    // example for new configuration setup
    Settings.BasePath.setValue(basePath);
    Settings.DatabasePath.setValue(basePath + "/db");
    Settings.FilesPath.setValue(basePath + "/files");
    Settings.RelationshipCacheSize.setValue(1000);
    Settings.NodeCacheSize.setValue(1000);
    Settings.SuperUserName.setValue("superadmin");
    Settings.SuperUserPassword.setValue("sehrgeheim");
    Settings.ApplicationTitle.setValue("structr unit test app" + timestamp);
    Settings.ApplicationHost.setValue(host);
    Settings.HttpPort.setValue(httpPort);
    Settings.Servlets.setValue("JsonRestServlet");
    final Services services = Services.getInstance();
    // wait for service layer to be initialized
    do {
        try {
            Thread.sleep(100);
        } catch (Throwable t) {
        }
    } while (!services.isInitialized());
    securityContext = SecurityContext.getSuperUserInstance();
    app = StructrApp.getInstance(securityContext);
}
Also used : Services(org.structr.core.Services) Date(java.util.Date) BeforeClass(org.junit.BeforeClass)

Example 28 with Services

use of org.structr.core.Services in project structr by structr.

the class CronService method run.

@Override
public void run() {
    final Services servicesInstance = Services.getInstance();
    // wait for service layer to be initialized
    while (!servicesInstance.isInitialized()) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException iex) {
        }
    }
    // sleep 5 seconds more
    try {
        Thread.sleep(5000);
    } catch (InterruptedException iex) {
    }
    while (doRun) {
        // sleep for some time
        try {
            Thread.sleep(GRANULARITY_UNIT.toMillis(GRANULARITY));
        } catch (InterruptedException iex) {
        }
        for (CronEntry entry : cronEntries) {
            if (entry.getDelayToNextExecutionInMillis() < GRANULARITY_UNIT.toMillis(GRANULARITY)) {
                final String taskClassName = entry.getName();
                final Class taskClass = instantiate(taskClassName);
                try {
                    if (taskClass != null) {
                        Task task = (Task) taskClass.newInstance();
                        logger.debug("Starting task {}", taskClassName);
                        StructrApp.getInstance().processTasks(task);
                    } else {
                        try (final Tx tx = StructrApp.getInstance().tx()) {
                            // check for schema method with the given name
                            Actions.callAsSuperUser(taskClassName, Collections.EMPTY_MAP);
                            tx.success();
                        }
                    }
                } catch (Throwable t) {
                    logger.warn("Exception while executing cron task {}: {}", taskClassName, t.getMessage());
                }
            }
        }
    }
}
Also used : StructrServices(org.structr.api.service.StructrServices) Services(org.structr.core.Services) Task(org.structr.agent.Task) Tx(org.structr.core.graph.Tx)

Example 29 with Services

use of org.structr.core.Services in project structr by structr.

the class TextSearchModuleTest method startSystem.

@BeforeClass
public static void startSystem() {
    final Date now = new Date();
    final long timestamp = now.getTime();
    basePath = "/tmp/structr-test-" + timestamp;
    Settings.Services.setValue("NodeService LogService SchemaService HttpService AgentService");
    Settings.ConnectionUrl.setValue(Settings.TestingConnectionUrl.getValue());
    // example for new configuration setup
    Settings.BasePath.setValue(basePath);
    Settings.DatabasePath.setValue(basePath + "/db");
    Settings.FilesPath.setValue(basePath + "/files");
    Settings.RelationshipCacheSize.setValue(1000);
    Settings.NodeCacheSize.setValue(1000);
    Settings.SuperUserName.setValue("superadmin");
    Settings.SuperUserPassword.setValue("sehrgeheim");
    Settings.ApplicationTitle.setValue("structr unit test app" + timestamp);
    Settings.ApplicationHost.setValue(host);
    Settings.HttpPort.setValue(httpPort);
    Settings.Servlets.setValue("JsonRestServlet");
    final Services services = Services.getInstance();
    // wait for service layer to be initialized
    do {
        try {
            Thread.sleep(100);
        } catch (Throwable t) {
        }
    } while (!services.isInitialized());
    securityContext = SecurityContext.getSuperUserInstance();
    app = StructrApp.getInstance(securityContext);
}
Also used : Services(org.structr.core.Services) Date(java.util.Date) BeforeClass(org.junit.BeforeClass)

Example 30 with Services

use of org.structr.core.Services in project structr by structr.

the class StructrODFModuleTest method startSystem.

@BeforeClass
public static void startSystem() {
    final Date now = new Date();
    final long timestamp = now.getTime();
    basePath = "/tmp/structr-test-" + timestamp;
    Settings.Services.setValue("NodeService LogService SchemaService HttpService AgentService");
    Settings.ConnectionUrl.setValue(Settings.TestingConnectionUrl.getValue());
    // example for new configuration setup
    Settings.BasePath.setValue(basePath);
    Settings.DatabasePath.setValue(basePath + "/db");
    Settings.FilesPath.setValue(basePath + "/files");
    Settings.RelationshipCacheSize.setValue(1000);
    Settings.NodeCacheSize.setValue(1000);
    Settings.SuperUserName.setValue("superadmin");
    Settings.SuperUserPassword.setValue("sehrgeheim");
    Settings.ApplicationTitle.setValue("structr unit test app" + timestamp);
    Settings.ApplicationHost.setValue(host);
    Settings.HttpPort.setValue(httpPort);
    Settings.Servlets.setValue("JsonRestServlet");
    // Settings.LogSchemaOutput.setValue(true);
    final Services services = Services.getInstance();
    // wait for service layer to be initialized
    do {
        try {
            Thread.sleep(100);
        } catch (Throwable t) {
        }
    } while (!services.isInitialized());
    securityContext = SecurityContext.getSuperUserInstance();
    app = StructrApp.getInstance(securityContext);
}
Also used : Services(org.structr.core.Services) Date(java.util.Date) BeforeClass(org.junit.BeforeClass)

Aggregations

Services (org.structr.core.Services)30 BeforeClass (org.junit.BeforeClass)21 Date (java.util.Date)20 SuperUserAuthenticator (org.structr.core.auth.SuperUserAuthenticator)5 DefaultResourceProvider (org.structr.rest.DefaultResourceProvider)5 GraphDatabaseCommand (org.structr.core.graph.GraphDatabaseCommand)4 Tx (org.structr.core.graph.Tx)2 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 HttpSession (javax.servlet.http.HttpSession)1 Task (org.structr.agent.Task)1 SettingsGroup (org.structr.api.config.SettingsGroup)1 Service (org.structr.api.service.Service)1 StructrServices (org.structr.api.service.StructrServices)1 Attr (org.structr.api.util.html.Attr)1 Document (org.structr.api.util.html.Document)1 Tag (org.structr.api.util.html.Tag)1 SecurityContext (org.structr.common.SecurityContext)1 DatabaseServiceNotAvailableException (org.structr.common.error.DatabaseServiceNotAvailableException)1 FrameworkException (org.structr.common.error.FrameworkException)1