public SessionImpl( Repository repository, User currentUser, StorageClient client, Configuration configuration, StorageCacheManager storageCacheManager, StoreListener storeListener, PrincipalValidatorResolver principalValidatorResolver) throws ClientPoolException, StorageClientException, AccessDeniedException { this.currentUser = currentUser; this.repository = repository; this.client = client; this.storageCacheManager = storageCacheManager; this.storeListener = storeListener; this.configuration = configuration; if (this.storageCacheManager == null) { if ((nagclient % 1000) == 0) { LOGGER.warn( "No Cache Manager, All Caching disabled, please provide an Implementation of NamedCacheManager. This message will appear every 1000th time a session is created. "); } nagclient++; } accessControlManager = new AccessControlManagerImpl( client, currentUser, configuration, getCache(configuration.getAclColumnFamily()), storeListener, principalValidatorResolver); Map<String, CacheHolder> authorizableCache = getCache(configuration.getAuthorizableColumnFamily()); authorizableManager = new AuthorizableManagerImpl( currentUser, this, client, configuration, accessControlManager, authorizableCache, storeListener); contentManager = new ContentManagerImpl( client, accessControlManager, configuration, getCache(configuration.getContentColumnFamily()), storeListener); lockManager = new LockManagerImpl( client, configuration, currentUser, getCache(configuration.getLockColumnFamily())); authenticator = new AuthenticatorImpl(client, configuration, authorizableCache); storeListener.onLogin(currentUser.getId(), this.toString()); }
public Map<String, CacheHolder> getCache(String columnFamily) { if (storageCacheManager != null) { if (configuration.getAuthorizableColumnFamily().equals(columnFamily)) { return storageCacheManager.getAuthorizableCache(); } if (configuration.getAclColumnFamily().equals(columnFamily)) { return storageCacheManager.getAccessControlCache(); } if (configuration.getContentColumnFamily().equals(columnFamily)) { return storageCacheManager.getContentCache(); } return storageCacheManager.getCache(columnFamily); } return null; }
public synchronized void migrate(boolean dryRun, int limit, boolean reindexAll, Feedback feedback) throws ClientPoolException, StorageClientException, AccessDeniedException, IOException, PropertyMigrationException { SessionImpl session = (SessionImpl) repository.loginAdministrative(); StorageClient client = session.getClient(); FileRedoLogger migrateRedoLog = new FileRedoLogger(redoLogLocation, maxLogFileSize, feedback); client.setStorageClientListener(migrateRedoLog); try { if (client instanceof JDBCStorageClient) { JDBCStorageClient jdbcClient = (JDBCStorageClient) client; String keySpace = configuration.getKeySpace(); Indexer indexer = jdbcClient.getIndexer(); PropertyMigrator[] propertyMigrators = propertyMigratorTracker.getPropertyMigrators(); DependencySequence migratorDependencySequence = getMigratorSequence(session, propertyMigrators); for (PropertyMigrator p : migratorDependencySequence) { LOGGER.info("DryRun:{} Using Property Migrator {} ", dryRun, p); feedback.log("DryRun:{0} Using Property Migrator {1} ", dryRun, p); } for (PropertyMigrator p : migratorDependencySequence.getUnresolved()) { LOGGER.info("DryRun:{} Unresolved Property Migrator {} ", dryRun, p); feedback.log("DryRun:{0} Unresolved Property Migrator {1} ", dryRun, p); } for (Entry<String, Object> p : migratorDependencySequence.getAlreadyRun().entrySet()) { LOGGER.info("DryRun:{} Migrator Last Run {} ", dryRun, p); feedback.log("DryRun:{0} Migrator Last Run {1} ", dryRun, p); } if (migratorDependencySequence.hasUnresolved()) { throw new PropertyMigrationException( "There are unresolved dependencies " + migratorDependencySequence.getUnresolved()); } CacheAwareMigrationManager cacheAwareMigrationManager = new CacheAwareMigrationManager( jdbcClient, session.getCache(configuration.getAuthorizableColumnFamily())); reindex( dryRun, jdbcClient, cacheAwareMigrationManager, keySpace, configuration.getAuthorizableColumnFamily(), indexer, migratorDependencySequence, new IdExtractor() { public String getKey(Map<String, Object> properties) { if (properties.containsKey(Authorizable.ID_FIELD)) { return (String) properties.get(Authorizable.ID_FIELD); } return null; } }, limit, feedback, reindexAll); cacheAwareMigrationManager = new CacheAwareMigrationManager( jdbcClient, session.getCache(configuration.getContentColumnFamily())); reindex( dryRun, jdbcClient, cacheAwareMigrationManager, keySpace, configuration.getContentColumnFamily(), indexer, migratorDependencySequence, new IdExtractor() { public String getKey(Map<String, Object> properties) { if (properties.containsKey(BlockSetContentHelper.CONTENT_BLOCK_ID)) { // blocks of a bit stream return (String) properties.get(BlockSetContentHelper.CONTENT_BLOCK_ID); } else if (properties.containsKey(Content.UUID_FIELD)) { // a content item and content block item return (String) properties.get(Content.UUID_FIELD); } else if (properties.containsKey(Content.STRUCTURE_UUID_FIELD)) { // a structure item return (String) properties.get(Content.PATH_FIELD); } return null; } }, limit, feedback, reindexAll); cacheAwareMigrationManager = new CacheAwareMigrationManager( jdbcClient, session.getCache(configuration.getAclColumnFamily())); reindex( dryRun, jdbcClient, cacheAwareMigrationManager, keySpace, configuration.getAclColumnFamily(), indexer, migratorDependencySequence, new IdExtractor() { public String getKey(Map<String, Object> properties) { if (properties.containsKey(AccessControlManagerImpl._KEY)) { return (String) properties.get(AccessControlManagerImpl._KEY); } return null; } }, limit, feedback, reindexAll); saveMigratorSequence(session, migratorDependencySequence); } else { LOGGER.warn("This class will only re-index content for the JDBCStorageClients"); } } finally { client.setStorageClientListener(null); migrateRedoLog.close(); session.logout(); } }