use of org.opennms.netmgt.alarmd.northbounder.syslog.SyslogDestination in project opennms by OpenNMS.
the class SyslogNorthbounderConfigurationResource method updateSyslogDestination.
/**
* Update a specific Syslog Destination.
*
* @param destinationName the destination name
* @param params the parameters map
* @return the response
*/
@PUT
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Path("destinations/{destinationName}")
public Response updateSyslogDestination(@PathParam("destinationName") final String destinationName, final MultivaluedMapImpl params) {
writeLock();
try {
boolean modified = false;
SyslogDestination destination = getSyslogDestination(destinationName);
final BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(destination);
for (final String key : params.keySet()) {
if (wrapper.isWritableProperty(key)) {
final String stringValue = params.getFirst(key);
final Object value = wrapper.convertIfNecessary(stringValue, (Class<?>) wrapper.getPropertyType(key));
wrapper.setPropertyValue(key, value);
modified = true;
}
}
if (modified) {
saveConfiguration();
return Response.noContent().build();
}
return Response.notModified().build();
} finally {
writeUnlock();
}
}
Aggregations