Java Code Examples for org.eclipse.jetty.http.HttpStatus#CREATED_201

The following examples show how to use org.eclipse.jetty.http.HttpStatus#CREATED_201 . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CassandraMigrationRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@POST
@Path("upgrade/latest")
@ApiOperation("Triggers a migration of Cassandra schema to the latest available")
@ApiResponses({
    @ApiResponse(code = HttpStatus.CREATED_201, message = "The taskId of the given scheduled task", response = TaskIdDto.class,
        responseHeaders = {
            @ResponseHeader(name = "Location", description = "URL of the resource associated with the scheduled task")
        }),
    @ApiResponse(code = HttpStatus.CONFLICT_409, message = "Migration can not be done")
})
public Task upgradeToLatest() {
    try {
        return cassandraMigrationService.upgradeToLastVersion();
    } catch (IllegalStateException e) {
        LOGGER.info(MIGRATION_REQUEST_CAN_NOT_BE_DONE, e);
        throw ErrorResponder.builder()
            .statusCode(HttpStatus.CONFLICT_409)
            .type(ErrorType.WRONG_STATE)
            .message(MIGRATION_REQUEST_CAN_NOT_BE_DONE)
            .cause(e)
            .haltError();
    }
}
 
Example 2
Source File: EventDeadLettersRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@POST
@Path("")
@ApiOperation(value = "Performing action on all events")
@ApiImplicitParams({
    @ApiImplicitParam(
        required = true,
        dataType = "String",
        name = "action",
        paramType = "query",
        example = "?action=reDeliver",
        value = "Specify the action to perform on all events. 'reDeliver' is supported as an action, "
            + "and its purpose is to attempt a redelivery of all events present in dead letter."),
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.CREATED_201, message = "The taskId of the given scheduled task", response = TaskIdDto.class,
        responseHeaders = {
            @ResponseHeader(name = "Location", description = "URL of the resource associated with the scheduled task")
        }),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid action argument"),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = INTERNAL_SERVER_ERROR)
})
public Route performActionOnAllEvents() {
    return TaskFromRequestRegistry.of(RE_DELIVER, request -> eventDeadLettersService.redeliverAllEvents())
        .asRoute(taskManager);
}
 
Example 3
Source File: MailRepositoriesRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@DELETE
@Path("/{encodedPath}/mails")
@ApiOperation(value = "Deleting all mails in that mailRepository")
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.CREATED_201, message = "All mails are deleted", response = TaskIdDto.class),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side."),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Bad request - unknown action")
})
public void defineDeleteAll() {
    TaskFromRequest taskFromRequest = request -> {
        MailRepositoryPath path = decodedRepositoryPath(request);
        try {
            return repositoryStoreService.createClearMailRepositoryTask(path);
        } catch (MailRepositoryStore.MailRepositoryStoreException | MessagingException e) {
            throw ErrorResponder.builder()
                .statusCode(HttpStatus.INTERNAL_SERVER_ERROR_500)
                .type(ErrorResponder.ErrorType.SERVER_ERROR)
                .cause(e)
                .message("Error while deleting all mails")
                .haltError();
        }
    };
    service.delete(MAIL_REPOSITORIES + "/:encodedPath/mails", taskFromRequest.asRoute(taskManager), jsonTransformer);
}
 
Example 4
Source File: UserMailboxesRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@POST
@ApiImplicitParams({
    @ApiImplicitParam(required = true, dataType = "string", name = "username", paramType = "path"),
    @ApiImplicitParam(
        required = true,
        name = "task",
        paramType = "query parameter",
        dataType = "String",
        defaultValue = "none",
        example = "?task=reIndex",
        value = "Compulsory. Only supported value is `reIndex`")
})
@ApiOperation(value = "Perform an action on a user mailbox")
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.CREATED_201, message = "Task is created", response = TaskIdDto.class),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side."),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Bad request - details in the returned error message")
})
public Optional<Route> reIndexMailboxesRoute() {
    return TaskFromRequestRegistry.builder()
        .parameterName(TASK_PARAMETER)
        .registrations(usersMailboxesTaskRegistration)
        .buildAsRouteOptional(taskManager);
}
 
Example 5
Source File: UserQuotaRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@POST
@ApiOperation(value = "Recomputing current quotas of users")
@ApiImplicitParams({
    @ApiImplicitParam(
        required = true,
        name = "task",
        paramType = "query parameter",
        dataType = "String",
        defaultValue = "none",
        example = "?task=RecomputeCurrentQuotas",
        value = "Compulsory. Only supported value is `RecomputeCurrentQuotas`")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.CREATED_201, message = "Task is created", response = TaskIdDto.class),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side."),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Bad request - details in the returned error message")
})
public Optional<Route> definePostUsersQuota() {
    return TaskFromRequestRegistry.builder()
        .parameterName(TASK_PARAMETER)
        .registrations(usersQuotasTaskRegistration)
        .buildAsRouteOptional(taskManager);
}
 
Example 6
Source File: MessagesRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/")
@ApiOperation(value = "Operation on messages")
@ApiImplicitParams({
    @ApiImplicitParam(
        required = true,
        name = "task",
        paramType = "query parameter",
        dataType = "String",
        defaultValue = "none",
        example = "?task=SolveInconsistencies",
        value = "Compulsory. Depends on the tasks handled by the product")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.CREATED_201, message = "Task is created", response = TaskIdDto.class),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side."),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Bad request - details in the returned error message")
})
private Optional<Route> allMessagesOperations() {
    return TaskFromRequestRegistry.builder()
        .parameterName(TASK_PARAMETER)
        .registrations(allMessagesTaskRegistration)
        .buildAsRouteOptional(taskManager);
}
 
Example 7
Source File: DeletedMessagesVaultRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@DELETE
@ApiOperation(value = "Purge all expired messages based on retentionPeriod of deletedMessageVault configuration")
@ApiImplicitParams({
    @ApiImplicitParam(
        required = true,
        name = "scope",
        dataType = "String",
        paramType = "query",
        example = "?scope=expired",
        value = "Compulsory. Needs to be a purge action")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.CREATED_201, message = "Task is created", response = TaskIdDto.class),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Bad request - action is invalid"),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
private Route deleteWithScope() {
    return TaskFromRequestRegistry.builder()
        .parameterName(SCOPE_QUERY_PARAM)
        .register(EXPIRED_REGISTRATION_KEY, request -> deletedMessageVault.deleteExpiredMessagesTask())
        .buildAsRoute(taskManager);
}
 
Example 8
Source File: CassandraMappingsRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@POST
@Path(ROOT_PATH)
@ApiOperation(value = "Performing operations on cassandra data mappings")
@ApiImplicitParams({
    @ApiImplicitParam(
        required = true,
        dataType = "String",
        name = "action",
        paramType = "query",
        example = "?action=SolveInconsistencies",
        value = "Specify the action to perform on mappings. For now only 'SolveInconsistencies' is supported as an action, "
            + "and its purpose is to clean 'mappings_sources' projection table and repopulate it."),
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.CREATED_201, message = "The taskId of the given scheduled task", response = TaskIdDto.class,
        responseHeaders = {
            @ResponseHeader(name = "Location", description = "URL of the resource associated with the scheduled task")
        }),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = INVALID_ACTION_ARGUMENT_REQUEST),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = ACTION_REQUEST_CAN_NOT_BE_DONE)
})
public Route performActionOnMappings() {
    return TaskFromRequestRegistry.of(SOLVE_INCONSISTENCIES, request -> cassandraMappingsService.solveMappingsSourcesInconsistencies())
        .asRoute(taskManager);
}
 
Example 9
Source File: MailboxesRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@POST
@Path("/{mailboxId}")
@ApiOperation(value = "Re-indexes all the mails in a mailbox")
@ApiImplicitParams({
    @ApiImplicitParam(
        required = true,
        name = "task",
        paramType = "query parameter",
        dataType = "String",
        defaultValue = "none",
        example = "?task=reIndex",
        value = "Compulsory. Only supported value is `reIndex`"),
    @ApiImplicitParam(
        required = false,
        name = "messagesPerSecond",
        paramType = "query parameter",
        dataType = "Integer",
        defaultValue = "none",
        example = "?messagesPerSecond=100",
        value = "If present, determine the number of messages being processed in one second."),
    @ApiImplicitParam(
        required = true,
        name = "mailboxId",
        paramType = "path parameter",
        dataType = "String",
        defaultValue = "none",
        value = "Compulsory. Needs to be a valid mailbox ID")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.CREATED_201, message = "Task is created", response = TaskIdDto.class),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side."),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Bad request - details in the returned error message")
})
private static TaskFromRequest toTask(ReIndexer reIndexer, MailboxId.Factory mailboxIdFactory) {
    return wrap(request -> reIndexer.reIndex(extractMailboxId(mailboxIdFactory, request), ReindexingRunningOptionsParser.parse(request)));
}
 
Example 10
Source File: EventDeadLettersRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@POST
@Path("/groups/" + GROUP_PARAM)
@ApiOperation(value = "Performing action on events of a particular group")
@ApiImplicitParams({
    @ApiImplicitParam(
        required = true,
        name = "group",
        paramType = "path parameter",
        dataType = "String",
        defaultValue = "none",
        value = "Compulsory. Needs to be a valid group name"),
    @ApiImplicitParam(
        required = true,
        dataType = "String",
        name = "action",
        paramType = "query",
        example = "?action=reDeliver",
        value = "Specify the action to perform on all events of a particular group. 'reDeliver' is supported as an action, "
            + "and its purpose is to attempt a redelivery of all events present in dead letter for the specified group."),
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.CREATED_201, message = "The taskId of the given scheduled task", response = TaskIdDto.class,
        responseHeaders = {
            @ResponseHeader(name = "Location", description = "URL of the resource associated with the scheduled task")
        }),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid group name or action argument"),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = INTERNAL_SERVER_ERROR)
})
public Route performActionOnGroupEvents() {
    return TaskFromRequestRegistry.of(RE_DELIVER, request -> eventDeadLettersService.redeliverGroupEvents(parseGroup(request)))
        .asRoute(taskManager);
}
 
Example 11
Source File: MessagesRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@POST
@Path("/{messageId}")
@ApiOperation(value = "Re-indexes one email in the different mailboxes containing it")
@ApiImplicitParams({
    @ApiImplicitParam(
        required = true,
        name = "task",
        paramType = "query parameter",
        dataType = "String",
        defaultValue = "none",
        example = "?task=reIndex",
        value = "Compulsory. Only supported value is `reIndex`"),
    @ApiImplicitParam(
        required = true,
        name = "messageId",
        paramType = "path parameter",
        dataType = "String",
        defaultValue = "none",
        value = "Compulsory. Needs to be a valid messageId (format depends on the mailbox implementation)")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.CREATED_201, message = "Task is created", response = TaskIdDto.class),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side."),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Bad request - details in the returned error message")
})
private Route reIndexMessage() {
    return TaskFromRequestRegistry.builder()
        .parameterName(TASK_PARAMETER)
        .register(MailboxesRoutes.RE_INDEX, request -> reIndexer.reIndex(extractMessageId(request)))
        .buildAsRoute(taskManager);
}
 
Example 12
Source File: HttpCertSigner.java    From athenz with Apache License 2.0 5 votes vote down vote up
@Override
public String generateX509Certificate(String csr, String keyUsage, int expireMins) {
    
    // Key Usage value used in Go - https://golang.org/src/crypto/x509/x509.go?s=18153:18173#L558
    // we're only interested in ExtKeyUsageClientAuth - with value of 2
    
    List<Integer> extKeyUsage = null;
    if (InstanceProvider.ZTS_CERT_USAGE_CLIENT.equals(keyUsage)) {
        extKeyUsage = new ArrayList<>();
        extKeyUsage.add(2);
    }

    ContentResponse response = null;
    for (int i = 0; i < requestRetryCount; i++) {
        response = processX509CertRequest(csr, extKeyUsage, expireMins, i + 1);
        if (response != null) {
            break;
        }
    }
    if (response == null) {
        return null;
    }
    
    if (response.getStatus() != HttpStatus.CREATED_201) {
        LOGGER.error("unable to fetch requested uri '" + x509CertUri +
                "' status: " + response.getStatus());
        return null;
    }

    String data = response.getContentAsString();
    if (data == null || data.isEmpty()) {
        LOGGER.error("received empty response from uri '" + x509CertUri +
                "' status: " + response.getStatus());
        return null;
    }

    X509CertSignObject pemCert = JSON.fromString(data, X509CertSignObject.class);
    return (pemCert != null) ? pemCert.getPem() : null;
}
 
Example 13
Source File: DeletedMessagesVaultRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@DELETE
@Path("users/{user}/messages/{messageId}")
@ApiOperation(value = "Delete message with messageId")
@ApiImplicitParams({
    @ApiImplicitParam(
        required = true,
        name = "user",
        paramType = "path parameter",
        dataType = "String",
        defaultValue = "none",
        example = "[email protected]",
        value = "Compulsory. Needs to be a valid username represent for an user had requested to restore deleted emails"),
    @ApiImplicitParam(
        required = true,
        name = "messageId",
        paramType = "path parameter",
        dataType = "String",
        defaultValue = "none",
        value = "Compulsory, Need to be a valid messageId")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.CREATED_201, message = "Task is created", response = TaskIdDto.class),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Bad request - user param is invalid"),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Bad request - messageId param is invalid"),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
private Task deleteMessage(Request request) {
    Username username = extractUser(request);
    validateUserExist(username);
    MessageId messageId = parseMessageId(request);

    return new DeletedMessagesVaultDeleteTask(deletedMessageVault, username, messageId);
}
 
Example 14
Source File: DeletedMessagesVaultRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@POST
@Path("users/{user}")
@ApiOperation(value = "Restore deleted emails from a specified user to his new restore mailbox" +
    " or export their content to a destination mail address")
@ApiImplicitParams({
    @ApiImplicitParam(
        required = true,
        name = "user",
        paramType = "path parameter",
        dataType = "String",
        defaultValue = "none",
        example = "[email protected]",
        value = "Compulsory. Needs to be a valid username represent for an user had requested to restore deleted emails"),
    @ApiImplicitParam(
        required = true,
        dataType = "String",
        name = "action",
        paramType = "query",
        example = "?action=restore",
        value = "Compulsory. Needs to be a valid action represent for an operation to perform on the Deleted Message Vault, " +
            "valid action should be in the list (restore, export)"),
    @ApiImplicitParam(
        dataType = "String",
        name = "exportTo",
        paramType = "query",
        example = "[email protected]",
        value = "Compulsory if action is export. Needs to be a valid mail address. The content of the vault matching the query will be sent to that address")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.CREATED_201, message = "Task is created", response = TaskIdDto.class),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Bad request - user param is invalid"),
    @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "Not found - requested user does not exist"),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
private Route userActions() {
    return TaskFromRequestRegistry.builder()
        .register(EXPORT_REGISTRATION_KEY, this::export)
        .register(RESTORE_REGISTRATION_KEY, this::restore)
        .buildAsRoute(taskManager);
}
 
Example 15
Source File: MailRepositoriesRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@PATCH
@Path("/{encodedPath}/mails/{key}")
@ApiOperation(value = "Reprocessing a single mail in that mailRepository")
@ApiImplicitParams({
    @ApiImplicitParam(
        required = true,
        name = "action",
        paramType = "query parameter",
        dataType = "String",
        defaultValue = "none",
        example = "?action=reprocess",
        value = "Compulsory. Only supported value is `reprocess`"),
    @ApiImplicitParam(
        required = false,
        name = "queue",
        paramType = "query parameter",
        dataType = "String",
        defaultValue = "spool",
        example = "?queue=outgoing",
        value = "Indicates in which queue the mails stored in the repository should be re-enqueued"),
    @ApiImplicitParam(
        required = false,
        paramType = "query parameter",
        name = "processor",
        dataType = "String",
        defaultValue = "absent",
        example = "?processor=transport",
        value = "If present, modifies the state property of the mail to allow their processing by a specific mail container processor.")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.CREATED_201, message = "Task is created", response = TaskIdDto.class),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side."),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Bad request - unknown action")
})
public void defineReprocessOne() {
    service.patch(MAIL_REPOSITORIES + "/:encodedPath/mails/:key",
        TaskFromRequestRegistry.of(REPROCESS_ACTION, this::reprocessOne)
            .asRoute(taskManager),
        jsonTransformer);
}
 
Example 16
Source File: MailRepositoriesRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@PATCH
@Path("/{encodedPath}/mails")
@ApiOperation(value = "Reprocessing all mails in that mailRepository")
@ApiImplicitParams({
    @ApiImplicitParam(
        required = true,
        name = "action",
        paramType = "query parameter",
        dataType = "String",
        defaultValue = "none",
        example = "?action=reprocess",
        value = "Compulsory. Only supported value is `reprocess`"),
    @ApiImplicitParam(
        required = false,
        name = "queue",
        paramType = "query parameter",
        dataType = "String",
        defaultValue = "spool",
        example = "?queue=outgoing",
        value = "Indicates in which queue the mails stored in the repository should be re-enqueued"),
    @ApiImplicitParam(
        required = false,
        paramType = "query parameter",
        name = "processor",
        dataType = "String",
        defaultValue = "absent",
        example = "?processor=transport",
        value = "If present, modifies the state property of the mail to allow their processing by a specific mail container processor.")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.CREATED_201, message = "Task is created", response = TaskIdDto.class),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side."),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Bad request - unknown action")
})
public void defineReprocessAll() {
    service.patch(MAIL_REPOSITORIES + "/:encodedPath/mails",
        TaskFromRequestRegistry.of(REPROCESS_ACTION, this::reprocessAll)
            .asRoute(taskManager),
        jsonTransformer);
}
 
Example 17
Source File: CassandraMailboxMergingRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@POST
@ApiOperation("Triggers the merge of 2 mailboxes. Old mailbox Id will no more be accessible, rights and messages will be merged.")
@ApiImplicitParams(
    {
        @ApiImplicitParam(
            required = true,
            paramType = "body",
            dataTypeClass = MailboxMergingRequest.class,
            example = "{\"oldMailboxId\":\"4555-656-4554\",\"oldMailboxId\":\"9693-665-2500\"}",
            value = "The mailboxes to merge together.")
    })
@ApiResponses(
    {
        @ApiResponse(code = HttpStatus.CREATED_201, message = "The taskId of the given scheduled task",
            response = TaskIdDto.class, responseHeaders = {
            @ResponseHeader(name = "Location", description = "URL of the resource associated with the scheduled task")
        }),
        @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Error with supplied data (JSON parsing or invalid mailbox ids)")
    })
public Task mergeMailboxes(Request request) throws JsonExtractException {
    LOGGER.debug("Cassandra upgrade launched");
    MailboxMergingRequest mailboxMergingRequest = jsonExtractor.parse(request.body());
    CassandraId originId = mailboxIdFactory.fromString(mailboxMergingRequest.getMergeOrigin());
    CassandraId destinationId = mailboxIdFactory.fromString(mailboxMergingRequest.getMergeDestination());

    long totalMessagesToMove = counterDAO.countMessagesInMailbox(originId).defaultIfEmpty(0L).block();
    return new MailboxMergingTask(mailboxMergingTaskRunner, totalMessagesToMove, originId, destinationId);
}
 
Example 18
Source File: CassandraMigrationRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@POST
@Path("upgrade")
@ApiOperation("Triggers a migration of Cassandra schema to a specific version")
@ApiImplicitParams({
    @ApiImplicitParam(
        required = true,
        paramType = "body",
        dataType = "Integer",
        example = "3",
        value = "The schema version to upgrade to.")
})
@ApiResponses({
    @ApiResponse(code = HttpStatus.CREATED_201, message = "The taskId of the given scheduled task", response = TaskIdDto.class,
        responseHeaders = {
        @ResponseHeader(name = "Location", description = "URL of the resource associated with the scheduled task")
    }),
    @ApiResponse(code = HttpStatus.CONFLICT_409, message = "Migration can not be done")
})
public Task upgradeToVersion(Request request) {
    LOGGER.debug("Cassandra upgrade launched");
    CassandraVersionRequest cassandraVersionRequest = CassandraVersionRequest.parse(request.body());
    return cassandraMigrationService.upgradeToVersion(cassandraVersionRequest.getValue());
}
 
Example 19
Source File: EventDeadLettersRoutes.java    From james-project with Apache License 2.0 4 votes vote down vote up
@POST
@Path("/groups/" + GROUP_PARAM + "/" + INSERTION_ID_PARAMETER)
@ApiOperation(value = "Performing action on an event")
@ApiImplicitParams({
    @ApiImplicitParam(
        required = true,
        name = "group",
        paramType = "path parameter",
        dataType = "String",
        defaultValue = "none",
        value = "Compulsory. Needs to be a valid group name"),
    @ApiImplicitParam(
        required = true,
        name = "insertionId",
        paramType = "path parameter",
        dataType = "String",
        defaultValue = "none",
        value = "Compulsory. Needs to be a valid insertionId"),
    @ApiImplicitParam(
        required = true,
        dataType = "String",
        name = "action",
        paramType = "query",
        example = "?action=reDeliver",
        value = "Specify the action to perform on an unique event. 'reDeliver' is supported as an action, "
            + "and its purpose is to attempt a redelivery of the specified event."),
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.CREATED_201, message = "The taskId of the given scheduled task", response = TaskIdDto.class,
        responseHeaders = {
            @ResponseHeader(name = "Location", description = "URL of the resource associated with the scheduled task")
        }),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid group name, insertion id or action argument"),
    @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "No event with this insertionId"),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = INTERNAL_SERVER_ERROR)
})
public Route performActionOnSingleEvent() {
    return TaskFromRequestRegistry.of(RE_DELIVER,
            request -> eventDeadLettersService.redeliverSingleEvent(parseGroup(request), parseInsertionId(request)))
        .asRoute(taskManager);
}
 
Example 20
Source File: MailboxesRoutes.java    From james-project with Apache License 2.0 4 votes vote down vote up
@POST
@Path("/")
@ApiOperation(value = "Re-indexes all the mails on this server")
@ApiImplicitParams({
    @ApiImplicitParam(
        required = true,
        name = "task",
        paramType = "query parameter",
        dataType = "String",
        defaultValue = "none",
        example = "?task=reIndex",
        value = "Compulsory. Only supported value is `reIndex`"),
    @ApiImplicitParam(
        required = false,
        name = "messagesPerSecond",
        paramType = "query parameter",
        dataType = "Integer",
        defaultValue = "none",
        example = "?messagesPerSecond=100",
        value = "If present, determine the number of messages being processed in one second."),
    @ApiImplicitParam(
        name = "reIndexFailedMessagesOf",
        paramType = "query parameter",
        dataType = "String",
        defaultValue = "none",
        example = "?reIndexFailedMessagesOf=3294a976-ce63-491e-bd52-1b6f465ed7a2",
        value = "optional. References a previously run reIndexing task. if present, the messages that this previous " +
            "task failed to index will be reIndexed.")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.CREATED_201, message = "Task is created", response = TaskIdDto.class),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side."),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Bad request - details in the returned error message")
})
private static Task reIndexAll(PreviousReIndexingService previousReIndexingService, ReIndexer reIndexer, Request request) throws MailboxException {
    boolean indexingCorrection = !Strings.isNullOrEmpty(request.queryParams(RE_INDEX_FAILED_MESSAGES_QUERY_PARAM));
    if (indexingCorrection) {
        IndexingDetailInformation indexingDetailInformation = retrieveIndexingExecutionDetails(previousReIndexingService, request);
        return reIndexer.reIndex(indexingDetailInformation.failures(), ReindexingRunningOptionsParser.parse(request));
    }

    return reIndexer.reIndex(ReindexingRunningOptionsParser.parse(request));
}