Search in sources :

Example 16 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 SchemaService FtpService SSHService");
    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.FtpPort.setValue(ftpPort);
    Settings.SshPort.setValue(sshPort);
    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 17 with Services

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

the class StructrKnowledgeModuleTest 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 18 with Services

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

the class JavaParserModuleTest 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 19 with Services

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

the class ConfigServlet method createConfigDocument.

// ----- private methods -----
private Document createConfigDocument(final HttpServletRequest request, final PrintWriter writer) {
    final Document doc = new Document(writer);
    final Tag body = setupDocument(request, doc);
    final Tag form = body.block("form").css("config-form");
    final Tag main = form.block("div").id("main");
    final Tag tabs = main.block("div").id("configTabs");
    final Tag menu = tabs.block("ul").id("configTabsMenu");
    // configure form
    form.attr(new Attr("action", ConfigUrl), new Attr("method", "post"));
    for (final SettingsGroup group : Settings.getGroups()) {
        final String key = group.getKey();
        final String name = group.getName();
        menu.block("li").block("a").id(key + "Menu").attr(new Attr("href", "#" + key)).block("span").text(name);
        final Tag container = tabs.block("div").css("tab-content").id(key);
        // let settings group render itself
        group.render(container);
        // stop floating
        container.block("div").attr(new Style("clear: both;"));
    }
    // add services tab
    menu.block("li").block("a").id("servicesMenu").attr(new Attr("href", "#services")).block("span").text("Services");
    final Services services = Services.getInstance();
    final Tag container = tabs.block("div").css("tab-content").id("services");
    final Tag table = container.block("table").id("services-table");
    final Tag header = table.block("tr");
    header.block("th").text("Service Name");
    header.block("th").attr(new Attr("colspan", "2"));
    for (final String serviceClassName : services.getServices()) {
        final Class<Service> serviceClass = services.getServiceClassForName(serviceClassName);
        final boolean running = serviceClass != null ? services.isReady(serviceClass) : false;
        final Tag row = table.block("tr");
        row.block("td").text(serviceClassName);
        if (running) {
            row.block("td").block("button").attr(new Type("button"), new OnClick("window.location.href='" + ConfigUrl + "?restart=" + serviceClassName + "';")).text("Restart");
            if ("HttpService".equals(serviceClassName)) {
                row.block("td");
            } else {
                row.block("td").block("button").attr(new Type("button"), new OnClick("window.location.href='" + ConfigUrl + "?stop=" + serviceClassName + "';")).text("Stop");
            }
            row.block("td");
        } else {
            row.block("td");
            row.block("td");
            row.block("td").block("button").attr(new Type("button"), new OnClick("window.location.href='" + ConfigUrl + "?start=" + serviceClassName + "';")).text("Start");
        }
    }
    // update active section so we can restore it when redirecting
    container.empty("input").attr(new Type("hidden"), new Name("active_section")).id("active_section");
    // stop floating
    container.block("div").attr(new Style("clear: both;"));
    // buttons
    final Tag buttons = form.block("div").css("buttons");
    buttons.block("button").attr(new Type("button")).id("new-entry-button").text("Add entry");
    buttons.block("button").attr(new Type("button"), new OnClick("window.location.href='" + ConfigUrl + "?reload';")).text("Reload configuration file");
    buttons.empty("input").attr(new Type("submit"), new Value("Save to structr.conf"));
    body.block("script").text("$('#new-entry-button').on('click', createNewEntry);");
    return doc;
}
Also used : Service(org.structr.api.service.Service) Document(org.structr.api.util.html.Document) Attr(org.structr.api.util.html.Attr) Services(org.structr.core.Services) SettingsGroup(org.structr.api.config.SettingsGroup) Tag(org.structr.api.util.html.Tag)

Example 20 with Services

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

the class StructrCsvTest method start.

// ~--- set methods ----------------------------------------------------
@BeforeClass
public static void start() throws Exception {
    final Date now = new Date();
    final long timestamp = now.getTime();
    basePath = "/tmp/structr-test-" + timestamp;
    Settings.Services.setValue("NodeService LogService HttpService SchemaService");
    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 CsvServlet");
    Settings.RestAuthenticator.setValue(SuperUserAuthenticator.class.getName());
    Settings.RestResourceProvider.setValue(DefaultResourceProvider.class.getName());
    Settings.RestUserClass.setValue("");
    Settings.CsvServletPath.setValue(csvUrl);
    Settings.CsvAuthenticator.setValue(SuperUserAuthenticator.class.getName());
    Settings.CsvResourceProvider.setValue(DefaultResourceProvider.class.getName());
    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);
    // sleep again to wait for schema initialization
    try {
        Thread.sleep(2000);
    } catch (Throwable t) {
    }
}
Also used : Services(org.structr.core.Services) SuperUserAuthenticator(org.structr.core.auth.SuperUserAuthenticator) Date(java.util.Date) DefaultResourceProvider(org.structr.rest.DefaultResourceProvider) 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