use of lucee.commons.io.res.util.WildcardPatternFilter in project Lucee by lucee.
the class ZipParam method doStartTag.
@Override
public int doStartTag() throws PageException {
if (this.filter == null && !StringUtil.isEmpty(this.pattern)) {
this.filter = new WildcardPatternFilter(pattern, patternDelimiters);
}
if (source != null) {
notAllowed("source", "charset", charset);
notAllowed("source", "content", content);
getZip().setParam(new ZipParamSource(source, entryPath, filter, prefix, recurse()));
} else if (content != null) {
required("content", "entrypath", entryPath);
notAllowed("content,entrypath", "filter", filter);
notAllowed("content,entrypath", "prefix", prefix);
notAllowed("content,entrypath", "source", source);
notAllowed("content,entrypath", "recurse", recurse);
getZip().setParam(new ZipParamContent(content, entryPath, charset));
} else if (filter != null) {
notAllowed("filter", "charset", charset);
notAllowed("filter", "content", content);
notAllowed("filter", "prefix", prefix);
notAllowed("filter", "source", source);
getZip()._setFilter(filter);
// getZip().setParam(new ZipParamFilter(filter,entryPath,recurse()));
} else if (entryPath != null) {
notAllowed("entryPath", "charset", charset);
notAllowed("entryPath", "content", content);
notAllowed("entryPath", "prefix", prefix);
notAllowed("entryPath", "source", source);
getZip().setEntrypath(entryPath);
} else
throw new ApplicationException("invalid attribute combination");
return SKIP_BODY;
}
use of lucee.commons.io.res.util.WildcardPatternFilter in project Lucee by lucee.
the class ExportImportHandler method exportMapping.
private static List<Object> exportMapping(Mapping[] mappings, Resource dir, String pathAppendix, String filter) throws IOException {
List<Object> list = new ArrayList<Object>();
Map<String, Object> m;
for (Mapping mapping : mappings) {
MappingImpl mi = (MappingImpl) mapping;
m = new HashMap<String, Object>();
list.add(m);
m.put("virtual", mapping.getVirtual());
m.put("inspect", ConfigWebUtil.inspectTemplate(mi.getInspectTemplateRaw(), ""));
m.put("toplevel", mapping.isTopLevel());
m.put("readonly", mapping.isReadonly());
m.put("hidden", mapping.isHidden());
m.put("physicalFirst", mapping.isPhysicalFirst());
m.put("hidden", mapping.isHidden());
// archive
if (mapping.hasArchive()) {
Resource archive = mapping.getArchive();
if (archive.isFile()) {
Resource arcDir = dir.getRealResource("archive/");
arcDir.mkdir();
m.put("archive", pathAppendix + "archive/" + archive.getName());
IOUtil.copy(archive, arcDir.getRealResource(archive.getName()));
}
}
// physical
if (mapping.hasPhysical()) {
Resource physical = mi.getPhysical();
if (physical.isDirectory()) {
String id = CreateUniqueId.invoke();
Resource phyDir = dir.getRealResource("physical/" + id);
phyDir.mkdirs();
m.put("physical", pathAppendix + "physical/" + id);
ResourceFilter f = null;
if (!StringUtil.isEmpty(filter)) {
f = new OrResourceFilter(new ResourceFilter[] { new WildcardPatternFilter(filter, ","), DirectoryResourceFilter.FILTER });
}
if (// PATCH this needs more digging
!physical.getAbsolutePath().equals("/"))
ResourceUtil.copyRecursive(physical, phyDir, f);
}
}
}
return list;
}
Aggregations