/** * Add a request to read the properties and number of children of a node at the supplied location. * * @param of the location of the node whose children are to be read * @param workspaceName the name of the workspace * @return the request; never null * @throws IllegalArgumentException if the location or workspace name is null */ public ReadAllPropertiesRequest readAllProperties( Location of, String workspaceName ) { return process(new ReadAllPropertiesRequest(of, workspaceName)); }
/** * Add a request to read the properties and number of children of a node at the supplied location. * * @param of the location of the node whose children are to be read * @param workspaceName the name of the workspace * @return this builder for method chaining; never null * @throws IllegalArgumentException if the location or workspace name is null */ public BatchRequestBuilder readAllProperties( Location of, String workspaceName ) { return add(new ReadAllPropertiesRequest(of, workspaceName)); }
@Override protected Request createRequest() { return new ReadAllPropertiesRequest(validPathLocation1, workspace1); }
@Test( expected = IllegalArgumentException.class ) public void shouldNotAllowCreatingRequestWithNullFromLocation() { new ReadAllPropertiesRequest(null, workspace1); }
@Test public void shouldConsiderEqualTwoRequestsWithSameLocationsAndWorkspaceNames() { request = new ReadAllPropertiesRequest(validPathLocation1, workspace1); ReadAllPropertiesRequest request2 = new ReadAllPropertiesRequest(validPathLocation1, new String(workspace1)); assertThat(request, is(request2)); }
@Test( expected = IllegalArgumentException.class ) public void shouldNotAllowCreatingRequestWithNullWorkspaceName() { new ReadAllPropertiesRequest(validPathLocation1, null); }
@Test public void shouldConsiderNotEqualTwoRequestsWithDifferentWorkspaceNames() { request = new ReadAllPropertiesRequest(validPathLocation1, workspace1); ReadAllPropertiesRequest request2 = new ReadAllPropertiesRequest(validPathLocation1, workspace2); assertThat(request.equals(request2), is(false)); }
@Test public void shouldConsiderNotEqualTwoRequestsWithDifferentLocations() { request = new ReadAllPropertiesRequest(validPathLocation1, workspace1); ReadAllPropertiesRequest request2 = new ReadAllPropertiesRequest(validPathLocation2, workspace1); assertThat(request.equals(request2), is(false)); }
protected void indexProperties( String workspaceName, Location location ) { ReadAllPropertiesRequest readProps = new ReadAllPropertiesRequest(location, workspaceName); try { channel.addAndAwait(readProps); } catch (InterruptedException e) { // Clear the interrupted status of the thread and continue ... Thread.interrupted(); } checkRequestForErrors(readProps); // Now update the properties in the search engine ... location = readProps.getActualLocationOfNode(); Map<Name, Property> properties = readProps.getPropertiesByName(); UpdatePropertiesRequest request = new UpdatePropertiesRequest(location, workspaceName, properties, true); request.setActualLocationOfNode(location); process(request); checkRequestForErrors(readProps); }
@Test public void shouldCreateValidRequestWithValidLocation() { request = new ReadAllPropertiesRequest(validPathLocation1, workspace1); assertThat(request.at(), is(sameInstance(validPathLocation1))); assertThat(request.hasError(), is(false)); assertThat(request.getError(), is(nullValue())); }
@Test public void shouldAllowAddingProperties() { request = new ReadAllPropertiesRequest(validPathLocation, workspace1); request.addProperty(validProperty1); request.addProperty(validProperty2); assertThat(request.getProperties().size(), is(2)); assertThat(request.getProperties(), hasItems(validProperty1, validProperty2)); assertThat(request.getPropertiesByName().get(validProperty1.getName()), is(validProperty1)); assertThat(request.getPropertiesByName().get(validProperty2.getName()), is(validProperty2)); } }
@Test public void shouldIncludeTimeLoadedInReadAllPropertiesRequests() { String workspaceName = graph.getCurrentWorkspaceName(); // Don't use the graph so that we can obtain and interrogate the request ... CacheableRequest request = new ReadAllPropertiesRequest(location("/"), workspaceName); execute(request); assertThat(request.getTimeLoaded(), is(notNullValue())); }
/** * Process a request to verify that a node exists at the supplied location. * <p> * This method does nothing if the request is null. Unless overridden, this method converts the request that * {@link ReadAllPropertiesRequest reads the node} and uses the result to determine if the node exists. * </p> * * @param request the read request */ public void process( VerifyNodeExistsRequest request ) { if (request == null) return; ReadAllPropertiesRequest readNode = new ReadAllPropertiesRequest(request.at(), request.inWorkspace()); process(readNode); if (readNode.hasError()) { request.setError(readNode.getError()); return; } // Set the actual location ... request.setActualLocationOfNode(readNode.getActualLocationOfNode()); setCacheableInfo(request); }
/** * Process a request to read a single property of a node at the supplied location. * <p> * This method does nothing if the request is null. Unless overridden, this method converts the request that * {@link ReadAllPropertiesRequest reads the node} and simply returns the one property. * </p> * * @param request the read request */ public void process( ReadPropertyRequest request ) { if (request == null) return; ReadAllPropertiesRequest readNode = new ReadAllPropertiesRequest(request.on(), request.inWorkspace()); process(readNode); if (readNode.hasError()) { request.setError(readNode.getError()); return; } Property property = readNode.getPropertiesByName().get(request.named()); request.setProperty(property); // Set the actual location ... request.setActualLocationOfNode(readNode.getActualLocationOfNode()); setCacheableInfo(request); }
PlaceholderNode placeholder = projectedNode.asPlaceholder(); ReadAllPropertiesRequest placeholderRequest = new ReadAllPropertiesRequest(placeholder.location(), request.inWorkspace()); placeholderRequest.addProperties(placeholder.properties().values()); ProxyNode proxy = projectedNode.asProxy(); ReadAllPropertiesRequest pushDownRequest = new ReadAllPropertiesRequest(proxy.location(), proxy.workspaceName()); federatedRequest.add(pushDownRequest, proxy.isSameLocationAsOriginal(), false, proxy.projection());
if (request == null) return; ReadAllPropertiesRequest readProperties = new ReadAllPropertiesRequest(request.at(), request.inWorkspace()); process(readProperties); if (readProperties.hasError()) {