@NotNull @Override public Boolean perform() throws RepositoryException { return delegate.removeProperty(relPath); } });
@NotNull @Override public Boolean perform() throws RepositoryException { return delegate.removeProperty(relPath); } });
@Nonnull @Override public Boolean perform() throws RepositoryException { return delegate.removeProperty(relPath); } });
@Override public boolean removeProperty(String s) throws RepositoryException { try { return dlg.removeProperty(s); } finally { mgr.autosave(); } }
@Override public boolean removeProperty(String s) throws RepositoryException { try { return dlg.removeProperty(s); } finally { mgr.autosave(); } }
@Override public boolean removeProperty(String s) throws RepositoryException { try { return dlg.removeProperty(s); } finally { mgr.autosave(); } }
public boolean removeProperty(String name) throws RepositoryException { return user.removeProperty(name); }
@Test public void testRemoveProperty() throws Exception { for (String relPath : mappedPaths) { authorizable.removeProperty(relPath); } }
@Test public void testRemoveProperty2() throws Exception { for (String relPath : unmappedPaths) { try { authorizable.removeProperty(relPath); fail(); } catch (RepositoryException e) { // success } } } }
private ActionResult process(final Context context, boolean simulate) { ActionResult actionResult = new ActionResult(); try { Authorizable authorizable = context.getCurrentAuthorizable(); actionResult.setAuthorizable(authorizable.getID()); LOGGER.info(String.format("Removing property %s from authorizable with id = %s", nameProperty, authorizable.getID())); if (!simulate) { authorizable.removeProperty(nameProperty); } actionResult.logMessage("Property " + nameProperty + " for " + authorizable.getID() + " removed"); } catch (RepositoryException | ActionExecutionException e) { actionResult.logError(MessagingUtils.createMessage(e)); } return actionResult; }
private ActionResult process(final Context context, boolean simulate) { ActionResult actionResult = new ActionResult(); try { Authorizable authorizable = context.getCurrentAuthorizable(); actionResult.setAuthorizable(authorizable.getID()); LOGGER.info(String.format("Removing property %s from authorizable with id = %s", nameProperty, authorizable.getID())); if (!simulate) { authorizable.removeProperty(nameProperty); } actionResult.logMessage("Property " + nameProperty + " for " + authorizable.getID() + " removed"); } catch (RepositoryException | ActionExecutionException e) { actionResult.logError(MessagingUtils.createMessage(e)); } return actionResult; }
public void testRemoveNotExistingProperty() throws RepositoryException, NotExecutableException { Authorizable auth = getTestUser(superuser); String hint = "Fullname"; String propName = hint; int i = 0; while (auth.hasProperty(propName)) { propName = hint + i; i++; } assertFalse(auth.removeProperty(propName)); save(superuser); }
@Test public void testIsSameIDPMissingExternalId() throws Exception { ExternalIdentity externalUser = idp.listUsers().next(); sync(externalUser); Authorizable a = userManager.getAuthorizable(externalUser.getId()); a.removeProperty(DefaultSyncContext.REP_EXTERNAL_ID); assertFalse(syncCtx.isSameIDP(a)); }
@Test public void testChangeUserProperties() throws Exception { createUser(userId); // make sure user can create/modify/remove regular properties modify("/", PrivilegeConstants.JCR_MODIFY_PROPERTIES, true); UserManager testUserMgr = getUserManager(testSession); Authorizable a = testUserMgr.getAuthorizable(userId); a.setProperty("someProp", testSession.getValueFactory().createValue("value")); testSession.save(); a.setProperty("someProperty", testSession.getValueFactory().createValue("modified")); testSession.save(); a.removeProperty("someProperty"); testSession.save(); }
public void testSetPropertyByRelPath() throws NotExecutableException, RepositoryException { Authorizable auth = getTestUser(superuser); Value[] v = new Value[] {superuser.getValueFactory().createValue("Super User")}; List<String> relPaths = new ArrayList<String>(); relPaths.add("testing/Fullname"); relPaths.add("testing/Email"); relPaths.add("testing/testing/testing/Fullname"); relPaths.add("testing/testing/testing/Email"); for (String relPath : relPaths) { try { auth.setProperty(relPath, v); save(superuser); assertTrue(auth.hasProperty(relPath)); String propName = Text.getName(relPath); assertFalse(auth.hasProperty(propName)); } finally { // try to remove the property even if previous calls failed. auth.removeProperty(relPath); save(superuser); } } }
@Test public void testRequiresSyncMissingSyncProperty() throws Exception { sync(USER_ID, false); Authorizable a = userManager.getAuthorizable(USER_ID); a.removeProperty(DefaultSyncContext.REP_LAST_SYNCED); root.commit(); SyncedIdentity si = syncHandler.findIdentity(userManager, USER_ID); assertNotNull(si); assertTrue(syncHandler.requiresSync(si)); }
@Test public void testSyncUpdateAfterXmlImport() throws Exception { try { // force initial sync login(new SimpleCredentials(USER_ID, new char[0])).close(); // remove properties according to the behavior in the XML-import Root systemRoot = getSystemRoot(); UserManager userManager = getUserManager(systemRoot); Authorizable a = userManager.getAuthorizable(USER_ID); a.removeProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES); a.removeProperty(ExternalIdentityConstants.REP_LAST_SYNCED); systemRoot.commit(); // login again to force sync of the user (and it's group membership) login(new SimpleCredentials(USER_ID, new char[0])).close(); systemRoot.refresh(); a = userManager.getAuthorizable(USER_ID); assertTrue(a.hasProperty(ExternalIdentityConstants.REP_LAST_SYNCED)); assertExternalPrincipalNames(userManager, USER_ID); } finally { options.clear(); } }
public void testGetPropertyNames() throws NotExecutableException, RepositoryException { Authorizable auth = getTestUser(superuser); // TODO: retrieve propname and value from config String propName = "Fullname"; Value v = superuser.getValueFactory().createValue("Super User"); try { auth.setProperty(propName, v); save(superuser); } catch (RepositoryException e) { throw new NotExecutableException("Cannot test 'Authorizable.setProperty'."); } try { for (Iterator<String> it = auth.getPropertyNames(); it.hasNext();) { String name = it.next(); assertTrue(auth.hasProperty(name)); assertNotNull(auth.getProperty(name)); } } finally { // try to remove the property again even if previous calls failed. auth.removeProperty(propName); save(superuser); } }
@Test public void testIsExpiredSyncedGroup() throws Exception { ExternalIdentity externalGroup = idp.listGroups().next(); sync(externalGroup); Authorizable a = userManager.getAuthorizable(externalGroup.getId()); assertFalse(syncCtx.isExpired(a, syncConfig.group().getExpirationTime(), "any")); assertTrue(syncCtx.isExpired(a, -1, "any")); // create a ctx with a newer 'now' DefaultSyncContext ctx = new DefaultSyncContext(syncConfig, idp, userManager, valueFactory); long expTime = ctx.now - syncCtx.now - 1; assertTrue(ctx.isExpired(a, expTime, "any")); // remove last-sync property a.removeProperty(DefaultSyncContext.REP_LAST_SYNCED); assertTrue(syncCtx.isExpired(a, syncConfig.group().getExpirationTime(), "any")); }
@Test public void testIsExpiredSyncedUser() throws Exception { ExternalIdentity externalUser = idp.listUsers().next(); sync(externalUser); Authorizable a = userManager.getAuthorizable(externalUser.getId()); assertFalse(syncCtx.isExpired(a, syncConfig.user().getExpirationTime(), "any")); assertTrue(syncCtx.isExpired(a, -1, "any")); // create a ctx with a newer 'now' DefaultSyncContext ctx = new DefaultSyncContext(syncConfig, idp, userManager, valueFactory); long expTime = ctx.now - syncCtx.now - 1; assertTrue(ctx.isExpired(a, expTime, "any")); // remove last-sync property a.removeProperty(DefaultSyncContext.REP_LAST_SYNCED); assertTrue(syncCtx.isExpired(a, syncConfig.user().getExpirationTime(), "any")); }