use of org.opennms.netmgt.config.microblog.MicroblogConfiguration in project opennms by OpenNMS.
the class DefaultMicroblogConfigurationDao method saveProfile.
public void saveProfile(final MicroblogProfile profile) throws IOException {
reloadConfiguration();
final MicroblogConfiguration config = getContainer().getObject();
boolean found = false;
final ListIterator<MicroblogProfile> it = config.getMicroblogProfiles().listIterator();
while (it.hasNext()) {
final MicroblogProfile existing = it.next();
if (existing.getName().equals(profile.getName())) {
found = true;
it.set(profile);
break;
}
}
if (!found)
config.addMicroblogProfile(profile);
final File file = getContainer().getFile();
if (file == null) {
LOG.warn("No file associated with this config. Skipping marshal.");
return;
}
FileWriter writer = null;
try {
writer = new FileWriter(file);
JaxbUtils.marshal(config, writer);
} finally {
IOUtils.closeQuietly(writer);
}
}
Aggregations