net.openesb.rest.api.resources.ComponentApplicationVariableResource 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.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import net.openesb.model.api.ApplicationVariable;
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 ComponentApplicationVariableResource extends AbstractResource {
@Inject
private ConfigurationService configurationService;
private final String componentName;
public ComponentApplicationVariableResource(String componentName) {
this.componentName = componentName;
}
@GET
@Produces(MediaType.APPLICATION_JSON)
public Set getApplicationVariables() throws ManagementException {
Set variables = new TreeSet(new Comparator() {
@Override
public int compare(ApplicationVariable var1, ApplicationVariable var2) {
return var1.getName().compareTo(var2.getName());
}
});
variables.addAll(configurationService.
getApplicationVariables(componentName));
return variables;
}
@DELETE
@Produces(MediaType.APPLICATION_JSON)
public Set deleteApplicationVariables(@QueryParam("name") String name) throws ManagementException {
configurationService.deleteApplicationVariables(componentName, new String []{name});
return getApplicationVariables();
}
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Set updateApplicationVariable(Set variables) throws ManagementException {
configurationService.updateApplicationVariable(componentName, variables);
return getApplicationVariables();
}
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Set addApplicationVariable(Set variables) throws ManagementException {
configurationService.addApplicationVariable(componentName, variables);
return getApplicationVariables();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy