use of lucee.commons.io.res.filter.ExtensionResourceFilter in project Lucee by lucee.
the class Controler method checkOldClientFile.
private void checkOldClientFile(ConfigWeb config) {
ExtensionResourceFilter filter = new ExtensionResourceFilter(".script", false);
// move old structured file in new structure
try {
Resource dir = config.getClientScopeDir(), trgres;
Resource[] children = dir.listResources(filter);
String src, trg;
int index;
for (int i = 0; i < children.length; i++) {
src = children[i].getName();
index = src.indexOf('-');
trg = StorageScopeFile.getFolderName(src.substring(0, index), src.substring(index + 1), false);
trgres = dir.getRealResource(trg);
if (!trgres.exists()) {
trgres.createFile(true);
ResourceUtil.copy(children[i], trgres);
}
// children[i].moveTo(trgres);
children[i].delete();
}
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
}
use of lucee.commons.io.res.filter.ExtensionResourceFilter in project Lucee by lucee.
the class ConfigImpl method setTagDirectory.
protected void setTagDirectory(Resource tagDirectory) {
// this.tagDirectory=tagDirectory;
this.tagMapping = new MappingImpl(this, "/mapping-tag/", tagDirectory.getAbsolutePath(), null, ConfigImpl.INSPECT_NEVER, true, true, true, true, false, true, null, -1, -1);
TagLib tlc = getCoreTagLib(CFMLEngine.DIALECT_CFML);
TagLib tll = getCoreTagLib(CFMLEngine.DIALECT_LUCEE);
// now overwrite with new data
if (tagDirectory.isDirectory()) {
String[] files = tagDirectory.list(new ExtensionResourceFilter(getMode() == ConfigImpl.MODE_STRICT ? Constants.getComponentExtensions() : Constants.getExtensions()));
for (int i = 0; i < files.length; i++) {
if (tlc != null)
createTag(tlc, files[i]);
if (tll != null)
createTag(tll, files[i]);
}
}
}
use of lucee.commons.io.res.filter.ExtensionResourceFilter in project Lucee by lucee.
the class ConfigImpl method setFldFile.
protected void setFldFile(Resource fileFld, int dialect) throws FunctionLibException {
if (dialect == CFMLEngine.DIALECT_BOTH) {
setFldFile(fileFld, CFMLEngine.DIALECT_CFML);
setFldFile(fileFld, CFMLEngine.DIALECT_LUCEE);
return;
}
FunctionLib[] flds = dialect == CFMLEngine.DIALECT_CFML ? cfmlFlds : luceeFlds;
// merge all together (backward compatibility)
if (flds.length > 1)
for (int i = 1; i < flds.length; i++) {
overwrite(flds[0], flds[i]);
}
flds = new FunctionLib[] { flds[0] };
if (dialect == CFMLEngine.DIALECT_CFML) {
cfmlFlds = flds;
// TODO improve check
if (cfmlFlds != flds)
combinedCFMLFLDs = null;
} else {
luceeFlds = flds;
// TODO improve check
if (luceeFlds != flds)
combinedLuceeFLDs = null;
}
if (fileFld == null)
return;
this.fldFile = fileFld;
// overwrite with addional functions
FunctionLib fl;
if (fileFld.isDirectory()) {
Resource[] files = fileFld.listResources(new ExtensionResourceFilter(new String[] { "fld", "fldx" }));
for (int i = 0; i < files.length; i++) {
try {
fl = FunctionLibFactory.loadFromFile(files[i], getIdentification());
overwrite(flds[0], fl);
} catch (FunctionLibException fle) {
SystemOut.printDate(out, "can't load fld " + files[i]);
fle.printStackTrace(getErrWriter());
}
}
} else {
fl = FunctionLibFactory.loadFromFile(fileFld, getIdentification());
overwrite(flds[0], fl);
}
}
use of lucee.commons.io.res.filter.ExtensionResourceFilter in project Lucee by lucee.
the class ConfigImpl method setTldFile.
/**
* set the optional directory of the tag library deskriptors
* @param fileTld directory of the tag libray deskriptors
* @throws TagLibException
*/
protected void setTldFile(Resource fileTld, int dialect) throws TagLibException {
if (dialect == CFMLEngine.DIALECT_BOTH) {
setTldFile(fileTld, CFMLEngine.DIALECT_CFML);
setTldFile(fileTld, CFMLEngine.DIALECT_LUCEE);
return;
}
TagLib[] tlds = dialect == CFMLEngine.DIALECT_CFML ? cfmlTlds : luceeTlds;
if (fileTld == null)
return;
this.tldFile = fileTld;
String key;
Map<String, TagLib> map = new HashMap<String, TagLib>();
// First fill existing to set
for (int i = 0; i < tlds.length; i++) {
key = getKey(tlds[i]);
map.put(key, tlds[i]);
}
TagLib tl;
// now overwrite with new data
if (fileTld.isDirectory()) {
Resource[] files = fileTld.listResources(new ExtensionResourceFilter(new String[] { "tld", "tldx" }));
for (int i = 0; i < files.length; i++) {
try {
tl = TagLibFactory.loadFromFile(files[i], getIdentification());
key = getKey(tl);
if (!map.containsKey(key))
map.put(key, tl);
else
overwrite(map.get(key), tl);
} catch (TagLibException tle) {
SystemOut.printDate(out, "can't load tld " + files[i]);
tle.printStackTrace(getErrWriter());
}
}
} else if (fileTld.isFile()) {
tl = TagLibFactory.loadFromFile(fileTld, getIdentification());
key = getKey(tl);
if (!map.containsKey(key))
map.put(key, tl);
else
overwrite(map.get(key), tl);
}
// now fill back to array
tlds = new TagLib[map.size()];
if (dialect == CFMLEngine.DIALECT_CFML)
cfmlTlds = tlds;
else
luceeTlds = tlds;
int index = 0;
Iterator<TagLib> it = map.values().iterator();
while (it.hasNext()) {
tlds[index++] = it.next();
}
}
use of lucee.commons.io.res.filter.ExtensionResourceFilter in project Lucee by lucee.
the class TagLibFactory method loadFromDirectory.
/**
* Laedt mehrere TagLib's die innerhalb eines Verzeichnisses liegen.
* @param dir Verzeichnis im dem die TagLib's liegen.
* @param saxParser Definition des Sax Parser mit dem die TagLib's eingelesen werden sollen.
* @return TagLib's als Array
* @throws TagLibException
*/
public static TagLib[] loadFromDirectory(Resource dir, Identification id) throws TagLibException {
if (!dir.isDirectory())
return new TagLib[0];
ArrayList<TagLib> arr = new ArrayList<TagLib>();
Resource[] files = dir.listResources(new ExtensionResourceFilter(new String[] { "tld", "tldx" }));
for (int i = 0; i < files.length; i++) {
if (files[i].isFile())
arr.add(TagLibFactory.loadFromFile(files[i], id));
}
return arr.toArray(new TagLib[arr.size()]);
}
Aggregations