@Override public Problems restoreRepository( File backupDirectory, RestoreOptions options ) throws RepositoryException { session().checkPermission(Path.ROOT_PATH, ModeShapePermissions.RESTORE); return repository().runningState().backupService().restoreRepository(repository(), backupDirectory, options); }
@Override public void reindex() throws RepositoryException { // First check permissions ... session.checkPermission(workspaceName, Path.ROOT_PATH, ModeShapePermissions.INDEX_WORKSPACE); // Then reindex ... repository().runningState().queryManager().reindexContent(this); }
public JcrVersionManager( JcrSession session ) { super(); this.session = session; versionStoragePath = absolutePath(JcrLexicon.SYSTEM, JcrLexicon.VERSION_STORAGE); ExecutionContext context = session.context(); versionHistoryPathAlgorithm = new HiearchicalPathAlgorithm(versionStoragePath, context); readableSystem = new SystemContent(this.session.cache()); }
@Override protected void startRepositoryWithConfiguration( Document doc ) throws Exception { stopRepository(); RepositoryConfiguration config = new RepositoryConfiguration(doc, REPO_NAME).with(new TestingEnvironment()); repository = new JcrRepository(config); repository.start(); session = repository.login(); rootNode = session.getRootNode(); addSequencingListeners(session); }
private void restoreBackup() throws Exception { startRepositoryWithConfiguration(resourceStream("config/backup-repo-config.json")); JcrSession session = repository().login(); Problems problems = session.getWorkspace().getRepositoryManager().restoreRepository(backupDirectory); assertNoProblems(problems); session.logout(); }
protected QueryResult assertJcrSql2Query( String sql, long expectedRowCount ) throws RepositoryException { Query query = session().getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2); QueryResult results = query.execute(); printMessage(query.getStatement()); ValidateQuery.validateQuery().printDetail(print).rowCount(expectedRowCount).validate(query, results); return results; }
private void setCreatedByIfNecessary( JcrSession outputSession, List<AbstractJcrNode> outputNodes ) throws RepositoryException { // if the mix:created mixin is on any of the new nodes, we need to set the createdBy here, otherwise it will be // set by the system session when it saves and it will default to "modeshape-worker" for (AbstractJcrNode node : outputNodes) { if (node.isNodeType(JcrMixLexicon.CREATED)) { node.setProperty(JcrLexicon.CREATED_BY, outputSession.getValueFactory().createValue(work.getUserId()), true, true, false, false); } } }
@Override public Problems backupRepository( File backupDirectory, BackupOptions backupOptions ) throws RepositoryException { session().checkPermission(Path.ROOT_PATH, ModeShapePermissions.BACKUP); return repository().runningState().backupService().backupRepository(backupDirectory, backupOptions); }
protected void startRepository() throws Exception { RepositoryConfiguration repositoryConfiguration = createRepositoryConfiguration(REPO_NAME); repositoryConfiguration = repositoryConfiguration.with(new TestingEnvironment()); repository = new JcrRepository(repositoryConfiguration); repository.start(); session = repository.login(); }
@Override public Future<Boolean> reindexAsync() throws RepositoryException { // First check permissions ... session.checkPermission(workspaceName, Path.ROOT_PATH, ModeShapePermissions.INDEX_WORKSPACE); // Then reindex ... return repository().runningState().queryManager().reindexContentAsync(this); }
protected TextExtractors( JcrRepository.RunningState repository, RepositoryConfiguration.TextExtraction extracting ) { this(repository.context().getCachedTreadPool(extracting.getThreadPoolName(), extracting.getMaxPoolSize()), getConfiguredExtractors(repository, extracting)); }
final AbstractJcrNode node( CachedNode node, Path path ) throws PathNotFoundException, AccessDeniedException, RepositoryException { CachedNode child = cachedNode(cache, node, path, ModeShapePermissions.READ); AbstractJcrNode result = node(child, (Type)null, null); if (result.isShareable()) { // Find the shared node with the desired path ... AbstractJcrNode atOrBelow = result.sharedSet().getSharedNodeAtOrBelow(path); if (atOrBelow != null) result = atOrBelow; } return result; }
@Override NodeDefinitionId nodeDefinitionId() throws RepositoryException { if (rootNodeDefnId == null) { // Idempotent so we can do this without a lock ... rootNodeDefnId = session.workspace().nodeTypeManager().getRootNodeDefinition().getId(); } return rootNodeDefnId; }
@Override public boolean holdsLock( String absPath ) throws PathNotFoundException, RepositoryException { AbstractJcrNode node = session.node(session.absolutePathFor(absPath)); return lockManager.findLockFor(node.key()) != null; }
@Override public IndexManager getIndexManager() throws RepositoryException { session.checkLive(); return repository().queryManager().getIndexManager(); }
protected Node addMixin( String path, String... nodeTypes ) throws RepositoryException { Node node = session().getRootNode().getNode(relativePath(path)); return addMixin(node, false, nodeTypes); }
private void setCreatedByIfNecessary( JcrSession outputSession, List<AbstractJcrNode> outputNodes ) throws RepositoryException { // if the mix:created mixin is on any of the new nodes, we need to set the createdBy here, otherwise it will be // set by the system session when it saves and it will default to "modeshape-worker" for (AbstractJcrNode node : outputNodes) { if (node.isNodeType(JcrMixLexicon.CREATED)) { node.setProperty(JcrLexicon.CREATED_BY, outputSession.getValueFactory().createValue(work.getUserId()), true, true, false, false); } } }
@Override public Problems backupRepository( File backupDirectory, BackupOptions backupOptions ) throws RepositoryException { session().checkPermission(Path.ROOT_PATH, ModeShapePermissions.BACKUP); return repository().runningState().backupService().backupRepository(backupDirectory, backupOptions); }
public JcrVersionManager( JcrSession session ) { super(); this.session = session; versionStoragePath = absolutePath(JcrLexicon.SYSTEM, JcrLexicon.VERSION_STORAGE); ExecutionContext context = session.context(); versionHistoryPathAlgorithm = new HiearchicalPathAlgorithm(versionStoragePath, context); readableSystem = new SystemContent(this.session.cache()); }
protected TextExtractors( JcrRepository.RunningState repository, RepositoryConfiguration.TextExtraction extracting ) { this(repository.context().getCachedTreadPool(extracting.getThreadPoolName(), extracting.getMaxPoolSize()), getConfiguredExtractors(repository, extracting)); }