Search in sources :

Example 1 with ContentContext

use of org.alfresco.filesys.repo.ContentContext in project alfresco-repository by Alfresco.

the class MultiTenantShareMapper method createTenantShare.

/**
 * Create a tenant domain specific share
 */
private final DiskSharedDevice createTenantShare(String tenantDomain) {
    logger.debug("create tenant share for domain " + tenantDomain);
    StoreRef storeRef = new StoreRef(getStoreName());
    NodeRef rootNodeRef = new NodeRef(storeRef.getProtocol(), storeRef.getIdentifier(), "dummy");
    // Root nodeRef is required for storeRef part
    rootNodeRef = m_alfrescoConfig.getTenantService().getRootNode(m_alfrescoConfig.getNodeService(), m_alfrescoConfig.getSearchService(), m_alfrescoConfig.getNamespaceService(), getRootPath(), rootNodeRef);
    // Create the disk driver and context
    DiskInterface diskDrv = getRepoDiskInterface();
    ContentContext diskCtx = new ContentContext(m_tenantShareName, getStoreName(), getRootPath(), rootNodeRef);
    if (m_quotaManager != null) {
        diskCtx.setQuotaManager(m_quotaManager);
    }
    if (m_config instanceof ServerConfigurationBean) {
        ServerConfigurationBean config = (ServerConfigurationBean) m_config;
        config.initialiseRuntimeContext("cifs.tenant." + tenantDomain, diskCtx);
    } else {
        throw new AlfrescoRuntimeException("configuration error, unknown configuration bean");
    }
    // Default the filesystem to look like an 80Gb sized disk with 90% free space
    diskCtx.setDiskInformation(new SrvDiskInfo(2560, 64, 512, 2304));
    return new DiskSharedDevice(m_tenantShareName, diskDrv, diskCtx);
}
Also used : StoreRef(org.alfresco.service.cmr.repository.StoreRef) NodeRef(org.alfresco.service.cmr.repository.NodeRef) SrvDiskInfo(org.alfresco.jlan.server.filesys.SrvDiskInfo) ServerConfigurationBean(org.alfresco.filesys.config.ServerConfigurationBean) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) DiskInterface(org.alfresco.jlan.server.filesys.DiskInterface) ContentContext(org.alfresco.filesys.repo.ContentContext) DiskSharedDevice(org.alfresco.jlan.server.filesys.DiskSharedDevice)

Example 2 with ContentContext

use of org.alfresco.filesys.repo.ContentContext in project alfresco-repository by Alfresco.

the class ServerConfigurationBean method processFilesystemsConfig.

/**
 * Process the filesystems configuration
 */
protected void processFilesystemsConfig() {
    // Create the filesystems configuration section
    FilesystemsConfigSection fsysConfig = new FilesystemsConfigSection(this);
    // Access the security configuration section
    SecurityConfigSection secConfig = (SecurityConfigSection) getConfigSection(SecurityConfigSection.SectionName);
    if (this.filesystemContexts != null) {
        for (DeviceContext filesystem : this.filesystemContexts) {
            try {
                // Check the filesystem type and use the appropriate driver
                DiskSharedDevice filesys = null;
                // Create a new filesystem driver instance and register a context for
                // the new filesystem
                ExtendedDiskInterface filesysDriver = getRepoDiskInterface();
                ContentContext filesysContext = (ContentContext) filesystem;
                // Create state cache here and inject
                StandaloneFileStateCache standaloneCache = new StandaloneFileStateCache();
                standaloneCache.initializeCache(new GenericConfigElement(""), this);
                filesysContext.setStateCache(standaloneCache);
                if (filesysContext.hasStateCache()) {
                    // Register the state cache with the reaper thread
                    // has many side effects including initialisation of the cache
                    fsysConfig.addFileStateCache(filesystem.getDeviceName(), filesysContext.getStateCache());
                    // Create the lock manager for the context.
                    FileStateLockManager lockMgr = new FileStateLockManager(filesysContext.getStateCache());
                    filesysContext.setLockManager(lockMgr);
                    filesysContext.setOpLockManager(lockMgr);
                }
                if (!ftpConfigBean.getServerEnabled() && isContentDiskDriver2(filesysDriver)) {
                    ((ContentContext) filesystem).setDisableNodeMonitor(true);
                }
                filesysDriver.registerContext(filesystem);
                // Check if an access control list has been specified
                AccessControlList acls = null;
                AccessControlListBean accessControls = filesysContext.getAccessControlList();
                if (accessControls != null) {
                    // Parse the access control list
                    acls = accessControls.toAccessControlList(secConfig);
                } else if (secConfig.hasGlobalAccessControls()) {
                    // Use the global access control list for this disk share
                    acls = secConfig.getGlobalAccessControls();
                }
                // Create the shared filesystem
                filesys = new DiskSharedDevice(filesystem.getDeviceName(), filesysDriver, filesysContext);
                filesys.setConfiguration(this);
                // Add any access controls to the share
                filesys.setAccessControlList(acls);
                if (filesysContext.getDisableChangeNotifications() == false)
                    filesysContext.enableChangeHandler(true);
                // Start the filesystem
                filesysContext.startFilesystem(filesys);
                // Add the new filesystem
                fsysConfig.addShare(filesys);
            } catch (DeviceContextException ex) {
                throw new AlfrescoRuntimeException("Error creating filesystem " + filesystem.getDeviceName(), ex);
            } catch (InvalidConfigurationException ex) {
                throw new AlfrescoRuntimeException(ex.getMessage(), ex);
            }
        }
    } else {
        // No filesystems defined
        logger.warn("No filesystems defined");
    }
// home folder share mapper could be declared in security config
}
Also used : AccessControlList(org.alfresco.jlan.server.auth.acl.AccessControlList) DeviceContextException(org.alfresco.jlan.server.core.DeviceContextException) SecurityConfigSection(org.alfresco.jlan.server.config.SecurityConfigSection) GenericConfigElement(org.springframework.extensions.config.element.GenericConfigElement) ExtendedDiskInterface(org.alfresco.filesys.alfresco.ExtendedDiskInterface) StandaloneFileStateCache(org.alfresco.jlan.server.filesys.cache.StandaloneFileStateCache) AccessControlListBean(org.alfresco.filesys.config.acl.AccessControlListBean) InvalidConfigurationException(org.alfresco.jlan.server.config.InvalidConfigurationException) FilesystemsConfigSection(org.alfresco.jlan.server.filesys.FilesystemsConfigSection) DeviceContext(org.alfresco.jlan.server.core.DeviceContext) FileStateLockManager(org.alfresco.jlan.server.filesys.cache.FileStateLockManager) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) ContentContext(org.alfresco.filesys.repo.ContentContext) DiskSharedDevice(org.alfresco.jlan.server.filesys.DiskSharedDevice)

Aggregations

AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)2 ContentContext (org.alfresco.filesys.repo.ContentContext)2 DiskSharedDevice (org.alfresco.jlan.server.filesys.DiskSharedDevice)2 ExtendedDiskInterface (org.alfresco.filesys.alfresco.ExtendedDiskInterface)1 ServerConfigurationBean (org.alfresco.filesys.config.ServerConfigurationBean)1 AccessControlListBean (org.alfresco.filesys.config.acl.AccessControlListBean)1 AccessControlList (org.alfresco.jlan.server.auth.acl.AccessControlList)1 InvalidConfigurationException (org.alfresco.jlan.server.config.InvalidConfigurationException)1 SecurityConfigSection (org.alfresco.jlan.server.config.SecurityConfigSection)1 DeviceContext (org.alfresco.jlan.server.core.DeviceContext)1 DeviceContextException (org.alfresco.jlan.server.core.DeviceContextException)1 DiskInterface (org.alfresco.jlan.server.filesys.DiskInterface)1 FilesystemsConfigSection (org.alfresco.jlan.server.filesys.FilesystemsConfigSection)1 SrvDiskInfo (org.alfresco.jlan.server.filesys.SrvDiskInfo)1 FileStateLockManager (org.alfresco.jlan.server.filesys.cache.FileStateLockManager)1 StandaloneFileStateCache (org.alfresco.jlan.server.filesys.cache.StandaloneFileStateCache)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 StoreRef (org.alfresco.service.cmr.repository.StoreRef)1 GenericConfigElement (org.springframework.extensions.config.element.GenericConfigElement)1