/** * Returns the node as it was at the given version. * * @param version * version to get * @return node at version */ private static Node getNodeAtVersion( final PentahoJcrConstants pentahoJcrConstants, final Version version ) throws RepositoryException { return version.getNode( pentahoJcrConstants.getJCR_FROZENNODE() ); }
/** * Tests if <code>Version.getNode(String)</code> returns the right child * Node */ public void testGetNode() throws Exception { assertTrue("Version.getNode(String) does not return a sub-node of type nt:frozenNode", version.getNode(jcrFrozenNode).isNodeType(ntFrozenNode)); }
public JcrVersion(Version version) throws RepositoryException { // storing node's properties into variables to reduce 'throws' for // getters Node frozen = version.getNode(JcrNT.FROZEN_NODE); initVersion(frozen); lastModified = version.getProperty("jcr:created").getDate().getTime(); }
/** * Tests if the jcr:frozenUuid property has the correct type * @throws Exception */ public void testFrozenUUID() throws Exception { Property p = version.getNode(jcrFrozenNode).getProperty(jcrFrozenUuid); assertEquals("jcr:fronzenUuid should be of type string", PropertyType.TYPENAME_STRING, PropertyType.nameFromValue(p.getType())); } }
public JcrVersion(Version version) throws RepositoryException { // storing node's properties into variables to reduce 'throws' for // getters Node frozen = version.getNode(JcrNT.FROZEN_NODE); initVersion(frozen); lastModified = version.getProperty("jcr:created").getDate().getTime(); }
public VersionedNode(Version versionedNode, Node baseNode) throws PathNotFoundException, RepositoryException { super(versionedNode.getNode(MgnlNodeType.JCR_FROZENNODE), new VersionedNodeContentDecorator()); ((VersionedNodeContentDecorator) getContentDecorator()).setVersionedNode(this); this.version = versionedNode; this.baseNode = baseNode; }
/** * Set frozen node of this version as working node. */ private void init() throws RepositoryException { this.setNode(this.state.getNode(ItemType.JCR_FROZENNODE)); try { if (!StringUtils.equalsIgnoreCase(this.state.getName(), VersionManager.ROOT_VERSION)) { this.rule = VersionManager.getInstance().getUsedFilter(this.getJCRNode()); } } catch (Exception e) { log.error(e.getMessage(), e); } if (this.rule == null) { log.info("failed to get filter used for creating this version, use open filter"); this.rule = new Rule(); } }
handleVersion = handleIter.nextVersion(); if (!handleVersion.getName().equals("jcr:rootVersion")) { variantIterator = handleVersion.getNode("jcr:frozenNode").getNodes(); break; boolean match = true; for (Map.Entry<String, String> entry : criteria.entrySet()) { Node variant = version.getNode("jcr:frozenNode"); if (!variant.hasProperty(entry.getKey()) || !variant.getProperty(entry.getKey()).getString().equals(entry.getValue())) {
@Test public void testUnwrap() throws Exception { final Version version = mock(Version.class); when(version.getNode(JcrConstants.JCR_FROZENNODE)).thenReturn(root); final VersionedNode wrapper = new VersionedNode(version, root); assertEquals(root, NodeUtil.unwrap(wrapper)); }
Node content = variant.getNode("jcr:frozenNode"); if (content.hasProperty("hippostd:state") && "draft".equals(content.getProperty("hippostd:state").getString())) {
Node node = version.getNode("jcr:frozenNode"); Calendar nodeCreated = version.getProperty("jcr:created").getDate(); if (!node.hasProperty(HippoNodeType.HIPPO_PATHS)) {
for (Value v : unwrappedVersion.getNode(JcrConstants.JCR_FROZENNODE).getProperty("jcr:frozenMixinTypes").getValues()) { mixins.add(v.getString());
/** * Tests if after each checkin an additional node is returned in a result * of a query. */ public void testCheckin() throws RepositoryException { // current time Calendar c = Calendar.getInstance(); Node n1 = testRootNode.addNode(nodeName1); n1.setProperty(propertyName1, c); n1.addMixin(mixVersionable); testRootNode.save(); String statement = "//*[@" + propertyName1 + "=xs:dateTime('" + n1.getProperty(propertyName1).getString() + "')]"; Node v1 = n1.checkin().getNode(jcrFrozenNode); executeXPathQuery(statement, new Node[]{n1,v1}); n1.checkout(); Node v2 = n1.checkin().getNode(jcrFrozenNode); executeXPathQuery(statement, new Node[]{n1,v1,v2}); n1.checkout(); Node v3 = n1.checkin().getNode(jcrFrozenNode); executeXPathQuery(statement, new Node[]{n1,v1,v2,v3}); } }
Version[] mockVersionsList2 = { mockVersion }; when( mockVersion.getSuccessors() ).thenReturn( mockVersionsList, mockVersionsList2, null ); when( mockVersion.getNode( (String) anyObject() ) ).thenReturn( versionNode ); when( mockVersion.getName() ).thenReturn( versionName ); when( mockVersion.getCreated() ).thenReturn( cal );
@Test public void createVersionedNode() throws Exception{ Node asset = JcrUtils.getOrCreateByPath("/bundlingtest/foo.png", "oak:Unstructured", "oak:Asset", s, false); asset.addMixin(JcrConstants.MIX_VERSIONABLE); Node content = asset.addNode("jcr:content", "oak:Unstructured"); content.addNode("metadata", "oak:Unstructured"); s.save(); VersionManager vm = s.getWorkspace().getVersionManager(); String assetPath = asset.getPath(); vm.checkin(assetPath); String versionedPath = vm.getBaseVersion(assetPath).getNode("jcr:frozenNode").getPath(); //Both normal node and versioned nodes should be bundled assertNull(getNodeDocument(concat(assetPath, "jcr:content"))); assertNull(getNodeDocument(concat(versionedPath, "jcr:content"))); }
/** * Checks if jcr:deref works when dereferencing into the version storage. */ public void testDerefToVersionNode() throws RepositoryException { Node referenced = testRootNode.addNode(nodeName1); referenced.addMixin(mixVersionable); testRootNode.save(); Version version = referenced.checkin(); Node referencedVersionNode = version.getNode(jcrFrozenNode); Node referencer = testRootNode.addNode(nodeName2); referencer.setProperty(propertyName1, referencedVersionNode); testRootNode.save(); String query = "/" + testRoot + "/*[@" + propertyName1 + "]/jcr:deref(@" + propertyName1 + ",'*')"; QueryManager qm = superuser.getWorkspace().getQueryManager(); Query q = qm.createQuery(query, Query.XPATH); QueryResult qr = q.execute(); NodeIterator ni = qr.getNodes(); assertEquals("Must find one result in query", 1, ni.getSize()); while (ni.hasNext()) { Node node = (Node) ni.next(); assertTrue(node.getProperty("jcr:frozenUuid").getString().equals(referenced.getUUID())); } }
@Test public void sourceWorkspaceIsSavedForVersionInMetaData() throws Exception { // GIVEN prepareForTestNodesWithSameIdentifiers(websiteSession, usersSession, "test"); // WHEN Version version = versionManager.getVersion(websiteSession.getNode("/test"), "1.0"); // THEN assertThat(version.getNode(BaseVersionManager.SYSTEM_NODE), hasProperty(BaseVersionManager.SOURCE_WORKSPACE, RepositoryConstants.WEBSITE)); // WHEN version = versionManager.getVersion(usersSession.getNode("/test"), "1.3"); // THEN assertThat(version.getNode(BaseVersionManager.SYSTEM_NODE), hasProperty(BaseVersionManager.SOURCE_WORKSPACE, RepositoryConstants.USERS)); }
protected static Node getNode4Version(Node node, CommonVersion version) throws RepositoryException { Node result = null; VersionHistory vh = node.getVersionHistory(); VersionIterator vi = vh.getAllVersions(); while (vi.hasNext()) { Version jcrVersion = vi.nextVersion(); if (NodeUtil.isRootVersion(jcrVersion)) { // TODO Shall we add first (0) version? (It is marker like, no // real values) } else { JcrVersion jvi = new JcrVersion(jcrVersion); CommonVersionImpl cv = new CommonVersionImpl(jvi.getRevision()); if (cv.compareTo(version) == 0) { result = jcrVersion.getNode(JcrNT.FROZEN_NODE); break; } } } if (result == null) { throw new RepositoryException("Cannot find version '" + version.getVersionName() + "'!"); } return result; }
protected static Node getNode4Version(Node node, CommonVersion version) throws RepositoryException { Node result = null; VersionHistory vh = node.getVersionHistory(); VersionIterator vi = vh.getAllVersions(); while (vi.hasNext()) { Version jcrVersion = vi.nextVersion(); if (NodeUtil.isRootVersion(jcrVersion)) { // TODO Shall we add first (0) version? (It is marker like, no // real values) } else { JcrVersion jvi = new JcrVersion(jcrVersion); CommonVersionImpl cv = new CommonVersionImpl(jvi.getRevision()); if (cv.compareTo(version) == 0) { result = jcrVersion.getNode(JcrNT.FROZEN_NODE); break; } } } if (result == null) { throw new RepositoryException("Cannot find version '" + version.getVersionName() + "'!"); } return result; }