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

The following examples show how to use org.eclipse.jetty.http.HttpStatus#INTERNAL_SERVER_ERROR_500 . 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: DomainMappingsRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@DELETE
@Path(SPECIFIC_MAPPING_PATH)
@ApiOperation(value = "Removes domain mapping between source and destination domains.")
@ApiImplicitParams({
    @ApiImplicitParam(required = true, dataType = "string", name = FROM_DOMAIN, paramType = "path")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "Ok"),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Domain name is invalid"),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
        message = "Internal server error - Something went bad on the server side.")
})
public HaltException removeDomainMapping(Request request, Response response) throws RecipientRewriteTableException {
    MappingSource mappingSource = mappingSourceFrom(request);
    Domain destinationDomain = extractDomain(request.body());

    recipientRewriteTable.removeDomainMapping(mappingSource, destinationDomain);
    return halt(HttpStatus.NO_CONTENT_204);
}
 
Example 2
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 3
Source File: UserRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@PUT
@Path("/{username}")
@ApiOperation(value = "Creating an user")
@ApiImplicitParams({
        @ApiImplicitParam(required = true, dataType = "string", name = "username", paramType = "path"),
        @ApiImplicitParam(required = true, dataTypeClass = AddUserRequest.class, paramType = "body")
})
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK. New user is added."),
        @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid input user."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
            message = "Internal server error - Something went bad on the server side.")
})
public void defineCreateUser() {
    service.put(USERS + SEPARATOR + USER_NAME, this::upsertUser);
}
 
Example 4
Source File: DomainsRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@PUT
@Path("/{destinationDomain}/aliases/{sourceDomain}")
@ApiOperation(value = "Add an alias for a specific domain")
@ApiImplicitParams({
    @ApiImplicitParam(required = true, dataType = "string", name = "sourceDomain", paramType = "path"),
    @ApiImplicitParam(required = true, dataType = "string", name = "destinationDomain", paramType = "path")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK", response = List.class),
    @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The domain does not exist."),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
        message = "Internal server error - Something went bad on the server side.")
})
public void defineAddAlias(Service service) {
    service.put(SPECIFIC_ALIAS, this::addDomainAlias, jsonTransformer);
}
 
Example 5
Source File: DomainQuotaRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@DELETE
@Path("/size")
@ApiOperation(value = "Removing per domain mail size limitation by updating to unlimited value")
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "The value is updated to unlimited value."),
        @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The requested domain can not be found."),
        @ApiResponse(code = HttpStatus.METHOD_NOT_ALLOWED_405, message = "Domain Quota configuration not supported when virtual hosting is desactivated."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineDeleteQuotaSize() {
    service.delete(SIZE_ENDPOINT, (request, response) -> {
        Domain domain = checkDomainExist(request);
        domainQuotaService.remoteMaxQuotaSize(domain);
        return Responses.returnNoContent(response);
    });
}
 
Example 6
Source File: MailQueueRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@GET
@ApiOperation(
    value = "Listing existing MailQueues"
)
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.OK_200, message = "OK", response = List.class),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineListQueues(Service service) {
    service.get(BASE_URL,
        (request, response) -> mailQueueFactory.listCreatedMailQueues()
            .stream()
            .map(MailQueueName::asString)
            .collect(Guavate.toImmutableList()),
        jsonTransformer);
}
 
Example 7
Source File: DomainMappingsRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@GET
@Path(SPECIFIC_MAPPING_PATH)
@ApiOperation(value = "Lists mappings for specific domain.")
@ApiImplicitParams({
    @ApiImplicitParam(required = true, dataType = "string", name = FROM_DOMAIN, paramType = "path")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.OK_200, message = "Domain mappings.", responseContainer = "List"),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Domain name is invalid"),
    @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "Not existing mappings."),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
        message = "Internal server error - Something went bad on the server side.")
})
public List<String> getMapping(Request request, Response response) throws RecipientRewriteTableException {
    MappingSource mappingSource = mappingSourceFrom(request);

    return Optional.of(recipientRewriteTable.getStoredMappings(mappingSource).select(Mapping.Type.Domain))
        .filter(mappings -> mappings.contains(Mapping.Type.Domain))
        .map(this::toDomainList)
        .orElseThrow(() -> ErrorResponder.builder()
            .statusCode(HttpStatus.NOT_FOUND_404)
            .type(ErrorResponder.ErrorType.NOT_FOUND)
            .message(String.format("Cannot find mappings for %s", mappingSource.getFixedDomain()))
            .haltError());
}
 
Example 8
Source File: UserRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@HEAD
@Path("/{username}")
@ApiOperation(value = "Testing an user existence")
@ApiImplicitParams({
    @ApiImplicitParam(required = true, dataType = "string", name = "username", paramType = "path")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.OK_200, message = "OK. User exists."),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid input user."),
    @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "User does not exist."),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
        message = "Internal server error - Something went bad on the server side.")
})
public void defineUserExist() {
    service.head(USERS + SEPARATOR + USER_NAME, this::userExist);
}
 
Example 9
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 10
Source File: DomainQuotaRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@PUT
@Path("/size")
@ApiOperation(value = "Updating per domain mail size limitation")
@ApiImplicitParams({
        @ApiImplicitParam(required = true, dataType = "integer", paramType = "body")
})
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK. The value has been updated."),
        @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "The body is not a positive integer."),
        @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The requested domain can not be found."),
        @ApiResponse(code = HttpStatus.METHOD_NOT_ALLOWED_405, message = "Domain Quota configuration not supported when virtual hosting is desactivated."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineUpdateQuotaSize() {
    service.put(SIZE_ENDPOINT, (request, response) -> {
        Domain domain = checkDomainExist(request);
        QuotaSizeLimit quotaSize = Quotas.quotaSize(request.body());
        domainQuotaService.setMaxSizeQuota(domain, quotaSize);
        return Responses.returnNoContent(response);
    });
}
 
Example 11
Source File: AliasRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@DELETE
@Path(ROOT_PATH + "/{" + ALIAS_DESTINATION_ADDRESS + "}/sources/{" + ALIAS_SOURCE_ADDRESS + "}")
@ApiOperation(value = "remove an alias from a destination address")
@ApiImplicitParams({
    @ApiImplicitParam(required = true, dataType = "string", name = ALIAS_DESTINATION_ADDRESS, paramType = "path",
        value = "Destination mail address of the alias to remove.\n" +
            MAILADDRESS_ASCII_DISCLAIMER),
    @ApiImplicitParam(required = true, dataType = "string", name = ALIAS_SOURCE_ADDRESS, paramType = "path",
        value = "Source mail address of the alias to remove.\n" +
            MAILADDRESS_ASCII_DISCLAIMER)
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK"),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400,
        message = ALIAS_DESTINATION_ADDRESS + " or alias structure format is not valid"),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
        message = "Internal server error - Something went bad on the server side.")
})
public HaltException deleteAlias(Request request, Response response) throws RecipientRewriteTableException {
    MailAddress destinationAddress = MailAddressParser.parseMailAddress(request.params(ALIAS_DESTINATION_ADDRESS), ADDRESS_TYPE);
    MailAddress aliasToBeRemoved = MailAddressParser.parseMailAddress(request.params(ALIAS_SOURCE_ADDRESS), ADDRESS_TYPE);
    MappingSource source = MappingSource.fromMailAddress(aliasToBeRemoved);
    recipientRewriteTable.removeAliasMapping(source, destinationAddress.asString());
    return halt(HttpStatus.NO_CONTENT_204);
}
 
Example 12
Source File: MailRepositoriesRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@DELETE
@Path("/{encodedPath}/mails/{mailKey}")
@ApiOperation(value = "Deleting a specific mail from that mailRepository")
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.OK_200, message = "Mail is no more stored in the repository", response = List.class),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side."),
})
public void defineDeleteMail() {
    service.delete(MAIL_REPOSITORIES + "/:encodedPath/mails/:mailKey", (request, response) -> {
        MailRepositoryPath path = decodedRepositoryPath(request);
        MailKey mailKey = new MailKey(request.params("mailKey"));
        try {
            repositoryStoreService.deleteMail(path, mailKey);
            return Responses.returnNoContent(response);
        } 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 mail")
                .haltError();
        }
    });
}
 
Example 13
Source File: DomainQuotaRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/count")
@ApiOperation(value = "Reading per domain mail count limitation")
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.OK_200, message = "OK", response = Long.class),
        @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The requested domain can not be found."),
        @ApiResponse(code = HttpStatus.METHOD_NOT_ALLOWED_405, message = "Domain Quota configuration not supported when virtual hosting is desactivated."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineGetQuotaCount() {
    service.get(COUNT_ENDPOINT, (request, response) -> {
        Domain domain = checkDomainExist(request);
        Optional<QuotaCountLimit> maxCountQuota = domainQuotaService.getMaxCountQuota(domain);
        if (maxCountQuota.isPresent()) {
            return maxCountQuota;
        }
        return Responses.returnNoContent(response);
    }, jsonTransformer);
}
 
Example 14
Source File: GlobalQuotaRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@PUT
@Path("/size")
@ApiOperation(value = "Updating per quotaroot mail size limitation")
@ApiImplicitParams({
        @ApiImplicitParam(required = true, dataType = "integer", paramType = "body")
})
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK. The value has been updated."),
        @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "The body is not a positive integer."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineUpdateQuotaSize() {
    service.put(SIZE_ENDPOINT, (request, response) -> {
        QuotaSizeLimit quotaSize = Quotas.quotaSize(request.body());
        globalQuotaService.defineMaxSizeQuota(quotaSize);
        return Responses.returnNoContent(response);
    });
}
 
Example 15
Source File: UserQuotaRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@DELETE
@Path("/size")
@ApiOperation(value = "Removing per user mail size limitation by updating to unlimited value")
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "The value is updated to unlimited value."),
        @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The user name does not exist."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineDeleteQuotaSize() {
    service.delete(SIZE_ENDPOINT, (request, response) -> {
        Username username = checkUserExist(request);
        userQuotaService.deleteMaxSizeQuota(username);
        return Responses.returnNoContent(response);
    });
}
 
Example 16
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 17
Source File: GlobalQuotaRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@DELETE
@Path("/count")
@ApiOperation(value = "Removing per quotaroot mail count limitation by updating to unlimited value")
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "The value is updated to unlimited value."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineDeleteQuotaCount() {
    service.delete(COUNT_ENDPOINT, (request, response) -> {
        globalQuotaService.deleteMaxCountQuota();
        return Responses.returnNoContent(response);
    });
}
 
Example 18
Source File: DomainsRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@DELETE
@Path("/{domainName}")
@ApiOperation(value = "Deleting a domain")
@ApiImplicitParams({
        @ApiImplicitParam(required = true, dataType = "string", name = "domainName", paramType = "path")
})
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK. Domain is removed."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
            message = "Internal server error - Something went bad on the server side.")
})
public void defineDeleteDomain() {
    service.delete(SPECIFIC_DOMAIN, this::removeDomain);
}
 
Example 19
Source File: UserQuotaRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@DELETE
@Path("/count")
@ApiOperation(value = "Removing per user mail count limitation by updating to unlimited value")
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "The value is updated to unlimited value."),
        @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The user name does not exist."),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void defineDeleteQuotaCount() {
    service.delete(COUNT_ENDPOINT, (request, response) -> {
        Username username = checkUserExist(request);
        userQuotaService.deleteMaxCountQuota(username);
        return Responses.returnNoContent(response);
    });
}
 
Example 20
Source File: MailQueueRoutes.java    From james-project with Apache License 2.0 4 votes vote down vote up
@DELETE
@Path("/{mailQueueName}/mails")
@ApiImplicitParams({
    @ApiImplicitParam(required = true, dataType = "string", name = "mailQueueName", paramType = "path"),
    @ApiImplicitParam(
            required = false, 
            dataTypeClass = MailAddress.class,
            name = SENDER_QUERY_PARAM, 
            paramType = "query",
            example = "[email protected]",
            value = "The sender of the mails to be deleted should be equals to this query parameter."),
    @ApiImplicitParam(
            required = false, 
            dataType = "String", 
            name = NAME_QUERY_PARAM,
            paramType = "query",
            example = "?name=mailName",
            value = "The name of the mails to be deleted should be equals to this query parameter."),
    @ApiImplicitParam(
            required = false, 
            dataType = "MailAddress", 
            name = RECIPIENT_QUERY_PARAM, 
            paramType = "query",
            example = "[email protected]",
            value = "The recipients of the mails to be deleted should contain this query parameter."),
})
@ApiOperation(
    value = "Delete mails from the MailQueue"
)
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.CREATED_201, message = "OK, the task for deleting mails is created"),
    @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The MailQueue does not exist."),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid request for deleting mails from the mail queue."),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void deleteMails(Service service) {
    TaskFromRequest taskFromRequest = this::deleteMails;
    service.delete(BASE_URL + SEPARATOR + MAIL_QUEUE_NAME + MAILS,
            taskFromRequest.asRoute(taskManager),
            jsonTransformer);
}