@Before @Override public void beforeEach() throws Exception { startRepositoryWithConfigurationFrom("config/repo-config-mock-federation.json"); testRoot = ((Node)session.getRootNode()).addNode("testRoot"); session.save(); federationManager = ((Workspace)session.getWorkspace()).getFederationManager(); }
/** * Application server calls this method to force any cleanup on the ManagedConnection instance. * * @throws ResourceException generic exception if operation fails */ @Override public void cleanup() throws ResourceException { this.session.logout(); this.session = openSession(); this.transactions = session.getRepository().transactions(); this.handles.clear(); }
void checkPermission( CachedNode node, NodeCache cache, String... actions ) throws AccessDeniedException { checkPermission(this.workspace().getName(), pathSupplierFor(node, cache), actions); }
public MergeCommand( AbstractJcrNode targetNode, JcrSession sourceSession, boolean bestEffort, boolean isShallow ) { this.targetNode = targetNode; this.sourceSession = sourceSession; this.cache = this.sourceSession.cache(); this.bestEffort = bestEffort; this.isShallow = isShallow; this.sourceWorkspaceName = sourceSession.getWorkspace().getName(); this.failures = new LinkedList<AbstractJcrNode>(); }
@Test public void shouldAllowCreatingNodesTwoLevelsBelowRoot() throws Exception { Node node = session.getRootNode().addNode("testNode"); session.save(); node.addNode("childNode"); session.save(); }
@Test @FixFor( "MODE-1807" ) public void shouldRegisterCNDFileWithResidualChildDefinition() throws Exception { session = createSession(); InputStream cndStream = getClass().getResourceAsStream("/cnd/orc.cnd"); assertThat(cndStream, is(notNullValue())); session.getWorkspace().getNodeTypeManager().registerNodeTypes(cndStream, true); session.getRootNode().addNode("patient", "orc:patient").addNode("patientcase", "orc:patientcase"); session.save(); assertNotNull(session.getNode("/patient/patientcase")); }
@Test @FixFor( "MODE-2424" ) public void shouldAllowAddingMixinOnLockedNodeForLockOwner() throws Exception { final AbstractJcrNode testNode = session.getRootNode().addNode("test"); final String path = testNode.getPath(); testNode.addMixin("mix:lockable"); session.save(); session.getWorkspace().getLockManager().lock(path, false, true, Long.MAX_VALUE, session.getUserID()); testNode.addMixin("mix:created"); session.save(); }
private void addNodeAndAssertIndexUsed(JcrRepository repository) throws RepositoryException, InterruptedException { JcrSession session = repository.login(); session.getRootNode().addNode("testRoot"); session.save(); Thread.sleep(100); String sql = "select [jcr:path] from [nt:unstructured] where [jcr:name] = 'testRoot'"; Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2); ValidateQuery.validateQuery().rowCount(1).useIndex("nodesByName").validate(query, query.execute()); session.logout(); }
@Override public void remove( String absPath ) throws UnsupportedOperationException, PathNotFoundException, VersionException, RepositoryException { if (LOGGER.isDebugEnabled()) LOGGER.debug("VersionManager.remove('{0}')", absPath); JcrSession removeSession = session.spawnSession(false); AbstractJcrNode node = removeSession.getNode(absPath); checkVersionable(node); SessionCache systemCache = session.createSystemCache(false); removeHistories(node, systemCache); node.remove(); removeSession.cache().save(systemCache, null); }
private void assertNotFound( String absPath, JcrSession jcrSession ) throws RepositoryException { try { jcrSession.getNode(absPath); fail("Node " + absPath + " should not have been found in the session " + session); } catch (PathNotFoundException e) { // expected } } }
@Test @FixFor( "MODE-2012" ) public void clonedUUIDsShouldBeTheSame() throws Exception { tools.registerNodeTypes(session, "cnd/references.cnd"); Node nodeA = session.getRootNode().addNode("A", "test:node"); Node nodeB = session.getRootNode().addNode("B", "test:node"); session.save(); otherWorkspace.clone("default", "/", "/", true); assertEquals(nodeA.getIdentifier(), otherSession.getNode("/A").getIdentifier()); assertEquals(nodeB.getIdentifier(), otherSession.getNode("/B").getIdentifier()); }
@Test public void shouldNotAllowRemovingNodesInReadOnlyProjection() throws Exception { Node file = session.getNode("/testRoot/readonly/dir3/simple.json"); try { session.refresh(false); file.remove(); session.save(); fail("failed to throw read-only exception"); } catch (RepositoryException e) { // expected } }
@Test public void shouldAllowValidReferenceValue() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_REFERENCE); Value value = session.getValueFactory().createValue(session.getRootNode()); assertThat(prop.satisfiesConstraints(value, session), is(true)); }
private void makeBackup(BackupOptions options) throws RepositoryException { TestingUtil.waitUntilFolderCleanedUp(backupDirectory.getPath()); JcrSession session = repository().login(); try { Problems problems = session.getWorkspace().getRepositoryManager().backupRepository(backupDirectory, options); assertNoProblems(problems); } finally { session.logout(); } }
@SuppressWarnings( "deprecation" ) @Test public void shouldBeAbleToExecuteXPathQueryToFindAllCarNodes() throws RepositoryException { Query query = session.getWorkspace().getQueryManager().createQuery("//element(*,car:Car)", Query.XPATH); QueryResult result = query.execute(); String[] columnNames = {"jcr:primaryType", "jcr:mixinTypes", "jcr:path", "jcr:score", "jcr:created", "jcr:createdBy", "jcr:name", "mode:localName", "mode:depth", "mode:id", "car:mpgCity", "car:userRating", "car:mpgHighway", "car:engine", "car:model", "car:year", "car:maker", "car:lengthInInches", "car:valueRating", "car:wheelbaseInInches", "car:msrp", "car:alternateModels"}; validateQuery().rowCount(13).hasColumns(columnNames).validate(query, result); }
protected final Value[] getJcrValues() throws RepositoryException { Value[] values = new Value[this.values.size()]; ValueFactory factory = session.getValueFactory(); int i = 0; for (String value : this.values) { values[i++] = factory.createValue(value); } this.values = new LinkedHashSet<String>(); return values; }
private void assertUniqueChildren( JcrSession session, String nodeAbsPath, Set<String> names ) throws RepositoryException { ChildReferences childReferences = session.getNode(nodeAbsPath).node().getChildReferences(session.cache()); for (String name : names) { assertEquals(1, childReferences.getChildCount(session.nameFactory().create(name))); } }