net.openesb.rest.api.resources.ComponentConfigurationResource Maven / Gradle / Ivy
The newest version!
package net.openesb.rest.api.resources;
import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import net.openesb.model.api.ComponentConfiguration;
import net.openesb.management.api.ConfigurationService;
import net.openesb.management.api.ManagementException;
import net.openesb.rest.api.annotation.RequiresAuthentication;
/**
*
* @author David BRASSELY (brasseld at gmail.com)
* @author OpenESB Community
*/
@RequiresAuthentication
public class ComponentConfigurationResource extends AbstractResource {
@Inject
private ConfigurationService configurationService;
private final String componentName;
public ComponentConfigurationResource(String componentName) {
this.componentName = componentName;
}
@GET
@Produces(MediaType.APPLICATION_JSON)
public Set getComponentConfiguration() throws ManagementException {
Set configurations = new TreeSet(new Comparator() {
@Override
public int compare(ComponentConfiguration conf1, ComponentConfiguration conf2) {
return conf1.getName().compareTo(conf2.getName());
}
});
configurations.addAll(configurationService.
getComponentConfiguration(componentName));
return configurations;
}
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Set setComponentConfiguration(Set configurations) throws ManagementException {
configurationService.updateComponentConfiguration(
componentName, configurations);
return getComponentConfiguration();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy