Java Code Examples for javax.ws.rs.core.Response.Status#NOT_ACCEPTABLE
The following examples show how to use
javax.ws.rs.core.Response.Status#NOT_ACCEPTABLE .
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: TaskReportResourceImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public Response getTaskCountByCandidateGroupReport(Request request) { Variant variant = request.selectVariant(VARIANTS); if (variant != null) { MediaType mediaType = variant.getMediaType(); if (MediaType.APPLICATION_JSON_TYPE.equals(mediaType)) { List<TaskCountByCandidateGroupResultDto> result = getTaskCountByCandidateGroupResultAsJson(); return Response.ok(result, mediaType).build(); } else if (APPLICATION_CSV_TYPE.equals(mediaType) || TEXT_CSV_TYPE.equals(mediaType)) { String csv = getReportResultAsCsv(); return Response .ok(csv, mediaType) .header("Content-Disposition", "attachment; filename=\"task-count-by-candidate-group.csv\"") .build(); } } throw new InvalidRequestException(Status.NOT_ACCEPTABLE, "No acceptable content-type found"); }
Example 2
Source File: HistoricProcessInstanceRestServiceImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public Response getHistoricProcessInstancesReport(UriInfo uriInfo, Request request) { Variant variant = request.selectVariant(VARIANTS); if (variant != null) { MediaType mediaType = variant.getMediaType(); if (MediaType.APPLICATION_JSON_TYPE.equals(mediaType)) { List<ReportResultDto> result = getReportResultAsJson(uriInfo); return Response.ok(result, mediaType).build(); } else if (APPLICATION_CSV_TYPE.equals(mediaType) || TEXT_CSV_TYPE.equals(mediaType)) { String csv = getReportResultAsCsv(uriInfo); return Response .ok(csv, mediaType) .header("Content-Disposition", "attachment; filename=\"process-instance-report.csv\"") .build(); } } throw new InvalidRequestException(Status.NOT_ACCEPTABLE, "No acceptable content-type found"); }
Example 3
Source File: AbstractRestInvocation.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
protected void initProduceProcessor() { produceProcessor = restOperationMeta.ensureFindProduceProcessor(requestEx); if (produceProcessor == null) { LOGGER.error("Accept {} is not supported, operation={}.", requestEx.getHeader(HttpHeaders.ACCEPT), restOperationMeta.getOperationMeta().getMicroserviceQualifiedName()); String msg = String.format("Accept %s is not supported", requestEx.getHeader(HttpHeaders.ACCEPT)); throw new InvocationException(Status.NOT_ACCEPTABLE, msg); } }
Example 4
Source File: FilterResourceImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public Object executeSingleResult(Request request) { Variant variant = request.selectVariant(VARIANTS); if (variant != null) { if (MediaType.APPLICATION_JSON_TYPE.equals(variant.getMediaType())) { return executeJsonSingleResult(); } else if (Hal.APPLICATION_HAL_JSON_TYPE.equals(variant.getMediaType())) { return executeHalSingleResult(); } } throw new InvalidRequestException(Status.NOT_ACCEPTABLE, "No acceptable content-type found"); }
Example 5
Source File: FilterResourceImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public Object querySingleResult(Request request, String extendingQuery) { Variant variant = request.selectVariant(VARIANTS); if (variant != null) { if (MediaType.APPLICATION_JSON_TYPE.equals(variant.getMediaType())) { return queryJsonSingleResult(extendingQuery); } else if (Hal.APPLICATION_HAL_JSON_TYPE.equals(variant.getMediaType())) { return queryHalSingleResult(extendingQuery); } } throw new InvalidRequestException(Status.NOT_ACCEPTABLE, "No acceptable content-type found"); }
Example 6
Source File: FilterResourceImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public Object executeList(Request request, Integer firstResult, Integer maxResults) { Variant variant = request.selectVariant(VARIANTS); if (variant != null) { if (MediaType.APPLICATION_JSON_TYPE.equals(variant.getMediaType())) { return executeJsonList(firstResult, maxResults); } else if (Hal.APPLICATION_HAL_JSON_TYPE.equals(variant.getMediaType())) { return executeHalList(firstResult, maxResults); } } throw new InvalidRequestException(Status.NOT_ACCEPTABLE, "No acceptable content-type found"); }
Example 7
Source File: FilterResourceImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public Object queryList(Request request, String extendingQuery, Integer firstResult, Integer maxResults) { Variant variant = request.selectVariant(VARIANTS); if (variant != null) { if (MediaType.APPLICATION_JSON_TYPE.equals(variant.getMediaType())) { return queryJsonList(extendingQuery, firstResult ,maxResults); } else if (Hal.APPLICATION_HAL_JSON_TYPE.equals(variant.getMediaType())) { return queryHalList(extendingQuery, firstResult, maxResults); } } throw new InvalidRequestException(Status.NOT_ACCEPTABLE, "No acceptable content-type found"); }
Example 8
Source File: TaskResourceImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public Object getTask(Request request) { Variant variant = request.selectVariant(VARIANTS); if (variant != null) { if (MediaType.APPLICATION_JSON_TYPE.equals(variant.getMediaType())) { return getJsonTask(); } else if (Hal.APPLICATION_HAL_JSON_TYPE.equals(variant.getMediaType())) { return getHalTask(); } } throw new InvalidRequestException(Status.NOT_ACCEPTABLE, "No acceptable content-type found"); }
Example 9
Source File: NamespacesBase.java From pulsar with Apache License 2.0 | 4 votes |
protected void internalSetAutoTopicCreation(AsyncResponse asyncResponse, AutoTopicCreationOverride autoTopicCreationOverride) { final int maxPartitions = pulsar().getConfig().getMaxNumPartitionsPerPartitionedTopic(); validateAdminAccessForTenant(namespaceName.getTenant()); validatePoliciesReadOnlyAccess(); if (!AutoTopicCreationOverride.isValidOverride(autoTopicCreationOverride)) { throw new RestException(Status.PRECONDITION_FAILED, "Invalid configuration for autoTopicCreationOverride"); } if (maxPartitions > 0 && autoTopicCreationOverride.defaultNumPartitions > maxPartitions) { throw new RestException(Status.NOT_ACCEPTABLE, "Number of partitions should be less than or equal to " + maxPartitions); } // Force to read the data s.t. the watch to the cache content is setup. policiesCache().getWithStatAsync(path(POLICIES, namespaceName.toString())).thenApply( policies -> { if (policies.isPresent()) { Entry<Policies, Stat> policiesNode = policies.get(); policiesNode.getKey().autoTopicCreationOverride = autoTopicCreationOverride; try { // Write back the new policies into zookeeper globalZk().setData(path(POLICIES, namespaceName.toString()), jsonMapper().writeValueAsBytes(policiesNode.getKey()), policiesNode.getValue().getVersion(), (rc, path1, ctx, stat) -> { if (rc == KeeperException.Code.OK.intValue()) { policiesCache().invalidate(path(POLICIES, namespaceName.toString())); String autoOverride = autoTopicCreationOverride.allowAutoTopicCreation ? "enabled" : "disabled"; log.info("[{}] Successfully {} autoTopicCreation on namespace {}", clientAppId(), autoOverride, namespaceName); asyncResponse.resume(Response.noContent().build()); } else { String errorMsg = String.format( "[%s] Failed to modify autoTopicCreation status for namespace %s", clientAppId(), namespaceName); if (rc == KeeperException.Code.NONODE.intValue()) { log.warn("{} : does not exist", errorMsg); asyncResponse.resume(new RestException(Status.NOT_FOUND, "Namespace does not exist")); } else if (rc == KeeperException.Code.BADVERSION.intValue()) { log.warn("{} : concurrent modification", errorMsg); asyncResponse.resume(new RestException(Status.CONFLICT, "Concurrent modification")); } else { asyncResponse.resume(KeeperException.create(KeeperException.Code.get(rc), errorMsg)); } } }, null); return null; } catch (Exception e) { log.error("[{}] Failed to modify autoTopicCreation status on namespace {}", clientAppId(), namespaceName, e); asyncResponse.resume(new RestException(e)); return null; } } else { asyncResponse.resume(new RestException(Status.NOT_FOUND, "Namespace " + namespaceName + " does not exist")); return null; } } ).exceptionally(e -> { log.error("[{}] Failed to modify autoTopicCreation status on namespace {}", clientAppId(), namespaceName, e); asyncResponse.resume(new RestException(e)); return null; }); }
Example 10
Source File: HttpMediaTypeNotSupportedExceptionMapper.java From cloudbreak with Apache License 2.0 | 4 votes |
@Override Status getResponseStatus() { return Status.NOT_ACCEPTABLE; }
Example 11
Source File: HttpMediaTypeNotSupportedExceptionMapper.java From cloudbreak with Apache License 2.0 | 4 votes |
@Override Status getResponseStatus() { return Status.NOT_ACCEPTABLE; }
Example 12
Source File: DataElementService.java From semanticMDR with GNU General Public License v3.0 | 4 votes |
@GET @Path("/{deid}/es") @Produces(MediaType.APPLICATION_JSON) public Response getExtractionSpec( @QueryParam("specification-format") String specificationFormat, @QueryParam("content-model") String contentModel, @PathParam("deid") String deid) { Repository repository = RepositoryManager.getInstance().getRepository(); OntModel ontModel = repository.getMDRDatabase().getOntModel(); List<String> extractionSpecifications = new ArrayList<String>(); if (specificationFormat == null || contentModel == null) { throw new WebApplicationException(Status.NOT_ACCEPTABLE); } File getExtractionFile = new File(QUERY_FILE_GET_EXTRACTIONS); String queryString = ""; try { queryString = FileUtils.readFileToString(getExtractionFile); } catch (IOException e) { logger.error("File with context serialization query could not be found "); return Response.serverError().build(); } ParameterizedSparqlString query = new ParameterizedSparqlString( queryString); query.setLiteral("uuid", ResourceFactory.createTypedLiteral(deid)); query.setLiteral("specFormat", ResourceFactory.createTypedLiteral(specificationFormat)); query.setLiteral("contentModel", ResourceFactory.createTypedLiteral(contentModel)); QueryExecution qe = QueryExecutionFactory.create(query.asQuery(), ontModel); String spec = ""; ResultSet rs = qe.execSelect(); while (rs.hasNext()) { QuerySolution qs = rs.next(); spec = qs.getLiteral("extractionSpec").getString(); if (spec != null && !spec.equals("")) { extractionSpecifications.add(spec); } } return Response.ok(extractionSpecifications).build(); }