use of org.opennms.netmgt.alarmd.northbounder.email.EmailDestination in project opennms by OpenNMS.
the class EmailNorthbounderConfigurationResource method updateEmailDestination.
/**
* Updates a specific email 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 updateEmailDestination(@PathParam("destinationName") final String destinationName, final MultivaluedMapImpl params) {
writeLock();
try {
boolean modified = false;
final EmailDestination destination = getEmailDestination(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