/** * {@inheritDoc} * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals( Object obj ) { if (obj == this) return true; if (this.getClass().isInstance(obj)) { LockBranchRequest that = (LockBranchRequest)obj; if (this.lockTimeoutInMillis() != that.lockTimeoutInMillis()) return false; if (!this.at().isSame(that.at())) return false; if (this.lockScope() != that.lockScope()) return false; if (!this.inWorkspace().equals(that.inWorkspace())) return false; return true; } return false; }
/** * {@inheritDoc} * <p> * This method does not clone the results. * </p> * * @see org.modeshape.graph.request.ChangeRequest#clone() */ @Override public LockBranchRequest clone() { LockBranchRequest request = new LockBranchRequest(actualLocation != null ? actualLocation : at, workspaceName, isDeep, lockTimeoutInMillis); request.setActualLocation(actualLocation); return request; }
/** * {@inheritDoc} * * @see java.lang.Object#toString() */ @Override public String toString() { String workspaceName = this.workspaceName != null ? "'" + this.workspaceName + "'" : "default"; return "lock " + printable(at()) + " (in " + workspaceName + " workspace)" + (LockScope.SELF_AND_DESCENDANTS == lockScope() ? " and descendants" : ""); }
public void process( LockBranchRequest request ) { ProjectedNode projectedNode = project(request.at(), request.inWorkspace(), request, true); ProxyNode proxy = projectedNode.asProxy(); LockBranchRequest pushDownRequest = new LockBranchRequest(proxy.location(), proxy.workspaceName(), request.lockScope(), request.lockTimeoutInMillis()); federatedRequest.add(pushDownRequest, proxy.isSameLocationAsOriginal(), false, proxy.projection()); String msg = GraphI18n.unableToUpdatePlaceholder.text(readable(request.at()), request.inWorkspace(), getSourceName()); request.setError(new UnsupportedRequestException(msg));
/** * Process a request to lock a node or branch within a workspace * <p> * The default implementation of this method does nothing, as most connectors will not support locking. Any implementation of * this method should do nothing if the request is null. * </p> * <p> * Implementations that do support locking should throw a {@link LockFailedException} if the request could not be fulfilled. * </p> * * @param request the request */ public void process( LockBranchRequest request ) { Location actualLocation = request.at(); if (!actualLocation.hasPath()) { VerifyNodeExistsRequest nodeExists = new VerifyNodeExistsRequest(request.at(), request.inWorkspace()); process(nodeExists); if (nodeExists.hasError()) { request.setError(nodeExists.getError()); return; } actualLocation = nodeExists.getActualLocationOfNode(); } request.setActualLocation(actualLocation); }
protected void assertNextRequestIsLock( Location at, LockScope lockScope, long lockTimeout ) { Request request = executedRequests.poll(); assertThat(request, is(instanceOf(LockBranchRequest.class))); LockBranchRequest lock = (LockBranchRequest)request; assertThat(lock.at(), is(at)); assertThat(lock.lockScope(), is(lockScope)); assertThat(lock.lockTimeoutInMillis(), is(lockTimeout)); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.LockBranchRequest) */ @Override public void process( LockBranchRequest request ) { ProjectedRequest projected = federatedRequest.getFirstProjectedRequest(); // Check the projection first ... if (checkErrorOrCancel(request, federatedRequest)) return; LockBranchRequest source = (LockBranchRequest)projected.getRequest(); if (checkErrorOrCancel(request, source)) return; Location sourceLocation = source.getActualLocation(); request.setActualLocation(projectToFederated(request.at(), projected.getProjection(), sourceLocation, request)); }
@Override public void process( LockBranchRequest request ) { // Just update the actual location request.setActualLocation(actualLocationOf(request.at())); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.LockBranchRequest) */ @Override public void process( LockBranchRequest request ) { LockBranchRequest source = (LockBranchRequest)federatedRequest.getFirstProjectedRequest().getRequest(); if (checkErrorOrCancel(request, source)) return; request.setActualLocation(source.getActualLocation()); }
/** * {@inheritDoc} * * @see java.lang.Object#hashCode() */ @Override public int hashCode() { return HashCode.compute(at, workspaceName, lockScope(), lockTimeoutInMillis); }
/** * Create a request to lock a branch or node * * @param workspaceName the name of the workspace containing the node; may not be null * @param target the location of the top node in the existing branch that is to be locked * @param lockScope the {@link LockBranchRequest#lockScope()} scope of the lock * @param lockTimeoutInMillis the number of milliseconds that the lock should last before the lock times out; zero (0) * indicates that the connector default should be used * @return the request; never null * @throws IllegalArgumentException if any of the parameters are null */ public LockBranchRequest lockBranch( String workspaceName, Location target, LockScope lockScope, long lockTimeoutInMillis ) { return process(new LockBranchRequest(target, workspaceName, lockScope, lockTimeoutInMillis)); }
/** * Sets the actual and complete location of the node being locked. This method must be called when processing the request, and * the actual location must have a {@link Location#getPath() path}. * * @param actualLocation the actual location of the node before being locked * @throws IllegalArgumentException if the either location is null or is missing its path * @throws IllegalStateException if the request is frozen */ public void setActualLocation( Location actualLocation ) { checkNotFrozen(); CheckArg.isNotNull(actualLocation, "actualLocation"); if (!actualLocation.hasPath()) { throw new IllegalArgumentException(GraphI18n.actualOldLocationMustHavePath.text(actualLocation)); } this.actualLocation = actualLocation; }
/** * Create a request to lock a branch or node * * @param workspaceName the name of the workspace containing the node; may not be null * @param target the location of the top node in the existing branch that is to be locked * @param lockScope the {@link LockBranchRequest#lockScope()} scope of the lock * @param lockTimeoutInMillis the number of milliseconds that the lock should last before the lock times out; zero (0) * indicates that the connector default should be used * @return this builder for method chaining; never null * @throws IllegalArgumentException if any of the parameters are null */ public BatchRequestBuilder lockBranch( String workspaceName, Location target, LockScope lockScope, long lockTimeoutInMillis ) { return add(new LockBranchRequest(target, workspaceName, lockScope, lockTimeoutInMillis)); }
@Override public void process( LockBranchRequest request ) { WorkspaceType workspace = getWorkspace(request, request.inWorkspace()); NodeType node = getTargetNode(workspace, request, request.at()); if (node == null) return; txn.lockNode(workspace, node, request.lockScope(), request.lockTimeoutInMillis()); Location actualLocation = getActualLocation(workspace, request.at(), node); request.setActualLocation(actualLocation); recordChange(request); }
@Override public void process( LockBranchRequest request ) { MapWorkspace workspace = getWorkspace(request, request.inWorkspace()); MapNode node = getTargetNode(workspace, request, request.at()); if (node == null) return; workspace.lockNode(node, request.lockScope(), request.lockTimeoutInMillis()); Location actualLocation = getActualLocation(request.at(), node); request.setActualLocation(actualLocation); recordChange(request); }
@Override public void process( LockBranchRequest request ) { PathWorkspace workspace = getWorkspace(request, request.inWorkspace()); PathNode node = getTargetNode(workspace, request, request.at()); if (node == null) return; workspace.lockNode(node, request.lockScope(), request.lockTimeoutInMillis()); request.setActualLocation(Location.create(node.getPath(), node.getUuid())); recordChange(request); }