@Override public String getNodeTypeName() throws RepositoryException { if (this.node.hasProperty(ItemType.JCR_FROZEN_PRIMARY_TYPE)) { return this.node.getProperty(ItemType.JCR_FROZEN_PRIMARY_TYPE).getString(); } return this.node.getProperty(ItemType.JCR_PRIMARY_TYPE).getString(); }
@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"); } } } });
Node defineStandardPropertyIndex(Session session) throws Exception { Node index = new OakIndexUtils.PropertyIndex().property(INDEXED_PROPERTY).create(session); if (index == null) { throw new RuntimeException( "Error while creating the index definition. index node is null."); } if (!PropertyIndexEditorProvider.TYPE.equals(index.getProperty( IndexConstants.TYPE_PROPERTY_NAME).getString())) { throw new RuntimeException("The type of the index does not match the expected"); } session.save(); return index; }
@Test public void testSetCreation() throws RepositoryException { // GIVEN final String userName = "Junit"; // WHEN NodeTypes.Created.set(first, userName, Calendar.getInstance()); // THEN assertTrue("Created should just have been set", (Calendar.getInstance().getTimeInMillis() - first.getProperty(NodeTypes.Created.CREATED).getDate().getTimeInMillis()) < 1000); assertEquals(first.getProperty(NodeTypes.Created.CREATED).getString(), first.getProperty(NodeTypes.LastModified.LAST_MODIFIED).getString()); assertEquals(userName, first.getProperty(NodeTypes.Created.CREATED_BY).getString()); assertEquals(userName, first.getProperty(NodeTypes.LastModified.LAST_MODIFIED_BY).getString()); }
@Test public void testCreatingAnExistingNodeDataDoesNotFail() throws Exception { Node content = getTestNode(); Property nodeData = content.setProperty("nd1", "other"); assertEquals("other", nodeData.getString()); }
@Test public void testChangePassword() throws RepositoryException, NotExecutableException { try { String hash = getNode(user, superuser).getProperty(UserConstants.REP_PASSWORD).getString(); user.changePassword("changed"); superuser.save(); assertFalse(hash.equals(getNode(user, superuser).getProperty(UserConstants.REP_PASSWORD).getString())); } catch (Exception e) { // success } }
public void testRemoveWithInvalidArg() throws Exception { cNode.setProperty("foo", "foo_value"); Map<String, Object> props = c.getProperties(); props.remove("foo"); assertEquals("foo_value", cNode.getProperty("foo").getString()); }
/** * Test the persistence of a property modified with a String parameter and * saved from the Session Requires a single-value String (PROP_VALUE_2) */ public void testStringSession() throws RepositoryException { property1.setValue(PROP_VALUE_2); superuser.save(); assertEquals("String node property not saved", PROP_VALUE_2, property1.getString()); }
/** * 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 testDoNotUpdateLastModifiedWhenUpdateLastAccess() throws Exception { // GIVEN Node testUser = session.getNode("/admin/test"); String lastModify = testUser.getProperty("mgnl:lastModified").getString(); // WHEN um.updateLastAccessTimestamp(um.newUserInstance(testUser)); // THEN assertNotEquals(StringUtils.EMPTY, testUser.getProperty("lastaccess").getString()); assertEquals(lastModify, testUser.getProperty("mgnl:lastModified").getString()); }
@Test public void testSettingAnExistingNodeData() throws Exception { Node content = getTestNode(); // this should not fail Value value = createValue("test"); Property nodeData = content.setProperty("nd1", value); assertEquals("test", nodeData.getString()); }
@Test public void testChangePasswordWithOldPassword() throws RepositoryException, NotExecutableException { try { String hash = getNode(user, superuser).getProperty(UserConstants.REP_PASSWORD).getString(); user.changePassword("changed", testPw); superuser.save(); assertFalse(hash.equals(getNode(user, superuser).getProperty(UserConstants.REP_PASSWORD).getString())); } finally { user.changePassword(testPw); superuser.save(); } }
/** * Returns the latest activated version name or null if the version name isn't set. */ public static String getLastActivatedVersion(Node node) throws RepositoryException { return node.hasProperty(LAST_ACTIVATED_VERSION) ? node.getProperty(LAST_ACTIVATED_VERSION).getString() : 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); }
public void testRemovedProperty() throws RepositoryException, LockException, ConstraintViolationException, VersionException { Property p = testRootNode.setProperty(propertyName1, testValue); testRootNode.save(); p.remove(); testRootNode.refresh(false); // Property p must be reverted to 'existing' -> getString must succeed. p.getString(); // similarly accessing the property again must succeed. testRootNode.getProperty(propertyName1); }
@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"); } } });
@Test public void testNodeFromStringAndObjectArray() throws Exception { // GIVEN Object[][] data = new String[][]{{"a", "a-value"}}; // WHEN Node result = NodeTestUtil.createNode("root", data); // THEN assertEquals("root", result.getName()); assertEquals("a-value", result.getProperty("a").getString()); }
@Test public void doNotOverride() throws Exception { // GIVEN sessionConfig.getRootNode().addNode("someSrcNode").setProperty("someProperty", "somePropertyValue"); sessionConfig.getRootNode().addNode("someDestNode").setProperty("someProperty", "someOldValue"); Task task = new CopyPropertyTask("name", RepositoryConstants.CONFIG, "/someSrcNode", "/someDestNode", "someProperty", false); // WHEN task.execute(installContext); // THEN assertTrue(sessionConfig.propertyExists("/someSrcNode/someProperty")); assertEquals("someOldValue", sessionConfig.getProperty("/someDestNode/someProperty").getString()); }
/** * Returns the comment set when then node was last versioned or null if no comment has been set. */ public static String getComment(Node node) throws RepositoryException { return node.hasProperty(COMMENT) ? node.getProperty(COMMENT).getString() : null; }
public void testRestoreRemovedJcr2() throws RepositoryException { String path = versionableNode.getPath(); Version v1 = versionManager.checkin(path); versionableNode.remove(); versionableNode = null; superuser.save(); versionManager.restore(path, v1, true); versionableNode = superuser.getNode(path); String value = versionableNode.getProperty(propertyName1).getString(); assertEquals("Restoring a node must set the correct property.", propertyValue2, value); }