/** * Returns the name of the user that last activated the node or null if no activating user has been stored on the node. */ public static String getLastActivatedBy(Node node) throws RepositoryException { return node.hasProperty(LAST_ACTIVATED_BY) ? node.getProperty(LAST_ACTIVATED_BY).getString() : null; }
@Override protected void leaving(Node node, int level) throws RepositoryException { if (node.hasProperty("hipposys:nodetype")) { if ("hipposys:request".equals(node.getProperty("hipposys:nodetype").getString())) { node.setProperty("hipposys:nodetype", "hippostdpubwf:request"); } else if ("hippostd:publishable".equals(node.getProperty("hipposys:nodetype").getString())) { node.setProperty("hipposys:nodetype", "hippostdpubwf:document"); } } } });
private boolean permissionExists(Node aclNode, String path) throws RepositoryException { NodeIterator children = aclNode.getNodes(); while (children.hasNext()) { Node child = children.nextNode(); if (child.hasProperty("path") && child.getProperty("path").getString().equals(path)) { return true; } } return false; } }
public static String getDefaultPosition(final Node editorTemplate) throws RepositoryException { final Node root = editorTemplate.getNode("root"); if (root.hasProperty("wicket.extensions")) { final Value[] extensions = root.getProperty("wicket.extensions").getValues(); return root.getProperty(extensions[0].getString()).getString() + ".item"; } return "${cluster.id}.field"; }
/** * @return the lastModification or null it it was not set in JCR. * @deprecated since 5.0 use {@link info.magnolia.jcr.util.NodeTypes.LastModified#getLastModified(javax.jcr.Node)}. */ public static Calendar getLastModification(Node node) throws PathNotFoundException, RepositoryException, ValueFormatException { Node meta = node.getNode(MetaData.DEFAULT_META_NODE); String lastMod = RepositoryConstants.NAMESPACE_PREFIX + ":" + MetaData.LAST_MODIFIED; return (meta.hasProperty(lastMod)) ? meta.getProperty(lastMod).getDate() : null; }
@SuppressWarnings("deprecation") public void testRestoreRemoved() throws RepositoryException { Node parent = versionableNode.getParent(); String oldName = versionableNode.getName(); Version v1 = versionableNode.checkin(); versionableNode.remove(); versionableNode = null; parent.getSession().save(); parent.restore(v1, oldName, true); versionableNode = parent.getNode(oldName); String value = versionableNode.getProperty(propertyName1).getString(); assertEquals("Restoring a node must set the correct property.", propertyValue2, value); }
@Test public void setPropertyStringStringInt() throws RepositoryException { // GIVEN Node node = MgnlContext.getJCRSession("website").getRootNode().addNode("test", MgnlNodeType.NT_CONTENT); assertTrue(NodeUtil.isWrappedWith(node, MgnlAuditLoggingContentDecoratorNodeWrapper.class)); // WHEN node.setProperty("test", "true", PropertyType.BOOLEAN); // THEN assertEquals(PropertyType.BOOLEAN, node.getProperty("test").getType()); }
@Test public void testNodeWithCugInvalidPrincipals() throws Exception { doImport(getTargetPath(), XML_CHILD_WITH_CUG); Node cugNode = getTargetNode().getNode("child").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 testNodeFromStringAndStrings() throws Exception { // GIVEN String string1 = "/root/sub1.prop1=one"; String string2 = "/root/sub1.prop2=two"; // WHEN Node result = NodeTestUtil.createNode("root", "testWorkspace", string1, string2); // THEN assertEquals("root", result.getName()); assertEquals("one", result.getNode("/sub1").getProperty("prop1").getString()); assertEquals("two", result.getNode("/sub1").getProperty("prop2").getString()); }
public void removeProperty(String key) throws RepositoryException { Node parent = getParent(key); Property p = parent.getProperty(key); p.remove(); treeManager.join(this, parent, p); if (autoSave) { parent.getSession().save(); } }
public void testGetTypeOfPredecessors() throws RepositoryException { Node node = testRootNode.addNode(nodeName1, testNodeType); node.addMixin(mixVersionable); superuser.save(); VersionManager vMgr = superuser.getWorkspace().getVersionManager(); vMgr.checkin(node.getPath()); assertEquals(PropertyType.nameFromValue(PropertyType.REFERENCE), PropertyType.nameFromValue(node.getProperty(jcrPredecessors).getType())); }
@Override protected void leaving(Node node, int level) throws RepositoryException { if (node.hasProperty("hipposys:value") && node.getProperty("hipposys:value").getString().equals("hippo:facetsubsearch")) { node.setProperty("hipposys:value", "hipposys:facetsubsearch"); } } });
public static String getDefaultPosition(final Node editorTemplate) throws RepositoryException { final Node root = editorTemplate.getNode("root"); if (root.hasProperty("wicket.extensions")) { final Value[] extensions = root.getProperty("wicket.extensions").getValues(); return root.getProperty(extensions[0].getString()).getString() + ".item"; } return "${cluster.id}.field"; }
/** * Returns the name of the user that created a node. */ public static String getCreatedBy(Node node) throws RepositoryException { return node.hasProperty(CREATED_BY) ? node.getProperty(CREATED_BY).getString() : null; }
@Override public boolean hasNodeData(String name) throws RepositoryException { if (this.node.hasProperty(name)) { return true; } if (this.node.hasNode(name) && this.node.getNode(name).getProperty("jcr:frozenPrimaryType").getValue().getString().equals(ItemType.NT_RESOURCE)) { return true; } return false; }
@Test public void setPropertyStringValueArrayInt() throws RepositoryException { // GIVEN Node node = MgnlContext.getJCRSession("website").getRootNode().addNode("test", MgnlNodeType.NT_CONTENT); assertTrue(NodeUtil.isWrappedWith(node, MgnlAuditLoggingContentDecoratorNodeWrapper.class)); Value[] values = {ValueFactoryImpl.getInstance().createValue("true")}; // WHEN node.setProperty("test", values, PropertyType.BOOLEAN); // THEN assertEquals(PropertyType.BOOLEAN, node.getProperty("test").getType()); }
@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(); }
public void testChildInSubTree() throws Exception { Node frozenN1 = frozen.getNode(nodeName1); Node frozenN2 = frozenN1.getNode(nodeName2); assertEquals(NT_VERSIONEDCHILD, frozenN2.getPrimaryNodeType().getName()); Property childVh = frozenN2.getProperty(JCR_CHILD_VERSION_HISTORY); assertEquals(versionManager.getVersionHistory(testRoot + '/' + nodeName1 + '/' + nodeName2).getUUID(), childVh.getString()); Node frozenN3 = frozenN1.getNode(nodeName3); assertEquals(NT_FROZENNODE, frozenN3.getPrimaryNodeType().getName()); } }
/** * Replace a Property value. */ public static void updatePropertyIfExist(Node node, String propertyName, String oldValue, String newValue) throws RepositoryException { if(node.hasProperty(propertyName) && oldValue.equals(node.getProperty(propertyName).getString())){ node.setProperty(propertyName, newValue); } }
@Test public void testCreationOfFieldSubNode() throws RepositoryException, TaskExecutionException { // GIVEN // WHEN queryTask.execute(installContext); // THEN assertTrue(field.hasNode("field")); assertTrue(field.getNode("field").hasProperty("class")); assertEquals(LinkFieldDefinition.class.getName(), field.getNode("field").getProperty("class").getString()); }