@Override public void createWorkspace( String name, String srcWorkspace ) throws AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchWorkspaceException, RepositoryException { validateCrossWorkspaceAction(srcWorkspace); createWorkspace(name); JcrSession newWorkspaceSession = session.spawnSession(name, false); JcrSession srcWorkspaceSession = session.spawnSession(srcWorkspace, true); deepClone(srcWorkspaceSession, srcWorkspaceSession.getRootNode().key(), newWorkspaceSession, newWorkspaceSession.getRootNode().key()); }
@Override public void createWorkspace( String name, String srcWorkspace ) throws AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchWorkspaceException, RepositoryException { validateCrossWorkspaceAction(srcWorkspace); createWorkspace(name); JcrSession newWorkspaceSession = session.spawnSession(name, false); JcrSession srcWorkspaceSession = session.spawnSession(srcWorkspace, true); deepClone(srcWorkspaceSession, srcWorkspaceSession.getRootNode().key(), newWorkspaceSession, newWorkspaceSession.getRootNode().key()); }
@Override @Before public void beforeEach() throws Exception { super.beforeEach(); Node root = session.getRootNode(); Node a = root.addNode("a"); Node ab = a.addNode("b", "nt:unstructured"); Node abc = ab.addNode("c"); Node b = root.addNode("b"); abc.setProperty("stringProperty", "value"); session.save(); assertThat(b, is(notNullValue())); workspace = session.getWorkspace(); workspaceName = workspace.getName(); otherWorkspaceName = "anotherWs"; workspace.createWorkspace(otherWorkspaceName); otherSession = repository.login(otherWorkspaceName); otherWorkspace = otherSession.getWorkspace(); }
protected void importIntoWorkspace( String workspaceName, String resourcePath ) throws IOException, RepositoryException { Session session = null; try { session = repository().login(workspaceName); } catch (NoSuchWorkspaceException e) { // Create the workspace ... session().getWorkspace().createWorkspace(workspaceName); // Create a new session ... session = repository().login(workspaceName); } try { importContent(session.getRootNode(), resourcePath, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW); } finally { session.logout(); } } }
protected void addFilesToWorkspace(String workspaceName) throws Exception { Session session = null; try { session = repository().login(workspaceName); } catch (NoSuchWorkspaceException e) { // Create the workspace ... session().getWorkspace().createWorkspace(workspaceName); // Create a new session ... session = repository().login(workspaceName); } try { for (int i = 0; i < BINARY_RESOURCES.length; i++) { tools.uploadFile(session, "file_" + i, resourceStream(BINARY_RESOURCES[i])); } session.save(); } finally { session.logout(); } }
@Test public void shouldAllowCreatingNewWorkspacesByDefault() throws Exception { // Verify the workspace does not exist yet ... try { repository.login("new-workspace"); } catch (NoSuchWorkspaceException e) { // expected } JcrSession session1 = repository.login(); assertThat(session1.getRootNode(), is(notNullValue())); session1.getWorkspace().createWorkspace("new-workspace"); // Now create a session to that workspace ... JcrSession session2 = repository.login("new-workspace"); assertThat(session2.getRootNode(), is(notNullValue())); }
@Test public void shouldAllowDestroyingWorkspacesByDefault() throws Exception { // Verify the workspace does not exist yet ... try { repository.login("new-workspace"); } catch (NoSuchWorkspaceException e) { // expected } JcrSession session1 = repository.login(); assertThat(session1.getRootNode(), is(notNullValue())); session1.getWorkspace().createWorkspace("new-workspace"); // Now create a session to that workspace ... JcrSession session2 = repository.login("new-workspace"); assertThat(session2.getRootNode(), is(notNullValue())); }
@Test public void shouldImportInitialContentForAllWorkspaceConfigurations() throws Exception { startRepositoryWithConfigurationFrom("config/repo-config-initial-content.json"); //preconfigured ws String ws1 = "ws1"; assertCarsWithMixins(ws1); //preconfigured ws String ws2 = "ws2"; assertFilesAndFolders(ws2); //default ws String defaultWs = "default"; assertCarsWithoutNamespace(defaultWs); //create a new ws that has been configured with an empty import String ws4 = "ws4"; session.getWorkspace().createWorkspace(ws4); JcrSession ws4Session = repository.login(ws4); NodeIterator rootIterator = ws4Session.getNode("/").getNodes(); assertEquals("Expected an empty workspace", 1, rootIterator.getSize()); //create a new ws that has been configured the same as ws2 String ws5 = "ws5"; session.getWorkspace().createWorkspace(ws5); assertFilesAndFolders(ws5); //create a new ws that doesn't have a dedicated config, but should fall back to default String ws6 = "ws6"; session.getWorkspace().createWorkspace(ws6); assertCarsWithMixins(ws6); }
@BeforeClass public static final void beforeAll() throws Exception { MultiUseAbstractTest.beforeAll(); // Import the node types and the data ... registerNodeTypes("cars.cnd"); importContent("/", "io/cars-system-view-with-uuids.xml", ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW); // Create a binary property ... Node node = session.getRootNode().addNode("nodeWithBinaryProperty", "nt:unstructured"); String value = "This is the string value"; Binary binaryValue = session.getValueFactory().createBinary(new ByteArrayInputStream(value.getBytes())); node.setProperty("binProp", binaryValue); session.save(); // Create a new workspace and import the data ... session.getWorkspace().createWorkspace("workspace2"); JcrSession session2 = repository.login("workspace2"); AbstractJcrNode session2Root = session2.getRootNode(); importContent(session2Root, "io/cars-system-view-with-uuids.xml", ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW); }
@FixFor( "MODE-2371" ) @Test public void shouldInitializeWorkspacesWithOngoingUserTransaction() throws Exception { startRepositoryWithConfigurationFrom("config/repo-config-inmemory-txn.json"); startTransaction(); // the active tx should be suspended for the next call Session otherSession = repository.login("otherWorkspace"); otherSession.logout(); commitTransaction(); startTransaction(); session.getWorkspace().createWorkspace("newWS"); session.logout(); commitTransaction(); otherSession = repository.login("newWS"); otherSession.logout(); startTransaction(); session = repository.login(); session.getWorkspace().createWorkspace("newWS1"); session.logout(); otherSession = repository.login("newWS1"); otherSession.logout(); commitTransaction(); }
public void shouldRemoveAllNodesWhenRemovingWorkspace() throws Exception { final String wsName = "testWS"; workspace.createWorkspace(wsName); JcrSession testWsSession = repository.login(wsName); testWsSession.getRootNode().addNode("testRoot").addNode("subNode"); workspaceDeletedLatch.await(10, TimeUnit.SECONDS); workspace.createWorkspace(wsName); testWsSession = repository.login(wsName); assertNotNull(testWsSession.getNode("/jcr:system"));
session.getWorkspace().createWorkspace("QA", session.getWorkspace().getName()); Session sessionQa = repository.login("QA"); try {
session.getWorkspace().createWorkspace("QA", session.getWorkspace().getName()); Session sessionQa = repository.login("QA"); VersionManager versionManagerQa = sessionQa.getWorkspace().getVersionManager();
session.getWorkspace().createWorkspace("QA", session.getWorkspace().getName()); Session sessionQa = repository.login("QA"); try {
session.getWorkspace().createWorkspace("QA", session.getWorkspace().getName()); Session sessionQa = repository.login("QA"); VersionManager versionManagerQa = sessionQa.getWorkspace().getVersionManager();
session.getWorkspace().createWorkspace(newWorkspaceName); assertAccessibleWorkspace(session, newWorkspaceName); assertAccessibleWorkspace(session2, newWorkspaceName);
@Test @FixFor( "MODE-2109 ") public void shouldOnlyAllowCloningInSomeCases() throws Exception { session.getWorkspace().createWorkspace("other");
@Test @FixFor( "MODE-2109" ) public void shouldOnlyAllowCopyingInSomeCases() throws Exception { session.getWorkspace().createWorkspace("other");
@Test @FixFor( "MODE-2100" ) public void shouldAddPredefinedWorkspacesOnRestartViaConfigChange() throws Exception{ startRunStop(repository -> { JcrSession session = repository.login("ws1"); session.getWorkspace().createWorkspace("ws3"); session.logout(); session = repository.login("ws3"); session.logout(); }, "config/repo-config-persistent-predefined-ws.json"); startRunStop(repository -> { JcrSession session = repository.login("default"); session.logout(); session = repository.login("ws1"); session.logout(); session = repository.login("ws2"); session.logout(); session = repository.login("ws3"); session.logout(); }, "config/repo-config-persistent-predefined-ws-update.json"); startRunStop(repository -> repository.login("ws2").logout(), "config/repo-config-persistent-predefined-ws.json"); }
session.logout(); session = repository.login("ws1"); session.getWorkspace().createWorkspace("ws2"); session.logout(); session = repository.login("ws2");