/** * Creates a transient repository proxy that will use a copy of the given * repository configuration to initialize the underlying repository * instance. * * @param config repository configuration */ public TransientRepository(final RepositoryConfig config) { this(new RepositoryFactory() { public RepositoryImpl getRepository() throws RepositoryException { return RepositoryImpl.create(RepositoryConfig.create(config)); } }, config.getHomeDir()); }
/** * Creates a transient repository proxy that will use a copy of the given * repository configuration to initialize the underlying repository * instance. * * @param config repository configuration */ public TransientRepository(final RepositoryConfig config) { this(new RepositoryFactory() { public RepositoryImpl getRepository() throws RepositoryException { return RepositoryImpl.create(RepositoryConfig.create(config)); } }, config.getHomeDir()); }
/** * {@inheritDoc} */ public File getRepositoryHome() { return new File(getConfig().getHomeDir()); }
/** * {@inheritDoc} */ public File getRepositoryHome() { return new File(getConfig().getHomeDir()); }
@Override public void tearDownCluster() { for (RepositoryImpl repository : cluster) { File directory = new File(repository.getConfig().getHomeDir()); repository.shutdown(); try { DriverManager.getConnection("jdbc:derby:;shutdown=true"); } catch (SQLException e) { // ignore } FileUtils.deleteQuietly(directory); } }
@Override public void tearDownCluster() { for (RepositoryImpl repository : cluster) { File directory = new File(repository.getConfig().getHomeDir()); repository.shutdown(); try { DriverManager.getConnection("jdbc:derby:;shutdown=true"); } catch (SQLException e) { // ignore } FileUtils.deleteQuietly(directory); } }
/** * Closes the admin session, and in case of local transient respository for unit test, shuts down the repository and * cleans all temporary files. */ @Override protected void destroyRepository() { final RepositoryImpl repository = (RepositoryImpl) getRepository(); repository.shutdown(); LOG.info("Destroyed repository at {}", repository.getConfig().getHomeDir()); }
File targetDir = new File(target.getHomeDir()); File repoDir = new File(targetDir, "repository"); FileUtils.deleteQuietly(new File(repoDir, "index"));
File targetDir = new File(target.getHomeDir()); File repoDir = new File(targetDir, "repository"); FileUtils.deleteQuietly(new File(repoDir, "index"));
/** * Copies the full content from the source to the target repository. * <p> * The source repository <strong>must not be modified</strong> while * the copy operation is running to avoid an inconsistent copy. * <p> * This method leaves the search indexes of the target repository in * an * Note that both the source and the target repository must be closed * during the copy operation as this method requires exclusive access * to the repositories. * * @throws RepositoryException if the copy operation fails */ public void copy() throws RepositoryException { logger.info( "Copying repository content from {} to {}", source.getRepository().repConfig.getHomeDir(), target.getRepository().repConfig.getHomeDir()); try { copyNamespaces(); copyNodeTypes(); copyVersionStore(); copyWorkspaces(); } catch (Exception e) { throw new RepositoryException("Failed to copy content", e); } }
/** * Copies the full content from the source to the target repository. * <p> * The source repository <strong>must not be modified</strong> while * the copy operation is running to avoid an inconsistent copy. * <p> * This method leaves the search indexes of the target repository in * an * Note that both the source and the target repository must be closed * during the copy operation as this method requires exclusive access * to the repositories. * * @throws RepositoryException if the copy operation fails */ public void copy() throws RepositoryException { logger.info( "Copying repository content from {} to {}", source.getRepository().repConfig.getHomeDir(), target.getRepository().repConfig.getHomeDir()); try { copyNamespaces(); copyNodeTypes(); copyVersionStore(); copyWorkspaces(); } catch (Exception e) { throw new RepositoryException("Failed to copy content", e); } }
/** * Create the access manager. * * @param subject * @return access manager * @throws AccessDeniedException if the current subject is not granted access * to the current workspace * @throws RepositoryException if the access manager cannot be instantiated */ protected AccessManager createAccessManager(Subject subject) throws AccessDeniedException, RepositoryException { String wspName = getWorkspace().getName(); AMContext ctx = new AMContext( new File(context.getRepository().getConfig().getHomeDir()), context.getRepositoryContext().getFileSystem(), this, subject, context.getHierarchyManager(), context.getPrivilegeManager(), this, wspName); return repositoryContext.getSecurityManager().getAccessManager(this, ctx); }
/** * Create the access manager. * * @param subject * @return access manager * @throws AccessDeniedException if the current subject is not granted access * to the current workspace * @throws RepositoryException if the access manager cannot be instantiated */ protected AccessManager createAccessManager(Subject subject) throws AccessDeniedException, RepositoryException { String wspName = getWorkspace().getName(); AMContext ctx = new AMContext( new File(context.getRepository().getConfig().getHomeDir()), context.getRepositoryContext().getFileSystem(), this, subject, context.getHierarchyManager(), context.getPrivilegeManager(), this, wspName); return repositoryContext.getSecurityManager().getAccessManager(this, ctx); }
logger.info("Copying repository content from {} to Oak", config.getHomeDir()); try { NodeBuilder targetBuilder = target.getRoot().builder(); } else { logger.info("Initializing initial repository content from {}", config.getHomeDir()); new InitialContent().initialize(targetBuilder); if (initializer != null) { initializer.initialize(targetBuilder); logger.debug("InitialContent completed from {}", config.getHomeDir()); logger.debug("Repository initializer '" + ri.getClass().getName() + "' completed", config.getHomeDir()); logger.debug("Workspace initializer '" + wi.getClass().getName() + "' completed", config.getHomeDir());
logger.info("Copying repository content from {} to Oak", config.getHomeDir()); try { NodeBuilder targetBuilder = target.getRoot().builder(); } else { logger.info("Initializing initial repository content from {}", config.getHomeDir()); new InitialContent().initialize(targetBuilder); if (initializer != null) { initializer.initialize(targetBuilder); logger.debug("InitialContent completed from {}", config.getHomeDir()); logger.debug("Repository initializer '" + ri.getClass().getName() + "' completed", config.getHomeDir()); logger.debug("Workspace initializer '" + wi.getClass().getName() + "' completed", config.getHomeDir());
@Override protected AccessManager createAccessManager(Subject subject) throws AccessDeniedException, RepositoryException { AccessManagerConfig amConfig = context.getRepository().getConfig().getAccessManagerConfig(); try { HippoAMContext ctx = new HippoAMContext( new File((context.getRepository()).getConfig().getHomeDir()), context.getRepositoryContext().getFileSystem(), this, subject, context.getHierarchyManager(), context.getPrivilegeManager(), this, getWorkspace().getName(), context.getNodeTypeManager(), getItemStateManager()); AccessManager accessMgr = amConfig.newInstance(AccessManager.class); accessMgr.init(ctx); if (accessMgr instanceof ItemStateListener) { context.getItemStateManager().addListener((ItemStateListener) accessMgr); } return accessMgr; } catch (AccessDeniedException ex) { throw ex; } catch (Exception ex) { String msg = "failed to instantiate AccessManager implementation: "+amConfig.getClassName(); log.error(msg, ex); throw new RepositoryException(msg, ex); } }
@Override protected AccessManager createAccessManager(Subject subject) throws AccessDeniedException, RepositoryException { AccessManagerConfig amConfig = context.getRepository().getConfig().getAccessManagerConfig(); try { HippoAMContext ctx = new HippoAMContext( new File((context.getRepository()).getConfig().getHomeDir()), context.getRepositoryContext().getFileSystem(), this, subject, context.getHierarchyManager(), context.getPrivilegeManager(), this, getWorkspace().getName(), context.getNodeTypeManager(), getItemStateManager()); AccessManager accessMgr = amConfig.newInstance(AccessManager.class); accessMgr.init(ctx); if (accessMgr instanceof ItemStateListener) { context.getItemStateManager().addListener((ItemStateListener) accessMgr); } return accessMgr; } catch (AccessDeniedException ex) { throw ex; } catch (Exception ex) { String msg = "failed to instantiate AccessManager implementation: "+amConfig.getClassName(); log.error(msg, ex); throw new RepositoryException(msg, ex); } }
repLock.init(repConfig.getHomeDir()); repLock.acquire(); nodeIdFactory = new NodeIdFactory(repConfig.getHomeDir()); nodeIdFactory.open(); context.setNodeIdFactory(nodeIdFactory);
repLock.init(repConfig.getHomeDir()); repLock.acquire(); nodeIdFactory = new NodeIdFactory(repConfig.getHomeDir()); nodeIdFactory.open(); context.setNodeIdFactory(nodeIdFactory);
private void assertRepositoryConfiguration(RepositoryConfig config) throws ConfigurationException { assertEquals(DIR.getPath(), config.getHomeDir()); assertEquals("default", config.getDefaultWorkspaceName()); assertEquals(