Search in sources :

Example 1 with ContentFileCache

use of org.apache.sling.fsprovider.internal.parser.ContentFileCache in project sling by apache.

the class FsResourceProvider method activate.

// ---------- SCR Integration
@Activate
protected void activate(BundleContext bundleContext, final Config config) {
    fsMode = config.provider_fs_mode();
    String providerRoot = config.provider_root();
    if (StringUtils.isBlank(providerRoot)) {
        throw new IllegalArgumentException("provider.root property must be set");
    }
    String providerFileName = config.provider_file();
    if (StringUtils.isBlank(providerFileName)) {
        throw new IllegalArgumentException("provider.file property must be set");
    }
    this.providerRoot = providerRoot;
    this.providerFile = getProviderFile(providerFileName, bundleContext);
    this.overlayParentResourceProvider = false;
    InitialContentImportOptions options = new InitialContentImportOptions(config.provider_initial_content_import_options());
    File filterXmlFile = null;
    List<String> contentFileSuffixes = new ArrayList<>();
    if (fsMode == FsMode.FILEVAULT_XML) {
        contentFileSuffixes.add("/" + DOT_CONTENT_XML);
        if (StringUtils.isNotBlank(config.provider_filevault_filterxml_path())) {
            filterXmlFile = new File(config.provider_filevault_filterxml_path());
        }
    } else if (fsMode == FsMode.FILES_FOLDERS) {
        overlayParentResourceProvider = true;
    } else if (fsMode == FsMode.INITIAL_CONTENT) {
        overlayParentResourceProvider = !options.isOverwrite();
        if (!options.getIgnoreImportProviders().contains(ContentType.JSON.getExtension())) {
            contentFileSuffixes.add(ContentFileTypes.JSON_SUFFIX);
        }
        if (!options.getIgnoreImportProviders().contains(ContentType.JCR_XML.getExtension())) {
            contentFileSuffixes.add(ContentFileTypes.JCR_XML_SUFFIX);
        }
        if (!options.getIgnoreImportProviders().contains(ContentType.XML.getExtension())) {
            contentFileSuffixes.add(ContentFileTypes.XML_SUFFIX);
        }
    }
    ContentFileExtensions contentFileExtensions = new ContentFileExtensions(contentFileSuffixes);
    this.contentFileCache = new ContentFileCache(config.provider_cache_size());
    if (fsMode == FsMode.FILEVAULT_XML) {
        this.fileVaultMapper = new FileVaultResourceMapper(this.providerFile, filterXmlFile, this.contentFileCache);
    } else {
        this.fileMapper = new FileResourceMapper(this.providerRoot, this.providerFile, contentFileExtensions, this.contentFileCache);
        this.contentFileMapper = new ContentFileResourceMapper(this.providerRoot, this.providerFile, contentFileExtensions, this.contentFileCache);
    }
    // start background monitor if check interval is higher than 100
    if (config.provider_checkinterval() > 100) {
        this.monitor = new FileMonitor(this, config.provider_checkinterval(), fsMode, contentFileExtensions, this.contentFileCache);
    }
}
Also used : ContentFileResourceMapper(org.apache.sling.fsprovider.internal.mapper.ContentFileResourceMapper) ArrayList(java.util.ArrayList) FileVaultResourceMapper(org.apache.sling.fsprovider.internal.mapper.FileVaultResourceMapper) ContentFileCache(org.apache.sling.fsprovider.internal.parser.ContentFileCache) FileResourceMapper(org.apache.sling.fsprovider.internal.mapper.FileResourceMapper) ContentFileResourceMapper(org.apache.sling.fsprovider.internal.mapper.ContentFileResourceMapper) File(java.io.File) Activate(org.osgi.service.component.annotations.Activate)

Aggregations

File (java.io.File)1 ArrayList (java.util.ArrayList)1 ContentFileResourceMapper (org.apache.sling.fsprovider.internal.mapper.ContentFileResourceMapper)1 FileResourceMapper (org.apache.sling.fsprovider.internal.mapper.FileResourceMapper)1 FileVaultResourceMapper (org.apache.sling.fsprovider.internal.mapper.FileVaultResourceMapper)1 ContentFileCache (org.apache.sling.fsprovider.internal.parser.ContentFileCache)1 Activate (org.osgi.service.component.annotations.Activate)1