use of lucee.commons.io.log.Log 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.commons.io.log.Log 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);
}
}
use of lucee.commons.io.log.Log in project Lucee by lucee.
the class CFMLEngineImpl method deployBundledExtension.
private void deployBundledExtension(ConfigServerImpl cs) {
Resource dir = cs.getLocalExtensionProviderDirectory();
List<ExtensionDefintion> existing = DeployHandler.getLocalExtensions(cs);
Map<String, ExtensionDefintion> existingMap = new HashMap<String, ExtensionDefintion>();
{
Iterator<ExtensionDefintion> it = existing.iterator();
ExtensionDefintion ed;
while (it.hasNext()) {
ed = it.next();
try {
existingMap.put(ed.getSource().getName(), ed);
} catch (ApplicationException e) {
}
}
}
Log log = cs.getLog("deploy");
// get the index
ClassLoader cl = CFMLEngineFactory.getInstance().getCFMLEngineFactory().getClass().getClassLoader();
InputStream is = cl.getResourceAsStream("extensions/.index");
if (is == null)
is = cl.getResourceAsStream("/extensions/.index");
if (is == null)
is = SystemUtil.getResourceAsStream(null, "/extensions/.index");
if (is == null) {
log.error("extract-extension", "could not found [/extensions/.index] defined in the index in the lucee.jar");
return;
}
try {
String index = IOUtil.toString(is, CharsetUtil.UTF8);
log.info("extract-extension", "the following extensions are bundled with the lucee.jar [" + index + "]");
String[] names = lucee.runtime.type.util.ListUtil.listToStringArray(index, ';');
String name;
Resource temp = null;
RHExtension rhe;
ExtensionDefintion exist;
Iterator<ExtensionDefintion> it;
for (int i = 0; i < names.length; i++) {
name = names[i];
if (StringUtil.isEmpty(name, true))
continue;
name = name.trim();
// does it already exist?
if (existingMap.containsKey(name)) {
continue;
}
is = cl.getResourceAsStream("extensions/" + name);
if (is == null)
is = cl.getResourceAsStream("/extensions/" + name);
if (is == null) {
log.error("extract-extension", "could not found extension [" + name + "] defined in the index in the lucee.jar");
continue;
}
try {
temp = SystemUtil.getTempDirectory().getRealResource(name);
ResourceUtil.touch(temp);
Util.copy(is, temp.getOutputStream(), false, true);
rhe = new RHExtension(cs, temp, false);
ExtensionDefintion alreadyExists = null;
it = existing.iterator();
while (it.hasNext()) {
exist = it.next();
if (exist.equals(rhe)) {
alreadyExists = exist;
break;
}
}
String trgName = rhe.getId() + "-" + rhe.getVersion() + ".lex";
if (alreadyExists == null) {
temp.moveTo(dir.getRealResource(trgName));
log.info("extract-extension", "added [" + name + "] to [" + dir + "]");
} else if (!alreadyExists.getSource().getName().equals(trgName)) {
log.info("extract-extension", "rename [" + alreadyExists.getSource() + "] to [" + trgName + "]");
alreadyExists.getSource().moveTo(alreadyExists.getSource().getParentResource().getRealResource(trgName));
}
// now we check all extension name (for extension no longer delivered by lucee)
it = existing.iterator();
while (it.hasNext()) {
exist = it.next();
trgName = exist.getId() + "-" + exist.getVersion() + ".lex";
if (!trgName.equals(exist.getSource().getName())) {
exist.getSource().moveTo(exist.getSource().getParentResource().getRealResource(trgName));
log.info("extract-extension", "rename [" + exist.getSource() + "] to [" + trgName + "]");
}
}
} finally {
if (temp != null && temp.exists())
temp.delete();
}
}
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
log.error("extract-extension", t);
}
return;
}
use of lucee.commons.io.log.Log in project Lucee by lucee.
the class RHExtension method toQuery.
public static Query toQuery(Config config, Element[] children) throws PageException {
Log log = config.getLog("deploy");
Query qry = createQuery();
for (int i = 0; i < children.length; i++) {
try {
// ,i+1
new RHExtension(config, children[i]).populate(qry);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
log.error("extension", t);
}
}
return qry;
}
use of lucee.commons.io.log.Log in project Lucee by lucee.
the class RHExtension method readManifestConfig.
private void readManifestConfig(Manifest manifest, String label, String _img) throws ApplicationException {
boolean isWeb = config instanceof ConfigWeb;
type = isWeb ? "web" : "server";
Log logger = ((ConfigImpl) config).getLog("deploy");
Info info = ConfigWebUtil.getEngine(config).getInfo();
Attributes attr = manifest.getMainAttributes();
readName(label, StringUtil.unwrap(attr.getValue("name")));
label = name;
readVersion(label, StringUtil.unwrap(attr.getValue("version")));
label += " : " + version;
readId(label, StringUtil.unwrap(attr.getValue("id")));
readReleaseType(label, StringUtil.unwrap(attr.getValue("release-type")), isWeb);
description = StringUtil.unwrap(attr.getValue("description"));
trial = Caster.toBooleanValue(StringUtil.unwrap(attr.getValue("trial")), false);
if (_img == null)
_img = StringUtil.unwrap(attr.getValue("image"));
image = _img;
String cat = StringUtil.unwrap(attr.getValue("category"));
if (StringUtil.isEmpty(cat, true))
cat = StringUtil.unwrap(attr.getValue("categories"));
readCategories(label, cat);
readCoreVersion(label, StringUtil.unwrap(attr.getValue("lucee-core-version")), info);
readLoaderVersion(label, StringUtil.unwrap(attr.getValue("lucee-loader-version")));
startBundles = Caster.toBooleanValue(StringUtil.unwrap(attr.getValue("start-bundles")), true);
readAMF(label, StringUtil.unwrap(attr.getValue("amf")), logger);
readResource(label, StringUtil.unwrap(attr.getValue("resource")), logger);
readSearch(label, StringUtil.unwrap(attr.getValue("search")), logger);
readORM(label, StringUtil.unwrap(attr.getValue("orm")), logger);
readMonitor(label, StringUtil.unwrap(attr.getValue("monitor")), logger);
readCache(label, StringUtil.unwrap(attr.getValue("cache")), logger);
readCacheHandler(label, StringUtil.unwrap(attr.getValue("cache-handler")), logger);
readJDBC(label, StringUtil.unwrap(attr.getValue("jdbc")), logger);
readMapping(label, StringUtil.unwrap(attr.getValue("mapping")), logger);
readEventGatewayInstances(label, StringUtil.unwrap(attr.getValue("event-gateway-instance")), logger);
}
Aggregations