Search in sources :

Example 1 with MicroblogConfiguration

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);
    }
}
Also used : MicroblogProfile(org.opennms.netmgt.config.microblog.MicroblogProfile) FileWriter(java.io.FileWriter) File(java.io.File) MicroblogConfiguration(org.opennms.netmgt.config.microblog.MicroblogConfiguration)

Aggregations

File (java.io.File)1 FileWriter (java.io.FileWriter)1 MicroblogConfiguration (org.opennms.netmgt.config.microblog.MicroblogConfiguration)1 MicroblogProfile (org.opennms.netmgt.config.microblog.MicroblogProfile)1