类javax.ws.rs.OPTIONS源码实例Demo

下面列出了怎么用javax.ws.rs.OPTIONS的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jrestless   文件: CorsFilterIntTest.java
@Override
protected Application configure() {
	CorsFilter corsFilter = new CorsFilter.Builder()
			.allowMethod(HttpMethod.DELETE)
			.allowMethod(HttpMethod.OPTIONS)
			.allowHeader("ah0")
			.allowHeader("ah1")
			.allowOrigin(DEFAULT_ORIGIN)
			.allowOrigin("http://test.com")
			.exposeHeader("eh0")
			.exposeHeader("eh1")
			.build();
	ResourceConfig application = new ResourceConfig();
	application.register(corsFilter);
	application.register(TestResource.class);
	return application;
}
 
源代码2 项目: carbon-device-mgt   文件: AnnotationProcessor.java
private boolean isHttpMethodAvailable(Annotation[] annotations) {
    for (Annotation annotation : annotations) {
        if (annotation.annotationType().getName().equals(GET.class.getName())) {
            return true;
        } else if (annotation.annotationType().getName().equals(POST.class.getName())) {
            return true;
        } else if (annotation.annotationType().getName().equals(OPTIONS.class.getName())) {
            return true;
        } else if (annotation.annotationType().getName().equals(DELETE.class.getName())) {
            return true;
        } else if (annotation.annotationType().getName().equals(PUT.class.getName())) {
            return true;
        }
    }
    return false;
}
 
源代码3 项目: carbon-device-mgt   文件: AnnotationProcessor.java
/**
 * Read Method annotations indicating HTTP Methods
 *
 * @param resource
 * @param annotation
 */
private void processHTTPMethodAnnotation(APIResource resource, Annotation annotation) {
    if (annotation.annotationType().getName().equals(GET.class.getName())) {
        resource.setHttpVerb(HttpMethod.GET);
    }
    if (annotation.annotationType().getName().equals(POST.class.getName())) {
        resource.setHttpVerb(HttpMethod.POST);
    }
    if (annotation.annotationType().getName().equals(OPTIONS.class.getName())) {
        resource.setHttpVerb(HttpMethod.OPTIONS);
    }
    if (annotation.annotationType().getName().equals(DELETE.class.getName())) {
        resource.setHttpVerb(HttpMethod.DELETE);
    }
    if (annotation.annotationType().getName().equals(PUT.class.getName())) {
        resource.setHttpVerb(HttpMethod.PUT);
    }
}
 
源代码4 项目: carbon-device-mgt   文件: AnnotationProcessor.java
private boolean isHttpMethodAvailable(Annotation[] annotations) {
    for (Annotation annotation : annotations) {
        if (annotation.annotationType().getName().equals(GET.class.getName())) {
            return true;
        } else if (annotation.annotationType().getName().equals(POST.class.getName())) {
            return true;
        } else if (annotation.annotationType().getName().equals(OPTIONS.class.getName())) {
            return true;
        } else if (annotation.annotationType().getName().equals(DELETE.class.getName())) {
            return true;
        } else if (annotation.annotationType().getName().equals(PUT.class.getName())) {
            return true;
        }
    }
    return false;
}
 
源代码5 项目: vxms   文件: RestRsRouteInitializer.java
private static void initHttpOptions(
        VxmsShared vxmsShared,
        Router router,
        Object service,
        Method restMethod,
        Path path,
        Stream<Method> errorMethodStream,
        Optional<Consumes> consumes) {
    final Route route = router.options(URIUtil.cleanPath(path.value()));
    final Context context = getContext(vxmsShared);
    final String methodId =
            path.value()
                    + OPTIONS.class.getName()
                    + ConfigurationUtil.getCircuitBreakerIDPostfix(context.config());
    initHttpOperation(
            methodId,
            vxmsShared,
            service,
            restMethod,
            route,
            errorMethodStream,
            consumes,
            OPTIONS.class);
}
 
源代码6 项目: io   文件: DavRsCmp.java
/**
 * OPTIONSメソッド.
 * @return JAX-RS Response
 */
@OPTIONS
public Response options() {
    // アクセス制御
    this.checkAccessContext(this.getAccessContext(), BoxPrivilege.READ);

    return DcCoreUtils.responseBuilderForOptions(
            HttpMethod.GET,
            HttpMethod.PUT,
            HttpMethod.DELETE,
            com.fujitsu.dc.common.utils.DcCoreUtils.HttpMethod.MKCOL,
            com.fujitsu.dc.common.utils.DcCoreUtils.HttpMethod.PROPFIND,
            com.fujitsu.dc.common.utils.DcCoreUtils.HttpMethod.PROPPATCH,
            com.fujitsu.dc.common.utils.DcCoreUtils.HttpMethod.ACL
            ).build();
}
 
源代码7 项目: io   文件: DavCollectionResource.java
/**
 * OPTIONSメソッド.
 * @return JAX-RS Response
 */
@OPTIONS
public Response options() {
    // アクセス制御
    this.davRsCmp.checkAccessContext(this.davRsCmp.getAccessContext(), BoxPrivilege.READ);

    return DcCoreUtils.responseBuilderForOptions(
            HttpMethod.GET,
            HttpMethod.PUT,
            HttpMethod.DELETE,
            com.fujitsu.dc.common.utils.DcCoreUtils.HttpMethod.MKCOL,
            com.fujitsu.dc.common.utils.DcCoreUtils.HttpMethod.MOVE,
            com.fujitsu.dc.common.utils.DcCoreUtils.HttpMethod.PROPFIND,
            com.fujitsu.dc.common.utils.DcCoreUtils.HttpMethod.PROPPATCH,
            com.fujitsu.dc.common.utils.DcCoreUtils.HttpMethod.ACL
            ).build();
}
 
源代码8 项目: micro-integrator   文件: PeopleRestService.java
@Produces({ MediaType.APPLICATION_JSON })
@Path("/options")
@OPTIONS
public Response getOptions(@Context HttpHeaders headers, @Context Request request) {
    return Response.ok().header(CorsHeaderConstants.HEADER_AC_ALLOW_METHODS, "GET POST DELETE PUT OPTIONS")
            .header(CorsHeaderConstants.HEADER_AC_ALLOW_CREDENTIALS, "false")
            .header(CorsHeaderConstants.HEADER_AC_REQUEST_HEADERS, MediaType.APPLICATION_JSON).build();
}
 
@Override
public void initMethodAnnotationProcessor() {
  super.initMethodAnnotationProcessor();
  methodAnnotationMap.put(Path.class, new PathMethodAnnotationProcessor());

  HttpMethodAnnotationProcessor httpMethodAnnotationProcessor = new HttpMethodAnnotationProcessor();
  methodAnnotationMap.put(GET.class, httpMethodAnnotationProcessor);
  methodAnnotationMap.put(POST.class, httpMethodAnnotationProcessor);
  methodAnnotationMap.put(DELETE.class, httpMethodAnnotationProcessor);
  methodAnnotationMap.put(PATCH.class, httpMethodAnnotationProcessor);
  methodAnnotationMap.put(PUT.class, httpMethodAnnotationProcessor);
  methodAnnotationMap.put(OPTIONS.class, httpMethodAnnotationProcessor);
  methodAnnotationMap.put(HEAD.class, httpMethodAnnotationProcessor);
  methodAnnotationMap.put(Consumes.class, new ConsumesAnnotationProcessor());
}
 
源代码10 项目: opencps-v2   文件: DossierManagement.java
@OPTIONS
@Path("/{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Get the detail of Dossier by its id (or referenceId)", response = DossierDetailModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a list of Dossiers have been filtered", response = DossierDetailModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })

public Response getOptionDossier(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @PathParam("id") String id);
 
源代码11 项目: camunda-bpm-swagger   文件: JaxRsAnnotationStep.java
static Optional<Class<? extends Annotation>> javaxRsAnnotation(final Method method) {
  for (final Class<? extends Annotation> a : Arrays.asList(POST.class, GET.class, PUT.class, DELETE.class, OPTIONS.class)) {
    if (method.getAnnotation(a) != null) {
      return Optional.of(a);
    }
  }

  return Optional.empty();
}
 
源代码12 项目: trellis   文件: TrellisHttpResource.java
/**
 * Perform an OPTIONS operation on an LDP Resource.
 *
 * @param uriInfo the URI info
 * @param headers the HTTP headers
 * @param request the request
 * @return the async response
 */
@OPTIONS
@Timed
@Operation(summary = "Get the interaction options for a linked data resource")
@APIResponse(description = "The interaction options for a linked data resource")
public CompletionStage<Response> options(@Context final Request request, @Context final UriInfo uriInfo,
        @Context final HttpHeaders headers) {
    final TrellisRequest req = new TrellisRequest(request, uriInfo, headers);
    final OptionsHandler optionsHandler = new OptionsHandler(req, trellis, extensions);
    return supplyAsync(optionsHandler::ldpOptions).thenApply(ResponseBuilder::build)
        .exceptionally(this::handleException);
}
 
源代码13 项目: product-ei   文件: StockQuoteService.java
/**
 * Retrieve information on what methods are allowed on the Request-URI.
 * curl -i -X OPTIONS http://localhost:9090/stockquote/all
 *
 * @return Response
 */
@OPTIONS
@Path("/all")
@ApiOperation(
        value = "Get supported reuest methods",
        notes = "Return a response with headers that show the supported HTTP Requests on the Request-URI")
public Response getCommunicationInformationForRequestURI() {
    return Response.ok().header("Access-Control-Allow-Methods", "GET,OPTIONS").build();
}
 
源代码14 项目: carbon-device-mgt   文件: AnnotationProcessor.java
/**
 * Read Method annotations indicating HTTP Methods
 *
 * @param annotation
 */
private String getHTTPMethodAnnotation(Annotation annotation) {
    if (annotation.annotationType().getName().equals(GET.class.getName())) {
        return HttpMethod.GET;
    } else if (annotation.annotationType().getName().equals(POST.class.getName())) {
        return HttpMethod.POST;
    } else if (annotation.annotationType().getName().equals(OPTIONS.class.getName())) {
        return HttpMethod.OPTIONS;
    } else if (annotation.annotationType().getName().equals(DELETE.class.getName())) {
        return HttpMethod.DELETE;
    } else if (annotation.annotationType().getName().equals(PUT.class.getName())) {
        return HttpMethod.PUT;
    }
    return null;
}
 
源代码15 项目: vxms   文件: RESTJerseyClientTests.java
@Path("/stringOPTIONSResponse")
@OPTIONS
public void rsstringOPTIONSResponse(RestHandler handler) {

  String val = handler.request().body().getString(0, handler.request().body().length());
  System.out.println("stringOPTIONSResponse: " + val);
  handler.response().stringResponse((future) -> future.complete("hello")).execute();
}
 
源代码16 项目: msf4j   文件: StockQuoteService.java
/**
 * Retrieve information on what methods are allowed on the Request-URI.
 * curl -i -X OPTIONS http://localhost:8080/stockquote/all
 *
 * @return Response
 */
@OPTIONS
@Path("/all")
@ApiOperation(
        value = "Get supported reuest methods",
        notes = "Return a response with headers that show the supported HTTP Requests on the Request-URI")
public Response getCommunicationInformationForRequestURI() {
    return Response.ok().header("Access-Control-Allow-Methods", "GET,OPTIONS").build();
}
 
源代码17 项目: msf4j   文件: StockQuoteService.java
/**
 * Retrieve information on what methods are allowed on the Request-URI.
 * curl -i -X OPTIONS http://localhost:8080/stockquote/all
 *
 * @return Response
 */
@OPTIONS
@Path("/all")
@ApiOperation(
        value = "Get supported reuest methods",
        notes = "Return a response with headers that show the supported HTTP Requests on the Request-URI")
public Response getCommunicationInformationForRequestURI(){
    return Response.ok().header("Access-Control-Allow-Methods","GET,OPTIONS").build();
}
 
源代码18 项目: msf4j   文件: HttpResourceModel.java
/**
 * Fetches the HttpMethod from annotations and returns String representation of HttpMethod.
 * Return emptyString if not present.
 *
 * @param method Method handling the http request.
 * @return String representation of HttpMethod from annotations or emptyString as a default.
 */
private Set<String> getHttpMethods(Method method) {
    Set<String> httpMethods = new HashSet();
    boolean isSubResourceLocator = true;
    if (method.isAnnotationPresent(GET.class)) {
        httpMethods.add(HttpMethod.GET);
        isSubResourceLocator = false;
    }
    if (method.isAnnotationPresent(PUT.class)) {
        httpMethods.add(HttpMethod.PUT);
        isSubResourceLocator = false;
    }
    if (method.isAnnotationPresent(POST.class)) {
        httpMethods.add(HttpMethod.POST);
        isSubResourceLocator = false;
    }
    if (method.isAnnotationPresent(DELETE.class)) {
        httpMethods.add(HttpMethod.DELETE);
        isSubResourceLocator = false;
    }
    if (method.isAnnotationPresent(HEAD.class)) {
        httpMethods.add(HttpMethod.HEAD);
        isSubResourceLocator = false;
    }
    if (method.isAnnotationPresent(OPTIONS.class)) {
        httpMethods.add(HttpMethod.OPTIONS);
        isSubResourceLocator = false;
    }
    // If this is a sub resource locator need to add all the method designator
    if (isSubResourceLocator) {
        httpMethods.add(HttpMethod.GET);
        httpMethods.add(HttpMethod.POST);
        httpMethods.add(HttpMethod.PUT);
        httpMethods.add(HttpMethod.DELETE);
        httpMethods.add(HttpMethod.HEAD);
        httpMethods.add(HttpMethod.OPTIONS);
    }
    return Collections.unmodifiableSet(httpMethods);
}
 
源代码19 项目: msf4j   文件: Util.java
/**
 * Check if http verb is available for the method.
 *
 * @param method
 * @return
 */
public static boolean isHttpMethodAvailable(Method method) {
    return method.isAnnotationPresent(GET.class) ||
           method.isAnnotationPresent(PUT.class) ||
           method.isAnnotationPresent(POST.class) ||
           method.isAnnotationPresent(DELETE.class) ||
           method.isAnnotationPresent(HEAD.class) ||
           method.isAnnotationPresent(OPTIONS.class);
}
 
源代码20 项目: msf4j   文件: MicroserviceMetadata.java
private boolean isHttpMethodAvailable(Method method) {
    return method.isAnnotationPresent(GET.class) ||
            method.isAnnotationPresent(PUT.class) ||
            method.isAnnotationPresent(POST.class) ||
            method.isAnnotationPresent(DELETE.class) ||
            method.isAnnotationPresent(HEAD.class) ||
            method.isAnnotationPresent(OPTIONS.class);
}
 
源代码21 项目: io   文件: CellResource.java
/**
 * OPTIONSメソッド.
 * @return JAX-RS Response
 */
@OPTIONS
public Response options() {
    // アクセス制御
    this.cellRsCmp.checkAccessContext(this.cellRsCmp.getAccessContext(), CellPrivilege.SOCIAL_READ);
    return DcCoreUtils.responseBuilderForOptions(
            HttpMethod.POST,
            DcCoreUtils.HttpMethod.PROPFIND
            ).build();
}
 
源代码22 项目: cloud-odata-java   文件: ODataSubLocator.java
@OPTIONS
public Response handleOptions() throws ODataException {
  // RFC 2616, 5.1.1: "An origin server SHOULD return the status code [...]
  // 501 (Not Implemented) if the method is unrecognized or not implemented
  // by the origin server."
  return returnNotImplementedResponse(ODataNotImplementedException.COMMON);
}
 
源代码23 项目: io   文件: DavFileResource.java
/**
 * process OPTIONS Method.
 * @return JAX-RS response object
 */
@OPTIONS
public Response options() {
    // Access Control
    this.davRsCmp.checkAccessContext(this.davRsCmp.getAccessContext(), BoxPrivilege.READ);
    return DcCoreUtils.responseBuilderForOptions(
            HttpMethod.GET,
            HttpMethod.PUT,
            HttpMethod.DELETE,
            com.fujitsu.dc.common.utils.DcCoreUtils.HttpMethod.MOVE,
            com.fujitsu.dc.common.utils.DcCoreUtils.HttpMethod.PROPFIND,
            com.fujitsu.dc.common.utils.DcCoreUtils.HttpMethod.PROPPATCH,
            com.fujitsu.dc.common.utils.DcCoreUtils.HttpMethod.ACL
            ).build();
}
 
源代码24 项目: io   文件: ODataSvcCollectionResource.java
/**
 * OPTIONSメソッド.
 * @return JAX-RS Response
 */
@Override
@OPTIONS
public Response optionsRoot() {
    // アクセス制御
    this.checkAccessContext(this.getAccessContext(), BoxPrivilege.READ);
    return DcCoreUtils.responseBuilderForOptions(
            HttpMethod.GET,
            HttpMethod.DELETE,
            DcCoreUtils.HttpMethod.MOVE,
            DcCoreUtils.HttpMethod.PROPFIND,
            DcCoreUtils.HttpMethod.PROPPATCH,
            DcCoreUtils.HttpMethod.ACL
            ).build();
}
 
源代码25 项目: io   文件: DcEngineSourceCollection.java
/**
 * OPTIONSメソッドの処理.
 * @return JAX-RS応答オブジェクト
 */
@OPTIONS
public Response options() {
    // 移動元に対するアクセス制御
    this.davRsCmp.checkAccessContext(this.davRsCmp.getAccessContext(), BoxPrivilege.READ);
    return DcCoreUtils.responseBuilderForOptions(
            com.fujitsu.dc.common.utils.DcCoreUtils.HttpMethod.PROPFIND
            ).build();
}
 
源代码26 项目: io   文件: DcEngineSvcCollectionResource.java
/**
 * OPTIONSメソッド.
 * @return JAX-RS Response
 */
@OPTIONS
public Response options() {
    // アクセス制御
    this.davRsCmp.checkAccessContext(this.davRsCmp.getAccessContext(), BoxPrivilege.READ);
    return DcCoreUtils.responseBuilderForOptions(
            HttpMethod.DELETE,
            com.fujitsu.dc.common.utils.DcCoreUtils.HttpMethod.MOVE,
            com.fujitsu.dc.common.utils.DcCoreUtils.HttpMethod.PROPFIND,
            com.fujitsu.dc.common.utils.DcCoreUtils.HttpMethod.PROPPATCH,
            com.fujitsu.dc.common.utils.DcCoreUtils.HttpMethod.ACL
            ).build();
}
 
源代码27 项目: io   文件: ODataSvcSchemaResource.java
/**
 * OPTIONS Method.
 * @return JAX-RS Response
 */
@Override
@OPTIONS
@Path("")
public Response optionsRoot() {
    // アクセス制御
    this.checkAccessContext(this.getAccessContext(), BoxPrivilege.READ);
    return super.doGetOptionsMetadata();
}
 
源代码28 项目: io   文件: ODataEntityResource.java
/**
 * OPTIONSメソッド.
 * @return JAX-RS Response
 */
@OPTIONS
public Response options() {
    // アクセス制御
    this.odataResource.checkAccessContext(this.accessContext,
            this.odataResource.getNecessaryReadPrivilege(getEntitySetName()));

    return DcCoreUtils.responseBuilderForOptions(
            HttpMethod.GET,
            HttpMethod.PUT,
            DcCoreUtils.HttpMethod.MERGE,
            HttpMethod.DELETE
            ).build();
}
 
源代码29 项目: io   文件: ODataResource.java
/**
 * OPTIONSメソッド.
 * @return JAX-RS Response
 */
@OPTIONS
@Path("")
public Response optionsRoot() {
    // アクセス制御
    this.checkAccessContext(this.getAccessContext(), BoxPrivilege.READ);
    return DcCoreUtils.responseBuilderForOptions(
            HttpMethod.GET
            ).build();
}
 
源代码30 项目: io   文件: ODataPropertyResource.java
/**
 * OPTIONSメソッド.
 * @return JAX-RS Response
 */
@OPTIONS
public Response options() {
    // アクセス制御
    this.odataResource.checkAccessContext(this.accessContext,
            this.odataResource.getNecessaryOptionsPrivilege());
    return DcCoreUtils.responseBuilderForOptions(
            HttpMethod.GET,
            HttpMethod.POST
            ).build();
}
 
 类所在包
 类方法
 同包方法