use of lucee.commons.io.res.Resource in project Lucee by lucee.
the class XMLConfigAdmin method updateArchive.
void updateArchive(InputStream is, String name, boolean closeStream) throws IOException, PageException {
Resource res = write(SystemUtil.getTempDirectory(), is, name, closeStream);
// Resource res = write(DeployHandler.getDeployDirectory(config),is,name,closeStream);
updateArchive(config, res);
}
use of lucee.commons.io.res.Resource in project Lucee by lucee.
the class XMLConfigAdmin method updateJar.
public static void updateJar(Config config, Resource resJar, boolean reloadWhenClassicJar) throws IOException, BundleException {
BundleFile bf = new BundleFile(resJar);
// resJar is a bundle
if (bf.isBundle()) {
bf = installBundle(config, bf);
OSGiUtil.loadBundle(bf);
return;
}
Resource lib = ((ConfigImpl) config).getLibraryDirectory();
if (!lib.exists())
lib.mkdir();
Resource fileLib = lib.getRealResource(resJar.getName());
// if there is a existing, has the file changed?
if (fileLib.length() != resJar.length()) {
IOUtil.closeEL(config.getClassLoader());
ResourceUtil.copy(resJar, fileLib);
if (reloadWhenClassicJar)
ConfigWebUtil.reloadLib(config);
}
}
use of lucee.commons.io.res.Resource in project Lucee by lucee.
the class XMLConfigAdmin method storageGet.
public Object storageGet(Config config, String key) throws ConverterException, IOException, SecurityException {
checkReadAccess();
Resource storageDir = getStoragDir(config);
Resource storage = storageDir.getRealResource(key + ".wddx");
if (!storage.exists())
throw new IOException("there is no storage with name " + key);
WDDXConverter converter = new WDDXConverter(config.getTimeZone(), true, true);
return converter.deserialize(IOUtil.toString(storage, "UTF-8"), true);
}
use of lucee.commons.io.res.Resource in project Lucee by lucee.
the class XMLConfigAdmin method checkForChangesInConfigFile.
public static void checkForChangesInConfigFile(Config config) {
ConfigImpl ci = (ConfigImpl) config;
if (!ci.checkForChangesInConfigFile())
return;
Resource file = config.getConfigFile();
long diff = file.lastModified() - ci.lastModified();
if (diff < 10 && diff > -10)
return;
// reload
try {
XMLConfigAdmin admin = XMLConfigAdmin.newInstance(ci, null);
admin._reload();
SystemOut.printDate(ci.getOutWriter(), "reloaded the configuration [" + file + "] automaticly");
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
}
use of lucee.commons.io.res.Resource in project Lucee by lucee.
the class XMLConfigFactory method doNew.
public static UpdateInfo doNew(CFMLEngine engine, Resource contextDir, boolean readOnly) {
lucee.Info info = engine.getInfo();
try {
String strOldVersion;
final Resource resOldVersion = contextDir.getRealResource("version");
String strNewVersion = info.getVersion() + "-" + info.getRealeaseTime();
// fresh install
if (!resOldVersion.exists()) {
if (!readOnly) {
resOldVersion.createNewFile();
IOUtil.write(resOldVersion, strNewVersion, SystemUtil.getCharset(), false);
}
return UpdateInfo.NEW_FRESH;
} else // changed version
if (!(strOldVersion = IOUtil.toString(resOldVersion, SystemUtil.getCharset())).equals(strNewVersion)) {
if (!readOnly)
IOUtil.write(resOldVersion, strNewVersion, SystemUtil.getCharset(), false);
Version oldVersion = OSGiUtil.toVersion(strOldVersion);
return new UpdateInfo(oldVersion, oldVersion.getMajor() < 5 ? NEW_FROM4 : NEW_MINOR);
}
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
return UpdateInfo.NEW_NONE;
}
Aggregations