本文整理汇总了Java中org.apache.jackrabbit.JcrConstants类的典型用法代码示例。如果您正苦于以下问题:Java JcrConstants类的具体用法?Java JcrConstants怎么用?Java JcrConstants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JcrConstants类属于org.apache.jackrabbit包,在下文中一共展示了JcrConstants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Image
import org.apache.jackrabbit.JcrConstants; //导入依赖的package包/类
Image(@Nonnull Resource component) {
String fileReference = component.getValueMap().get(DownloadResource.PN_REFERENCE, String.class);
if (StringUtils.isNotEmpty(fileReference)) {
imageResource = component.getResourceResolver().getResource(fileReference);
source = Source.ASSET;
} else {
Resource childFileNode = component.getChild(DownloadResource.NN_FILE);
if (childFileNode != null) {
if (JcrConstants.NT_FILE.equals(childFileNode.getResourceType())) {
Resource jcrContent = childFileNode.getChild(JcrConstants.JCR_CONTENT);
if (jcrContent != null) {
if (jcrContent.getValueMap().containsKey(JcrConstants.JCR_DATA)) {
imageResource = childFileNode;
source = Source.FILE;
}
}
}
}
}
}
示例2: visit
import org.apache.jackrabbit.JcrConstants; //导入依赖的package包/类
@Override
public void visit(Condition.Impersonation condition) {
String principalName = condition.getName();
boolean isAdmin = false;
try {
Authorizable authorizable = userMgr.getAuthorizable(new PrincipalImpl(principalName));
isAdmin = authorizable != null && !authorizable.isGroup() && ((User) authorizable).isAdmin();
} catch (RepositoryException e) {
// unable to retrieve authorizable
}
if (isAdmin) {
statement.append('@')
.append(QueryUtil.escapeForQuery(JcrConstants.JCR_PRIMARYTYPE, namePathMapper))
.append("='")
.append(QueryUtil.escapeForQuery(UserConstants.NT_REP_USER, namePathMapper))
.append('\'');
} else {
statement.append('@')
.append(QueryUtil.escapeForQuery(UserConstants.REP_IMPERSONATORS, namePathMapper))
.append("='")
.append(QueryUtil.escapeForQuery(condition.getName()))
.append('\'');
}
}
示例3: getOrCreateTargetTree
import org.apache.jackrabbit.JcrConstants; //导入依赖的package包/类
/**
* Retrieves the node at {@code relPath} relative to node associated with
* this authorizable. If no such node exist it and any missing intermediate
* nodes are created.
*
* @param relPath A relative path.
* @return The corresponding node.
* @throws RepositoryException If an error occurs or if {@code relPath} refers
* to a node that is outside of the scope of this authorizable.
*/
@Nonnull
private Tree getOrCreateTargetTree(String relPath) throws RepositoryException {
Tree targetTree;
Tree userTree = getTree();
if (relPath != null) {
String userPath = userTree.getPath();
targetTree = getLocation(userTree, relPath).getTree();
if (targetTree != null) {
if (!Text.isDescendantOrEqual(userPath, targetTree.getPath())) {
throw new RepositoryException("Relative path " + relPath + " outside of scope of " + this);
}
} else {
targetTree = new NodeUtil(userTree).getOrAddTree(relPath, JcrConstants.NT_UNSTRUCTURED).getTree();
if (!Text.isDescendantOrEqual(userPath, targetTree.getPath())) {
throw new RepositoryException("Relative path " + relPath + " outside of scope of " + this);
}
}
} else {
targetTree = userTree;
}
return targetTree;
}
示例4: initialize
import org.apache.jackrabbit.JcrConstants; //导入依赖的package包/类
@Override
public void initialize(NodeBuilder builder, String workspaceName) {
// property index for rep:principalName stored in ACEs
NodeBuilder index = IndexUtils.getOrCreateOakIndex(builder);
if (!index.hasChildNode("acPrincipalName")) {
IndexUtils.createIndexDefinition(index, "acPrincipalName", true, false,
ImmutableList.<String>of(REP_PRINCIPAL_NAME),
ImmutableList.<String>of(NT_REP_DENY_ACE, NT_REP_GRANT_ACE, NT_REP_ACE));
}
// create the permission store and the root for this workspace.
NodeBuilder permissionStore =
builder.child(JCR_SYSTEM).child(REP_PERMISSION_STORE);
if (!permissionStore.hasProperty(JCR_PRIMARYTYPE)) {
permissionStore.setProperty(JCR_PRIMARYTYPE, NT_REP_PERMISSION_STORE, Type.NAME);
}
if (!permissionStore.hasChildNode(workspaceName)) {
permissionStore.child(workspaceName).setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_PERMISSION_STORE, Type.NAME);
}
}
示例5: createAclTree
import org.apache.jackrabbit.JcrConstants; //导入依赖的package包/类
/**
* @param oakPath the Oak path as specified with the ac mgr call.
* @param tree the access controlled node.
* @return the new acl tree.
* @throws AccessDeniedException In case the new acl tree is not accessible.
*/
@Nonnull
private Tree createAclTree(@Nullable String oakPath, @Nonnull Tree tree) throws AccessDeniedException {
if (!Util.isAccessControlled(oakPath, tree, ntMgr)) {
PropertyState mixins = tree.getProperty(JcrConstants.JCR_MIXINTYPES);
String mixinName = Util.getMixinName(oakPath);
if (mixins == null) {
tree.setProperty(JcrConstants.JCR_MIXINTYPES, Collections.singleton(mixinName), Type.NAMES);
} else {
PropertyBuilder pb = PropertyBuilder.copy(Type.NAME, mixins);
pb.addValue(mixinName);
tree.setProperty(pb.getPropertyState());
}
}
String aclName = Util.getAclName(oakPath);
return new NodeUtil(tree).addChild(aclName, NT_REP_ACL).getTree();
}
示例6: initialize
import org.apache.jackrabbit.JcrConstants; //导入依赖的package包/类
@Override
public void initialize(NodeBuilder builder) {
NodeBuilder system = builder.child(JcrConstants.JCR_SYSTEM);
system.setProperty(JcrConstants.JCR_PRIMARYTYPE, NodeTypeConstants.NT_REP_SYSTEM, Type.NAME);
if (!system.hasChildNode(REP_PRIVILEGES)) {
NodeBuilder privileges = system.child(REP_PRIVILEGES);
privileges.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_PRIVILEGES, Type.NAME);
NodeState base = builder.getNodeState();
NodeStore store = new MemoryNodeStore(base);
try {
new PrivilegeDefinitionWriter(new SystemRoot(store)).writeBuiltInDefinitions();
} catch (RepositoryException e) {
log.error("Failed to register built-in privileges", e);
throw new RuntimeException(e);
}
NodeState target = store.getRoot();
target.compareAgainstBaseState(base, new ApplyDiff(builder));
}
}
示例7: getValue
import org.apache.jackrabbit.JcrConstants; //导入依赖的package包/类
@Override
public PropertyValue getValue(String columnName) {
int index = query.getColumnIndex(columnName);
if (index >= 0) {
return values[index];
}
if (JcrConstants.JCR_PATH.equals(columnName)) {
return PropertyValues.newString(getPath());
}
// OAK-318:
// somebody might call rep:excerpt(text)
// even thought the query doesn't contain that column
if (columnName.startsWith(QueryImpl.REP_EXCERPT)) {
// missing excerpt, generate a default value
String ex = SimpleExcerptProvider.getExcerpt(getPath(), columnName,
query, true);
if (ex != null) {
return PropertyValues.newString(ex);
}
return PropertyValues.newString(getPath());
}
throw new IllegalArgumentException("Column not found: " + columnName);
}
示例8: getReferences
import org.apache.jackrabbit.JcrConstants; //导入依赖的package包/类
/**
* Searches all reference properties to the specified {@code tree} that match
* the given name and node type constraints.
*
* @param weak if {@code true} only weak references are returned. Otherwise only
* hard references are returned.
* @param tree The tree for which references should be searched.
* @param propertyName A name constraint for the reference properties;
* {@code null} if no constraint should be enforced.
* @param nodeTypeNames Node type constraints to be enforced when using
* for reference properties; the specified names are expected to be internal
* oak names.
* @return A set of oak paths of those reference properties referring to the
* specified {@code tree} and matching the constraints.
*/
@Nonnull
public Iterable<String> getReferences(boolean weak, Tree tree, final String propertyName, final String... nodeTypeNames) {
if (!nodeTypeManager.isNodeType(tree, JcrConstants.MIX_REFERENCEABLE)) {
return Collections.emptySet(); // shortcut
}
final String uuid = getIdentifier(tree);
String reference = weak ? PropertyType.TYPENAME_WEAKREFERENCE : PropertyType.TYPENAME_REFERENCE;
String pName = propertyName == null ? "*" : propertyName; // TODO: sanitize against injection attacks!?
Map<String, ? extends PropertyValue> bindings = Collections.singletonMap("uuid", PropertyValues.newString(uuid));
try {
Result result = root.getQueryEngine().executeQuery(
"SELECT * FROM [nt:base] WHERE PROPERTY([" + pName + "], '" + reference + "') = $uuid",
Query.JCR_SQL2, Long.MAX_VALUE, 0, bindings, NO_MAPPINGS);
return findPaths(result, uuid, propertyName, nodeTypeNames,
weak ? Type.WEAKREFERENCE : Type.REFERENCE,
weak ? Type.WEAKREFERENCES : Type.REFERENCES
);
} catch (ParseException e) {
log.error("query failed", e);
return Collections.emptySet();
}
}
示例9: getRequiredPrimaryTypes
import org.apache.jackrabbit.JcrConstants; //导入依赖的package包/类
@Override
public NodeType[] getRequiredPrimaryTypes() {
String[] oakNames = getNames(JcrConstants.JCR_REQUIREDPRIMARYTYPES);
if (oakNames == null) {
oakNames = new String[] { JcrConstants.NT_BASE };
}
NodeType[] types = new NodeType[oakNames.length];
Tree root = definition.getParent();
while (!JCR_NODE_TYPES.equals(root.getName())) {
root = root.getParent();
}
for (int i = 0; i < oakNames.length; i++) {
Tree type = root.getChild(oakNames[i]);
checkState(type.exists());
types[i] = new NodeTypeImpl(type, mapper);
}
return types;
}
示例10: setVersionablePath
import org.apache.jackrabbit.JcrConstants; //导入依赖的package包/类
private boolean setVersionablePath(PropertyState after) {
if (JcrConstants.JCR_VERSIONHISTORY.equals(after.getName()) && nodeAfter.isVersionable(versionManager)) {
NodeBuilder vhBuilder;
try {
vhBuilder = versionManager.getOrCreateVersionHistory(nodeAfter.builder, Collections.EMPTY_MAP);
} catch (CommitFailedException e) {
exceptions.add(e);
// stop further comparison
return false;
}
if (!vhBuilder.hasProperty(JcrConstants.JCR_MIXINTYPES)) {
vhBuilder.setProperty(
JcrConstants.JCR_MIXINTYPES,
ImmutableSet.of(MIX_REP_VERSIONABLE_PATHS),
Type.NAMES);
}
String versionablePath = nodeAfter.path;
vhBuilder.setProperty(workspaceName, versionablePath, Type.PATH);
}
return true;
}
示例11: propertyAdded
import org.apache.jackrabbit.JcrConstants; //导入依赖的package包/类
@Override
public void propertyAdded(PropertyState after)
throws CommitFailedException {
if (after.getName().equals(JCR_BASEVERSION)
&& this.after.hasProperty(JcrConstants.JCR_VERSIONHISTORY)
&& !this.after.hasProperty(JCR_ISCHECKEDOUT)
&& !this.before.exists()) {
// sentinel node for restore
vMgr.restore(node, after.getValue(Type.REFERENCE), null);
return;
}
if (!isReadOnly) {
return;
}
// JCR allows to put a lock on a checked in node.
if (after.getName().equals(JcrConstants.JCR_LOCKOWNER)
|| after.getName().equals(JcrConstants.JCR_LOCKISDEEP)) {
return;
}
throwCheckedIn("Cannot add property " + after.getName()
+ " on checked in node");
}
示例12: select
import org.apache.jackrabbit.JcrConstants; //导入依赖的package包/类
@Override
public NodeBuilder select(@Nonnull NodeBuilder history)
throws RepositoryException {
long latestDate = Long.MIN_VALUE;
NodeBuilder latestVersion = null;
for (String name: history.getChildNodeNames()) {
// OAK-1192 skip hidden child nodes
if (name.charAt(0) == ':') {
continue;
}
NodeBuilder v = history.getChildNode(name);
if (name.equals(JcrConstants.JCR_ROOTVERSION)
|| name.equals(JcrConstants.JCR_VERSIONLABELS)) {
// ignore root version and labels node
continue;
}
long c = ISO8601.parse(v.getProperty(JcrConstants.JCR_CREATED).getValue(Type.DATE)).getTimeInMillis();
if (c > latestDate && c <= timestamp) {
latestDate = c;
latestVersion = v;
} else if (c == latestDate) {
throw new RepositoryException("two versions share the same jcr:created timestamp in history:" + history);
}
}
return latestVersion;
}
示例13: before
import org.apache.jackrabbit.JcrConstants; //导入依赖的package包/类
@Override
@Before
public void before() throws Exception {
super.before();
Principal testPrincipal = getTestPrincipal();
NodeUtil rootNode = new NodeUtil(root.getTree("/"), namePathMapper);
NodeUtil testNode = rootNode.addChild("testPath", JcrConstants.NT_UNSTRUCTURED);
testNode.addChild("childNode", JcrConstants.NT_UNSTRUCTURED);
AccessControlManager acMgr = getAccessControlManager(root);
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, testPath);
acl.addAccessControlEntry(testPrincipal, privilegesFromNames(JCR_ADD_CHILD_NODES));
acl.addAccessControlEntry(EveryonePrincipal.getInstance(), privilegesFromNames(JCR_READ));
acMgr.setPolicy(testPath, acl);
root.commit();
testPrincipalName = testPrincipal.getName();
bitsProvider = new PrivilegeBitsProvider(root);
}
示例14: testAddNodeCollidingWithInvisibleNode
import org.apache.jackrabbit.JcrConstants; //导入依赖的package包/类
public void testAddNodeCollidingWithInvisibleNode() throws Exception {
setupPermission("/a", testPrincipal, true, PrivilegeConstants.JCR_ALL);
setupPermission("/a/b", testPrincipal, false, PrivilegeConstants.JCR_READ);
setupPermission("/a/b/c", testPrincipal, true, PrivilegeConstants.JCR_ALL);
Root testRoot = getTestRoot();
Tree a = testRoot.getTree("/a");
assertFalse(a.getChild("b").exists());
assertTrue(a.getChild("b").getChild("c").exists());
new NodeUtil(a).addChild("b", JcrConstants.NT_UNSTRUCTURED);
assertTrue(a.getChild("b").exists());
assertFalse(a.getChild("b").getChild("c").exists()); // now shadowed
// since we have write access, the old content gets replaced
testRoot.commit(); // note that also the deny-read ACL gets replaced
assertTrue(a.getChild("b").exists());
assertFalse(a.getChild("b").getChild("c").exists());
}
示例15: testCreateInvalidJcrUuid
import org.apache.jackrabbit.JcrConstants; //导入依赖的package包/类
/**
* Creating a referenceable tree with an invalid jcr:uuid must fail.
*/
@Test
public void testCreateInvalidJcrUuid() throws Exception {
setupPermission("/a", testPrincipal, true, PrivilegeConstants.JCR_READ, PrivilegeConstants.JCR_ADD_CHILD_NODES);
try {
Root testRoot = getTestRoot();
testRoot.refresh();
NodeUtil a = new NodeUtil(testRoot.getTree("/a"));
NodeUtil test = a.addChild("referenceable2", NT_NAME);
test.setString(JcrConstants.JCR_UUID, "not a uuid");
testRoot.commit();
fail("Creating a referenceable node with an invalid uuid must fail.");
} catch (CommitFailedException e) {
assertTrue(e.isConstraintViolation());
assertEquals(12, e.getCode());
}
}