Codota Logo
Property
Code IndexAdd Codota to your IDE (free)

How to use
Property
in
javax.jcr

Best Java code snippets using javax.jcr.Property (Showing top 20 results out of 2,304)

Refine searchRefine arrow

  • Node
  • Session
  • Value
  • Workspace
  • PropertyIterator
  • ValueFactory
  • Common ways to obtain Property
private void myMethod () {
Property p =
  • Codota IconNode node;String name;String value;node.setProperty(name, value)
  • Codota IconNode node;String relPath;node.getProperty(relPath)
  • Codota IconPropertyIterator iter;iter.nextProperty()
  • Smart code suggestions by Codota
}
origin: apache/jackrabbit

/**
 * Expanded names must always be resolved.
 * Test setting a NAME-value property.
 *
 * @throws RepositoryException
 */
public void testExpandedNameValueProperty() throws RepositoryException {
  ValueFactory vf = superuser.getValueFactory();
  Value nameValue = vf.createValue(Workspace.NAME_VERSION_STORAGE_NODE, PropertyType.NAME);
  Property p = testRootNode.setProperty(propertyName1, nameValue);
  assertEquals(PropertyType.NAME, p.getType());
  assertEquals(nameValue.getString(), p.getValue().getString());
  assertEquals(nameValue, p.getValue());
  assertEquals("jcr:versionStorage", p.getString());
}
origin: info.magnolia/magnolia-core

@Override
public NodeType[] getMixinNodeTypes() throws RepositoryException {
  Value[] vals = this.node.getProperty("jcr:frozenMixinTypes").getValues();
  NodeTypeManager typeMan = getJCRNode().getSession().getWorkspace().getNodeTypeManager();
  NodeType[] types = new NodeType[vals.length];
  int i = 0;
  for (Value val : vals) {
    types[i++] = typeMan.getNodeType(val.getString());
  }
  return types;
}
origin: info.magnolia/magnolia-core

private void appendNodeProperties(Node node, Properties out) throws RepositoryException {
  PropertyIterator propertyIterator = node.getProperties();
  while (propertyIterator.hasNext()) {
    Property property = propertyIterator.nextProperty();
    String path = getExportPath(node) + "." + property.getName();
    String propertyValue = getPropertyString(property);
    if (propertyValue != null) {
      out.setProperty(path, propertyValue);
    }
  }
}
origin: info.magnolia/magnolia-core

public static void moveProperty(Property source, Node targetNode) throws RepositoryException {
  // JCR props can't be moved, we gotta recreate w/ same value and delete
  if (source.isMultiple()) {
    targetNode.setProperty(source.getName(), source.getValues());
  } else {
    targetNode.setProperty(source.getName(), source.getValue());
  }
  source.remove();
}
origin: org.apache.jackrabbit/jackrabbit-jcr-commons

/**
 * Move <code>property</code> to the new <code>parent</code>.
 */
protected void move(Property property, Node parent) throws RepositoryException {
  parent.setProperty(property.getName(), property.getValue());
  property.remove();
}
origin: org.apache.jackrabbit/jackrabbit-jcr-commons

private Value[] getPropertyValues(PropertyValue operand, Node node)
    throws RepositoryException {
  Property property = getProperty(operand, node);
  if (property == null) {
    return new Value[0];
  } else if (property.isMultiple()) {
    return property.getValues();
  } else {
    return new Value[] { property.getValue() };
  }
}
origin: apache/jackrabbit-oak

public void testVersionReferencesV1() throws RepositoryException {
  Node n = testRootNode.addNode(nodeName1, testNodeType);
  n.addMixin(mixVersionable);
  superuser.save();
  String p = n.getPath();
  VersionManager vMgr = superuser.getWorkspace().getVersionManager();
  Version v1 = vMgr.checkpoint(p);
  // check if versionable node has references to v1.0
  assertEquals("v1.0", v1.getIdentifier(), n.getProperty(Property.JCR_BASE_VERSION).getString());
  assertEquals("v1.0", v1.getIdentifier(), n.getProperty(Property.JCR_PREDECESSORS).getValues()[0].getString());
  checkReferences("v1.0", v1.getReferences(),
      p + "/jcr:baseVersion",
      p + "/jcr:predecessors"
  );
}
origin: apache/jackrabbit

/**
 * @throws RepositoryException
 */
public void testFrozenNodeType() throws RepositoryException {
  VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
  String path = versionableNode.getPath();
  Version v = versionManager.checkin(path);
  Node n = v.getFrozenNode();
  String fuuid = n.getProperty("jcr:frozenPrimaryType").getValue().getString();
  String ruuid = versionableNode.getPrimaryNodeType().getName();
  assertEquals("jcr:frozenPrimaryType needs to be equal to the getPrimaryNodeType() return value.", ruuid, fuuid);
}
origin: apache/jackrabbit-oak

public void testVersionablePathsAfterRename() throws Exception {
  Node node1 = testRootNode.addNode(nodeName1);
  node1.addMixin(JcrConstants.MIX_VERSIONABLE);
  superuser.save();
  String destPath = testRoot + "/" + nodeName2;
  superuser.move(node1.getPath(), destPath);
  superuser.save();
  Node vh = getVersionManager().getVersionHistory(node1.getPath());
  assertTrue(vh.isNodeType("rep:VersionablePaths"));
  String workspaceName = superuser.getWorkspace().getName();
  assertTrue(vh.hasProperty(workspaceName));
  assertEquals(node1.getPath(), vh.getProperty(workspaceName).getString());
}
origin: apache/jackrabbit

public void testMoveJson() throws Exception {
  Node test = createJsonNode("test.json");
  test.getSession().getWorkspace().move(test.getPath(), test.getParent().getPath() + "/target.json");
  Session s = getHelper().getReadOnlySession();
  try {
    Property p = s.getNode(testRoot).getNode("target.json").getNode(JcrConstants.JCR_CONTENT)
        .getProperty(JcrConstants.JCR_DATA);
    assertEquals(jsondata, IOUtils.toString(p.getBinary().getStream(), "UTF-8"));
  } finally {
    s.logout();
  }
}
origin: apache/jackrabbit-oak

public void testMultiValues() throws Exception {
  superuser.importXML(targetPath, getImportStream(), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
  superuser.save();
  Node n = superuser.getNode(targetPath).getNode(nodeName4);
  Property p = n.getNode(nodeName2).getProperty("test:multiProperty");
  assertTrue(p.isMultiple());
  assertTrue(p.getDefinition().isMultiple());
  Value[] expected = new Value[] {vf.createValue("v1"), vf.createValue("v2")};
  Assert.assertArrayEquals(expected, p.getValues());
}
origin: apache/jackrabbit

/**
 * @throws RepositoryException
 */
public void testFrozenNodeUUUID() throws RepositoryException {
  VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
  String path = versionableNode.getPath();
  Version v = versionManager.checkin(path);
  Node n = v.getFrozenNode();
  String puuid = n.getProperty(jcrUUID).getValue().getString();
  String nuuid = n.getIdentifier();
  assertEquals("jcr:uuid needs to be equal to the getIdentifier() return value.", nuuid, puuid);
}
origin: info.magnolia/magnolia-core

@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());
}
origin: apache/jackrabbit-oak

@Test
public void getReferences() throws RepositoryException {
  Session session = getAdminSession();
  Node referee = getNode("/foo");
  referee.addMixin("mix:referenceable");
  getNode(TEST_PATH).setProperty("reference", session.getValueFactory().createValue(referee));
  session.save();
  PropertyIterator refs = referee.getReferences();
  assertTrue(refs.hasNext());
  Property p = refs.nextProperty();
  assertEquals("reference", p.getName());
  assertFalse(refs.hasNext());
}
origin: apache/jackrabbit

/**
 * 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);
}
origin: apache/jackrabbit-oak

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()));
}
origin: apache/jackrabbit-oak

@Override
public void runTest() throws Exception {
  Node node = session.getRootNode().getNode(ROOT_NODE_NAME);
  for (int i = 1; i < CHILD_COUNT; i++) {
    node.getNode("node" + i).setProperty("foo", "bar");
    session.save();
    node.getNode("node" + i).getProperty("foo").remove();
    node.getNode("node0").setProperty("foo", i);
    session.save();
  }
}
origin: ModeShape/modeshape

private InputStream storeBinaryProperty( byte[] data,
                     String nodeName ) throws RepositoryException {
  Node testRoot = jcrSession().getRootNode().addNode(nodeName);
  testRoot.setProperty("binary", session.getValueFactory().createValue(new ByteArrayInputStream(data)));
  jcrSession().save();
  Property binary = jcrSession().getNode("/" + nodeName).getProperty("binary");
  Assert.assertNotNull(binary);
  return binary.getBinary().getStream();
}
origin: org.onehippo.cms7/hippo-addon-channel-manager-content-service

static NodeIterator executeQuery(final Session session, final Node templateQueryNode) throws RepositoryException {
  final String statement = templateQueryNode.getProperty("jcr:statement").getString();
  final String language =  templateQueryNode.getProperty("jcr:language").getString();
  final QueryManager queryManager = session.getWorkspace().getQueryManager();
  final Query query = queryManager.createQuery(statement, language);
  final QueryResult queryResult = query.execute();
  return queryResult.getNodes();
}
origin: info.magnolia/magnolia-core

@MgnlDeprecated(since = "5.6.2", description = "No need to call since #addComment should not be called.")
@Deprecated
protected void cleanComment(final Node node) throws RepositoryException {
  synchronized (ExclusiveWrite.getInstance()) {
    if (node.hasProperty(NodeTypes.Versionable.COMMENT)
        && !StringUtils.EMPTY.equals(node.getProperty(NodeTypes.Versionable.COMMENT).getString())) {
      node.getProperty(NodeTypes.Versionable.COMMENT).remove();
      node.getSession().save();
    }
  }
}
javax.jcrProperty

Javadoc

A Property object represents the smallest granularity of content storage. It has a single parent node and no children. A property consists of a name and a value, or in the case of multi-value properties, a set of values all of the same type. See Value.

Most used methods

  • getString
    Returns a String representation of the value of this property. A shortcut for Property.getValue().g
  • getValues
    Returns an array of all the values of this property. Used to access multi-value properties. The arra
  • getValue
    Returns the value of this property as a Value object. The object returned is a copy of the stored va
  • getName
  • getType
    Returns the type of this Property. One of: * PropertyType.STRING * PropertyType.BINARY * Property
  • getBinary
    Returns a Binary representation of the value of this property. A shortcut for Property.getValue().g
  • getBoolean
    Returns a boolean representation of the value of this property. A shortcut for Property.getValue().
  • remove
  • isMultiple
    Returns true if this property is multi-valued andfalse if this property is single-valued.
  • getDate
    Returns a Calendar representation of the value of this property. A shortcut for Property.getValue()
  • getLong
    Returns a long representation of the value of this property. A shortcut for Property.getValue().get
  • getDefinition
    Returns the property definition that applies to this property. In some cases there may appear to be
  • getLong,
  • getDefinition,
  • setValue,
  • getParent,
  • getPath,
  • getNode,
  • getLength,
  • getDouble,
  • getStream,
  • getSession

Popular in Java

  • Reading from database using SQL prepared statement
  • getApplicationContext (Context)
  • getExternalFilesDir (Context)
  • getSystemService (Context)
  • BufferedInputStream (java.io)
    Wraps an existing InputStream and buffers the input. Expensive interaction with the underlying input
  • BigInteger (java.math)
    Immutable arbitrary-precision integers. All operations behave as if BigIntegers were represented in
  • Timer (java.util)
    A facility for threads to schedule tasks for future execution in a background thread. Tasks may be s
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now