/** * {@inheritDoc} * * @see java.lang.Object#toString() */ @Override public String toString() { String workspaceName = workspaceName() != null ? "'" + workspaceName() + "'" : "default"; return "destroy workspace " + workspaceName; }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.ChangeRequest#changes(java.lang.String, org.modeshape.graph.property.Path) */ @Override public boolean changes( String workspace, Path path ) { return workspaceName().equals(workspace); }
/** * {@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)) { DestroyWorkspaceRequest that = (DestroyWorkspaceRequest)obj; if (!this.workspaceName.equals(that.workspaceName())) return false; return true; } return false; }
@Override public void process( DestroyWorkspaceRequest request ) { if (!updatesAllowed(request)) return; PathWorkspace workspace = repository.getWorkspace(request.workspaceName()); if (workspace != null) { request.setActualRootLocation(Location.create(pathFactory.createRootPath(), repository.getRootNodeUuid())); recordChange(request); } else { String msg = GraphI18n.workspaceDoesNotExistInRepository.text(request.workspaceName(), repository.getSourceName()); request.setError(new InvalidWorkspaceException(msg)); } }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.DestroyWorkspaceRequest) */ @Override public void process( DestroyWorkspaceRequest request ) { if (!updatesAllowed(request)) return; MapWorkspace workspace = repository.getWorkspace(request.workspaceName()); if (workspace != null) { MapNode root = workspace.getRoot(); request.setActualRootLocation(Location.create(pathFactory.createRootPath(), root.getUuid())); recordChange(request); } else { String msg = GraphI18n.workspaceDoesNotExistInRepository.text(request.workspaceName(), repository.getSourceName()); request.setError(new InvalidWorkspaceException(msg)); } }
@Test public void shouldCreateValidRequestWithValidLocation() { request = new DestroyWorkspaceRequest(workspace1); assertThat(request.workspaceName(), is(workspace1)); assertThat(request.hasError(), is(false)); assertThat(request.getError(), is(nullValue())); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.DestroyWorkspaceRequest) */ @Override public void process( DestroyWorkspaceRequest request ) { if (!updatesAllowed(request)) return; WorkspaceType workspace = repository.getWorkspace(txn, request.workspaceName()); if (workspace != null) { Node root = txn.getRootNode(workspace); try { txn.destroyWorkspace(workspace); request.setActualRootLocation(Location.create(pathFactory.createRootPath(), root.getUuid())); recordChange(request); } catch (RuntimeException e) { request.setError(e); } } else { String msg = GraphI18n.workspaceDoesNotExistInRepository.text(request.workspaceName(), repository.getSourceName()); request.setError(new InvalidWorkspaceException(msg)); } }