@Override public void recordRow( Node outputNode, String[] columns ) throws RepositoryException { Node rowNode = outputNode.addNode(ROW); for (String column : columns) { Node columnNode = rowNode.addNode(COLUMN); columnNode.addMixin(COLUMN); columnNode.setProperty(DATA, column); } } }
private Node createNode(String name, final String type) throws RepositoryException, WorkflowException { Node folder = rootSession.getNodeByIdentifier(subject.getIdentifier()); name = NodeNameCodec.encode(name); if (isSameNameSibling(name, folder)){ throw new WorkflowException(MessageFormat.format( "A node with name {0} already exists in folder {1}. Not allowed to create same-name siblings", name, folder.getPath())); } final Node handle = folder.addNode(name, NT_HANDLE); handle.addMixin(MIX_REFERENCEABLE); final Node document = handle.addNode(name, type); document.setProperty(HIPPO_AVAILABILITY, new String[] { "live", "preview" }); return document; }
@Test public void testIsAvailableForItemThatIsMarkedAsDeleted() throws RepositoryException { // GIVEN Node node = webSiteSession.getRootNode().addNode("node2", NodeTypes.Page.NAME); node.addMixin(NodeTypes.Deleted.NAME); // WHEN Object itemId = JcrItemUtil.getItemId(node); boolean isAvailable = rule.isAvailableForItem(itemId); // THEN assertTrue(isAvailable); }
@Test public void shouldNotAllowUpdatingNodesInReadOnlyProjection() throws Exception { Node file = session.getNode("/testRoot/readonly/dir3/simple.json"); try { file.addMixin("flex:anyProperties"); file.setProperty("extraProp", "extraValue"); session.save(); fail("failed to throw read-only exception"); } catch (RepositoryException e) { // expected } }
@Test public void shouldBeAbleToVersionOutsideOfUserTransaction() throws Exception { VersionManager vm = session.getWorkspace().getVersionManager(); Node node = session.getRootNode().addNode("Test3"); node.addMixin("mix:versionable"); node.setProperty("name", "lalalal"); node.setProperty("code", "lalalal"); session.save(); vm.checkin(node.getPath()); }
public void testLastModifiedBy() throws RepositoryException { Node testNode = testSession.getNode(testRoot); testNode.addMixin(NodeTypeConstants.MIX_LASTMODIFIED); testNode.setProperty(propertyName1, "any value"); testSession.save(); assertTrue(testNode.hasProperty(NodeTypeConstants.JCR_LASTMODIFIEDBY)); assertEquals(testSession.getUserID(), testNode.getProperty(NodeTypeConstants.JCR_LASTMODIFIEDBY).getString()); removeTestUser(); testSession.refresh(false); // EXERCISE: do you expect the property to be still present? explain why and fix the test if necessary. assertTrue(testNode.hasProperty(NodeTypeConstants.JCR_LASTMODIFIEDBY)); }
@Test public void testCugInvalidPrincipals() throws Exception { Node targetNode = getTargetNode(); targetNode.addMixin(CugConstants.MIX_REP_CUG_MIXIN); doImport(getTargetPath(), XML_CUG_POLICY); Node cugNode = targetNode.getNode(CugConstants.REP_CUG_POLICY); Value[] principalNames = cugNode.getProperty(CugConstants.REP_PRINCIPAL_NAMES).getValues(); assertPrincipalNames(ImmutableSet.of(EveryonePrincipal.NAME), principalNames); getImportSession().save(); }
@Test public void testIsAvailableForItemThatIsMarkedAsDeleted() throws RepositoryException { // GIVEN Node node = webSiteSession.getRootNode().addNode("node2", NodeTypes.Page.NAME); node.addMixin(NodeTypes.Deleted.NAME); // WHEN Object itemId = JcrItemUtil.getItemId(node); boolean isAvailable = rule.isAvailableForItem(itemId); // THEN assertFalse(isAvailable); }
@Test public void shouldAllowAdditionIfResidualPropertyDoesNotConflict() throws Exception { session.getRootNode().addNode("a", "nt:unstructured"); session.save(); Node rootNode = session.getRootNode(); Node nodeA = rootNode.getNode("a"); nodeA.setProperty(PROPERTY_B, 10L); assertThat(nodeA.canAddMixin(MIXIN_TYPE_WITH_AUTO_PROP), is(true)); nodeA.addMixin(MIXIN_TYPE_WITH_AUTO_PROP); }
public void testReferenceableChild() throws RepositoryException { Node node = testRootNode.addNode(nodeName1, ntUnstructured); node.addMixin(mixVersionable); Node child = node.addNode(nodeName2, ntUnstructured); child.addMixin(mixReferenceable); superuser.save(); VersionManager vMgr = superuser.getWorkspace().getVersionManager(); vMgr.checkin(node.getPath()); }
@Override public void recordRow( Node outputNode, String[] columns ) throws RepositoryException { Node rowNode = outputNode.addNode(ROW); for (String column : columns) { Node columnNode = rowNode.addNode(COLUMN); columnNode.addMixin(COLUMN); columnNode.setProperty(DATA, column); } } }
@Test public void testCugInvalidPrincipals() throws Exception { Node targetNode = getTargetNode(); targetNode.addMixin(CugConstants.MIX_REP_CUG_MIXIN); doImport(getTargetPath(), XML_CUG_POLICY); Node cugNode = targetNode.getNode(CugConstants.REP_CUG_POLICY); Value[] principalNames = cugNode.getProperty(CugConstants.REP_PRINCIPAL_NAMES).getValues(); assertPrincipalNames(PRINCIPAL_NAMES, principalNames); getImportSession().save(); }
@Test public void shouldAllowRemovalIfExistingChildNodeWouldHaveDefinition() throws Exception { Node a = session.getRootNode().addNode("a", "nt:unstructured"); a.addMixin(MIXIN_TYPE_B); a.addNode(CHILD_NODE_B); session.save(); Node rootNode = session.getRootNode(); Node nodeA = rootNode.getNode("a"); nodeA.removeMixin(MIXIN_TYPE_B); }
private static Node newRequestNode(Node parent) throws RepositoryException { JcrUtils.ensureIsCheckedOut(parent); Node requestNode = parent.addNode(HippoStdPubWfNodeType.HIPPO_REQUEST, HippoStdPubWfNodeType.NT_HIPPOSTDPUBWF_REQUEST); requestNode.setProperty(HippoStdPubWfNodeType.HIPPOSTDPUBWF_CREATION_DATE, Calendar.getInstance()); requestNode.addMixin(JcrConstants.MIX_REFERENCEABLE); return requestNode; }
@Test public void testCugValidPrincipals() throws Exception { testGroup = ((JackrabbitSession) adminSession).getUserManager().createGroup(new PrincipalImpl(TEST_GROUP_PRINCIPAL_NAME)); adminSession.save(); Node targetNode = getTargetNode(); targetNode.addMixin(CugConstants.MIX_REP_CUG_MIXIN); doImport(getTargetPath(), XML_CUG_POLICY); adminSession.save(); }
public void testRecreateVersionableNodeWithRemovedChild() throws Exception { Node node = testRootNode.addNode(nodeName1, ntUnstructured); node.addMixin(mixVersionable); node.addNode(nodeName2, ntUnstructured).setProperty(propertyName1, "foo"); superuser.save(); VersionManager vm = superuser.getWorkspace().getVersionManager(); vm.checkin(node.getPath()); // re-create node node.remove(); node = testRootNode.addNode(nodeName1, ntUnstructured); node.addMixin(mixVersionable); superuser.save(); }
protected void initializeData() throws Exception { Node root = session.getRootNode(); Node a = root.addNode("a"); Node b = a.addNode("b"); Node c = b.addNode("c"); a.addMixin("mix:lockable"); a.setProperty("stringProperty", "value"); b.addMixin("mix:referenceable"); b.setProperty("booleanProperty", true); c.setProperty("stringProperty", "value"); c.setProperty("multiLineProperty", MULTI_LINE_VALUE); session.save(); }