use of lucee.commons.io.res.Resource in project Lucee by lucee.
the class XMLConfigAdmin method _updateWebContexts.
private static void _updateWebContexts(Config config, InputStream is, String realpath, boolean closeStream, List<Resource> filesDeployed, boolean store) throws PageException, IOException, SAXException, BundleException {
if (!(config instanceof ConfigServer))
throw new ApplicationException("invalid context, you can only call this method from server context");
ConfigServer cs = (ConfigServer) config;
Resource wcd = cs.getConfigDir().getRealResource("web-context-deployment");
Resource trg = wcd.getRealResource(realpath);
if (trg.exists())
trg.remove(true);
Resource p = trg.getParentResource();
if (!p.isDirectory())
p.createDirectory(true);
IOUtil.copy(is, trg.getOutputStream(false), closeStream, true);
filesDeployed.add(trg);
if (store)
_storeAndReload((ConfigImpl) config);
}
use of lucee.commons.io.res.Resource in project Lucee by lucee.
the class XMLConfigAdmin method _removeComponent.
private boolean _removeComponent(Config config, String realpath, boolean _store) throws PageException, IOException, SAXException, BundleException {
// MUST get dyn
Resource context = config.getConfigDir().getRealResource("components");
Resource trg = context.getRealResource(realpath);
if (trg.exists()) {
trg.remove(true);
if (_store)
XMLConfigAdmin._storeAndReload((ConfigImpl) config);
ResourceUtil.removeEmptyFolders(context, null);
return true;
}
return false;
}
use of lucee.commons.io.res.Resource in project Lucee by lucee.
the class XMLConfigAdmin method updateApplication.
Resource[] updateApplication(InputStream is, String realpath, boolean closeStream) throws PageException, IOException, SAXException {
List<Resource> filesDeployed = new ArrayList<Resource>();
Resource dir;
// server context
if (config instanceof ConfigServer)
dir = config.getConfigDir().getRealResource("web-deployment");
else
// if web context we simply deploy to that webcontext, that's all
dir = config.getRootDirectory();
deployFilesFromStream(config, dir, is, realpath, closeStream, filesDeployed);
return filesDeployed.toArray(new Resource[filesDeployed.size()]);
}
use of lucee.commons.io.res.Resource in project Lucee by lucee.
the class XMLConfigAdmin method write.
private static Resource write(Resource dir, InputStream is, String name, boolean closeStream) throws IOException {
if (!dir.exists())
dir.createDirectory(true);
Resource file = dir.getRealResource(name);
Resource p = file.getParentResource();
if (!p.exists())
p.createDirectory(true);
IOUtil.copy(is, file.getOutputStream(), closeStream, true);
return file;
}
use of lucee.commons.io.res.Resource in project Lucee by lucee.
the class XMLConfigAdmin method updateCPPCFX.
public void updateCPPCFX(String name, String procedure, String strServerLibrary, boolean keepAlive) throws PageException {
checkWriteAccess();
boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_CFX_SETTING);
if (!hasAccess)
throw new SecurityException("no access to change cfx settings");
// name
if (StringUtil.isEmpty(name))
throw new ExpressionException("name cannot be a empty value");
// serverLibrary
if (StringUtil.isEmpty(strServerLibrary))
throw new ExpressionException("serverLibrary cannot be a empty value");
Resource serverLibrary = ResourceUtil.toResourceExisting(config, strServerLibrary);
// procedure
if (StringUtil.isEmpty(procedure))
throw new ExpressionException("procedure cannot be a empty value");
renameOldstyleCFX();
Element tags = _getRootElement("ext-tags");
// Update
Element[] children = XMLConfigWebFactory.getChildren(tags, "ext-tag");
for (int i = 0; i < children.length; i++) {
String n = children[i].getAttribute("name");
if (n != null && n.equalsIgnoreCase(name)) {
Element el = children[i];
if (!"cpp".equalsIgnoreCase(el.getAttribute("type")))
throw new ExpressionException("there is already a java cfx tag with this name");
el.setAttribute("server-library", serverLibrary.getAbsolutePath());
el.setAttribute("procedure", procedure);
el.setAttribute("keep-alive", Caster.toString(keepAlive));
el.setAttribute("type", "cpp");
return;
}
}
// Insert
Element el = doc.createElement("ext-tag");
tags.appendChild(el);
el.setAttribute("server-library", serverLibrary.getAbsolutePath());
el.setAttribute("procedure", procedure);
el.setAttribute("keep-alive", Caster.toString(keepAlive));
el.setAttribute("name", name);
el.setAttribute("type", "cpp");
}
Aggregations