private Map<String, MdObjectAttribute> getAttributeChanges(Set<Attribute> attributes) { Map<String, MdObjectAttribute> changes = new HashMap<String, MdObjectAttribute>(); for (Attribute attr : attributes) { if (!attr.getValue().isEmpty()) { MdObjectAttribute a = new MdObjectAttribute( attr.getName(), MetadataState.LOCAL, attr.getValue().iterator().next().toString()); changes.put(attr.getName(), a); } else { MdObjectAttribute a = new MdObjectAttribute(attr.getName(), MetadataState.LOCAL, null); changes.put(attr.getName(), a); } } return changes; }
private boolean isRename(Set<Attribute> attributes) { for (Attribute attr : attributes) { if (Name.NAME.equals(attr.getName())) { return true; } } return false; }
private void displayUser(ConnectorObject user) { Set<Attribute> attributes = user.getAttributes(); for (Attribute attribute : attributes) { System.out.println(attribute.getName()); List<Object> values = attribute.getValue(); for (Object value : values) { System.out.println(" " + value.getClass().getName() + ":" + value); } } }
@Override public void serialize( final Attribute source, final JsonGenerator jgen, final SerializerProvider sp) throws IOException { jgen.writeStartObject(); jgen.writeStringField("name", source.getName()); jgen.writeFieldName("value"); if (source.getValue() == null) { jgen.writeNull(); } else { jgen.writeStartArray(); for (Object value : source.getValue()) { if (value == null) { jgen.writeNull(); } else if (value instanceof GuardedString) { jgen.writeObject(value); } else if (value instanceof Integer) { jgen.writeNumber((Integer) value); } else if (value instanceof Long) { jgen.writeNumber((Long) value); } else if (value instanceof Double) { jgen.writeNumber((Double) value); } else if (value instanceof Boolean) { jgen.writeBoolean((Boolean) value); } else if (value instanceof byte[]) { jgen.writeString(BYTE_ARRAY_PREFIX + Base64.encode((byte[]) value) + BYTE_ARRAY_SUFFIX); } else { jgen.writeString(value.toString()); } } jgen.writeEndArray(); } jgen.writeEndObject(); }