use of org.opennms.netmgt.provision.persist.foreignsource.PluginConfig in project opennms by OpenNMS.
the class DefaultProvisionService method getPluginsForForeignSource.
/**
* <p>getPluginsForForeignSource</p>
*
* @param pluginClass a {@link java.lang.Class} object.
* @param foreignSourceName a {@link java.lang.String} object.
* @param <T> a T object.
* @return a {@link java.util.List} object.
*/
public <T> List<T> getPluginsForForeignSource(final Class<T> pluginClass, final String foreignSourceName) {
final ForeignSource foreignSource = m_foreignSourceRepository.getForeignSource(foreignSourceName);
assertNotNull(foreignSource, "Expected a foreignSource with name %s", foreignSourceName);
final List<PluginConfig> configs = foreignSource.getPolicies();
if (configs == null) {
return Collections.emptyList();
}
final List<T> plugins = new ArrayList<T>(configs.size());
for (final PluginConfig config : configs) {
final T plugin = m_pluginRegistry.getPluginInstance(pluginClass, config);
if (plugin == null) {
LOG.trace("Configured plugin is not appropropriate for policy class {}: {}", pluginClass, config);
} else {
plugins.add(plugin);
}
}
return plugins;
}
use of org.opennms.netmgt.provision.persist.foreignsource.PluginConfig in project opennms by OpenNMS.
the class ForeignSourceRestService method deleteDetector.
/**
* <p>deleteDetector</p>
*
* @param foreignSource a {@link java.lang.String} object.
* @param detector a {@link java.lang.String} object.
* @return a {@link javax.ws.rs.core.Response} object.
*/
@DELETE
@Path("{foreignSource}/detectors/{detector}")
@Transactional
public Response deleteDetector(@PathParam("foreignSource") final String foreignSource, @PathParam("detector") final String detector) {
writeLock();
try {
ForeignSource fs = getActiveForeignSource(foreignSource);
List<PluginConfig> detectors = fs.getDetectors();
PluginConfig removed = removeEntry(detectors, detector);
if (removed != null) {
fs.updateDateStamp();
fs.setDetectors(detectors);
m_pendingForeignSourceRepository.save(fs);
return Response.accepted().build();
}
return Response.notModified().build();
} finally {
writeUnlock();
}
}
use of org.opennms.netmgt.provision.persist.foreignsource.PluginConfig in project opennms by OpenNMS.
the class ForeignSourceRestService method deletePolicy.
/**
* <p>deletePolicy</p>
*
* @param foreignSource a {@link java.lang.String} object.
* @param policy a {@link java.lang.String} object.
* @return a {@link javax.ws.rs.core.Response} object.
*/
@DELETE
@Path("{foreignSource}/policies/{policy}")
@Transactional
public Response deletePolicy(@PathParam("foreignSource") final String foreignSource, @PathParam("policy") final String policy) {
writeLock();
try {
ForeignSource fs = getActiveForeignSource(foreignSource);
List<PluginConfig> policies = fs.getPolicies();
PluginConfig removed = removeEntry(policies, policy);
if (removed != null) {
fs.updateDateStamp();
fs.setPolicies(policies);
m_pendingForeignSourceRepository.save(fs);
return Response.accepted().build();
}
return Response.notModified().build();
} finally {
writeUnlock();
}
}
Aggregations