use of org.apache.nifi.stream.io.ByteArrayOutputStream in project nifi by apache.
the class DataTransferResource method extendPortTransactionTTL.
public Response extendPortTransactionTTL(String portType, String portId, String transactionId, HttpServletRequest req, HttpServletResponse res, ServletContext context, UriInfo uriInfo, InputStream inputStream) {
final ValidateRequestResult validationResult = validateResult(req, portId, transactionId);
if (validationResult.errResponse != null) {
return validationResult.errResponse;
}
if (!PORT_TYPE_INPUT.equals(portType) && !PORT_TYPE_OUTPUT.equals(portType)) {
return responseCreator.wrongPortTypeResponse(portType, portId);
}
logger.debug("extendOutputPortTransactionTTL request: portType={}, portId={}, transactionId={}", portType, portId, transactionId);
final int transportProtocolVersion = validationResult.transportProtocolVersion;
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final Peer peer = constructPeer(req, inputStream, out, portId, transactionId);
try {
// Do handshake
initiateServerProtocol(req, peer, transportProtocolVersion);
transactionManager.extendTransaction(transactionId);
final TransactionResultEntity entity = new TransactionResultEntity();
entity.setResponseCode(ResponseCode.CONTINUE_TRANSACTION.getCode());
entity.setMessage("Extended TTL.");
return noCache(setCommonHeaders(Response.ok(entity), transportProtocolVersion, transactionManager)).build();
} catch (HandshakeException e) {
return responseCreator.handshakeExceptionResponse(e);
} catch (Exception e) {
return responseCreator.unexpectedErrorResponse(portId, transactionId, e);
}
}
Aggregations