Search in sources :

Example 1 with WildcardPatternFilter

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;
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) WildcardPatternFilter(lucee.commons.io.res.util.WildcardPatternFilter)

Example 2 with WildcardPatternFilter

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;
}
Also used : OrResourceFilter(lucee.commons.io.res.filter.OrResourceFilter) ResourceFilter(lucee.commons.io.res.filter.ResourceFilter) DirectoryResourceFilter(lucee.commons.io.res.filter.DirectoryResourceFilter) OrResourceFilter(lucee.commons.io.res.filter.OrResourceFilter) ArrayList(java.util.ArrayList) Resource(lucee.commons.io.res.Resource) Mapping(lucee.runtime.Mapping) WildcardPatternFilter(lucee.commons.io.res.util.WildcardPatternFilter) MappingImpl(lucee.runtime.MappingImpl)

Aggregations

WildcardPatternFilter (lucee.commons.io.res.util.WildcardPatternFilter)2 ArrayList (java.util.ArrayList)1 Resource (lucee.commons.io.res.Resource)1 DirectoryResourceFilter (lucee.commons.io.res.filter.DirectoryResourceFilter)1 OrResourceFilter (lucee.commons.io.res.filter.OrResourceFilter)1 ResourceFilter (lucee.commons.io.res.filter.ResourceFilter)1 Mapping (lucee.runtime.Mapping)1 MappingImpl (lucee.runtime.MappingImpl)1 ApplicationException (lucee.runtime.exp.ApplicationException)1