@Deprecated public Map<String, Profile> getAllProfiles() { Map<String, Profile> legacyProfiles = new HashMap<String, Profile>(); for (Map.Entry<String, BasicProfile> entry : getAllBasicProfiles().entrySet()) { final String profileName = entry.getKey(); legacyProfiles.put(profileName, new Profile(profileName, entry.getValue().getProperties(), new StaticCredentialsProvider( getCredentials(profileName)))); } return legacyProfiles; }
private void writeProfile(Profile profile) { writeProfileName(profile.getProfileName()); for (Entry<String, String> entry : profile.getProperties().entrySet()) { writeProperty(entry.getKey(), entry.getValue()); } }
@Override protected void onProfileProperty(String profileName, String propertyKey, String propertyValue, boolean isSupportedProperty, String line) { // Record that this property key has been declared for this profile if (existingProfileProperties.get(profileName) == null) { existingProfileProperties.put(profileName, new HashSet<String>()); } existingProfileProperties.get(profileName).add(propertyKey); if (deletedProfiles.contains(profileName)) return; // Keep the unsupported properties if ( !isSupportedProperty ) { writeLine(line); return; } // flush all the buffered comments and empty lines before this property line flush(); // Modify the property value if (newProfiles.containsKey(profileName)) { String newValue = newProfiles.get(profileName) .getPropertyValue(propertyKey); if (newValue != null) { writeProperty(propertyKey, newValue); } // else remove that line } else { writeLine(line); } }
/** * Modify or insert new profiles into an existing credentials file by * in-place modification. Only the properties of the affected profiles will * be modified; all the unaffected profiles and comment lines will remain * the same. This method does not support renaming a profile. * * @param destination * The destination file to modify * @param profiles * All the credential profiles to be written. */ public static void modifyOrInsertProfiles(File destination, Profile... profiles) { final Map<String, Profile> modifications = new LinkedHashMap<String, Profile>(); for (Profile profile : profiles) { modifications.put(profile.getProfileName(), profile); } modifyProfiles(destination, modifications); }
/** * Returns the value of a specific property that is included in this Profile instance. * @see Profile#getProperties() */ public String getPropertyValue(String propertyName) { return getProperties().get(propertyName); } }
@Override protected void onProfileStartingLine(String profileName, String line) { existingProfileProperties.put(profileName, new HashSet<String>()); // Copy the line after flush the buffer flush(); if (deletedProfiles.contains(profileName)) return; // If the profile name is changed if (newProfiles.get(profileName) != null) { String newProfileName = newProfiles.get(profileName).getProfileName(); if ( !newProfileName.equals(profileName) ) { line = "[" + newProfileName + "]"; } } writeLine(line); }
@Override protected void onProfileEndingLine(String prevProfileName) { // Check whether we need to insert new properties into this profile Profile modifiedProfile = newProfiles.get(prevProfileName); if (modifiedProfile != null) { for (Entry<String, String> entry : modifiedProfile.getProperties().entrySet()) { String propertyKey = entry.getKey(); String propertyValue = entry.getValue(); if ( !existingProfileProperties.get(prevProfileName).contains(propertyKey) ) { writeProperty(propertyKey, propertyValue); } } } // flush all the buffered comments and empty lines flush(); }
private void writeProfile(Profile profile) { writeProfileName(profile.getProfileName()); for (Entry<String, String> entry : profile.getProperties().entrySet()) { writeProperty(entry.getKey(), entry.getValue()); } }
final Map<String, Profile> modifications = new LinkedHashMap<String, Profile>(); for (Profile profile : profiles) { modifications.put(profile.getProfileName(), profile);
/** * Returns the value of a specific property that is included in this Profile instance. * @see Profile#getProperties() */ public String getPropertyValue(String propertyName) { return getProperties().get(propertyName); } }
@Deprecated public Map<String, Profile> getAllProfiles() { Map<String, Profile> legacyProfiles = new HashMap<String, Profile>(); for (Map.Entry<String, BasicProfile> entry : getAllBasicProfiles().entrySet()) { final String profileName = entry.getKey(); legacyProfiles.put(profileName, new Profile(profileName, entry.getValue().getProperties(), new StaticCredentialsProvider( getCredentials(profileName)))); } return legacyProfiles; }
@Override protected void onProfileProperty(String profileName, String propertyKey, String propertyValue, boolean isSupportedProperty, String line) { // Record that this property key has been declared for this profile if (existingProfileProperties.get(profileName) == null) { existingProfileProperties.put(profileName, new HashSet<String>()); } existingProfileProperties.get(profileName).add(propertyKey); if (deletedProfiles.contains(profileName)) return; // Keep the unsupported properties if ( !isSupportedProperty ) { writeLine(line); return; } // flush all the buffered comments and empty lines before this property line flush(); // Modify the property value if (newProfiles.containsKey(profileName)) { String newValue = newProfiles.get(profileName) .getPropertyValue(propertyKey); if (newValue != null) { writeProperty(propertyKey, newValue); } // else remove that line } else { writeLine(line); } }
private void writeProfile(Profile profile) { writeProfileName(profile.getProfileName()); for (Entry<String, String> entry : profile.getProperties().entrySet()) { writeProperty(entry.getKey(), entry.getValue()); } }
/** * Modify or insert new profiles into an existing credentials file by * in-place modification. Only the properties of the affected profiles will * be modified; all the unaffected profiles and comment lines will remain * the same. This method does not support renaming a profile. * * @param destination * The destination file to modify * @param profiles * All the credential profiles to be written. */ public static void modifyOrInsertProfiles(File destination, Profile... profiles) { final Map<String, Profile> modifications = new LinkedHashMap<String, Profile>(); for (Profile profile : profiles) { modifications.put(profile.getProfileName(), profile); } modifyProfiles(destination, modifications); }
@Override protected void onProfileEndingLine(String prevProfileName) { // Check whether we need to insert new properties into this profile Profile modifiedProfile = newProfiles.get(prevProfileName); if (modifiedProfile != null) { for (Entry<String, String> entry : modifiedProfile.getProperties().entrySet()) { String propertyKey = entry.getKey(); String propertyValue = entry.getValue(); if ( !existingProfileProperties.get(prevProfileName).contains(propertyKey) ) { writeProperty(propertyKey, propertyValue); } } } // flush all the buffered comments and empty lines flush(); }
@Deprecated public Map<String, Profile> getAllProfiles() { Map<String, Profile> legacyProfiles = new HashMap<String, Profile>(); for (Map.Entry<String, BasicProfile> entry : getAllBasicProfiles().entrySet()) { final String profileName = entry.getKey(); legacyProfiles.put(profileName, new Profile(profileName, entry.getValue().getProperties(), new StaticCredentialsProvider( getCredentials(profileName)))); } return legacyProfiles; }
@Override protected void onProfileProperty(String profileName, String propertyKey, String propertyValue, boolean isSupportedProperty, String line) { // Record that this property key has been declared for this profile if (existingProfileProperties.get(profileName) == null) { existingProfileProperties.put(profileName, new HashSet<String>()); } existingProfileProperties.get(profileName).add(propertyKey); if (deletedProfiles.contains(profileName)) return; // Keep the unsupported properties if ( !isSupportedProperty ) { writeLine(line); return; } // flush all the buffered comments and empty lines before this property line flush(); // Modify the property value if (newProfiles.containsKey(profileName)) { String newValue = newProfiles.get(profileName) .getPropertyValue(propertyKey); if (newValue != null) { writeProperty(propertyKey, newValue); } // else remove that line } else { writeLine(line); } }
@Override protected void onProfileStartingLine(String profileName, String line) { existingProfileProperties.put(profileName, new HashSet<String>()); // Copy the line after flush the buffer flush(); if (deletedProfiles.contains(profileName)) return; // If the profile name is changed if (newProfiles.get(profileName) != null) { String newProfileName = newProfiles.get(profileName).getProfileName(); if ( !newProfileName.equals(profileName) ) { line = "[" + newProfileName + "]"; } } writeLine(line); }
/** * Returns the value of a specific property that is included in this Profile instance. * @see Profile#getProperties() */ public String getPropertyValue(String propertyName) { return getProperties().get(propertyName); } }
final Map<String, Profile> modifications = new LinkedHashMap<String, Profile>(); for (Profile profile : profiles) { modifications.put(profile.getProfileName(), profile);