use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.
the class XMLConfigAdmin method updateRequestTimeout.
/**
* updates request timeout value
* @param span
* @throws SecurityException
* @throws ApplicationException
*/
public void updateRequestTimeout(TimeSpan span) throws SecurityException, ApplicationException {
checkWriteAccess();
boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_SETTING);
if (!hasAccess)
throw new SecurityException("no access to update scope setting");
Element scope = _getRootElement("scope");
Element application = _getRootElement("application");
if (span != null) {
if (span.getMillis() <= 0)
throw new ApplicationException("value must be a positive number");
application.setAttribute("requesttimeout", span.getDay() + "," + span.getHour() + "," + span.getMinute() + "," + span.getSecond());
} else
application.removeAttribute("requesttimeout");
// remove deprecated attribute
if (scope.hasAttribute("requesttimeout"))
scope.removeAttribute("requesttimeout");
}
use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.
the class XMLConfigAdmin method updateSecurity.
/**
* update a security manager that match the given id
* @param id
* @param setting
* @param file
* @param fileAccess
* @param directJavaAccess
* @param mail
* @param datasource
* @param mapping
* @param customTag
* @param cfxSetting
* @param cfxUsage
* @param debugging
* @param search
* @param scheduledTasks
* @param tagExecute
* @param tagImport
* @param tagObject
* @param tagRegistry
* @throws SecurityException
* @throws ApplicationException
*/
public void updateSecurity(String id, short setting, short file, Resource[] fileAccess, short directJavaAccess, short mail, short datasource, short mapping, short remote, short customTag, short cfxSetting, short cfxUsage, short debugging, short search, short scheduledTasks, short tagExecute, short tagImport, short tagObject, short tagRegistry, short cache, short gateway, short orm, short accessRead, short accessWrite) throws SecurityException, ApplicationException {
checkWriteAccess();
if (!(config instanceof ConfigServer))
throw new SecurityException("can't change security settings from this context");
Element security = _getRootElement("security");
Element[] children = XMLConfigWebFactory.getChildren(security, "accessor");
Element accessor = null;
for (int i = 0; i < children.length; i++) {
if (id.equals(children[i].getAttribute("id"))) {
accessor = children[i];
}
}
if (accessor == null)
throw new ApplicationException("there is noc Security Manager for id [" + id + "]");
updateSecurityFileAccess(accessor, fileAccess, file);
accessor.setAttribute("setting", SecurityManagerImpl.toStringAccessValue(setting));
accessor.setAttribute("file", SecurityManagerImpl.toStringAccessValue(file));
accessor.setAttribute("direct_java_access", SecurityManagerImpl.toStringAccessValue(directJavaAccess));
accessor.setAttribute("mail", SecurityManagerImpl.toStringAccessValue(mail));
accessor.setAttribute("datasource", SecurityManagerImpl.toStringAccessValue(datasource));
accessor.setAttribute("mapping", SecurityManagerImpl.toStringAccessValue(mapping));
accessor.setAttribute("remote", SecurityManagerImpl.toStringAccessValue(remote));
accessor.setAttribute("custom_tag", SecurityManagerImpl.toStringAccessValue(customTag));
accessor.setAttribute("cfx_setting", SecurityManagerImpl.toStringAccessValue(cfxSetting));
accessor.setAttribute("cfx_usage", SecurityManagerImpl.toStringAccessValue(cfxUsage));
accessor.setAttribute("debugging", SecurityManagerImpl.toStringAccessValue(debugging));
accessor.setAttribute("search", SecurityManagerImpl.toStringAccessValue(search));
accessor.setAttribute("scheduled_task", SecurityManagerImpl.toStringAccessValue(scheduledTasks));
accessor.setAttribute("cache", SecurityManagerImpl.toStringAccessValue(cache));
accessor.setAttribute("gateway", SecurityManagerImpl.toStringAccessValue(gateway));
accessor.setAttribute("orm", SecurityManagerImpl.toStringAccessValue(orm));
accessor.setAttribute("tag_execute", SecurityManagerImpl.toStringAccessValue(tagExecute));
accessor.setAttribute("tag_import", SecurityManagerImpl.toStringAccessValue(tagImport));
accessor.setAttribute("tag_object", SecurityManagerImpl.toStringAccessValue(tagObject));
accessor.setAttribute("tag_registry", SecurityManagerImpl.toStringAccessValue(tagRegistry));
accessor.setAttribute("access_read", SecurityManagerImpl.toStringAccessRWValue(accessRead));
accessor.setAttribute("access_write", SecurityManagerImpl.toStringAccessRWValue(accessWrite));
}
use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.
the class XMLConfigAdmin method updateArchive.
public void updateArchive(Config config, Resource archive) throws PageException {
Log logger = ((ConfigImpl) config).getLog("deploy");
String type = null, virtual = null, name = null;
boolean readOnly, topLevel, hidden, physicalFirst;
short inspect;
int listMode, listType;
InputStream is = null;
ZipFile file = null;
try {
file = new ZipFile(FileWrapper.toFile(archive));
ZipEntry entry = file.getEntry("META-INF/MANIFEST.MF");
// no manifest
if (entry == null) {
DeployHandler.moveToFailedFolder(config.getDeployDirectory(), archive);
throw new ApplicationException("cannot deploy " + Constants.NAME + " Archive [" + archive + "], file is to old, the file does not have a MANIFEST.");
}
is = file.getInputStream(entry);
Manifest manifest = new Manifest(is);
Attributes attr = manifest.getMainAttributes();
// id = unwrap(attr.getValue("mapping-id"));
type = StringUtil.unwrap(attr.getValue("mapping-type"));
virtual = StringUtil.unwrap(attr.getValue("mapping-virtual-path"));
name = ListUtil.trim(virtual, "/");
readOnly = Caster.toBooleanValue(StringUtil.unwrap(attr.getValue("mapping-readonly")), false);
topLevel = Caster.toBooleanValue(StringUtil.unwrap(attr.getValue("mapping-top-level")), false);
listMode = ConfigWebUtil.toListenerMode(StringUtil.unwrap(attr.getValue("mapping-listener-mode")), -1);
listType = ConfigWebUtil.toListenerType(StringUtil.unwrap(attr.getValue("mapping-listener-type")), -1);
inspect = ConfigWebUtil.inspectTemplate(StringUtil.unwrap(attr.getValue("mapping-inspect")), Config.INSPECT_UNDEFINED);
if (inspect == Config.INSPECT_UNDEFINED) {
Boolean trusted = Caster.toBoolean(StringUtil.unwrap(attr.getValue("mapping-trusted")), null);
if (trusted != null) {
if (trusted.booleanValue())
inspect = Config.INSPECT_NEVER;
else
inspect = Config.INSPECT_ALWAYS;
}
}
hidden = Caster.toBooleanValue(StringUtil.unwrap(attr.getValue("mapping-hidden")), false);
physicalFirst = Caster.toBooleanValue(StringUtil.unwrap(attr.getValue("mapping-physical-first")), false);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
DeployHandler.moveToFailedFolder(config.getDeployDirectory(), archive);
throw Caster.toPageException(t);
} finally {
IOUtil.closeEL(is);
ZipUtil.close(file);
}
try {
Resource trgDir = config.getConfigDir().getRealResource("archives").getRealResource(type).getRealResource(name);
Resource trgFile = trgDir.getRealResource(archive.getName());
trgDir.mkdirs();
// delete existing files
ResourceUtil.deleteContent(trgDir, null);
ResourceUtil.moveTo(archive, trgFile, true);
logger.log(Log.LEVEL_INFO, "archive", "add " + type + " mapping [" + virtual + "] with archive [" + trgFile.getAbsolutePath() + "]");
if ("regular".equalsIgnoreCase(type))
_updateMapping(virtual, null, trgFile.getAbsolutePath(), "archive", inspect, topLevel, listMode, listType, readOnly);
else if ("cfc".equalsIgnoreCase(type))
_updateComponentMapping(virtual, null, trgFile.getAbsolutePath(), "archive", inspect);
else if ("ct".equalsIgnoreCase(type))
_updateCustomTag(virtual, null, trgFile.getAbsolutePath(), "archive", inspect);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
DeployHandler.moveToFailedFolder(config.getDeployDirectory(), archive);
throw Caster.toPageException(t);
}
}
use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.
the class XMLConfigAdmin method updateCFMLWriterType.
public void updateCFMLWriterType(String writerType) throws SecurityException, ApplicationException {
checkWriteAccess();
boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_SETTING);
if (!hasAccess)
throw new SecurityException("no access to update scope setting");
Element scope = _getRootElement("setting");
writerType = writerType.trim();
// remove
if (StringUtil.isEmpty(writerType)) {
if (scope.hasAttribute("cfml-writer"))
scope.removeAttribute("cfml-writer");
return;
}
// update
if (!"white-space".equalsIgnoreCase(writerType) && !"white-space-pref".equalsIgnoreCase(writerType) && !"regular".equalsIgnoreCase(writerType))
throw new ApplicationException("invalid writer type defintion [" + writerType + "], valid types are [white-space, white-space-pref, regular]");
scope.setAttribute("cfml-writer", writerType.toLowerCase());
}
use of lucee.runtime.exp.ApplicationException in project Lucee by lucee.
the class XMLConfigAdmin method removeArchive.
public void removeArchive(Resource archive) throws IOException, PageException {
Log logger = ((ConfigImpl) config).getLog("deploy");
String virtual = null, type = null;
InputStream is = null;
ZipFile file = null;
try {
file = new ZipFile(FileWrapper.toFile(archive));
ZipEntry entry = file.getEntry("META-INF/MANIFEST.MF");
// no manifest
if (entry == null)
throw new ApplicationException("cannot remove " + Constants.NAME + " Archive [" + archive + "], file is to old, the file does not have a MANIFEST.");
is = file.getInputStream(entry);
Manifest manifest = new Manifest(is);
Attributes attr = manifest.getMainAttributes();
virtual = StringUtil.unwrap(attr.getValue("mapping-virtual-path"));
type = StringUtil.unwrap(attr.getValue("mapping-type"));
logger.info("archive", "remove " + type + " mapping [" + virtual + "]");
if ("regular".equalsIgnoreCase(type))
removeMapping(virtual);
else if ("cfc".equalsIgnoreCase(type))
removeComponentMapping(virtual);
else if ("ct".equalsIgnoreCase(type))
removeCustomTag(virtual);
else
throw new ApplicationException("invalid type [" + type + "], valid types are [regular, cfc, ct]");
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
throw Caster.toPageException(t);
} finally {
IOUtil.closeEL(is);
ZipUtil.close(file);
}
}
Aggregations