/** * Stores the given Device Print Profiles for the specified user. * * @param amIdentity The user's identity. * @param profiles The {@code List} of the user's device print profiles. */ void saveProfiles(AMIdentityWrapper amIdentity, List<Map<String, Object>> profiles) { try { Set<String> vals = new HashSet<String>(); for (Map<String, Object> profile : profiles) { StringWriter writer = new StringWriter(); MAPPER.writeValue(writer, profile); vals.add(writer.toString()); } Map<String, Set> profilesMap = new HashMap<String, Set>(); profilesMap.put(LDAP_DEVICE_PRINT_ATTRIBUTE_NAME, vals); amIdentity.setAttributes(profilesMap); amIdentity.store(); DEBUG.message("Profiles stored"); } catch (Exception e) { DEBUG.error("Could not store profiles. " + e); } }
/** * Gets the Device Print Profiles for the specified user. * * @param amIdentity The user's identity. * @return A {@code List} of the user's device print profiles. * @throws IdRepoException If there is a problem getting the device print profiles from LDAP. * @throws SSOException If there is a problem getting the device print profiles from LDAP. * @throws IOException If there is a problem parsing the device print profiles. */ List<Map<String, Object>> getProfiles(AMIdentityWrapper amIdentity) throws IdRepoException, SSOException, IOException { Set<String> set = (Set<String>) amIdentity.getAttribute(LDAP_DEVICE_PRINT_ATTRIBUTE_NAME); List<Map<String, Object>> profiles = new ArrayList<Map<String, Object>>(); for (String profile : set) { profiles.add(MAPPER.readValue(profile, Map.class)); } return profiles; }