use of lucee.runtime.db.ClassDefinition in project Lucee by lucee.
the class Admin method doUpdateGatewayEntry.
private void doUpdateGatewayEntry() throws PageException {
String strStartupMode = getString("admin", action, "startupMode");
int startup = GatewayEntryImpl.toStartup(strStartupMode, -1);
if (startup == -1)
throw new ApplicationException("invalid startup mode [" + strStartupMode + "], valid values are [automatic,manual,disabled]");
// print.out("doUpdateGatewayEntry");
ClassDefinition cd = new ClassDefinitionImpl(getString("admin", action, "class"), getString("bundleName", null), getString("bundleVersion", null), config.getIdentification());
admin.updateGatewayEntry(getString("admin", action, "id"), cd, getString("admin", action, "cfcPath"), getString("admin", action, "listenerCfcPath"), startup, getStruct("admin", action, "custom"), getBoolV("readOnly", false));
store();
adminSync.broadcast(attributes, config);
}
use of lucee.runtime.db.ClassDefinition in project Lucee by lucee.
the class Admin method doUpdateCacheConnection.
private void doUpdateCacheConnection() throws PageException {
ClassDefinition cd = new ClassDefinitionImpl(getString("admin", action, "class"), getString("bundleName", null), getString("bundleVersion", null), config.getIdentification());
admin.updateCacheConnection(getString("admin", action, "name"), cd, toCacheConstant("default"), getStruct("admin", action, "custom"), getBoolV("readOnly", false), getBoolV("storage", false));
store();
adminSync.broadcast(attributes, config);
}
use of lucee.runtime.db.ClassDefinition in project Lucee by lucee.
the class XMLConfigWebFactory method loadResourceProvider.
private static void loadResourceProvider(ConfigServerImpl configServer, ConfigImpl config, Document doc) throws ClassException, BundleException {
boolean hasCS = configServer != null;
config.clearResourceProviders();
Element resources = getChildByName(doc.getDocumentElement(), "resources");
Element[] providers = getChildren(resources, "resource-provider");
Element[] defaultProviders = getChildren(resources, "default-resource-provider");
// Default Resource Provider
if (hasCS)
config.setDefaultResourceProvider(configServer.getDefaultResourceProvider());
if (defaultProviders != null && defaultProviders.length > 0) {
Element defaultProvider = defaultProviders[defaultProviders.length - 1];
ClassDefinition defProv = getClassDefinition(defaultProvider, "", config.getIdentification());
String strDefaultProviderComponent = getAttr(defaultProvider, "component");
if (StringUtil.isEmpty(strDefaultProviderComponent))
strDefaultProviderComponent = getAttr(defaultProvider, "class");
// class
if (defProv.hasClass()) {
config.setDefaultResourceProvider(defProv.getClazz(), toArguments(getAttr(defaultProvider, "arguments"), true));
} else // component
if (!StringUtil.isEmpty(strDefaultProviderComponent)) {
strDefaultProviderComponent = strDefaultProviderComponent.trim();
Map<String, String> args = toArguments(getAttr(defaultProvider, "arguments"), true);
args.put("component", strDefaultProviderComponent);
config.setDefaultResourceProvider(CFMLResourceProvider.class, args);
}
}
// Resource Provider
if (hasCS)
config.setResourceProviders(configServer.getResourceProviders());
if (providers != null && providers.length > 0) {
ClassDefinition prov;
String strProviderCFC;
String strProviderScheme;
ClassDefinition httpClass = null;
Map httpArgs = null;
boolean hasHTTPs = false;
for (int i = 0; i < providers.length; i++) {
try {
prov = getClassDefinition(providers[i], "", config.getIdentification());
strProviderCFC = getAttr(providers[i], "component");
if (StringUtil.isEmpty(strProviderCFC))
strProviderCFC = getAttr(providers[i], "class");
// lucee.commons.io.res.type.s3.S3ResourceProvider
if ("lucee.extension.io.resource.type.s3.S3ResourceProvider".equals(prov.getClassName()) || "lucee.commons.io.res.type.s3.S3ResourceProvider".equals(prov.getClassName()))
continue;
// prov=new ClassDefinitionImpl(S3ResourceProvider.class);
strProviderScheme = getAttr(providers[i], "scheme");
// class
if (prov.hasClass() && !StringUtil.isEmpty(strProviderScheme)) {
strProviderScheme = strProviderScheme.trim().toLowerCase();
config.addResourceProvider(strProviderScheme, prov, toArguments(getAttr(providers[i], "arguments"), true));
// patch for user not having
if (strProviderScheme.equalsIgnoreCase("http")) {
httpClass = prov;
httpArgs = toArguments(getAttr(providers[i], "arguments"), true);
} else if (strProviderScheme.equalsIgnoreCase("https"))
hasHTTPs = true;
} else // cfc
if (!StringUtil.isEmpty(strProviderCFC) && !StringUtil.isEmpty(strProviderScheme)) {
strProviderCFC = strProviderCFC.trim();
strProviderScheme = strProviderScheme.trim().toLowerCase();
Map<String, String> args = toArguments(getAttr(providers[i], "arguments"), true);
args.put("component", strProviderCFC);
config.addResourceProvider(strProviderScheme, CFMLResourceProvider.class, args);
}
} catch (Throwable t) {
// TODO log the exception
ExceptionUtil.rethrowIfNecessary(t);
}
}
// adding https when not exist
if (!hasHTTPs && httpClass != null) {
config.addResourceProvider("https", httpClass, httpArgs);
}
// we make sure we have the default on server level
if (!hasCS && !config.hasResourceProvider("s3")) {
ClassDefinition s3Class = new ClassDefinitionImpl(DummyS3ResourceProvider.class);
;
config.addResourceProvider("s3", s3Class, toArguments("lock-timeout:10000;", false));
}
}
}
use of lucee.runtime.db.ClassDefinition in project Lucee by lucee.
the class XMLConfigWebFactory method loadScope.
/**
* @param configServer
* @param config
* @param doc
* @throws PageException
* @throws IOException
*/
private static void loadScope(ConfigServerImpl configServer, ConfigImpl config, Document doc, int mode) throws PageException {
boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_SETTING);
Element scope = getChildByName(doc.getDocumentElement(), "scope");
boolean hasCS = configServer != null;
// Cluster Scope
if (!hasCS) {
ClassDefinition cd = getClassDefinition(scope, "cluster-", config.getIdentification());
if (hasAccess && cd.hasClass()) {
try {
Class clazz = cd.getClazz();
if (!Reflector.isInstaneOf(clazz, Cluster.class) && !Reflector.isInstaneOf(clazz, ClusterRemote.class))
throw new ApplicationException("class [" + clazz.getName() + "] does not implement interface [" + Cluster.class.getName() + "] or [" + ClusterRemote.class.getName() + "]");
config.setClusterClass(clazz);
} catch (Exception e) {
SystemOut.printDate(e);
}
}
}
// Local Mode
if (mode == ConfigImpl.MODE_STRICT) {
config.setLocalMode(Undefined.MODE_LOCAL_OR_ARGUMENTS_ALWAYS);
} else {
String strLocalMode = getAttr(scope, "local-mode");
if (hasAccess && !StringUtil.isEmpty(strLocalMode)) {
config.setLocalMode(strLocalMode);
} else if (hasCS)
config.setLocalMode(configServer.getLocalMode());
}
// CGI readonly
String strCGIReadonly = getAttr(scope, "cgi-readonly");
if (hasAccess && !StringUtil.isEmpty(strCGIReadonly)) {
config.setCGIScopeReadonly(Caster.toBooleanValue(strCGIReadonly, true));
} else if (hasCS)
config.setCGIScopeReadonly(configServer.getCGIScopeReadonly());
// Session-Type
String strSessionType = getAttr(scope, "session-type");
if (hasAccess && !StringUtil.isEmpty(strSessionType)) {
config.setSessionType(AppListenerUtil.toSessionType(strSessionType, hasCS ? configServer.getSessionType() : Config.SESSION_TYPE_APPLICATION));
} else if (hasCS)
config.setSessionType(configServer.getSessionType());
// Cascading
if (mode == ConfigImpl.MODE_STRICT) {
config.setScopeCascadingType(Config.SCOPE_STRICT);
} else {
String strScopeCascadingType = getAttr(scope, "cascading");
if (hasAccess && !StringUtil.isEmpty(strScopeCascadingType)) {
config.setScopeCascadingType(ConfigWebUtil.toScopeCascading(strScopeCascadingType, Config.SCOPE_STANDARD));
} else if (hasCS)
config.setScopeCascadingType(configServer.getScopeCascadingType());
}
// cascade-to-resultset
if (mode == ConfigImpl.MODE_STRICT) {
config.setAllowImplicidQueryCall(false);
} else {
String strAllowImplicidQueryCall = getAttr(scope, "cascade-to-resultset");
if (hasAccess && !StringUtil.isEmpty(strAllowImplicidQueryCall)) {
config.setAllowImplicidQueryCall(toBoolean(strAllowImplicidQueryCall, true));
} else if (hasCS)
config.setAllowImplicidQueryCall(configServer.allowImplicidQueryCall());
}
// Merge url and Form
String strMergeFormAndURL = getAttr(scope, "merge-url-form");
if (hasAccess && !StringUtil.isEmpty(strMergeFormAndURL)) {
config.setMergeFormAndURL(toBoolean(strMergeFormAndURL, false));
} else if (hasCS)
config.setMergeFormAndURL(configServer.mergeFormAndURL());
// Client-Storage
{
String clientStorage = getAttr(scope, "clientstorage");
if (StringUtil.isEmpty(clientStorage, true))
clientStorage = getAttr(scope, "client-storage");
if (hasAccess && !StringUtil.isEmpty(clientStorage)) {
config.setClientStorage(clientStorage);
} else if (hasCS)
config.setClientStorage(configServer.getClientStorage());
}
// Session-Storage
{
String sessionStorage = getAttr(scope, "sessionstorage");
if (StringUtil.isEmpty(sessionStorage, true))
sessionStorage = getAttr(scope, "session-storage");
if (hasAccess && !StringUtil.isEmpty(sessionStorage)) {
config.setSessionStorage(sessionStorage);
} else if (hasCS)
config.setSessionStorage(configServer.getSessionStorage());
}
// Client Timeout
String clientTimeout = getAttr(scope, "clienttimeout");
if (StringUtil.isEmpty(clientTimeout, true))
clientTimeout = getAttr(scope, "client-timeout");
if (StringUtil.isEmpty(clientTimeout, true)) {
// deprecated
clientTimeout = getAttr(scope, "client-max-age");
int days = Caster.toIntValue(clientTimeout, -1);
if (days > 0)
clientTimeout = days + ",0,0,0";
else
clientTimeout = "";
}
if (hasAccess && !StringUtil.isEmpty(clientTimeout)) {
config.setClientTimeout(clientTimeout);
} else if (hasCS)
config.setClientTimeout(configServer.getClientTimeout());
// Session Timeout
String sessionTimeout = getAttr(scope, "sessiontimeout");
if (hasAccess && !StringUtil.isEmpty(sessionTimeout)) {
config.setSessionTimeout(sessionTimeout);
} else if (hasCS)
config.setSessionTimeout(configServer.getSessionTimeout());
// App Timeout
String appTimeout = getAttr(scope, "applicationtimeout");
if (hasAccess && !StringUtil.isEmpty(appTimeout)) {
config.setApplicationTimeout(appTimeout);
} else if (hasCS)
config.setApplicationTimeout(configServer.getApplicationTimeout());
// Client Type
String strClientType = getAttr(scope, "clienttype");
if (hasAccess && !StringUtil.isEmpty(strClientType)) {
config.setClientType(strClientType);
} else if (hasCS)
config.setClientType(configServer.getClientType());
// Client
Resource configDir = config.getConfigDir();
String strClientDirectory = getAttr(scope, "client-directory");
if (hasAccess && !StringUtil.isEmpty(strClientDirectory)) {
strClientDirectory = ConfigWebUtil.translateOldPath(strClientDirectory);
Resource res = ConfigWebUtil.getFile(configDir, strClientDirectory, "client-scope", configDir, FileUtil.TYPE_DIR, config);
config.setClientScopeDir(res);
} else {
config.setClientScopeDir(configDir.getRealResource("client-scope"));
}
String strMax = getAttr(scope, "client-directory-max-size");
if (hasAccess && !StringUtil.isEmpty(strMax)) {
config.setClientScopeDirSize(ByteSizeParser.parseByteSizeDefinition(strMax, config.getClientScopeDirSize()));
} else if (hasCS)
config.setClientScopeDirSize(configServer.getClientScopeDirSize());
// Session Management
String strSessionManagement = getAttr(scope, "sessionmanagement");
if (hasAccess && !StringUtil.isEmpty(strSessionManagement)) {
config.setSessionManagement(toBoolean(strSessionManagement, true));
} else if (hasCS)
config.setSessionManagement(configServer.isSessionManagement());
// Client Management
String strClientManagement = getAttr(scope, "clientmanagement");
if (hasAccess && !StringUtil.isEmpty(strClientManagement)) {
config.setClientManagement(toBoolean(strClientManagement, false));
} else if (hasCS)
config.setClientManagement(configServer.isClientManagement());
// Client Cookies
String strClientCookies = getAttr(scope, "setclientcookies");
if (hasAccess && !StringUtil.isEmpty(strClientCookies)) {
config.setClientCookies(toBoolean(strClientCookies, true));
} else if (hasCS)
config.setClientCookies(configServer.isClientCookies());
// Domain Cookies
String strDomainCookies = getAttr(scope, "setdomaincookies");
if (hasAccess && !StringUtil.isEmpty(strDomainCookies)) {
config.setDomainCookies(toBoolean(strDomainCookies, false));
} else if (hasCS)
config.setDomainCookies(configServer.isDomainCookies());
}
use of lucee.runtime.db.ClassDefinition in project Lucee by lucee.
the class XMLConfigWebFactory method getClassDefinition.
private static ClassDefinition getClassDefinition(Element el, String prefix, Identification id) {
String cn = getAttr(el, prefix + "class");
String bn = getAttr(el, prefix + "bundle-name");
String bv = getAttr(el, prefix + "bundle-version");
// proxy jar libary no longer provided, so if still this class name is used ....
if ("com.microsoft.jdbc.sqlserver.SQLServerDriver".equals(cn)) {
cn = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
}
ClassDefinition cd = new ClassDefinitionImpl(cn, bn, bv, id);
// if(!StringUtil.isEmpty(cd.className,true))cd.getClazz();
return cd;
}
Aggregations