public Object jsGet_long() { try { return property.getLong(); } catch (RepositoryException re) { return Undefined.instance; } }
@Override protected int getMaxResults() { try { if (content.hasProperty("maxResults")) { return (int) content.getProperty("maxResults").getLong(); } return Integer.MAX_VALUE; } catch (RepositoryException e) { return Integer.MAX_VALUE; } }
public static Long getLong(Node node, String name, Long defaultValue) { if (node != null) { try { if (node.hasProperty(name)) { return node.getProperty(name).getLong(); } } catch (RepositoryException e) { log.error("can't read value '{}' of the Node '{}' will return default value", name, node.toString(), e); } } return defaultValue; }
/** * Tests if adding a property with <code>Node.setProperty(String, * long)</code> works with <code>Session.save()</code> */ public void testNewLongPropertySession() throws Exception { testNode.setProperty(propertyName1, l1); superuser.save(); assertEquals("Setting property with Node.setProperty(String, long) and Session.save() not working", new Long(l1), new Long(testNode.getProperty(propertyName1).getLong())); }
/** * Tests if adding a property with <code>Node.setProperty(String, * long)</code> works with <code>parentNode.save()</code> */ public void testNewLongPropertyParent() throws Exception { testNode.setProperty(propertyName1, l1); testRootNode.getSession().save(); assertEquals("Setting property with Node.setProperty(String, long) and parentNode.save() not working", new Long(l1), new Long(testNode.getProperty(propertyName1).getLong())); }
public long getLongProperty(String name) { try { final Property property = getJCRProperty(name); if (property != null) { return property.getLong(); } } catch (RepositoryException re) { log.error(re.getMessage(), re); } return 0L; }
private ForumsWeeklyStatistic getForumsWeeklyStatistic(Node node) throws Exception { ForumsWeeklyStatistic statistic = new ForumsWeeklyStatistic(); statistic.setId(node.getName()); statistic.setStartDate(node.getProperty("exo:startDate").getDate().getTime()); statistic.setStartPostsCountOfWeek(node.getProperty("exo:startPostsCountOfWeek").getLong()); statistic.setPostsCountOfWeek(node.getProperty("exo:postsCountOfWeek").getLong()); statistic.setLastStatEntry(node.getProperty("exo:lastStatEntry").getDate().getTime()); return statistic; }
@Override public long getContentSize() { try { if (hasDescriptionProperty(CONTENT_SIZE)) { return getDescriptionProperty(CONTENT_SIZE).getLong(); } } catch (final RepositoryException e) { LOGGER.warn("Could not get contentSize(): {}", e.getMessage()); } return -1L; }
@Override public long getLong() { if (isExist()) { try { return getJCRProperty().getLong(); } catch (RepositoryException e) { throw new RuntimeException("Can't read value of nodedata " + toString(), e); } } return 0; }
public long getLong(Property property) throws RepositoryException { if (getPrevious() != null) { return getPrevious().getLong(property); } else { return property.getLong(); } }
@Override protected void entering(Node node, int level) throws RepositoryException { if (node.isNodeType("rep:Permissions") && node.hasProperty("rep:accessControlledPath") && path.equals(node.getProperty("rep:accessControlledPath").getString())) { assertEquals(index, node.getProperty("rep:index").getLong()); assertEquals(isAllow, node.getProperty("rep:isAllow").getBoolean()); } } };
private static void assertCounter(@NotNull final Node counter, final long expectedCount) throws RepositoryException { checkNotNull(counter); assertTrue(counter.hasProperty(PROP_COUNTER)); assertEquals(expectedCount, counter.getProperty(PROP_COUNTER).getLong()); assertFalse(counter.hasProperty(PROP_INCREMENT)); }
protected void assertFile( Node node, File file ) throws Exception { assertThat(node.getName(), is(file.getName())); assertThat(node.getIndex(), is(1)); assertThat(node.getPrimaryNodeType().getName(), is("nt:file")); assertThat(node.getProperty("jcr:created").getLong(), is(createdTimeFor(file))); Node content = node.getNode("jcr:content"); assertThat(content.getName(), is("jcr:content")); assertThat(content.getIndex(), is(1)); assertThat(content.getPrimaryNodeType().getName(), is("nt:resource")); assertThat(content.getProperty("jcr:lastModified").getLong(), is(file.lastModified())); }
@Test public void shouldSequenceTextTemplate() throws Exception { // GIVEN String filename = "text.ott"; // WHEN createNodeWithContentFromFile(filename, filename); // THEN Node sequencedNode = getOutputNode(rootNode, "sequenced/odf/" + filename); assertThat(sequencedNode.getProperty(JcrConstants.JCR_MIME_TYPE).getString(), is("application/vnd.oasis.opendocument.text-template")); assertThat(sequencedNode.getProperty(PAGES).getLong(), is(2L)); assertCommonMetadata(sequencedNode); }
private void checkACL(String path, long right, String permissionNodeName) throws RepositoryException { assertTrue(userRoleSession.nodeExists("/superuser/acl_userroles")); aclUserrolesNode = userRoleSession.getNode("/superuser/acl_userroles"); assertTrue(aclUserrolesNode.hasNode(permissionNodeName)); Node permission = aclUserrolesNode.getNode(permissionNodeName); assertTrue(permission.hasProperty("path")); assertEquals(path, permission.getProperty("path").getString()); assertTrue(permission.hasProperty("permissions")); assertEquals(right, permission.getProperty("permissions").getLong()); } }
@Test public void setPropertyToInteger() throws Exception { // GIVEN final int value = 123; PropertyUtil.setProperty(root, PROPERTY_NAME, value); // WHEN Long longValue = root.getProperty(PROPERTY_NAME).getLong(); // THEN assertEquals(value, longValue.intValue()); }
@Test public void setPropertyToLong() throws Exception { // GIVEN final Object value = Long.valueOf(123l); PropertyUtil.setProperty(root, PROPERTY_NAME, value); // WHEN long resr = root.getProperty(PROPERTY_NAME).getLong(); // THEN assertEquals(value, resr); }
public void testReset() throws Exception { TokenInfo info = tokenProvider.createToken(testuser, new SimpleCredentials(userId, userId.toCharArray())); long expTime = getTokenNode(info).getProperty("rep:token.exp").getLong(); long loginTime = waitForSystemTimeIncrement(System.currentTimeMillis()); assertFalse(info.resetExpiration(loginTime)); assertFalse(info.resetExpiration(loginTime + TokenBasedAuthentication.TOKEN_EXPIRATION)); assertTrue(info.resetExpiration(loginTime + TokenBasedAuthentication.TOKEN_EXPIRATION / 2)); long expTime2 = getTokenNode(info).getProperty("rep:token.exp").getLong(); assertFalse(expTime == expTime2); }
@Test public void shouldCreateProjectionWithoutAlias() throws Exception { // link the first external document federationManager.createProjection("/testRoot", SOURCE_NAME, MockConnector.DOC1_LOCATION, null); assertEquals(1, testRoot.getNodes().getSize()); Node doc1Federated = assertNodeFound("/testRoot" + MockConnector.DOC1_LOCATION); assertEquals(testRoot.getIdentifier(), doc1Federated.getParent().getIdentifier()); assertEquals("a string", doc1Federated.getProperty("federated1_prop1").getString()); assertEquals(12, doc1Federated.getProperty("federated1_prop2").getLong()); }