/** * Get the {@link FederatedWorkspace workspace} information, given its name. * * @param name the name of the workspace, or null if the default workspace should be returned * @return the workspace * @throws InvalidWorkspaceException if the specified workspace does not exist */ public FederatedWorkspace getWorkspace( String name ) { if (name == null) { assert defaultWorkspace != null; return defaultWorkspace; } FederatedWorkspace workspace = workspacesByName.get(name); if (workspace == null) { String msg = GraphI18n.workspaceDoesNotExistInFederatedRepository.text(name, getSourceName()); throw new InvalidWorkspaceException(msg); } return workspace; }
protected WorkspaceType getWorkspace( Request request, String workspaceName ) { // Get the workspace for this request ... WorkspaceType workspace = repository.getWorkspace(txn, workspaceName); if (workspace == null) { String msg = GraphI18n.workspaceDoesNotExistInRepository.text(workspaceName, repository.getSourceName()); request.setError(new InvalidWorkspaceException(msg)); } return workspace; }
protected MapWorkspace getWorkspace( Request request, String workspaceName ) { // Get the workspace for this request ... MapWorkspace workspace = repository.getWorkspace(workspaceName); if (workspace == null) { String msg = GraphI18n.workspaceDoesNotExistInRepository.text(workspaceName, repository.getSourceName()); request.setError(new InvalidWorkspaceException(msg)); } return workspace; }
protected PathWorkspace getWorkspace( Request request, String workspaceName ) { // Get the workspace for this request ... PathWorkspace workspace = repository.getWorkspace(workspaceName); if (workspace == null) { String msg = GraphI18n.workspaceDoesNotExistInRepository.text(workspaceName, repository.getSourceName()); request.setError(new InvalidWorkspaceException(msg)); } return workspace; }
/** * {@inheritDoc} * * @see org.modeshape.graph.Graph.DestroyWorkspace#named(java.lang.String) */ public boolean named( String workspaceName ) { CheckArg.isNotNull(workspaceName, "workspaceName"); if (getCurrentWorkspaceName().equals(workspaceName)) { String msg = GraphI18n.currentWorkspaceCannotBeDeleted.text(workspaceName, getSourceName()); throw new InvalidWorkspaceException(msg); } DestroyWorkspaceRequest request = requests.destroyWorkspace(workspaceName); if (request.hasError()) return false; return true; } };
when(repository.getExecutor()).thenReturn(executor); when(repository.getConnectionFactory()).thenReturn(connectionFactory); when(repository.getWorkspace(nonExistantWorkspaceName)).thenThrow(new InvalidWorkspaceException());
@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)); } }
request.setError(new InvalidWorkspaceException(msg)); return; String msg = GraphI18n.workspaceDoesNotExistInRepository.text(nameOfWorkspaceToBeCloned, repository.getSourceName()); request.setError(new InvalidWorkspaceException(msg)); return; case SKIP_CLONE:
/** * {@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)); } }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.CreateWorkspaceRequest) */ @Override public void process( CreateWorkspaceRequest request ) { if (!creatingWorkspacesAllowed(request)) return; String clonedWorkspaceName = null; WorkspaceType workspace = repository.createWorkspace(txn, request.desiredNameOfNewWorkspace(), request.conflictBehavior(), clonedWorkspaceName); if (workspace == null) { String msg = GraphI18n.workspaceAlreadyExistsInRepository.text(request.desiredNameOfNewWorkspace(), repository.getSourceName()); request.setError(new InvalidWorkspaceException(msg)); } else { Node root = txn.getRootNode(workspace); request.setActualRootLocation(Location.create(pathFactory.createRootPath(), root.getUuid())); request.setActualWorkspaceName(workspace.getName()); recordChange(request); } }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.CreateWorkspaceRequest) */ @Override public void process( CreateWorkspaceRequest request ) { if (!updatesAllowed(request)) return; MapWorkspace workspace = repository.createWorkspace(getExecutionContext(), request.desiredNameOfNewWorkspace(), request.conflictBehavior()); if (workspace == null) { String msg = GraphI18n.workspaceAlreadyExistsInRepository.text(request.desiredNameOfNewWorkspace(), repository.getSourceName()); request.setError(new InvalidWorkspaceException(msg)); } else { MapNode root = workspace.getRoot(); request.setActualRootLocation(Location.create(pathFactory.createRootPath(), root.getUuid())); request.setActualWorkspaceName(workspace.getName()); recordChange(request); } }
request.setError(new InvalidWorkspaceException(msg)); return; String msg = GraphI18n.workspaceDoesNotExistInRepository.text(nameOfWorkspaceToBeCloned, repository.getSourceName()); request.setError(new InvalidWorkspaceException(msg)); return; case SKIP_CLONE:
@Override public void process( CreateWorkspaceRequest request ) { // There's a separate flag to allow creating workspaces (which may not require modifying existing data) // if (!updatesAllowed(request)) return; if (!repository.isWritable()) { String msg = GraphI18n.sourceIsReadOnly.text(repository.getSourceName()); request.setError(new InvalidRequestException(msg)); return; } WritablePathRepository writableRepo = (WritablePathRepository)repository; PathWorkspace workspace = writableRepo.createWorkspace(getExecutionContext(), request.desiredNameOfNewWorkspace(), request.conflictBehavior()); if (workspace == null) { String msg = GraphI18n.workspaceAlreadyExistsInRepository.text(request.desiredNameOfNewWorkspace(), repository.getSourceName()); request.setError(new InvalidWorkspaceException(msg)); } else { request.setActualRootLocation(Location.create(pathFactory.createRootPath(), repository.getRootNodeUuid())); request.setActualWorkspaceName(workspace.getName()); recordChange(request); } }
request.setError(new InvalidWorkspaceException(msg)); return; String msg = GraphI18n.workspaceDoesNotExistInRepository.text(nameOfWorkspaceToBeCloned, repository.getSourceName()); request.setError(new InvalidWorkspaceException(msg)); return; case SKIP_CLONE: