use of lucee.commons.io.res.filter.ExtensionResourceFilter in project Lucee by lucee.
the class DataSourceServiceImpl method getDrivers.
@Override
public Struct getDrivers() throws ServiceException, SecurityException {
checkReadAccess();
Struct rtn = new StructImpl();
Struct driver;
try {
Resource luceeContext = ResourceUtil.toResourceExisting(pc(), "/lucee/admin/dbdriver/");
Resource[] children = luceeContext.listResources(new ExtensionResourceFilter(Constants.getComponentExtensions()));
String name;
for (int i = 0; i < children.length; i++) {
driver = new StructImpl();
name = ListFirst.call(pc(), children[i].getName(), ".");
driver.setEL(KeyConstants._name, name);
driver.setEL("handler", children[i].getName());
rtn.setEL(name, driver);
}
} catch (ExpressionException e) {
throw new ServiceException(e.getMessage());
}
return rtn;
}
use of lucee.commons.io.res.filter.ExtensionResourceFilter in project Lucee by lucee.
the class Admin method doGetDatasourceDriverList.
private void doGetDatasourceDriverList() throws PageException {
Resource luceeContext = ResourceUtil.toResourceExisting(pageContext, "/lucee/admin/dbdriver/");
Resource[] children = luceeContext.listResources(new ExtensionResourceFilter(Constants.getComponentExtensions()));
String rtnVar = getString("admin", action, "returnVariable");
lucee.runtime.type.Query qry = new QueryImpl(new String[] { "name" }, children.length, rtnVar);
for (int i = 0; i < children.length; i++) {
qry.setAt("name", i + 1, children[i].getName());
}
pageContext.setVariable(rtnVar, qry);
}
use of lucee.commons.io.res.filter.ExtensionResourceFilter in project Lucee by lucee.
the class ConfigImpl method setFunctionDirectory.
protected void setFunctionDirectory(Resource functionDirectory) {
this.functionMapping = new MappingImpl(this, "/mapping-function/", functionDirectory.getAbsolutePath(), null, ConfigImpl.INSPECT_NEVER, true, true, true, true, false, true, null, -1, -1);
FunctionLib flc = cfmlFlds[cfmlFlds.length - 1];
FunctionLib fll = luceeFlds[luceeFlds.length - 1];
// now overwrite with new data
if (functionDirectory.isDirectory()) {
String[] files = functionDirectory.list(new ExtensionResourceFilter(Constants.getTemplateExtensions()));
for (int i = 0; i < files.length; i++) {
if (flc != null)
createFunction(flc, files[i]);
if (fll != null)
createFunction(fll, files[i]);
}
combinedCFMLFLDs = null;
combinedLuceeFLDs = null;
}
}
use of lucee.commons.io.res.filter.ExtensionResourceFilter in project Lucee by lucee.
the class ConfigServerImpl method loadLocalExtensions.
@Override
public List<ExtensionDefintion> loadLocalExtensions() {
Resource[] locReses = getLocalExtensionProviderDirectory().listResources(new ExtensionResourceFilter(".lex"));
if (localExtensions == null || localExtSize != locReses.length || extHash(locReses) != localExtHash) {
localExtensions = new ArrayList<ExtensionDefintion>();
Map<String, String> map = new HashMap<String, String>();
RHExtension ext;
String v, fileName, uuid, version;
ExtensionDefintion ed;
for (int i = 0; i < locReses.length; i++) {
ed = null;
// we stay happy with the file name when it has the right pattern (uuid-version.lex)
fileName = locReses[i].getName();
if (fileName.length() > 39) {
uuid = fileName.substring(0, 35);
version = fileName.substring(36, fileName.length() - 4);
if (Decision.isUUId(uuid)) {
ed = new ExtensionDefintion(uuid, version);
ed.setSource(this, locReses[i]);
}
}
if (ed == null) {
try {
ext = new RHExtension(this, locReses[i], false);
ed = new ExtensionDefintion(ext.getId(), ext.getVersion());
ed.setSource(ext);
} catch (Exception e) {
SystemOut.printDate(e);
}
}
if (ed != null) {
// check if we already have an extension with the same id to avoid having more than once
v = map.get(ed.getId());
if (v != null && v.compareToIgnoreCase(ed.getId()) > 0)
continue;
map.put(ed.getId(), ed.getVersion());
localExtensions.add(ed);
}
}
localExtHash = extHash(locReses);
// we store the size because localExtensions size could be smaller because of duplicates
localExtSize = locReses.length;
}
return localExtensions;
}
use of lucee.commons.io.res.filter.ExtensionResourceFilter in project Lucee by lucee.
the class MappingUtil method searchMappingRecursive.
public static PageSource searchMappingRecursive(Mapping mapping, String name, boolean onlyCFC) {
if (name.indexOf('/') == -1) {
// TODO handle this as well?
Config config = mapping.getConfig();
ExtensionResourceFilter ext = null;
if (onlyCFC)
ext = new ExtensionResourceFilter(Constants.getComponentExtensions(), true, true);
else {
ext = new ExtensionResourceFilter(Constants.getExtensions(), true, true);
// ext.addExtension(config.getComponentExtension());
}
if (mapping.isPhysicalFirst()) {
PageSource ps = searchPhysical(mapping, name, ext);
if (ps != null)
return ps;
ps = searchArchive(mapping, name, onlyCFC);
if (ps != null)
return ps;
} else {
PageSource ps = searchArchive(mapping, name, onlyCFC);
if (ps != null)
return ps;
ps = searchPhysical(mapping, name, ext);
if (ps != null)
return ps;
}
}
return null;
}
Aggregations