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

The following examples show how to use org.eclipse.jetty.http.HttpStatus#NO_CONTENT_204 . 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
@PUT
@Path(SPECIFIC_MAPPING_PATH)
@ApiOperation(value = "Creating 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.BAD_REQUEST_400, message = "Domain in the source is not managed by the DomainList"),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
        message = "Internal server error - Something went bad on the server side.")
})
public HaltException addDomainMapping(Request request, Response response) throws RecipientRewriteTableException {
    MappingSource mappingSource = mappingSourceFrom(request);
    Domain destinationDomain = extractDomain(request.body());
    addAliasDomainMapping(mappingSource, destinationDomain);
    return halt(HttpStatus.NO_CONTENT_204);
}
 
Example 2
Source File: DLPConfigurationRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@DELETE
@Path("/{senderDomain}")
@ApiOperation(value = "Clear a DLP configuration for a given senderDomain")
@ApiImplicitParams({
    @ApiImplicitParam(required = true, dataType = "string", name = "senderDomain", paramType = "path")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK. DLP configuration is cleared"),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid senderDomain in request",
        response = ErrorResponder.ErrorDetail.class),
    @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The domain does not exist.",
        response = ErrorResponder.ErrorDetail.class),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
        message = "Internal server error - Something went bad on the server side.",
        response = ErrorResponder.ErrorDetail.class)
})
public void defineClear(Service service) {
    service.delete(SPECIFIC_DLP_RULE_DOMAIN, (request, response) -> {
        Domain senderDomain = parseDomain(request);
        dlpConfigurationStore.clear(senderDomain);

        return Responses.returnNoContent(response);
    }, jsonTransformer);
}
 
Example 3
Source File: UserQuotaRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@PUT
@Path("/size")
@ApiOperation(value = "Updating per user 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 nor -1."),
        @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 defineUpdateQuotaSize() {
    service.put(SIZE_ENDPOINT, (request, response) -> {
        Username username = checkUserExist(request);
        QuotaSizeLimit quotaSize = Quotas.quotaSize(request.body());
        userQuotaService.defineMaxSizeQuota(username, quotaSize);
        return Responses.returnNoContent(response);
    });
}
 
Example 4
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 5
Source File: GlobalQuotaRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@PUT
@Path("/count")
@ApiOperation(value = "Updating per quotaroot mail count 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 defineUpdateQuotaCount() {
    service.put(COUNT_ENDPOINT, (request, response) -> {
        QuotaCountLimit quotaRequest = Quotas.quotaCount(request.body());
        globalQuotaService.defineMaxCountQuota(quotaRequest);
        return Responses.returnNoContent(response);
    });
}
 
Example 6
Source File: UserQuotaRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/count")
@ApiOperation(value = "Reading per user mail count limitation")
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.OK_200, message = "OK", response = Long.class),
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "No value defined"),
        @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 defineGetQuotaCount() {
    service.get(COUNT_ENDPOINT, (request, response) -> {
        Username username = checkUserExist(request);
        Optional<QuotaCountLimit> maxCountQuota = userQuotaService.getMaxCountQuota(username);
        if (maxCountQuota.isPresent()) {
            return maxCountQuota;
        }
        return Responses.returnNoContent(response);
    }, jsonTransformer);
}
 
Example 7
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 8
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 9
Source File: UserRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/{username}/allowedFromHeaders")
@ApiOperation(value = "List all possible From header value for an existing user")
@ApiImplicitParams({
    @ApiImplicitParam(required = true, dataType = "string", name = "username", paramType = "path")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK.", response = List.class),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "user is not valid."),
    @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 defineAllowedFromHeaders() {
    service.get(USERS + SEPARATOR + USER_NAME + SEPARATOR + "allowedFromHeaders",
        this::allowedFromHeaders,
        jsonTransformer);
}
 
Example 10
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 11
Source File: UserQuotaRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@GET
@Path("/size")
@ApiOperation(value = "Reading per user mail size limitation")
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.OK_200, message = "OK", response = Long.class),
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "No value defined"),
        @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 defineGetQuotaSize() {
    service.get(SIZE_ENDPOINT, (request, response) -> {
        Username username = checkUserExist(request);
        Optional<QuotaSizeLimit> maxSizeQuota = userQuotaService.getMaxSizeQuota(username);
        if (maxSizeQuota.isPresent()) {
            return maxSizeQuota;
        }
        return Responses.returnNoContent(response);
    }, jsonTransformer);
}
 
Example 12
Source File: RegexMappingRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@POST
@Path(ADD_ADDRESS_MAPPING_PATH)
@ApiOperation(value = "adding address-regex mappings to RecipientRewriteTable")
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "Mapping successfully added"),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid parameter")
})
private HaltException addRegexMapping(Request request, Response response) throws Exception {
    try {
        MappingSource mappingSource = extractMappingSource(request);
        String regex = URLDecoder.decode(request.params(REGEX_PARAM), StandardCharsets.UTF_8.toString());
        recipientRewriteTable.addRegexMapping(mappingSource, regex);
    } catch (InvalidRegexException e) {
        throw ErrorResponder.builder()
            .statusCode(HttpStatus.BAD_REQUEST_400)
            .type(ErrorResponder.ErrorType.INVALID_ARGUMENT)
            .message(e.getMessage())
            .haltError();
    }
    return halt(HttpStatus.NO_CONTENT_204);
}
 
Example 13
Source File: UserRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@GET
@ApiOperation(value = "Getting all users")
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK.", response = UserResponse.class),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
            message = "Internal server error - Something went bad on the server side.")
})
public void defineGetUsers() {
    service.get(USERS,
        (request, response) -> userService.getUsers(),
        jsonTransformer);
}
 
Example 14
Source File: TasksRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@DELETE
@Path("/{taskId}")
@ApiOperation(value = "Cancel a given task")
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "Task is cancelled"),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "The taskId is invalid")
})
public Object cancel(Request req, Response response) {
    TaskId taskId = getTaskId(req);
    taskManager.cancel(taskId);
    return Responses.returnNoContent(response);
}
 
Example 15
Source File: EventDeadLettersRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@DELETE
@Path("/groups/" + GROUP_PARAM + "/" + INSERTION_ID_PARAMETER)
@ApiOperation(value = "Deletes 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")
})
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK - Event deleted"),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid group name or insertion id"),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = INTERNAL_SERVER_ERROR)
})
private String deleteEvent(Request request, Response response) {
    Group group = parseGroup(request);
    EventDeadLetters.InsertionId insertionId = parseInsertionId(request);

    eventDeadLettersService.deleteEvent(group, insertionId);
    return Responses.returnNoContent(response);
}
 
Example 16
Source File: DomainsRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@PUT
@Path("/{domainName}")
@ApiOperation(value = "Creating new domain")
@ApiImplicitParams({
        @ApiImplicitParam(required = true, dataType = "string", name = "domainName", paramType = "path")
})
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK. New domain is created."),
        @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid request for domain creation"),
        @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
            message = "Internal server error - Something went bad on the server side.")
})
public void defineAddDomain() {
    service.put(SPECIFIC_DOMAIN, this::addDomain);
}
 
Example 17
Source File: DomainQuotaRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@PUT
@ApiOperation(value = "Updating count and size at the same time")
@ApiImplicitParams({
        @ApiImplicitParam(required = true, dataTypeClass = QuotaDTO.class, 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 or not unlimited value (-1)."),
        @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 defineUpdateQuota() {
    service.put(QUOTA_ENDPOINT, ((request, response) -> {
        try {
            Domain domain = checkDomainExist(request);
            QuotaDTO quotaDTO = jsonExtractor.parse(request.body());
            ValidatedQuotaDTO validatedQuotaDTO = quotaDTOValidator.validatedQuotaDTO(quotaDTO);
            domainQuotaService.defineQuota(domain, validatedQuotaDTO);
            return Responses.returnNoContent(response);
        } catch (IllegalArgumentException e) {
            throw ErrorResponder.builder()
                .statusCode(HttpStatus.BAD_REQUEST_400)
                .type(ErrorType.INVALID_ARGUMENT)
                .message("Quota should be positive or unlimited (-1)")
                .cause(e)
                .haltError();
        }
    }));
}
 
Example 18
Source File: DomainsRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@GET
@ApiOperation(value = "Getting all domains")
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, 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 defineGetDomains() {
    service.get(DOMAINS,
        (request, response) ->
            domainList.getDomains().stream().map(Domain::name).collect(Collectors.toList()),
        jsonTransformer);
}
 
Example 19
Source File: UserMailboxesRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@DELETE
@ApiImplicitParams({
        @ApiImplicitParam(required = true, dataType = "string", name = "username", paramType = "path")
})
@ApiOperation(value = "Deleting user mailboxes.")
@ApiResponses(value = {
        @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "The user does not have any mailbox", response = String.class),
        @ApiResponse(code = HttpStatus.UNAUTHORIZED_401, message = "Unauthorized. The user is not authenticated on the platform"),
        @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 defineDeleteUserMailboxes() {
    service.delete(USER_MAILBOXES_BASE, (request, response) -> {
        try {
            userMailboxesService.deleteMailboxes(getUsernameParam(request));
            return Responses.returnNoContent(response);
        } catch (IllegalStateException e) {
            LOGGER.info("Invalid delete on user mailboxes", e);
            throw ErrorResponder.builder()
                .statusCode(HttpStatus.NOT_FOUND_404)
                .type(ErrorType.NOT_FOUND)
                .message("Invalid delete on user mailboxes")
                .cause(e)
                .haltError();
        }
    });
}
 
Example 20
Source File: MailQueueRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@PATCH
@Path("/{mailQueueName}/mails")
@ApiImplicitParams({
    @ApiImplicitParam(
        required = true,
        dataType = "string",
        name = "mailQueueName",
        paramType = "path"),
    @ApiImplicitParam(
        required = false,
        dataType = "boolean",
        name = DELAYED_QUERY_PARAM,
        paramType = "query",
        example = "?delayed=true",
        value = "Whether the mails are delayed in the mail queue or not (already sent).")
})
@ApiOperation(
    value = "Force delayed mails delivery"
)
@ApiResponses(value = {
    @ApiResponse(code = HttpStatus.NO_CONTENT_204, message = "OK"),
    @ApiResponse(code = HttpStatus.BAD_REQUEST_400, message = "Invalid request for getting the mail queue."),
    @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "The MailQueue does not exist."),
    @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "Internal server error - Something went bad on the server side.")
})
public void forceDelayedMailsDelivery(Service service) {
    service.patch(BASE_URL + SEPARATOR + MAIL_QUEUE_NAME + MAILS,
        this::forceDelayedMailsDelivery,
        jsonTransformer);
}