/** * Add a request to obtain the information about the available workspaces. * * @return this builder for method chaining; never null */ public BatchRequestBuilder getWorkspaces() { return add(new GetWorkspacesRequest()); }
/** * Get the set of workspace names that are known to this source and accessible by this {@link #getContext() context}. * * @return the set of workspace names; never null */ public Set<String> getWorkspaces() { return requests.getWorkspaces().getAvailableWorkspaceNames(); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.GetWorkspacesRequest) */ @Override public void process( GetWorkspacesRequest request ) { request.setAvailableWorkspaceNames(repository.getWorkspaceNames()); }
/** * Index (or re-index) all of the content in all of the workspaces within the source. This method operates synchronously and * returns when the requested indexing is completed. * * @return this object for convenience in method chaining; never null * @throws RepositorySourceException if there is a problem accessing the content * @throws SearchEngineException if there is a problem updating the indexes * @throws IllegalArgumentException if the context is null, or if depth per read is not positive */ public SearchEngineIndexer indexAllWorkspaces() throws RepositorySourceException, SearchEngineException { // Get the names of all the workspaces ... GetWorkspacesRequest getWorkspaces = new GetWorkspacesRequest(); try { channel.addAndAwait(getWorkspaces); checkRequestForErrors(getWorkspaces); } catch (InterruptedException e) { // Clear the interrupted status of the thread and continue ... Thread.interrupted(); return this; } // Index all of the workspaces ... Path rootPath = context.getValueFactories().getPathFactory().createRootPath(); Location rootLocation = Location.create(rootPath); for (String workspaceName : getWorkspaces.getAvailableWorkspaceNames()) { index(workspaceName, rootLocation); } return this; }
/** * Set the names of the workspaces that are available (at least to the current user) * * @param availableWorkspaceNames Sets availableWorkspaceNames to the specified value. * @throws IllegalStateException if the request is frozen */ public void setAvailableWorkspaceNames( Set<String> availableWorkspaceNames ) { checkNotFrozen(); this.availableWorkspaceNames = availableWorkspaceNames; }
@Test public void shouldMakeAvailablePredefinedWorkspaces() { RepositoryConnection connection = source.getConnection(); GetWorkspacesRequest request = new GetWorkspacesRequest(); connection.execute(context, request); Set<String> workspaces = request.getAvailableWorkspaceNames(); Set<String> graphWorkspaces = new HashSet<String>(Arrays.asList(predefinedWorkspaces)); assertThat(workspaces, is(graphWorkspaces)); // Use each workspace ... for (String workspaceName : predefinedWorkspaces) { ReadNodeRequest readRoot = new ReadNodeRequest(locationFor("/"), workspaceName); connection.execute(context, readRoot); assertThat(readRoot.getActualLocationOfNode().getPath(), is(pathFor("/"))); } }
@Override public void process( GetWorkspacesRequest request ) { Set<String> names = repository.getWorkspaceNames(); request.setAvailableWorkspaceNames(new HashSet<String>(names)); setCacheableInfo(request); }
/** * Add a request to obtain the information about the available workspaces. * * @return the request; never null */ public GetWorkspacesRequest getWorkspaces() { GetWorkspacesRequest request = new GetWorkspacesRequest(); process(request); return request; }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.GetWorkspacesRequest) */ @Override public void process( GetWorkspacesRequest request ) { Set<String> names = repository.getWorkspaceNames(); request.setAvailableWorkspaceNames(new HashSet<String>(names)); setCacheableInfo(request); }
@Override protected Request createRequest() { return new GetWorkspacesRequest(); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.GetWorkspacesRequest) */ @Override public void process( GetWorkspacesRequest request ) { // Always ask the transaction (in case a new workspace was added by another process) ... Set<String> names = txn.getWorkspaceNames(); request.setAvailableWorkspaceNames(new HashSet<String>(names)); setCacheableInfo(request); }
@Test public void shouldConsiderEqualAnyTwoRequests() { assertThat(new GetWorkspacesRequest(), is(new GetWorkspacesRequest())); } }
@Override public void process( GetWorkspacesRequest request ) { request.setAvailableWorkspaceNames(Collections.singleton("Test workspace")); }