Search in sources :

Example 1 with FileDataRecord

use of org.apache.jackrabbit.core.data.FileDataRecord in project jackrabbit-oak by apache.

the class OakFileDataStore method getAllRecords.

@Override
public Iterator<DataRecord> getAllRecords() {
    final String path = normalizeNoEndSeparator(new File(getPath()).getAbsolutePath());
    final OakFileDataStore store = this;
    return Files.fileTreeTraverser().postOrderTraversal(new File(path)).filter(new Predicate<File>() {

        @Override
        public boolean apply(File input) {
            return input.isFile() && !input.getParent().equals(path);
        }
    }).transform(new Function<File, DataRecord>() {

        @Override
        public DataRecord apply(File input) {
            return new FileDataRecord(store, new DataIdentifier(input.getName()), input);
        }
    }).iterator();
}
Also used : Function(com.google.common.base.Function) DataIdentifier(org.apache.jackrabbit.core.data.DataIdentifier) FileDataRecord(org.apache.jackrabbit.core.data.FileDataRecord) File(java.io.File)

Example 2 with FileDataRecord

use of org.apache.jackrabbit.core.data.FileDataRecord in project jackrabbit-oak by apache.

the class OakFileDataStore method getAllMetadataRecords.

@Override
public List<DataRecord> getAllMetadataRecords(String prefix) {
    File root = new File(getPath());
    List<DataRecord> rootRecords = new ArrayList<DataRecord>();
    for (File file : FileFilterUtils.filterList(FileFilterUtils.prefixFileFilter(prefix), root.listFiles())) {
        if (!file.isDirectory()) {
            // skip directories which are actual data store files
            rootRecords.add(new FileDataRecord(this, new DataIdentifier(file.getName()), file));
        }
    }
    return rootRecords;
}
Also used : DataIdentifier(org.apache.jackrabbit.core.data.DataIdentifier) ArrayList(java.util.ArrayList) FileDataRecord(org.apache.jackrabbit.core.data.FileDataRecord) FileDataRecord(org.apache.jackrabbit.core.data.FileDataRecord) DataRecord(org.apache.jackrabbit.core.data.DataRecord) File(java.io.File)

Aggregations

File (java.io.File)2 DataIdentifier (org.apache.jackrabbit.core.data.DataIdentifier)2 FileDataRecord (org.apache.jackrabbit.core.data.FileDataRecord)2 Function (com.google.common.base.Function)1 ArrayList (java.util.ArrayList)1 DataRecord (org.apache.jackrabbit.core.data.DataRecord)1