use of javax.annotation.security.RolesAllowed in project iaf by ibissource.
the class TransactionalStorage method downloadPipeMessage.
@GET
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/adapters/{adapterName}/pipes/{pipeName}/messages/{messageId}/download")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response downloadPipeMessage(@PathParam("adapterName") String adapterName, @PathParam("pipeName") String pipeName, @PathParam("messageId") String messageId) throws ApiException {
Adapter adapter = getIbisManager().getRegisteredAdapter(adapterName);
if (adapter == null) {
throw new ApiException("Adapter not found!");
}
MessageSendingPipe pipe = (MessageSendingPipe) adapter.getPipeLine().getPipe(pipeName);
if (pipe == null) {
throw new ApiException("Pipe [" + pipeName + "] not found!");
}
// messageId is double URLEncoded, because it can contain '/' in ExchangeMailListener
messageId = Misc.urlDecode(messageId);
String message = getMessage(pipe.getMessageLog(), messageId);
MediaType mediaType = getMediaType(message);
String contentDispositionHeader = getContentDispositionHeader(mediaType, messageId);
return Response.status(Response.Status.OK).type(mediaType).entity(message).header("Content-Disposition", contentDispositionHeader).build();
}
use of javax.annotation.security.RolesAllowed in project iaf by ibissource.
the class TransactionalStorage method browsePipeMessage.
@GET
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/adapters/{adapterName}/pipes/{pipeName}/messages/{messageId}")
@Produces(MediaType.APPLICATION_JSON)
public Response browsePipeMessage(@PathParam("adapterName") String adapterName, @PathParam("pipeName") String pipeName, @PathParam("messageId") String messageId) throws ApiException {
Adapter adapter = getIbisManager().getRegisteredAdapter(adapterName);
if (adapter == null) {
throw new ApiException("Adapter not found!");
}
MessageSendingPipe pipe = (MessageSendingPipe) adapter.getPipeLine().getPipe(pipeName);
if (pipe == null) {
throw new ApiException("Pipe [" + pipeName + "] not found!");
}
IMessageBrowser<?> storage = pipe.getMessageLog();
// messageId is double URLEncoded, because it can contain '/' in ExchangeMailListener
messageId = Misc.urlDecode(messageId);
try {
String message = getMessage(storage, messageId);
StorageItemDTO entity = getMessageMetadata(storage, messageId, message);
return Response.status(Response.Status.OK).entity(entity).build();
} catch (ListenerException e) {
throw new ApiException("Could not get message metadata", e);
}
}
use of javax.annotation.security.RolesAllowed in project iaf by ibissource.
the class TransactionalStorage method deleteReceiverMessages.
@DELETE
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/adapters/{adapterName}/receivers/{receiverName}/stores/Error")
@Relation("pipeline")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response deleteReceiverMessages(@PathParam("adapterName") String adapterName, @PathParam("receiverName") String receiverName, MultipartBody input) throws ApiException {
Adapter adapter = getIbisManager().getRegisteredAdapter(adapterName);
if (adapter == null) {
throw new ApiException("Adapter not found!");
}
Receiver<?> receiver = adapter.getReceiverByName(receiverName);
if (receiver == null) {
throw new ApiException("Receiver [" + receiverName + "] not found!");
}
String[] messageIds = getMessages(input);
List<String> errorMessages = new ArrayList<>();
for (int i = 0; i < messageIds.length; i++) {
try {
deleteMessage(receiver.getMessageBrowser(ProcessState.ERROR), messageIds[i]);
} catch (ApiException e) {
// The message of an ApiException is wrapped in HTML, try to get the original message instead!
errorMessages.add(e.getCause().getMessage());
} catch (Exception e) {
errorMessages.add(e.getMessage());
}
}
if (errorMessages.isEmpty()) {
return Response.status(Response.Status.OK).build();
}
return Response.status(Response.Status.ACCEPTED).entity(errorMessages).build();
}
use of javax.annotation.security.RolesAllowed in project jersey by jersey.
the class AircraftsResource method delete.
@DELETE
@Path("{id}")
@Produces(TEXT_PLAIN)
@RolesAllowed("admin")
public String delete(@ValidAircraftId @PathParam("id") Integer id) {
Flight flight = DataStore.selectFlightByAircraft(id);
if (flight != null) {
throw new BadRequestException("Aircraft assigned to a flight.");
}
Aircraft aircraft = DataStore.removeAircraft(id);
return String.format("%03d", aircraft.getId());
}
use of javax.annotation.security.RolesAllowed in project jersey by jersey.
the class AircraftsResource method create.
@POST
@Consumes(APPLICATION_FORM_URLENCODED)
@RolesAllowed("admin")
@Detail
public Aircraft create(@FormParam("manufacturer") String manufacturer, @FormParam("type") String type, @FormParam("capacity") Integer capacity, @DefaultValue("0") @FormParam("x-pos") Integer x, @DefaultValue("0") @FormParam("y-pos") Integer y) {
if (manufacturer == null || type == null || capacity == null) {
throw new BadRequestException("Incomplete data.");
}
Aircraft aircraft = new Aircraft();
aircraft.setType(new AircraftType(manufacturer, type, capacity));
aircraft.setLocation(SimEngine.bound(new Location(x, y)));
if (!DataStore.addAircraft(aircraft)) {
throw new InternalServerErrorException("Unable to add new aircraft.");
}
return aircraft;
}
Aggregations