/** * {@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" : ""); }
/** * {@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; }
@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 ) { // Just update the actual location request.setActualLocation(actualLocationOf(request.at())); }
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)); }
/** * 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); }
/** * {@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 ) { 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); }
public void process( LockBranchRequest request ) { ProjectedNode projectedNode = project(request.at(), request.inWorkspace(), request, true); String msg = GraphI18n.unableToUpdatePlaceholder.text(readable(request.at()), request.inWorkspace(), getSourceName()); request.setError(new UnsupportedRequestException(msg));