/** * Remove the property */ @Override public boolean remove() { if (parent.hasProperty(name)) { parent.removeProperty(name); return true; } else { return false; } }
private static boolean hasRestrictionProperty(Tree aceTree, String name) { if (aceTree.hasProperty(name)) { return true; } Tree restrictionTree = aceTree.getChild(AccessControlConstants.REP_RESTRICTIONS); return restrictionTree.exists() && restrictionTree.hasProperty(name); }
boolean hasAny() { if (hasAny == null) { Tree rootTree = root.getTree(PathUtils.ROOT_PATH); hasAny = rootTree.hasProperty(HIDDEN_TOP_CUG_CNT) || CugUtil.hasCug(rootTree); } return hasAny; }
private void loadExisting(Tree aggregate) { for (Tree tree : aggregate.getChildren()){ if (tree.hasProperty(FulltextIndexConstants.AGG_PATH)) { Include include = new Include(this, tree); includes.put(include.getPath(), include); } } }
@Override public boolean matches(@NotNull Tree tree, @Nullable PropertyState property) { boolean match = false; // configured property name found on underlying jcr:content node has precedence if (tree.hasChild(JcrConstants.JCR_CONTENT)) { match = tree.getChild(JcrConstants.JCR_CONTENT).hasProperty(propertyName); } if (!match) { match = tree.hasProperty(propertyName); } return negate ? !match : match; }
PrivilegeDefinitionWriter(@NotNull Root root) { this.root = root; this.bitsMgr = new PrivilegeBitsProvider(root); Tree privilegesTree = bitsMgr.getPrivilegesTree(); if (privilegesTree.exists() && privilegesTree.hasProperty(REP_NEXT)) { next = PrivilegeBits.getInstance(privilegesTree); } else { next = PrivilegeBits.NEXT_AFTER_BUILT_INS; } }
PrivilegeDefinitionWriter(@NotNull Root root) { this.root = root; this.bitsMgr = new PrivilegeBitsProvider(root); Tree privilegesTree = bitsMgr.getPrivilegesTree(); if (privilegesTree.exists() && privilegesTree.hasProperty(REP_NEXT)) { next = PrivilegeBits.getInstance(privilegesTree); } else { next = PrivilegeBits.NEXT_AFTER_BUILT_INS; } }
@Nullable private String getPrimaryTypeName(@NotNull Tree tree) { String primaryTypeName = null; if (tree.hasProperty(JcrConstants.JCR_PRIMARYTYPE)) { primaryTypeName = TreeUtil.getPrimaryTypeName(tree); } else if (tree.getStatus() != Status.NEW) { // OAK-2441: for backwards compatibility with Jackrabbit 2.x try to // read the primary type from the underlying node state. primaryTypeName = TreeUtil.getPrimaryTypeName(RootFactory.createReadOnlyRoot(sessionDelegate.getRoot()).getTree(tree.getPath())); } return primaryTypeName; }
@Before public void before() { existingTree = Mockito.mock(Tree.class); when(existingTree.exists()).thenReturn(true); when(existingTree.getName()).thenReturn(PathUtils.ROOT_NAME); when(existingTree.getPath()).thenReturn(PathUtils.ROOT_PATH); when(existingTree.hasProperty(JcrConstants.JCR_PRIMARYTYPE)).thenReturn(true); when(existingTree.getProperty(JcrConstants.JCR_PRIMARYTYPE)).thenReturn(PropertyStates.createProperty(JcrConstants.JCR_PRIMARYTYPE, "rep:root")); }
@NotNull @Override public RestrictionPattern getPattern(@Nullable String oakPath, @NotNull Tree tree) { boolean hasRestriction = false; for (RestrictionDefinition rd : getSupportedRestrictions(oakPath)) { if (tree.hasProperty(rd.getName())) { hasRestriction = true; break; } } return (hasRestriction) ? new MatchingPattern() : RestrictionPattern.EMPTY; }
@Test public void testHasProperty() { Tree a = root.getTree("/a"); for (String propName : hiddenProps) { assertFalse(a.hasProperty(propName)); } }
private void enableIndexDefinitionIndex() throws CommitFailedException { Tree nodetype = root.getTree("/oak:index/nodetype"); assertTrue(nodetype.exists()); List<String> nodetypes = Lists.newArrayList(); if (nodetype.hasProperty(DECLARING_NODE_TYPES)){ nodetypes = Lists.newArrayList(nodetype.getProperty(DECLARING_NODE_TYPES).getValue(Type.STRINGS)); } nodetypes.add(INDEX_DEFINITIONS_NODE_TYPE); nodetype.setProperty(DECLARING_NODE_TYPES, nodetypes, Type.NAMES); nodetype.setProperty(IndexConstants.REINDEX_PROPERTY_NAME, true); root.commit(); }
@Test public void testKnownMemberThresholdReached() throws Exception { List<String> memberIds = new ArrayList(); for (int i = 0; i <= MembershipWriter.DEFAULT_MEMBERSHIP_THRESHOLD; i++) { memberIds.add(userProvider.getContentID("m"+i)); } groupTree.setProperty(REP_MEMBERS, memberIds, Type.STRINGS); importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, knownMemberContentId))); importer.processReferences(); assertEquals(1, memberRefList.getChildrenCount(100)); assertTrue(memberRefList.getChildren().iterator().next().hasProperty(REP_MEMBERS)); }
@Test public void testKnownMemberThresholdNotReached() throws Exception { importer.startChildInfo(createNodeInfo("memberRef", NT_REP_MEMBER_REFERENCES), ImmutableList.of(createPropInfo(REP_MEMBERS, knownMemberContentId))); importer.processReferences(); assertTrue(groupTree.hasProperty(REP_MEMBERS)); }
@Test public void testPropertiesCompletedIdMissing() throws Exception { init(); Tree userTree = createUserTree(); importer.propertiesCompleted(userTree); assertTrue(userTree.hasProperty(REP_AUTHORIZABLE_ID)); }
@Test public void testHasNoPassword() throws Exception { User user = createUser(null); Tree userTree = root.getTree(user.getPath()); assertFalse(userTree.hasProperty(UserConstants.REP_PASSWORD)); }
@Test public void testHasProperty() throws Exception { setupPermission("/a", testPrincipal, false, PrivilegeConstants.REP_READ_PROPERTIES); testRoot.refresh(); Tree a = testRoot.getTree("/a"); assertFalse(a.hasProperty("aProp")); }
@Test public void testSystemUserTree() throws Exception { Tree t = root.getTree(createUser(null).getPath()); assertFalse(t.hasProperty(UserConstants.REP_PASSWORD)); assertEquals(UserConstants.NT_REP_SYSTEM_USER, TreeUtil.getPrimaryTypeName(t)); }
@Test public void testCreateTokenWithExpirationParam() throws Exception { SimpleCredentials sc = new SimpleCredentials(userId, new char[0]); sc.setAttribute(TokenProvider.PARAM_TOKEN_EXPIRATION, 100000); TokenInfo info = tokenProvider.createToken(sc); assertTokenInfo(info, userId); Tree tokenTree = getTokenTree(info); assertNotNull(tokenTree); assertTrue(tokenTree.exists()); assertTrue(tokenTree.hasProperty(TokenProvider.PARAM_TOKEN_EXPIRATION)); assertEquals(100000, tokenTree.getProperty(TokenProvider.PARAM_TOKEN_EXPIRATION).getValue(Type.LONG).longValue()); }
@Test public void testSyncUserByIdUpdate() throws Exception { ExternalIdentity externalId = idp.listUsers().next(); Authorizable a = userManager.createUser(externalId.getId(), null); a.setProperty(DefaultSyncContext.REP_EXTERNAL_ID, valueFactory.createValue(externalId.getExternalId().getString())); syncContext.setForceUserSync(true); SyncResult result = syncContext.sync(externalId.getId()); assertEquals(SyncResult.Status.UPDATE, result.getStatus()); Tree t = r.getTree(a.getPath()); assertTrue(t.hasProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES)); }