Search in sources :

Example 1 with SpoolerEngineImpl

use of lucee.runtime.spooler.SpoolerEngineImpl in project Lucee by lucee.

the class Admin method doGetMailSetting.

/**
 * @throws PageException
 */
private void doGetMailSetting() throws PageException {
    Struct sct = new StructImpl();
    pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
    int maxThreads = 20;
    SpoolerEngine engine = config.getSpoolerEngine();
    if (engine instanceof SpoolerEngineImpl) {
        maxThreads = ((SpoolerEngineImpl) engine).getMaxThreads();
    }
    sct.set("spoolEnable", Caster.toBoolean(config.isMailSpoolEnable()));
    sct.set("spoolInterval", Caster.toInteger(config.getMailSpoolInterval()));
    sct.set("maxThreads", Caster.toDouble(maxThreads));
    sct.set("timeout", Caster.toInteger(config.getMailTimeout()));
    sct.set("defaultencoding", config.getMailDefaultCharset().name());
}
Also used : StructImpl(lucee.runtime.type.StructImpl) SpoolerEngine(lucee.runtime.spooler.SpoolerEngine) SpoolerEngineImpl(lucee.runtime.spooler.SpoolerEngineImpl) Struct(lucee.runtime.type.Struct)

Example 2 with SpoolerEngineImpl

use of lucee.runtime.spooler.SpoolerEngineImpl in project Lucee by lucee.

the class Admin method doGetTaskSetting.

private void doGetTaskSetting() throws PageException {
    Struct sct = new StructImpl();
    pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
    int maxThreads = 20;
    SpoolerEngine engine = config.getSpoolerEngine();
    if (engine instanceof SpoolerEngineImpl) {
        SpoolerEngineImpl ei = ((SpoolerEngineImpl) engine);
        maxThreads = ei.getMaxThreads();
    }
    sct.set("maxThreads", Caster.toDouble(maxThreads));
}
Also used : StructImpl(lucee.runtime.type.StructImpl) SpoolerEngine(lucee.runtime.spooler.SpoolerEngine) SpoolerEngineImpl(lucee.runtime.spooler.SpoolerEngineImpl) Struct(lucee.runtime.type.Struct)

Example 3 with SpoolerEngineImpl

use of lucee.runtime.spooler.SpoolerEngineImpl in project Lucee by lucee.

the class Admin method doGetSpoolerTasks.

private void doGetSpoolerTasks() throws PageException {
    int startrow = getInt("startrow", 1);
    if (startrow < 1)
        startrow = 1;
    int maxrow = getInt("maxrow", -1);
    String result = getString("result", null);
    SpoolerEngineImpl engine = (SpoolerEngineImpl) config.getSpoolerEngine();
    Query qry = engine.getAllTasksAsQuery(startrow, maxrow);
    pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
    if (!StringUtil.isEmpty(result)) {
        Struct sct = new StructImpl();
        pageContext.setVariable(result, sct);
        sct.setEL("open", engine.getOpenTaskCount());
        sct.setEL("closed", engine.getClosedTaskCount());
    }
/*
		 * SpoolerTask[] open = config.getSpoolerEngine().getOpenTasks(); SpoolerTask[] closed = config.getSpoolerEngine().getClosedTasks(); String v="VARCHAR";
		 * lucee.runtime.type.Query qry=new QueryImpl( new
		 * String[]{"type","name","detail","id","lastExecution","nextExecution","closed","tries","exceptions","triesmax"}, new
		 * String[]{v,v,"object",v,d,d,"boolean","int","object","int"}, open.length+closed.length,"query");
		 * 
		 * int row=0; row=doGetRemoteClientTasks(qry,open,row); doGetRemoteClientTasks(qry,closed,row);
		 * pageContext.setVariable(getString("admin",action,"returnVariable"),qry);
		 */
}
Also used : StructImpl(lucee.runtime.type.StructImpl) Query(lucee.runtime.type.Query) SpoolerEngineImpl(lucee.runtime.spooler.SpoolerEngineImpl) Struct(lucee.runtime.type.Struct)

Example 4 with SpoolerEngineImpl

use of lucee.runtime.spooler.SpoolerEngineImpl in project Lucee by lucee.

the class XMLConfigWebFactory method loadRemoteClient.

private static void loadRemoteClient(ConfigServerImpl configServer, ConfigImpl config, Document doc) {
    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManagerImpl.TYPE_REMOTE);
    // SNSN
    // RemoteClientUsage
    // boolean hasCS=configServer!=null;
    Element _clients = getChildByName(doc.getDocumentElement(), "remote-clients");
    // usage
    String strUsage = getAttr(_clients, "usage");
    Struct sct;
    if (!StringUtil.isEmpty(strUsage))
        // config.setRemoteClientUsage(toStruct(strUsage));
        sct = toStruct(strUsage);
    else
        sct = new StructImpl();
    // TODO make this generic
    if (configServer != null) {
        String sync = Caster.toString(configServer.getRemoteClientUsage().get("synchronisation", ""), "");
        if (!StringUtil.isEmpty(sync)) {
            sct.setEL("synchronisation", sync);
        }
    }
    config.setRemoteClientUsage(sct);
    // max-threads
    int maxThreads = Caster.toIntValue(getAttr(_clients, "max-threads"), -1);
    if (maxThreads < 1 && configServer != null) {
        SpoolerEngineImpl engine = (SpoolerEngineImpl) configServer.getSpoolerEngine();
        if (engine != null)
            maxThreads = engine.getMaxThreads();
    }
    if (maxThreads < 1)
        maxThreads = 20;
    // directory
    Resource file = ConfigWebUtil.getFile(config.getRootDirectory(), _clients.getAttribute("directory"), "client-task", config.getConfigDir(), FileUtil.TYPE_DIR, config);
    config.setRemoteClientDirectory(file);
    Element[] clients;
    Element client;
    if (!hasAccess)
        clients = new Element[0];
    else
        clients = getChildren(_clients, "remote-client");
    java.util.List<RemoteClient> list = new ArrayList<RemoteClient>();
    for (int i = 0; i < clients.length; i++) {
        client = clients[i];
        // type
        String type = getAttr(client, "type");
        if (StringUtil.isEmpty(type))
            type = "web";
        // url
        String url = getAttr(client, "url");
        String label = getAttr(client, "label");
        if (StringUtil.isEmpty(label))
            label = url;
        String sUser = getAttr(client, "server-username");
        String sPass = ConfigWebUtil.decrypt(getAttr(client, "server-password"));
        String aPass = ConfigWebUtil.decrypt(getAttr(client, "admin-password"));
        String aCode = ConfigWebUtil.decrypt(getAttr(client, "security-key"));
        // if(aCode!=null && aCode.indexOf('-')!=-1)continue;
        String usage = getAttr(client, "usage");
        if (usage == null)
            usage = "";
        String pUrl = getAttr(client, "proxy-server");
        int pPort = Caster.toIntValue(getAttr(client, "proxy-port"), -1);
        String pUser = getAttr(client, "proxy-username");
        String pPass = ConfigWebUtil.decrypt(getAttr(client, "proxy-password"));
        ProxyData pd = null;
        if (!StringUtil.isEmpty(pUrl, true)) {
            pd = new ProxyDataImpl();
            pd.setServer(pUrl);
            if (!StringUtil.isEmpty(pUser)) {
                pd.setUsername(pUser);
                pd.setPassword(pPass);
            }
            if (pPort > 0)
                pd.setPort(pPort);
        }
        list.add(new RemoteClientImpl(label, type, url, sUser, sPass, aPass, pd, aCode, usage));
    }
    if (list.size() > 0)
        config.setRemoteClients(list.toArray(new RemoteClient[list.size()]));
    else
        config.setRemoteClients(new RemoteClient[0]);
    // init spooler engine
    Resource dir = config.getRemoteClientDirectory();
    if (dir != null && !dir.exists())
        dir.mkdirs();
    if (config.getSpoolerEngine() == null) {
        config.setSpoolerEngine(new SpoolerEngineImpl(config, dir, "Remote Client Spooler", config.getLog("remoteclient"), maxThreads));
    } else {
        SpoolerEngineImpl engine = (SpoolerEngineImpl) config.getSpoolerEngine();
        engine.setConfig(config);
        engine.setLog(config.getLog("remoteclient"));
        engine.setPersisDirectory(dir);
        engine.setMaxThreads(maxThreads);
    }
}
Also used : Element(org.w3c.dom.Element) Resource(lucee.commons.io.res.Resource) ArrayList(java.util.ArrayList) ProxyDataImpl(lucee.runtime.net.proxy.ProxyDataImpl) lucee.aprint(lucee.aprint) Struct(lucee.runtime.type.Struct) StructImpl(lucee.runtime.type.StructImpl) ProxyData(lucee.runtime.net.proxy.ProxyData) SpoolerEngineImpl(lucee.runtime.spooler.SpoolerEngineImpl)

Aggregations

SpoolerEngineImpl (lucee.runtime.spooler.SpoolerEngineImpl)4 Struct (lucee.runtime.type.Struct)4 StructImpl (lucee.runtime.type.StructImpl)4 SpoolerEngine (lucee.runtime.spooler.SpoolerEngine)2 ArrayList (java.util.ArrayList)1 lucee.aprint (lucee.aprint)1 Resource (lucee.commons.io.res.Resource)1 ProxyData (lucee.runtime.net.proxy.ProxyData)1 ProxyDataImpl (lucee.runtime.net.proxy.ProxyDataImpl)1 Query (lucee.runtime.type.Query)1 Element (org.w3c.dom.Element)1