Search in sources :

Example 1 with VFSItemExcludePrefixFilter

use of org.olat.core.util.vfs.filters.VFSItemExcludePrefixFilter in project OpenOLAT by OpenOLAT.

the class CPFile method deleteIfEmpty.

/**
 * Deletes the container if it is empty (excluding files with '.' prefix).
 *
 * @param parentContainer
 */
private void deleteIfEmpty(VFSContainer container) {
    String[] unwantedPrefixes = { "." };
    VFSItemFilter filter = new VFSItemExcludePrefixFilter(unwantedPrefixes);
    if (container != null) {
        List<VFSItem> items = container.getItems(filter);
        if (items == null || items.size() == 0) {
            container.delete();
        }
    }
}
Also used : VFSItemFilter(org.olat.core.util.vfs.filters.VFSItemFilter) VFSItemExcludePrefixFilter(org.olat.core.util.vfs.filters.VFSItemExcludePrefixFilter) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 2 with VFSItemExcludePrefixFilter

use of org.olat.core.util.vfs.filters.VFSItemExcludePrefixFilter in project openolat by klemens.

the class CPFile method deleteIfEmpty.

/**
 * Deletes the container if it is empty (excluding files with '.' prefix).
 *
 * @param parentContainer
 */
private void deleteIfEmpty(VFSContainer container) {
    String[] unwantedPrefixes = { "." };
    VFSItemFilter filter = new VFSItemExcludePrefixFilter(unwantedPrefixes);
    if (container != null) {
        List<VFSItem> items = container.getItems(filter);
        if (items == null || items.size() == 0) {
            container.delete();
        }
    }
}
Also used : VFSItemFilter(org.olat.core.util.vfs.filters.VFSItemFilter) VFSItemExcludePrefixFilter(org.olat.core.util.vfs.filters.VFSItemExcludePrefixFilter) VFSItem(org.olat.core.util.vfs.VFSItem)

Aggregations

VFSItem (org.olat.core.util.vfs.VFSItem)2 VFSItemExcludePrefixFilter (org.olat.core.util.vfs.filters.VFSItemExcludePrefixFilter)2 VFSItemFilter (org.olat.core.util.vfs.filters.VFSItemFilter)2