Search in sources :

Example 51 with ApplicationException

use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.

the class Admin method doReadBundle.

private void doReadBundle() throws PageException {
    String ret = getString("admin", action, "returnvariable");
    Resource res = ResourceUtil.toResourceExisting(pageContext, getString("admin", action, "bundle"));
    if (!res.isFile())
        throw new ApplicationException("[" + res + "] is not a file");
    try {
        Struct sct = new StructImpl();
        pageContext.setVariable(ret, new BundleFile(res).info());
    } catch (Exception e) {
        throw Caster.toPageException(e);
    }
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) StructImpl(lucee.runtime.type.StructImpl) Resource(lucee.commons.io.res.Resource) BundleFile(lucee.runtime.osgi.BundleFile) PageException(lucee.runtime.exp.PageException) SecurityException(lucee.runtime.exp.SecurityException) IOException(java.io.IOException) DeprecatedException(lucee.runtime.exp.DeprecatedException) BundleException(org.osgi.framework.BundleException) MalformedURLException(java.net.MalformedURLException) SMTPException(lucee.runtime.net.mail.SMTPException) ApplicationException(lucee.runtime.exp.ApplicationException) Struct(lucee.runtime.type.Struct)

Example 52 with ApplicationException

use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.

the class Admin method doGetDatasource.

/**
 * @throws PageException
 */
private void doGetDatasource() throws PageException {
    String name = getString("admin", action, "name");
    Map ds = config.getDataSourcesAsMap();
    Iterator it = ds.keySet().iterator();
    while (it.hasNext()) {
        String key = (String) it.next();
        if (key.equalsIgnoreCase(name)) {
            DataSource d = (DataSource) ds.get(key);
            Struct sct = new StructImpl();
            ClassDefinition cd = d.getClassDefinition();
            sct.setEL(KeyConstants._name, key);
            sct.setEL(KeyConstants._host, d.getHost());
            sct.setEL("classname", cd.getClassName());
            sct.setEL("class", cd.getClassName());
            sct.setEL("bundleName", cd.getName());
            sct.setEL("bundleVersion", cd.getVersionAsString());
            sct.setEL("dsn", d.getDsnOriginal());
            sct.setEL("database", d.getDatabase());
            sct.setEL("port", d.getPort() < 1 ? "" : Caster.toString(d.getPort()));
            sct.setEL("dsnTranslated", d.getDsnTranslated());
            sct.setEL("timezone", toStringTimeZone(d.getTimeZone()));
            sct.setEL("password", d.getPassword());
            sct.setEL("passwordEncrypted", ConfigWebUtil.encrypt(d.getPassword()));
            sct.setEL("username", d.getUsername());
            sct.setEL("readonly", Caster.toBoolean(d.isReadOnly()));
            sct.setEL("select", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_SELECT)));
            sct.setEL("delete", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_DELETE)));
            sct.setEL("update", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_UPDATE)));
            sct.setEL("insert", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_INSERT)));
            sct.setEL("create", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_CREATE)));
            sct.setEL("insert", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_INSERT)));
            sct.setEL("drop", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_DROP)));
            sct.setEL("grant", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_GRANT)));
            sct.setEL("revoke", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_REVOKE)));
            sct.setEL("alter", Boolean.valueOf(d.hasAllow(DataSource.ALLOW_ALTER)));
            sct.setEL("connectionLimit", d.getConnectionLimit() < 1 ? "" : Caster.toString(d.getConnectionLimit()));
            sct.setEL("connectionTimeout", d.getConnectionTimeout() < 1 ? "" : Caster.toString(d.getConnectionTimeout()));
            sct.setEL("metaCacheTimeout", Caster.toDouble(d.getMetaCacheTimeout()));
            sct.setEL("custom", d.getCustoms());
            sct.setEL("blob", Boolean.valueOf(d.isBlob()));
            sct.setEL("clob", Boolean.valueOf(d.isClob()));
            sct.setEL("validate", Boolean.valueOf(d.validate()));
            sct.setEL("storage", Boolean.valueOf(d.isStorage()));
            if (d instanceof DataSourceImpl) {
                DataSourceImpl di = ((DataSourceImpl) d);
                sct.setEL("literalTimestampWithTSOffset", Boolean.valueOf(di.getLiteralTimestampWithTSOffset()));
                sct.setEL("alwaysSetTimeout", Boolean.valueOf(di.getAlwaysSetTimeout()));
                sct.setEL("dbdriver", Caster.toString(di.getDbDriver(), ""));
            }
            pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
            return;
        }
    }
    throw new ApplicationException("there is no datasource with name [" + name + "]");
}
Also used : StructImpl(lucee.runtime.type.StructImpl) ApplicationException(lucee.runtime.exp.ApplicationException) DataSourceImpl(lucee.runtime.db.DataSourceImpl) Iterator(java.util.Iterator) ClassDefinition(lucee.runtime.db.ClassDefinition) Map(java.util.Map) HashMap(java.util.HashMap) DataSource(lucee.runtime.db.DataSource) Struct(lucee.runtime.type.Struct)

Example 53 with ApplicationException

use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.

the class Admin method doGetMapping.

/**
 * @throws PageException
 */
private void doGetMapping() throws PageException {
    Mapping[] mappings = config.getMappings();
    Struct sct = new StructImpl();
    String virtual = getString("admin", action, "virtual");
    for (int i = 0; i < mappings.length; i++) {
        MappingImpl m = (MappingImpl) mappings[i];
        if (!m.getVirtual().equals(virtual))
            continue;
        sct.set("archive", m.getArchive());
        sct.set("strarchive", m.getStrArchive());
        sct.set("physical", m.getPhysical());
        sct.set("strphysical", m.getStrPhysical());
        sct.set("virtual", m.getVirtual());
        sct.set(KeyConstants._hidden, Caster.toBoolean(m.isHidden()));
        sct.set("physicalFirst", Caster.toBoolean(m.isPhysicalFirst()));
        sct.set("readonly", Caster.toBoolean(m.isReadonly()));
        sct.set("inspect", ConfigWebUtil.inspectTemplate(m.getInspectTemplateRaw(), ""));
        sct.set("toplevel", Caster.toBoolean(m.isTopLevel()));
        pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
        return;
    }
    throw new ApplicationException("there is no mapping with virtual [" + virtual + "]");
}
Also used : StructImpl(lucee.runtime.type.StructImpl) ApplicationException(lucee.runtime.exp.ApplicationException) Mapping(lucee.runtime.Mapping) MappingImpl(lucee.runtime.MappingImpl) Struct(lucee.runtime.type.Struct)

Example 54 with ApplicationException

use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.

the class Admin method doUpdateORMSetting.

private void doUpdateORMSetting() throws SecurityException, PageException {
    ORMConfiguration oc = config.getORMConfig();
    Struct settings = new StructImpl();
    settings.set(ORMConfigurationImpl.AUTO_GEN_MAP, getBool("admin", action, "autogenmap"));
    settings.set(ORMConfigurationImpl.EVENT_HANDLING, getBool("admin", action, "eventHandling"));
    settings.set(ORMConfigurationImpl.FLUSH_AT_REQUEST_END, getBool("admin", action, "flushatrequestend"));
    settings.set(ORMConfigurationImpl.LOG_SQL, getBool("admin", action, "logSQL"));
    settings.set(ORMConfigurationImpl.SAVE_MAPPING, getBool("admin", action, "savemapping"));
    settings.set(ORMConfigurationImpl.USE_DB_FOR_MAPPING, getBool("admin", action, "useDBForMapping"));
    settings.set(ORMConfigurationImpl.SECONDARY_CACHE_ENABLED, getBool("admin", action, "secondarycacheenabled"));
    settings.set(ORMConfigurationImpl.CATALOG, getString("admin", action, "catalog"));
    settings.set(ORMConfigurationImpl.SCHEMA, getString("admin", action, "schema"));
    settings.set(ORMConfigurationImpl.SQL_SCRIPT, getString("admin", action, "sqlscript"));
    settings.set(ORMConfigurationImpl.CACHE_CONFIG, getString("admin", action, "cacheconfig"));
    settings.set(ORMConfigurationImpl.CACHE_PROVIDER, getString("admin", action, "cacheProvider"));
    settings.set(ORMConfigurationImpl.ORM_CONFIG, getString("admin", action, "ormConfig"));
    // dbcreate
    String strDbcreate = getString("admin", action, "dbcreate");
    String dbcreate = "none";
    if ("none".equals(strDbcreate))
        dbcreate = "none";
    else if ("update".equals(strDbcreate))
        dbcreate = "update";
    else if ("dropcreate".equals(strDbcreate))
        dbcreate = "dropcreate";
    else
        throw new ApplicationException("invalid dbcreate definition [" + strDbcreate + "], valid dbcreate definitions are [none,update,dropcreate]");
    settings.set(ORMConfigurationImpl.DB_CREATE, dbcreate);
    // cfclocation
    String strCfclocation = getString("admin", action, "cfclocation");
    Array arrCfclocation = lucee.runtime.type.util.ListUtil.listToArray(strCfclocation, ",\n");
    Iterator it = arrCfclocation.valueIterator();
    String path;
    while (it.hasNext()) {
        path = (String) it.next();
        ResourceUtil.toResourceExisting(config, path);
    }
    settings.set(KeyConstants._cfcLocation, arrCfclocation);
    admin.updateORMSetting(ORMConfigurationImpl.load(config, null, settings, null, oc));
    store();
    adminSync.broadcast(attributes, config);
}
Also used : Array(lucee.runtime.type.Array) StructImpl(lucee.runtime.type.StructImpl) ApplicationException(lucee.runtime.exp.ApplicationException) Iterator(java.util.Iterator) ORMConfiguration(lucee.runtime.orm.ORMConfiguration) Struct(lucee.runtime.type.Struct)

Example 55 with ApplicationException

use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.

the class Admin method doStopThread.

private void doStopThread() throws PageException {
    String contextId = getString("admin", "stopThread", "contextId");
    String threadId = getString("admin", "stopThread", "threadId");
    String stopType = getString("stopType", "exception");
    if (!(config instanceof ConfigServer))
        throw new ApplicationException("invalid context for this action");
    ConfigServer cs = (ConfigServer) config;
    ConfigWeb[] webs = cs.getConfigWebs();
    boolean has = false;
    for (int i = 0; i < webs.length; i++) {
        ConfigWebImpl cw = (ConfigWebImpl) webs[i];
        if (!cw.getIdentification().getId().equals(contextId))
            continue;
        ((CFMLFactoryImpl) cw.getFactory()).stopThread(threadId, stopType);
        has = true;
        break;
    }
    if (!has) {
        for (int i = 0; i < webs.length; i++) {
            ConfigWebImpl cw = (ConfigWebImpl) webs[i];
            if (!contextId.equals(cw.getLabel()))
                continue;
            ((CFMLFactoryImpl) cw.getFactory()).stopThread(threadId, stopType);
            has = true;
            break;
        }
    }
}
Also used : ConfigWebImpl(lucee.runtime.config.ConfigWebImpl) ApplicationException(lucee.runtime.exp.ApplicationException) CFMLFactoryImpl(lucee.runtime.CFMLFactoryImpl) ConfigServer(lucee.runtime.config.ConfigServer) ConfigWeb(lucee.runtime.config.ConfigWeb)

Aggregations

ApplicationException (lucee.runtime.exp.ApplicationException)173 IOException (java.io.IOException)41 Resource (lucee.commons.io.res.Resource)36 PageException (lucee.runtime.exp.PageException)30 Struct (lucee.runtime.type.Struct)25 SecurityException (lucee.runtime.exp.SecurityException)17 BundleException (org.osgi.framework.BundleException)16 StructImpl (lucee.runtime.type.StructImpl)15 MalformedURLException (java.net.MalformedURLException)13 Element (org.w3c.dom.Element)13 Array (lucee.runtime.type.Array)12 Key (lucee.runtime.type.Collection.Key)12 Iterator (java.util.Iterator)11 InputStream (java.io.InputStream)10 Query (lucee.runtime.type.Query)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 ExpressionException (lucee.runtime.exp.ExpressionException)9 Entry (java.util.Map.Entry)8 PageContextImpl (lucee.runtime.PageContextImpl)8 ClassDefinition (lucee.runtime.db.ClassDefinition)8