use of nl.nn.adapterframework.configuration.IbisManager.IbisAction in project iaf by ibissource.
the class IbisActionJob method configure.
@Override
public void configure() throws ConfigurationException {
super.configure();
// Try and parse the JobDefFunction as an IbisAction
this.ibisAction = EnumUtils.parse(IbisAction.class, "function", jobAction.name());
if (StringUtils.isEmpty(getAdapterName())) {
throw new ConfigurationException("a adapterName must be specified");
}
Adapter adapter = adapterManager.getAdapter(getAdapterName());
if (adapter == null) {
// Make sure the adapter is registered in this configuration
String msg = "Jobdef [" + getName() + "] got error: adapter [" + getAdapterName() + "] not registered.";
throw new ConfigurationException(msg);
}
if (jobAction == Action.STOPRECEIVER || jobAction == Action.STARTRECEIVER) {
if (StringUtils.isEmpty(getReceiverName())) {
throw new ConfigurationException("a receiverName must be specified");
}
if (adapter.getReceiverByName(getReceiverName()) == null) {
String msg = "Jobdef [" + getName() + "] got error: adapter [" + getAdapterName() + "] receiver [" + getReceiverName() + "] not registered.";
throw new ConfigurationException(msg);
}
}
}
use of nl.nn.adapterframework.configuration.IbisManager.IbisAction in project iaf by ibissource.
the class ShowConfigurationStatus method updateAdapters.
@SuppressWarnings("unchecked")
// Normally you don't use the PUT method on a collection...
@PUT
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/adapters/")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateAdapters(LinkedHashMap<String, Object> json) throws ApiException {
// PUT defaults to no content
Response.ResponseBuilder response = Response.status(Response.Status.NO_CONTENT);
IbisAction action = null;
ArrayList<String> adapters = new ArrayList<>();
for (Entry<String, Object> entry : json.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (key.equalsIgnoreCase("action")) {
// Start or stop an adapter!
if (value.equals("stop")) {
action = IbisAction.STOPADAPTER;
}
if (value.equals("start")) {
action = IbisAction.STARTADAPTER;
}
}
if (key.equalsIgnoreCase("adapters")) {
try {
adapters.addAll((ArrayList<String>) value);
} catch (Exception e) {
return response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
}
if (action != null) {
response.status(Response.Status.ACCEPTED);
if (adapters.isEmpty()) {
getIbisManager().handleAction(action, "*ALL*", "*ALL*", null, getUserPrincipalName(), false);
} else {
for (Iterator<String> iterator = adapters.iterator(); iterator.hasNext(); ) {
String adapterName = iterator.next();
getIbisManager().handleAction(action, "", adapterName, null, getUserPrincipalName(), false);
}
}
}
return response.build();
}
use of nl.nn.adapterframework.configuration.IbisManager.IbisAction in project iaf by ibissource.
the class ShowConfigurationStatus method updateReceiver.
@PUT
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/adapters/{adapterName}/receivers/{receiverName}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateReceiver(@PathParam("adapterName") String adapterName, @PathParam("receiverName") String receiverName, LinkedHashMap<String, Object> json) throws ApiException {
Adapter adapter = getAdapter(adapterName);
Receiver<?> receiver = adapter.getReceiverByName(receiverName);
if (receiver == null) {
throw new ApiException("Receiver [" + receiverName + "] not found!");
}
// PUT defaults to no content
Response.ResponseBuilder response = Response.status(Response.Status.NO_CONTENT);
for (Entry<String, Object> entry : json.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (key.equalsIgnoreCase("action")) {
// Start or stop an adapter!
IbisAction action = null;
if (value.equals("stop")) {
action = IbisAction.STOPRECEIVER;
} else if (value.equals("start")) {
action = IbisAction.STARTRECEIVER;
} else if (value.equals("incthread")) {
action = IbisAction.INCTHREADS;
} else if (value.equals("decthread")) {
action = IbisAction.DECTHREADS;
}
if (action == null)
throw new ApiException("no or unknown action provided");
getIbisManager().handleAction(action, "", adapterName, receiverName, getUserPrincipalName(), false);
response.entity("{\"status\":\"ok\"}");
}
}
return response.build();
}
use of nl.nn.adapterframework.configuration.IbisManager.IbisAction in project iaf by ibissource.
the class ShowConfigurationStatus method updateAdapter.
@PUT
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/adapters/{adapterName}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateAdapter(@PathParam("adapterName") String adapterName, LinkedHashMap<String, Object> json) throws ApiException {
// Check if the adapter exists!
getAdapter(adapterName);
// PUT defaults to no content
Response.ResponseBuilder response = Response.status(Response.Status.NO_CONTENT);
for (Entry<String, Object> entry : json.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (key.equalsIgnoreCase("action")) {
// Start or stop an adapter!
IbisAction action = null;
if (value.equals("stop")) {
action = IbisAction.STOPADAPTER;
}
if (value.equals("start")) {
action = IbisAction.STARTADAPTER;
}
getIbisManager().handleAction(action, "", adapterName, null, getUserPrincipalName(), false);
response.entity("{\"status\":\"ok\"}");
}
}
return response.build();
}
Aggregations