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);
}
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);
}
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);
}
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;
}
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) {
}
}
Aggregations