class OrchestrationRequests {

    @POST
    @Path("/{version: [vV][4-7]}/{requestId}/unlock")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    @Operation(description = "Unlock Orchestrated Requests for a given requestId", responses = @ApiResponse(
            content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))))
    @Transactional
    public Response unlockOrchestrationRequest(String requestJSON, @PathParam("requestId") String requestId,
            @PathParam("version") String version) throws ApiException {

        logger.debug("requestId is: {}", requestId);
        ServiceInstancesRequest sir;

        try {
            ObjectMapper mapper = new ObjectMapper();
            sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
        } catch (IOException e) {
            logger.error("Exception occurred", e);
            ErrorLoggerInfo errorLoggerInfo =
                    new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError)
                            .build();
            ValidateException validateException =
                    new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(),
                            HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
                                    .errorInfo(errorLoggerInfo).build();

            throw validateException;

        }
        try {
            msoRequest.parseOrchestration(sir);
        } catch (Exception e) {
            logger.error("Exception occurred", e);
            ErrorLoggerInfo errorLoggerInfo =
                    new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError)
                            .build();
            ValidateException validateException =
                    new ValidateException.Builder("Error parsing request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST,
                            ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build();
            throw validateException;
        }

        InfraActiveRequests infraActiveRequest = infraActiveRequestLookup(requestId);

        String status = infraActiveRequest.getRequestStatus();
        if (Status.IN_PROGRESS.toString().equalsIgnoreCase(status) || Status.PENDING.toString().equalsIgnoreCase(status)
                || Status.PENDING_MANUAL_TASK.toString().equalsIgnoreCase(status)) {
            infraActiveRequest.setRequestStatus(Status.UNLOCKED.toString());
            infraActiveRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
            infraActiveRequest.setRequestId(requestId);
            requestsDbClient.save(infraActiveRequest);
        } else {

            ErrorLoggerInfo errorLoggerInfo =
                    new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, ErrorCode.DataError).build();

            ValidateException validateException = new ValidateException.Builder(
                    "Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked",
                    HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo)
                            .build();

            throw validateException;
        }
        return Response.status(HttpStatus.SC_NO_CONTENT).entity("").build();
    }

}