/** * Gets the {@link ValueFactory} from the {@link Session} * * @param node the {@link Node} from which to get the {@link Session} * * @return a {@link ValueFactory} * * @throws RepositoryException In case something goes wrong while trying to get the {@link Session} or {@link ValueFactory} */ public static ValueFactory getValueFactory(Node node) throws RepositoryException { return node.getSession().getValueFactory(); } }
protected void _setReferenced(Node referent, String propertyName, Node referenced) throws RepositoryException { if (referenced != null) { String path = referenced.getPath(); ValueFactory valueFactory = session.getValueFactory(); Value value = valueFactory.createValue(path, PropertyType.PATH); referent.setProperty(propertyName, value); } else { referent.setProperty(propertyName, (String)null); } }
protected void setUp() throws Exception { super.setUp(); // initialize some date value value = superuser.getValueFactory().createValue(GregorianCalendar.getInstance()); // create a new node under the testRootNode node = testRootNode.addNode(nodeName1, testNodeType); // create a new single-value property and save it Calendar initialValue = GregorianCalendar.getInstance(); initialValue.setTimeInMillis(0); property1 = node.setProperty(propertyName1, initialValue); superuser.save(); }
public final Property set(Node node, String name, Object value) throws RepositoryException { Value v = wrap(node.getSession().getValueFactory(), value); if (v != null) { try { return node.setProperty(name, v); } catch (ValueFormatException e) { return node.setProperty(name, new Value[]{v}); } } return null; }
public void testReferenceLiteral() throws RepositoryException, NotExecutableException { ensureMixinType(node1, mixReferenceable); superuser.save(); Value literal = superuser.getValueFactory().createValue(node1); QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal); checkQOM(qom, new Node[]{}); }
/** * Test if versionable node N's jcr:baseVersion property is set to refer to * the new version after checkin. * * @throws RepositoryException */ public void testBaseVersionAfterCheckinJcr2() throws RepositoryException { VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager(); String path = versionableNode.getPath(); Version v = versionManager.checkin(path); Value baseVersionRef = versionableNode.getProperty(jcrBaseVersion).getValue(); assertEquals("Checked-in node's jcr:baseVersion property is set to refer to the version created on checkin.", superuser.getValueFactory().createValue(v), baseVersionRef); }
@Override protected void setUp() throws Exception { super.setUp(); // ChromatticSessionImpl session = login(); Node rootNode = session.getRoot(); cNode = rootNode.addNode("tp_c_a", getNodeTypeName(D.class)); c = session.findByNode(D.class, cNode); factory = session.getJCRSession().getValueFactory(); }
/** * {@inheritDoc} */ public void createContentNode( final Session session, final PentahoJcrConstants pentahoJcrConstants, final SimpleRepositoryFileData data, final Node fileNode ) throws RepositoryException { Node resourceNode = fileNode.addNode( pentahoJcrConstants.getJCR_CONTENT(), pentahoJcrConstants.getNT_RESOURCE() ); // mandatory property on nt:resource; give them a value to satisfy Jackrabbit resourceNode.setProperty( pentahoJcrConstants.getJCR_LASTMODIFIED(), fileNode.getProperty( pentahoJcrConstants.getJCR_CREATED() ).getDate() ); if ( StringUtils.hasText( data.getEncoding() ) ) { resourceNode.setProperty( pentahoJcrConstants.getJCR_ENCODING(), data.getEncoding() ); } resourceNode.setProperty( pentahoJcrConstants.getJCR_DATA(), session.getValueFactory().createBinary( data.getStream() ) ); resourceNode.setProperty( pentahoJcrConstants.getJCR_MIMETYPE(), data.getMimeType() ); }
private void addListingFile(JSONObject fileListing, String cachePath, Session adminSession) throws RepositoryException, JSONException { JcrUtil.createPath(cachePath, "sling:Folder", "nt:file", adminSession, false); Node cacheContentNode = JcrUtil.createPath(cachePath + "/jcr:content", "nt:resource", adminSession); Calendar calTS = Calendar.getInstance(); cacheContentNode.setProperty("jcr:data", adminSession.getValueFactory().createBinary(new ByteArrayInputStream(fileListing.toString(3).getBytes()))); cacheContentNode.setProperty("jcr:lastModified", calTS); adminSession.save(); }
@Before public void setup() throws RepositoryException { session = getAdminSession(); directUploader = (JackrabbitValueFactory) session.getValueFactory(); if (session.getNode("/").hasNode(TEST_ROOT)) { session.getNode("/" + TEST_ROOT).remove(); session.save(); } session.getNode("/").addNode(TEST_ROOT); getConfigurableHttpDataRecordProvider().setDirectUploadURIExpirySeconds(60*5); getConfigurableHttpDataRecordProvider().setDirectDownloadURIExpirySeconds(60*5); }
public void testAutocreatedProperties() throws RepositoryException, NotExecutableException { givePrivileges(path, testUser.getPrincipal(), privilegesFromName(PrivilegeRegistry.REP_WRITE), getRestrictions(superuser, path)); // test user is not allowed to READ the protected property jcr:created. Map<String, Value> restr = getRestrictions(superuser, path); restr.put(((SessionImpl) superuser).getJCRName(ACLTemplate.P_GLOB), superuser.getValueFactory().createValue("/afolder/jcr:created")); withdrawPrivileges(path, testUser.getPrincipal(), privilegesFromName(Privilege.JCR_READ), restr); // still: adding a nt:folder node should be possible Node n = getTestSession().getNode(path); Node folder = n.addNode("afolder", "nt:folder"); assertFalse(folder.hasProperty("jcr:created")); }
@Before public void cleanRepoContents() throws RepositoryException { Session anonymousSession = getAnonymousSession(); uploadProvider = (JackrabbitValueFactory) getAdminSession().getValueFactory(); anonymousUploadProvider = (JackrabbitValueFactory) anonymousSession.getValueFactory(); if (getAdminSession().nodeExists(FILE_PATH)) { getAdminSession().getNode(FILE_PATH).remove(); getAdminSession().save(); } }
protected void setUp() throws Exception { super.setUp(); // initialize some long value value = superuser.getValueFactory().createValue(73057230); // create a new node under the testRootNode node = testRootNode.addNode(nodeName1, testNodeType); // create a new single-value property and save it property1 = node.setProperty(propertyName1, 0L); superuser.save(); }
public final Property set(Node node, String name, Object value) throws RepositoryException { Value v = wrap(node.getSession().getValueFactory(), value); if (v != null) { try { return node.setProperty(name, v); } catch (ValueFormatException e) { return node.setProperty(name, new Value[]{v}); } } return null; }
public void testWeakReferenceLiteral() throws RepositoryException, NotExecutableException { ensureMixinType(node1, mixReferenceable); superuser.save(); Value literal = superuser.getValueFactory().createValue(node1, true); QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal); checkQOM(qom, new Node[]{}); }
public void testExtendedNameBasedPathValue() throws RepositoryException { ValueFactory vf = superuser.getValueFactory(); Value pathValue = vf.createValue(Workspace.PATH_VERSION_STORAGE_NODE, PropertyType.PATH); Property p = testRootNode.setProperty(propertyName1, pathValue); assertEquals("/jcr:system/jcr:versionStorage", p.getString()); String path = Workspace.PATH_VERSION_STORAGE_NODE + "/a/b/c/jcr:frozenNode"; pathValue = vf.createValue(path, PropertyType.PATH); p = testRootNode.setProperty(propertyName1, pathValue); assertEquals("/jcr:system/jcr:versionStorage/a/b/c/jcr:frozenNode", p.getString()); }
@Override protected void setUp() throws Exception { super.setUp(); testValue = testRootNode.getSession().getValueFactory().createValue("anyString"); if (!testRootNode.getPrimaryNodeType().canSetProperty(propertyName1, testValue)) { throw new NotExecutableException(""); } }
@Override protected void setUp() throws Exception { super.setUp(); // ChromatticSessionImpl session = login(); Node rootNode = session.getRoot(); fNode = rootNode.addNode("tp_c_a", getNodeTypeName(D.class)); f = session.findByNode(D.class, fNode); factory = session.getJCRSession().getValueFactory(); }
@Test public void collectBinary() throws RepositoryException { // GIVEN final Node node = session.getRootNode().addNode("node", NodeTypes.Resource.NAME); final Binary binary = session.getValueFactory().createBinary(new ByteArrayInputStream(new byte[]{})); final Property property = node.setProperty(PropertyType.TYPENAME_BINARY, binary); aggregationState.setHandle(property.getPath()); // WHEN boolean success = filter.collect(); // THEN assertTrue(success); assertNotNull(aggregationState.getFile()); assertEquals("/node", aggregationState.getHandle()); }
private void setDefaultResourceProperties(Node node, String mimeType, InputStream inputStream) throws RepositoryException { try{ setDefaultResourceProperties(node, mimeType, node.getSession().getValueFactory().createBinary(inputStream)); } finally { IOUtils.closeQuietly(inputStream); } }