use of com.twinsoft.convertigo.engine.scheduler.SchedulerManager in project convertigo by convertigo.
the class CreateScheduledElements method getServiceResult.
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
SchedulerManager schedulerManager = Engine.theApp.schedulerManager;
SchedulerXML schedulerXML = schedulerManager.getSchedulerXML();
boolean edit = (request.getParameter("edit") != null);
boolean del = (request.getParameter("del") != null);
Type type = null;
try {
type = Type.valueOf(request.getParameter("type"));
} catch (Exception e) {
throw new ServiceException("invalide \"type\" parameter");
}
Element rootElement = document.getDocumentElement();
AbstractBase ab = null;
Exception eProb = null;
try {
if (edit || del) {
String exname = ServiceUtils.getRequiredParameter(request, "exname");
if (ScheduledJob.class.isAssignableFrom(type.c)) {
ab = schedulerXML.getScheduledJob(exname);
} else if (AbstractSchedule.class.isAssignableFrom(type.c)) {
ab = schedulerXML.getSchedule(exname);
} else if (AbstractJob.class.isAssignableFrom(type.c)) {
ab = schedulerXML.getJob(exname);
}
if (del) {
schedulerXML.delAbstractBase(ab);
ab = null;
}
} else {
ab = type.c.getConstructor().newInstance();
}
if (ab != null) {
String exName = ab.getName();
String name = ServiceUtils.getRequiredParameter(request, "name");
ab.setName(name);
ab.setDescription(ServiceUtils.getRequiredParameter(request, "description"));
ab.setEnable("true".equals(ServiceUtils.getRequiredParameter(request, "enabled")));
if (ScheduledJob.class.isAssignableFrom(type.c)) {
ScheduledJob sj = (ScheduledJob) ab;
sj.setJob(schedulerXML.getJob(ServiceUtils.getRequiredParameter(request, "jobName")));
sj.setSchedule(schedulerXML.getSchedule(ServiceUtils.getRequiredParameter(request, "scheduleName")));
} else if (AbstractSchedule.class.isAssignableFrom(type.c)) {
AbstractSchedule as = (AbstractSchedule) ab;
if (ScheduleCron.class.isAssignableFrom(type.c)) {
ScheduleCron sc = (ScheduleCron) as;
sc.setCron(ServiceUtils.getRequiredParameter(request, "cron"));
}
} else if (AbstractJob.class.isAssignableFrom(type.c)) {
AbstractJob aj = (AbstractJob) ab;
if (JobGroupJob.class.isAssignableFrom(type.c)) {
JobGroupJob jgj = (JobGroupJob) aj;
jgj.setParallelJob(Integer.parseInt(ServiceUtils.getRequiredParameter(request, "parallelJob")));
jgj.delAllJobs();
for (String jobname : request.getParameterValues("jobsname")) {
AbstractJob jobToAdd = schedulerXML.getJob(jobname);
if (jobToAdd != null) {
jgj.addJob(jobToAdd);
}
}
} else if (AbstractConvertigoJob.class.isAssignableFrom(type.c)) {
AbstractConvertigoJob acj = (AbstractConvertigoJob) aj;
acj.setContextName(ServiceUtils.getRequiredParameter(request, "context"));
acj.setProjectName(ServiceUtils.getRequiredParameter(request, "project"));
acj.setWriteOutput("true".equals(ServiceUtils.getRequiredParameter(request, "writeOutput")));
if (TransactionConvertigoJob.class.isAssignableFrom(type.c)) {
TransactionConvertigoJob tcj = (TransactionConvertigoJob) acj;
tcj.setConnectorName(ServiceUtils.getParameter(request, "connector", ""));
tcj.setTransactionName(ServiceUtils.getParameter(request, "transaction", ""));
} else if (SequenceConvertigoJob.class.isAssignableFrom(type.c)) {
SequenceConvertigoJob scj = (SequenceConvertigoJob) acj;
scj.setSequenceName(ServiceUtils.getParameter(request, "sequence", ""));
}
Map<String, String[]> parameters = new HashMap<String, String[]>();
Matcher prefix = prefixPattern.matcher("");
for (String pname : Collections.list(GenericUtils.<Enumeration<String>>cast(request.getParameterNames()))) {
prefix.reset(pname);
if (prefix.find()) {
String para_name = prefix.group(1);
String[] values = request.getParameterValues(pname);
// for (String value : values) {
// parameters.put(para_name, value);
parameters.put(para_name, values);
// }
}
if (pname.equals("parameters")) {
String value = request.getParameter(pname);
if (!value.equals("0")) {
parameters.put("__testcase", new String[] { value });
}
}
}
acj.setParameters(parameters);
}
}
List<String> problems = schedulerXML.checkProblems(ab);
if (exName.equals(name) && edit) {
problems.remove(SchedulerXML.prob_alreadyExist);
}
if (problems.size() > 0) {
for (String problem : problems) {
rootElement.appendChild(document.createElement("problem")).appendChild(document.createTextNode(problem));
}
throw (eProb = new Exception("problem!"));
} else {
if (!edit) {
schedulerXML.addAbstractBase(ab);
}
}
}
schedulerManager.save();
schedulerManager.refreshJobs();
} catch (Exception e) {
schedulerManager.load();
if (e != eProb) {
throw e;
}
}
}
use of com.twinsoft.convertigo.engine.scheduler.SchedulerManager in project convertigo by convertigo.
the class List method getServiceResult.
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
Category category = null;
try {
category = Category.valueOf(request.getParameter("category"));
} catch (Exception e) {
// just ignore parse exception
}
Element rootElement = document.getDocumentElement();
SchedulerManager schedulerManager = Engine.theApp.schedulerManager;
SchedulerXML schedulerXML = schedulerManager.getSchedulerXML();
if (category == null || category == Category.scheduledJobs) {
for (ScheduledJob sj : schedulerXML.getScheduledJobs()) {
Element element = prepareElement(document, Category.scheduledJobs, sj);
AbstractJob job = sj.getJob();
AbstractSchedule schedule = sj.getSchedule();
element.setAttribute("jobName", job == null ? "..." : job.getName());
element.setAttribute("scheduleName", schedule == null ? "..." : schedule.getName());
StringBuffer info = new StringBuffer();
if (schedulerManager.getRunningScheduledJobs().contains(sj)) {
info.append("[ currently running ] ");
}
if (sj.isAllEnabled()) {
info.append("[ ready to run ] ");
} else {
info.append("[ not ready to run ] ");
if (sj.isEnable()) {
info.append("caused by ");
if (job == null) {
info.append("[ job is not defined ]");
} else if (!job.isEnable()) {
info.append("[ job is disabled ]");
}
if (schedule == null) {
info.append("[ schedule is not defined ]");
} else if (!schedule.isEnable()) {
info.append("[ schedule is disabled ]");
}
}
}
element.setAttribute("info", info.toString());
rootElement.appendChild(element);
}
}
if (category == null || category == Category.jobs) {
for (AbstractJob aj : schedulerXML.getJobs()) {
Element element = prepareElement(document, Category.jobs, aj);
if (aj instanceof AbstractConvertigoJob) {
AbstractConvertigoJob acj = (AbstractConvertigoJob) aj;
element.setAttribute("writeOutput", Boolean.toString(acj.isWriteOutput()));
element.setAttribute("project", acj.getProjectName());
element.setAttribute("context", acj.getContextName());
element.setAttribute("info", "URL : " + acj.getConvertigoURL());
for (Map.Entry<String, String[]> entry : acj.getParameters().entrySet()) {
Element parameter = document.createElement("parameter");
parameter.setAttribute("name", entry.getKey());
for (String value : entry.getValue()) {
if (!value.isEmpty()) {
Element parameter_value = document.createElement("value");
parameter_value.setTextContent(value);
parameter.appendChild(parameter_value);
}
}
element.appendChild(parameter);
}
if (acj instanceof SequenceConvertigoJob) {
SequenceConvertigoJob scj = (SequenceConvertigoJob) acj;
element.setAttribute("sequence", scj.getSequenceName());
} else if (acj instanceof TransactionConvertigoJob) {
TransactionConvertigoJob tcj = (TransactionConvertigoJob) acj;
element.setAttribute("connector", ((TransactionConvertigoJob) acj).getConnectorName());
element.setAttribute("transaction", tcj.getTransactionName());
}
} else if (aj instanceof JobGroupJob) {
JobGroupJob jgj = (JobGroupJob) aj;
element.setAttribute("parallelJob", Integer.toString(jgj.getParallelJob()));
for (AbstractJob sub : jgj.getJobGroup()) {
Element job = document.createElement("job_group_member");
job.appendChild(document.createTextNode(sub.getName()));
element.appendChild(job);
}
element.setAttribute("info", (jgj.isSerial() ? "serial " : "parallel ") + new ArrayList<AbstractJob>(jgj.getJobGroup()).toString());
}
rootElement.appendChild(element);
}
}
if (category == null || category == Category.schedules) {
for (AbstractSchedule as : schedulerXML.getSchedules()) {
Element element = prepareElement(document, Category.schedules, as);
if (as instanceof ScheduleCron) {
ScheduleCron sc = (ScheduleCron) as;
element.setAttribute("cron", sc.getCron());
element.setAttribute("info", "CRON [" + sc.getCron() + "]");
}
if (as instanceof ScheduleRunNow) {
element.setAttribute("info", "RunNow");
}
rootElement.appendChild(element);
}
}
}
use of com.twinsoft.convertigo.engine.scheduler.SchedulerManager in project convertigo by convertigo.
the class Engine method start.
public static synchronized void start() throws EngineException {
if (Engine.theApp == null) {
System.out.println("Starting Convertigo Enterprise Mobility Server");
System.out.println("Version: " + ProductVersion.fullProductVersion);
// If the engine has been stopped by the admin, we must reload
// properties
EnginePropertiesManager.loadProperties();
boolean bProjectsDataCompatibilityMode = Boolean.parseBoolean(EnginePropertiesManager.getProperty(PropertyName.PROJECTS_DATA_COMPATIBILITY_MODE));
if (bProjectsDataCompatibilityMode) {
System.out.println("Projects data compatibility mode required");
try {
Engine.PROJECTS_PATH = new File(Engine.WEBAPP_PATH + "/projects").getCanonicalPath();
File projectsDir = new File(Engine.PROJECTS_PATH);
projectsDir.mkdir();
} catch (IOException e) {
throw new EngineException("Unable to update projects path for compatibility mode", e);
}
}
isStarted = false;
isStartFailed = false;
RequestableObject.nbCurrentWorkerThreads = 0;
Engine.startStopDate = System.currentTimeMillis();
System.out.println("Creating/updating loggers");
String logFile = EnginePropertiesManager.getProperty(PropertyName.LOG4J_APPENDER_CEMSAPPENDER_FILE);
System.out.println("Log file: " + logFile);
// Main loggers
Engine.logConvertigo = Logger.getLogger("cems");
Engine.logEngine = Logger.getLogger("cems.Engine");
Engine.logAdmin = Logger.getLogger("cems.Admin");
Engine.logBeans = Logger.getLogger("cems.Beans");
Engine.logBillers = Logger.getLogger("cems.Billers");
Engine.logEmulators = Logger.getLogger("cems.Emulators");
Engine.logContext = Logger.getLogger("cems.Context");
Engine.logUser = Logger.getLogger("cems.Context.User");
Engine.logUsageMonitor = Logger.getLogger("cems.UsageMonitor");
Engine.logStatistics = Logger.getLogger("cems.Statistics");
Engine.logScheduler = Logger.getLogger("cems.Scheduler");
Engine.logSiteClipper = Logger.getLogger("cems.SiteClipper");
Engine.logSecurityFilter = Logger.getLogger("cems.SecurityFilter");
Engine.logStudio = Logger.getLogger("cems.Studio");
Engine.logAudit = Logger.getLogger("cems.Context.Audit");
// Managers
Engine.logContextManager = Logger.getLogger("cems.ContextManager");
Engine.logCacheManager = Logger.getLogger("cems.CacheManager");
Engine.logTracePlayerManager = Logger.getLogger("cems.TracePlayerManager");
Engine.logJobManager = Logger.getLogger("cems.JobManager");
Engine.logCertificateManager = Logger.getLogger("cems.CertificateManager");
Engine.logDatabaseObjectManager = Logger.getLogger("cems.DatabaseObjectManager");
Engine.logProxyManager = Logger.getLogger("cems.ProxyManager");
Engine.logDevices = Logger.getLogger("cems.Devices");
Engine.logCouchDbManager = Logger.getLogger("cems.CouchDbManager");
Engine.logSecurityTokenManager = Logger.getLogger("cems.SecurityTokenManager");
// Logger for compatibility issues
Engine.log = new LogWrapper(Engine.logConvertigo);
LogWrapper.initWrapper(Engine.logEmulators);
LogCleaner.start();
try {
Engine.logEngine.info("===========================================================");
Engine.logEngine.info("Web app home: " + Engine.WEBAPP_PATH);
Engine.logEngine.info("User workspace: " + Engine.USER_WORKSPACE_PATH);
Engine.logEngine.info("Configuration path: " + Engine.CONFIGURATION_PATH);
Engine.logEngine.info("Projects path: " + Engine.PROJECTS_PATH);
if (bProjectsDataCompatibilityMode) {
Engine.logEngine.warn("Projects data compatibility mode required");
}
Engine.logEngine.info("Log: " + Engine.LOG_PATH);
if (cloud_customer_name != null) {
Engine.logEngine.info("Cloud customer: " + cloud_customer_name);
}
// Check environment and native dependencies
if (!isStudioMode()) {
StartupDiagnostics.run();
}
// Initializing the engine
Engine.theApp = new Engine();
CachedIntrospector.prefetchDatabaseObjectsAsync();
try {
Engine.theApp.usageMonitor = new UsageMonitor();
Engine.theApp.usageMonitor.init();
Thread vulture = new Thread(Engine.theApp.usageMonitor);
vulture.setName("UsageMonitor");
vulture.setDaemon(true);
vulture.start();
} catch (Exception e) {
Engine.logEngine.error("Unable to launch the usage monitor.", e);
}
Engine.theApp.eventManager = new EventManager();
Engine.theApp.eventManager.init();
Engine.theApp.databaseObjectsManager = new DatabaseObjectsManager();
Engine.theApp.databaseObjectsManager.init();
Engine.theApp.databaseObjectsManager.addDatabaseObjectListener(ComponentRefManager.get(Mode.start));
Engine.theApp.systemDatabaseObjectsManager = new SystemDatabaseObjectsManager();
Engine.theApp.systemDatabaseObjectsManager.init();
Engine.theApp.sqlConnectionManager = new JdbcConnectionManager();
Engine.theApp.sqlConnectionManager.init();
Engine.theApp.filePropertyManager = new FilePropertyManager();
Engine.theApp.filePropertyManager.init();
try {
Engine.theApp.proxyManager = new ProxyManager();
Engine.theApp.proxyManager.init();
} catch (Exception e) {
Engine.logEngine.error("Unable to launch the proxy manager.", e);
}
try {
Engine.theApp.billerTokenManager = new BillerTokenManager();
Engine.theApp.billerTokenManager.init();
} catch (Exception e) {
Engine.logEngine.error("Unable to launch the biller token manager.", e);
}
try {
Engine.theApp.billingManager = new BillingManager();
Engine.theApp.billingManager.init();
} catch (Exception e) {
Engine.logEngine.error("Unable to launch the billing manager.", e);
}
// Initialization of the trace player
try {
Engine.theApp.tracePlayerManager = new TracePlayerManager();
Engine.theApp.tracePlayerManager.init();
} catch (Exception e) {
Engine.logEngine.error("Unable to run the trace player.", e);
}
try {
Engine.theApp.minificationManager = new MinificationManager();
Engine.theApp.minificationManager.init();
} catch (Exception e) {
Engine.logEngine.error("Unable to run the minification manager.", e);
}
try {
Engine.theApp.couchDbManager = new CouchDbManager();
Engine.theApp.couchDbManager.init();
} catch (Exception e) {
Engine.logEngine.error("Unable to run the couchDbProxy manager.", e);
}
try {
Engine.theApp.pluginsManager = new PluginsManager();
Engine.theApp.pluginsManager.init();
} catch (Exception e) {
Engine.logEngine.error("Unable to run the plugins manager.", e);
}
try {
Engine.theApp.restApiManager = RestApiManager.getInstance();
Engine.theApp.restApiManager.init();
} catch (Exception e) {
Engine.logEngine.error("Unable to run the rest api manager.", e);
}
Engine.logEngine.info("Current working directory is '" + System.getProperty("user.dir") + "'.");
// Creating the Carioca Authentication objects
Engine.logEngine.debug("Creating the Carioca Authentication objects");
String cariocaUserName = EnginePropertiesManager.getProperty(PropertyName.CARIOCA_DEFAULT_USER_NAME);
String cariocaPassword = EnginePropertiesManager.getProperty(PropertyName.CARIOCA_DEFAULT_USER_PASSWORD);
Engine.theApp.authentications = new HashMap<String, Authentication>();
// Initialization of the default TAS properties
try {
KeyManager.log = new LogWrapper(Engine.logEngine);
Authentication auth = Engine.theApp.getAuthenticationObject("", null);
auth.login(cariocaUserName, cariocaPassword);
} catch (Exception e) {
Engine.logEngine.error("The authentication to Carioca has failed (user name: \"" + cariocaUserName + "\", user password: \"" + cariocaPassword + "\").", e);
}
// TODO : retrieve SOA flag from KeyManager
isSOA = true;
// Creation of the session manager
Engine.theApp.sessionManager = new SessionManager();
Engine.theApp.sessionManager.setLog(new LogWrapper(Engine.logEngine));
Engine.theApp.sessionManager.setProductCode(SessionManager.CONVERTIGO);
String s = EnginePropertiesManager.getProperty(PropertyName.CONNECTORS_MONITORING);
Engine.theApp.setMonitored(s.equalsIgnoreCase("true"));
// Create Projects directory if needed
File projectsDirFile = new File(Engine.PROJECTS_PATH);
try {
if (!projectsDirFile.exists())
projectsDirFile.mkdirs();
} catch (Exception e) {
Engine.logEngine.error("An error occured while creating projects directory.", e);
}
// Starts projects migration process
MigrationManager.performProjectsMigration();
// Security providers registration
try {
File dir = new File(Engine.CERTIFICATES_PATH);
String[] files = dir.list(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith((".pkcs11"));
}
});
if (files != null && files.length > 0) {
Engine.logEngine.info("Registering security providers...");
try {
Class<?> sunPKCS11Class = Class.forName("sun.security.pkcs11.SunPKCS11");
String file;
for (int i = 0; i < files.length; i++) {
file = Engine.CERTIFICATES_PATH + "/" + files[i];
try {
Constructor<?> constructor = sunPKCS11Class.getConstructor(new Class[] { String.class });
Provider provider = (Provider) constructor.newInstance(new Object[] { file });
Security.addProvider(provider);
Engine.logEngine.info("Provider '" + provider.getName() + "' has been successfully registered.");
} catch (Exception e) {
Engine.logEngine.error("Unable to register security provider from file: " + file + " . Please check that the implementation library is in the Java lib path.");
}
}
} catch (ClassNotFoundException e) {
Engine.logEngine.error("Unable to find sun.security.pkcs11.SunPKCS11 class! PKCS#11 authentication won't be available. You must use JVM 1.5 or higher in order to use PKCS#11 authentication.");
}
}
Provider[] providers = Security.getProviders();
String sProviders = "";
for (int i = 0; i < providers.length; i++) {
sProviders += providers[i].getName() + ", ";
}
Engine.logEngine.debug("Registered providers: " + sProviders);
} catch (Exception e) {
Engine.logEngine.error("Unable to register security providers.", e);
}
// Launch the cache manager
try {
String cacheManagerClassName = EnginePropertiesManager.getProperty(PropertyName.CACHE_MANAGER_CLASS);
Engine.logEngine.debug("Cache manager class: " + cacheManagerClassName);
Engine.theApp.cacheManager = (CacheManager) Class.forName(cacheManagerClassName).getConstructor().newInstance();
Engine.theApp.cacheManager.init();
} catch (Exception e) {
Engine.logEngine.error("Unable to launch the cache manager.", e);
}
// Launch the thread manager
try {
Engine.theApp.threadManager = new ThreadManager();
Engine.theApp.threadManager.init();
Thread vulture = new Thread(Engine.theApp.threadManager);
Engine.theApp.threadManager.executionThread = vulture;
vulture.setName("ThreadManager");
vulture.setDaemon(true);
vulture.start();
} catch (Exception e) {
Engine.theApp.threadManager = null;
Engine.logEngine.error("Unable to launch the thread manager.", e);
}
// Launch the context manager
try {
Engine.theApp.contextManager = new ContextManager();
Engine.theApp.contextManager.init();
Thread vulture = new Thread(Engine.theApp.contextManager);
Engine.theApp.contextManager.executionThread = vulture;
vulture.setName("ContextManager");
vulture.setDaemon(true);
vulture.start();
} catch (Exception e) {
Engine.theApp.contextManager = null;
Engine.logEngine.error("Unable to launch the context manager.", e);
}
// Initialize the HttpClient
try {
Engine.logEngine.debug("HttpClient initializing...");
HttpMethodParams.getDefaultParams().setParameter(HttpMethodParams.CREDENTIAL_CHARSET, "UTF-8");
Engine.theApp.httpClient = HttpUtils.makeHttpClient3(true);
Engine.theApp.httpClient4 = HttpUtils.makeHttpClient(true);
Engine.logEngine.debug("HttpClient initialized!");
} catch (Exception e) {
Engine.logEngine.error("Unable to initialize the HttpClient.", e);
}
// Initialization of the schedule manager
Engine.theApp.schedulerManager = new SchedulerManager(true);
// Initialization of the RSA manager
Engine.theApp.rsaManager = new RsaManager();
Engine.theApp.rsaManager.init();
// Initialization of the Schema manager
Engine.theApp.schemaManager = new SchemaManager();
Engine.theApp.schemaManager.init();
Engine.theApp.referencedProjectManager = new ReferencedProjectManager();
// XUL initialization
String xulrunner_url = System.getProperty("org.eclipse.swt.browser.XULRunnerPath");
if (xulrunner_url == null || xulrunner_url.equals("")) {
xulrunner_url = EnginePropertiesManager.getProperty(PropertyName.XULRUNNER_URL);
}
File f = new File(xulrunner_url);
if (f.exists()) {
xulrunner_url = f.getAbsolutePath();
Engine.logEngine.debug("initMozillaSWT: org.eclipse.swt.browser.XULRunnerPath=" + xulrunner_url);
System.setProperty("org.eclipse.swt.browser.XULRunnerPath", xulrunner_url);
Engine.bXulRunner = true;
} else {
if (Engine.isLinux() && "i386".equals(System.getProperty("os.arch"))) {
Engine.logEngine.error("Error in initMozillaSWT: " + xulrunner_url + " doesn't exist, fix it with xulrunner.url");
} else {
Engine.logEngine.debug("No XulRunner to init.");
}
}
if (Engine.isEngineMode() && Engine.isLinux() && "true".equals(EnginePropertiesManager.getProperty(PropertyName.LINUX_LAUNCH_XVNC))) {
final String display = System.getenv("DISPLAY");
Engine.logEngine.debug("Linux launch XVNC on display: " + display);
if (display != null) {
try {
String port = System.getProperty("xvnc.port");
if (port == null) {
port = "" + (Integer.parseInt(display.replaceAll(".*:(\\d*)", "$1")) + 5900);
System.setProperty("xvnc.port", port);
}
Engine.logEngine.debug("Xvnc should listen on " + port + " port");
} catch (Exception e) {
}
try {
File vncDir = new File(Engine.WEBAPP_PATH + "/WEB-INF/xvnc");
File Xvnc = new File(vncDir, "/Xvnc");
File fonts = new File(vncDir, "/fonts");
File wm = new File(vncDir, "/matchbox-window-manager");
if (vncDir.exists() && Xvnc.exists() && fonts.exists() && wm.exists()) {
for (File file : GenericUtils.<File>asList(Xvnc, wm)) {
new ProcessBuilder("/bin/chmod", "u+x", file.getAbsolutePath()).start().waitFor();
}
String depth = EnginePropertiesManager.getProperty(PropertyName.LINUX_XVNC_DEPTH);
String geometry = EnginePropertiesManager.getProperty(PropertyName.LINUX_XVNC_GEOMETRY);
Engine.logEngine.debug("Xvnc will use depth " + depth + " and geometry " + geometry);
Process pr_xvnc = new ProcessBuilder(Xvnc.getAbsolutePath(), display, "-fp", fonts.getAbsolutePath(), "-depth", depth, "-geometry", geometry).start();
Thread.sleep(500);
try {
int exit = pr_xvnc.exitValue();
InputStream err = pr_xvnc.getErrorStream();
byte[] buf = new byte[err.available()];
err.read(buf);
Engine.logEngine.debug("Xvnc failed to run with exit code " + exit + " and this error : <<" + new String(buf, "UTF-8") + ">>");
} catch (Exception e) {
new ProcessBuilder(wm.getAbsolutePath()).start();
Engine.logEngine.debug("Xvnc successfully started !");
}
} else {
Engine.logEngine.info(vncDir.getAbsolutePath() + " not found or incomplet, cannot start Xvnc");
}
} catch (Exception e) {
Engine.logEngine.info("failed to launch Xvnc (maybe already launched", e);
}
} else
Engine.logEngine.warn("Trying to start Xvnc on Linux without DISPLAY environment variable !");
}
isStarted = true;
Engine.logEngine.info("Convertigo engine started");
if (Engine.isEngineMode()) {
theApp.addMigrationListener(new MigrationListener() {
@Override
public void projectMigrated(EngineEvent engineEvent) {
}
@Override
public void migrationFinished(EngineEvent engineEvent) {
List<String> names = Engine.theApp.databaseObjectsManager.getAllProjectNamesList();
Engine.logEngine.info("Convertigo engine will load: " + names);
for (String name : names) {
try {
Engine.theApp.databaseObjectsManager.getProjectByName(name);
} catch (Exception e) {
Engine.logEngine.error("Failed to load " + name, e);
}
}
boolean newProjectLoaded = Engine.theApp.referencedProjectManager.check();
if (!newProjectLoaded && Thread.currentThread().getName().equalsIgnoreCase("Migration")) {
Engine.logEngine.info("Convertigo will run auto start Sequences.");
for (String name : names) {
Project.executeAutoStartSequences(name);
}
}
}
});
}
if (DelegateServlet.canDelegate()) {
execute(() -> {
try {
Engine.logEngine.info("Call delegate action 'engineStarted'");
JSONObject json = new JSONObject();
json.put("action", "engineStarted");
DelegateServlet.delegate(json);
} catch (JSONException e) {
}
});
}
} catch (Throwable e) {
isStartFailed = true;
Engine.logEngine.error("Unable to successfully start the engine.", e);
}
} else {
Engine.logEngine.info("Convertigo engine already started");
}
}
Aggregations