public int compare(T o1, T o2) { if (o1 instanceof User && o2 instanceof User) { if (ascending) { return o1.getKey().compareTo(o2.getKey()); } else { return o2.getKey().compareTo(o1.getKey()); } } else { Group g1 = (Group)o1; Group g2 = (Group)o2; if (ascending) { return g1.getName().compareTo(g2.getName()); } else { return g2.getName().compareTo(g1.getName()); } } } });
private static void filterByIdFilter(List<? extends IdentityType> types, String filter) throws Exception { Set<IdentityType> toRemove = new HashSet<IdentityType>(); String regex = Tools.wildcardToRegex(filter); for (IdentityType type : types) { String id = null; if (type instanceof User) { id = type.getKey(); } else if (type instanceof Group) { id = ((Group)type).getName(); } else { // shouldn't happen throw new IllegalStateException(); } if (!id.matches(regex)) { toRemove.add(type); } } for (IdentityType type : toRemove) { types.remove(type); } }
public void removeAttributes(IdentityType identityType, String[] attributeNames) throws IdentityException { try { checkNotNullArgument(identityType, "IdentityType"); checkNotNullArgument(attributeNames, "Attribute names"); preAttributesRemove(identityType, attributeNames); getRepository().removeAttributes(getInvocationContext(), createIdentityObject(identityType), attributeNames); if (cache != null) { // Grab the new profile and persist in cache cache.invalidateAttributes(cacheNS, identityType.getKey()); this.getAttributes(identityType); } postAttributesRemove(identityType, attributeNames); } catch (IdentityException e) { if (log.isLoggable(Level.FINER)) { log.log(Level.FINER, "Exception occurred: ", e); } throw e; } }
public void addAttributes(IdentityType identityType, Attribute[] attributes) throws IdentityException { try { checkNotNullArgument(identityType, "IdentityType"); checkNotNullArgument(attributes, "Attributes"); preAttributesAdd(identityType, attributes); getRepository().addAttributes(getInvocationContext(), createIdentityObject(identityType), convertAttributes(attributes)); if (cache != null) { // Grab the new profile and persist in cache cache.invalidateAttributes(cacheNS, identityType.getKey()); this.getAttributes(identityType); } postAttributesAdd(identityType, attributes); } catch (IdentityException e) { if (log.isLoggable(Level.FINER)) { log.log(Level.FINER, "Exception occurred: ", e); } throw e; } }
public void updateAttributes(IdentityType identity, Attribute[] attributes) throws IdentityException { try { checkNotNullArgument(identity, "IdentityType"); checkNotNullArgument(attributes, "Attributes"); preAttributesUpdate(identity, attributes); getRepository().updateAttributes(getInvocationContext(), createIdentityObject(identity), convertAttributes(attributes)); if (cache != null) { // Grab the new profile and persist in cache cache.invalidateAttributes(cacheNS, identity.getKey()); this.getAttributes(identity); } postAttributesUpdate(identity, attributes); } catch (IdentityException e) { if (log.isLoggable(Level.FINER)) { log.log(Level.FINER, "Exception occurred: ", e); } throw e; } }