本文整理汇总了Java中javax.ws.rs.HEAD类的典型用法代码示例。如果您正苦于以下问题:Java HEAD类的具体用法?Java HEAD怎么用?Java HEAD使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HEAD类属于javax.ws.rs包,在下文中一共展示了HEAD类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verb
import javax.ws.rs.HEAD; //导入依赖的package包/类
private String verb(Method m) {
if (m.getAnnotation(DELETE.class) != null) {
return "DELETE ";
} else if (m.getAnnotation(GET.class) != null) {
return "GET ";
} else if (m.getAnnotation(HEAD.class) != null) {
return "HEAD ";
} else if (m.getAnnotation(OPTIONS.class) != null) {
return "OPTIONS ";
} else if (m.getAnnotation(POST.class) != null) {
return "POST ";
} else if (m.getAnnotation(PUT.class) != null) {
return "PUT ";
} else {
return null;
}
}
示例2: documentOperations
import javax.ws.rs.HEAD; //导入依赖的package包/类
public static List<SwaggerOperation> documentOperations(SwaggerModel models, Method method) {
List<SwaggerOperation> ops = new ArrayList<SwaggerOperation>();
Annotation[] annotations = method.getAnnotations();
if (annotationPresent(GET.class, annotations)) {
ops.add(createOperation(models, GET, method, annotations));
}
if (annotationPresent(PUT.class, annotations)) {
ops.add(createOperation(models, PUT, method, annotations));
}
if (annotationPresent(POST.class, annotations)) {
ops.add(createOperation(models, POST, method, annotations));
}
if (annotationPresent(DELETE.class, annotations)) {
ops.add(createOperation(models, DELETE, method, annotations));
}
if (annotationPresent(HEAD.class, annotations)) {
ops.add(createOperation(models, HEAD, method, annotations));
}
if (annotationPresent(OPTIONS.class, annotations)) {
ops.add(createOperation(models, OPTIONS, method, annotations));
}
return ops;
}
示例3: countAssets
import javax.ws.rs.HEAD; //导入依赖的package包/类
@HEAD
@Path("/assets")
public Response countAssets(@Context UriInfo info, @Context SecurityContext sc) throws InvalidParameterException {
if (logger.isLoggable(Level.FINE)) {
logger.fine("countAssets called with query parameters: " + info.getRequestUri().getRawQuery());
}
AssetQueryParameters params = AssetQueryParameters.create(info);
Collection<AssetFilter> filters = params.getFilters();
if (!sc.isUserInRole(ADMIN_ROLE)) {
filters.add(ASSET_IS_PUBLISHED);
}
int count = assetService.countAllAssets(filters, params.getSearchTerm());
return Response.noContent().header("count", count).build();
}
示例4: getHttpMethod
import javax.ws.rs.HEAD; //导入依赖的package包/类
public static String getHttpMethod(Method method){
if (method.getAnnotation(GET.class)!=null){
return HttpMethod.GET;
}
if (method.getAnnotation(POST.class)!=null){
return HttpMethod.POST;
}
if (method.getAnnotation(DELETE.class)!=null){
return HttpMethod.DELETE;
}
if (method.getAnnotation(PUT.class)!=null){
return HttpMethod.PUT;
}
if (method.getAnnotation(OPTIONS.class)!=null){
return HttpMethod.OPTIONS;
}
if (method.getAnnotation(HEAD.class)!=null){
return HttpMethod.HEAD;
}
return null;
}
示例5: headConsumer
import javax.ws.rs.HEAD; //导入依赖的package包/类
@Path("attributes-{attributes}/{consumer-id}")
@HEAD
public Response headConsumer(@PathParam("attributes") int attributes,
@PathParam("consumer-id") String consumerId,
@Context UriInfo uriInfo) throws Exception {
ActiveMQRestLogger.LOGGER.debug("Handling HEAD request for \"" + uriInfo.getPath() + "\"");
QueueConsumer consumer = findConsumer(attributes, consumerId, uriInfo);
Response.ResponseBuilder builder = Response.noContent();
// we synchronize just in case a failed request is still processing
synchronized (consumer) {
if ((attributes & ACKNOWLEDGED) > 0) {
AcknowledgedQueueConsumer ackedConsumer = (AcknowledgedQueueConsumer) consumer;
Acknowledgement ack = ackedConsumer.getAck();
if (ack == null || ack.wasSet()) {
AcknowledgedQueueConsumer.setAcknowledgeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/attributes-" + attributes + "/" + consumer.getId(), Long.toString(consumer.getConsumeIndex()));
} else {
ackedConsumer.setAcknowledgementLink(builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/attributes-" + attributes + "/" + consumer.getId());
}
} else {
QueueConsumer.setConsumeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/attributes-" + attributes + "/" + consumer.getId(), Long.toString(consumer.getConsumeIndex()));
}
}
return builder.build();
}
示例6: getHttpMethod
import javax.ws.rs.HEAD; //导入依赖的package包/类
private HTTPMethod getHttpMethod(Method m) {
if (m.isAnnotationPresent(GET.class)) {
return HTTPMethod.GET;
}
if (m.isAnnotationPresent(POST.class)) {
return HTTPMethod.POST;
}
if (m.isAnnotationPresent(PUT.class)) {
return HTTPMethod.PUT;
}
if (m.isAnnotationPresent(DELETE.class)) {
return HTTPMethod.DELETE;
}
if (m.isAnnotationPresent(HEAD.class)) {
return HTTPMethod.HEAD;
}
return HTTPMethod.OPTIONS;
}
示例7: addHTTPMethodToMethodModel
import javax.ws.rs.HEAD; //导入依赖的package包/类
/**
* add value of the HTTPMethod to the jaxrs-method model. axis2 only supports POST,GET,PUT,DELETE.
* it doesnt support HEAD. if HEAD is given it resolves to the default method (POST)
* @param annotation
* @param methodModel
*/
private static void addHTTPMethodToMethodModel(Annotation annotation,JAXRSModel methodModel){
if (annotation instanceof POST) {
methodModel.setHTTPMethod(Constants.Configuration.HTTP_METHOD_POST);
} else if (annotation instanceof GET) {
methodModel.setHTTPMethod(Constants.Configuration.HTTP_METHOD_GET);
} else if (annotation instanceof PUT) {
methodModel.setHTTPMethod(Constants.Configuration.HTTP_METHOD_PUT);
} else if (annotation instanceof DELETE) {
methodModel.setHTTPMethod(Constants.Configuration.HTTP_METHOD_DELETE);
} else if (annotation instanceof HEAD) {
log.warn("HTTP Method HEAD is not supported by AXIS2");
}
}
示例8: head
import javax.ws.rs.HEAD; //导入依赖的package包/类
/**
* LDP 1.0 - 4.2.6.1 LDP servers must support the HTTP HEAD method.
* @param uriInfo the full URL details of the resource
* @param path the path of the resource
* @param headers the headers included in the request
* @param request the request itself
* @return an LDP compliant response to the HEAD request
*/
@HEAD
@Path(ENDPOINT_PATH)
public Response head(
@Context UriInfo uriInfo,
@PathParam(ENDPOINT_PATH_PARAM) String path,
@Context HttpHeaders headers,
@Context Request request) {
OperationContext context =
newOperationBuilder(HttpMethod.HEAD).
withEndpointPath(path).
withUriInfo(uriInfo).
withHeaders(headers).
withRequest(request).
build();
return
EndpointControllerFactory.
newController().
head(context);
}
示例9: repositoryExists
import javax.ws.rs.HEAD; //导入依赖的package包/类
@HEAD
@Path("/repository/{repo}")
public Response repositoryExists(@HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization,
@NotNull @PathParam("repo") String repository) {
Identity identity = identities.getGitHubIdentity(authorization);
GitHubService gitHubService = gitHubServiceFactory.create(identity);
if (gitHubService.repositoryExists(gitHubService.getLoggedUser().getLogin() + "/" + repository)) {
return Response.ok().build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
}
}
示例10: openShiftProjectExists
import javax.ws.rs.HEAD; //导入依赖的package包/类
@HEAD
@Path("/project/{project}")
public Response openShiftProjectExists(@HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization,
@NotNull @PathParam("project") String project,
@QueryParam("cluster") String cluster) {
Identity identity = identities.getOpenShiftIdentity(authorization, cluster);
OpenShiftCluster openShiftCluster = clusterRegistry.findClusterById(cluster)
.orElseThrow(() -> new IllegalStateException("Cluster not found"));
OpenShiftService openShiftService = openShiftServiceFactory.create(openShiftCluster, identity);
if (openShiftService.projectExists(project)) {
return Response.ok().build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
}
}
示例11: openShiftTokenExists
import javax.ws.rs.HEAD; //导入依赖的package包/类
@HEAD
@Path("/token/openshift")
public Response openShiftTokenExists(@HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization,
@QueryParam("cluster") String cluster) {
Identity identity = identities.getOpenShiftIdentity(authorization, cluster);
boolean tokenExists = (identity != null);
if (tokenExists) {
return Response.ok().build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
}
}
示例12: gitHubTokenExists
import javax.ws.rs.HEAD; //导入依赖的package包/类
@HEAD
@Path("/token/github")
public Response gitHubTokenExists(@HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization) {
Identity identity = identities.getGitHubIdentity(authorization);
boolean tokenExists = (identity != null);
if (tokenExists) {
return Response.ok().build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
}
}
示例13: head
import javax.ws.rs.HEAD; //导入依赖的package包/类
/**
* Retrieve the resource headers
*
* @return response
*/
@HEAD
@Produces({TURTLE_WITH_CHARSET + ";qs=1.0", JSON_LD + ";qs=0.8",
N3_WITH_CHARSET, N3_ALT2_WITH_CHARSET, RDF_XML, NTRIPLES, TEXT_PLAIN_WITH_CHARSET,
TURTLE_X, TEXT_HTML_WITH_CHARSET})
public Response head() throws UnsupportedAlgorithmException {
LOGGER.info("HEAD for: {}", externalPath);
final URI internalUri = createFromPath(externalPath);
final Container container = getContainerService().find(internalUri);
if (container == null) {
if (!isRoot(internalUri)) {
return Response.status(Response.Status.NOT_FOUND).build();
}
}
return ok().build();
}
示例14: existsZNode
import javax.ws.rs.HEAD; //导入依赖的package包/类
@HEAD
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
MediaType.APPLICATION_XML })
public Response existsZNode(@PathParam("path") String path,
@Context UriInfo ui) throws InterruptedException, KeeperException {
Stat stat = zk.exists(path, false);
if (stat == null) {
throwNotFound(path, ui);
}
return Response.status(Response.Status.OK).build();
}
示例15: existsZNodeAsOctet
import javax.ws.rs.HEAD; //导入依赖的package包/类
@HEAD
@Produces( { MediaType.APPLICATION_OCTET_STREAM })
public Response existsZNodeAsOctet(@PathParam("path") String path,
@Context UriInfo ui) throws InterruptedException, KeeperException {
Stat stat = zk.exists(path, false);
if (stat == null) {
throwNotFound(path, ui);
}
return Response.status(Response.Status.NO_CONTENT).build();
}