Java Code Examples for javax.ws.rs.core.HttpHeaders#IF_NONE_MATCH

The following examples show how to use javax.ws.rs.core.HttpHeaders#IF_NONE_MATCH . 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: APIEndpointV1.java    From microprofile-starter with Apache License 2.0 5 votes vote down vote up
@Path("/supportMatrix")
@GET
@Produces({"application/json"})
@Override
public Response supportMatrix(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch) {
    return api.supportMatrixV1(ifNoneMatch);
}
 
Example 2
Source File: APIEndpointV1.java    From microprofile-starter with Apache License 2.0 5 votes vote down vote up
@Path("/supportMatrix/servers")
@GET
@Produces({"application/json"})
@Override
public Response supportMatrixServers(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch) {
    return api.supportMatrixServersV1(ifNoneMatch);
}
 
Example 3
Source File: APIEndpointV1.java    From microprofile-starter with Apache License 2.0 5 votes vote down vote up
@Path("/project")
@GET
@Produces({"application/zip", "application/json"})
public Response getProject(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch,
                           @QueryParam("supportedServer") SupportedServer supportedServer,
                           @QueryParam("groupId") String groupId,
                           @QueryParam("artifactId") String artifactId,
                           @QueryParam("mpVersion") MicroProfileVersion mpVersion,
                           @QueryParam("javaSEVersion") JavaSEVersion javaSEVersion,
                           @QueryParam("selectedSpecs") List<MicroprofileSpec> selectedSpecs) {
    return api.getProjectV1(ifNoneMatch, supportedServer, groupId, artifactId, mpVersion, javaSEVersion, selectedSpecs);
}
 
Example 4
Source File: APIEndpointV1.java    From microprofile-starter with Apache License 2.0 5 votes vote down vote up
@Path("/project")
@POST
@Consumes({"application/json"})
@Produces({"application/zip", "application/json"})
@Override
public Response projectPost(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch, @NotNull Project body) {
    return api.getProjectV1(ifNoneMatch, body);
}
 
Example 5
Source File: APIEndpointLatest.java    From microprofile-starter with Apache License 2.0 5 votes vote down vote up
@Path("/project")
@GET
@Produces({"application/zip", "application/json"})
public Response getProject(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch,
                           @QueryParam("supportedServer") SupportedServer supportedServer,
                           @QueryParam("groupId") String groupId,
                           @QueryParam("artifactId") String artifactId,
                           @QueryParam("mpVersion") MicroProfileVersion mpVersion,
                           @QueryParam("javaSEVersion") JavaSEVersion javaSEVersion,
                           @QueryParam("selectedSpecs") List<MicroprofileSpec> selectedSpecs,
                           @QueryParam("selectAllSpecs") boolean selectAllSpecs) {
    return api.getProject(ifNoneMatch, supportedServer, groupId, artifactId, mpVersion, javaSEVersion, selectedSpecs, selectAllSpecs);
}
 
Example 6
Source File: APIEndpointLatest.java    From microprofile-starter with Apache License 2.0 5 votes vote down vote up
@Path("/project")
@POST
@Consumes({"application/json"})
@Produces({"application/zip", "application/json"})
public Response projectPost(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch, @NotNull Project body) {
    return api.getProject(ifNoneMatch, body);
}
 
Example 7
Source File: APIEndpointV2.java    From microprofile-starter with Apache License 2.0 5 votes vote down vote up
@Path("/project")
@GET
@Produces({"application/zip", "application/json"})
public Response getProject(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch,
                           @QueryParam("supportedServer") SupportedServer supportedServer,
                           @QueryParam("groupId") String groupId,
                           @QueryParam("artifactId") String artifactId,
                           @QueryParam("mpVersion") MicroProfileVersion mpVersion,
                           @QueryParam("javaSEVersion") JavaSEVersion javaSEVersion,
                           @QueryParam("selectedSpecs") List<MicroprofileSpec> selectedSpecs) {
    return api.getProjectV1(ifNoneMatch, supportedServer, groupId, artifactId, mpVersion, javaSEVersion, selectedSpecs);
}
 
Example 8
Source File: APIEndpointV2.java    From microprofile-starter with Apache License 2.0 5 votes vote down vote up
@Path("/project")
@POST
@Consumes({"application/json"})
@Produces({"application/zip", "application/json"})
@Override
public Response projectPost(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch, @NotNull Project body) {
    return api.getProjectV1(ifNoneMatch, body);
}
 
Example 9
Source File: APIEndpointV3.java    From microprofile-starter with Apache License 2.0 5 votes vote down vote up
@Path("/supportMatrix/servers")
@GET
@Produces({"application/json"})
@Override
public Response supportMatrixServers(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch) {
    return api.supportMatrixServersV3(ifNoneMatch);
}
 
Example 10
Source File: LogResource.java    From io with Apache License 2.0 5 votes vote down vote up
/**
 * イベントログファイルを取得する.
 * @param ifNoneMatch If-None-Matchヘッダ
 * @param logCollection Collection名
 * @param fileName fileName
 * @return JAXRS Response
 */
@Path("{logCollection}/{filename}")
@GET
public final Response getLogFile(@HeaderParam(HttpHeaders.IF_NONE_MATCH) final String ifNoneMatch,
        @PathParam("logCollection") final String logCollection,
        @PathParam("filename") final String fileName) {

    // アクセス制御
    this.davRsCmp.checkAccessContext(this.davRsCmp.getAccessContext(), CellPrivilege.LOG_READ);

    // イベントログのCollection名のチェック
    if (!isValidLogCollection(logCollection)) {
        throw DcCoreException.Dav.RESOURCE_NOT_FOUND;
    }

    // ファイル名がdefault.log以外の場合は404を返却
    if (!isValidLogFile(logCollection, fileName)) {
        throw DcCoreException.Dav.RESOURCE_NOT_FOUND;
    }

    String cellId = davRsCmp.getCell().getId();
    String owner = davRsCmp.getCell().getOwner();

    // ログファイルのパスを取得
    StringBuilder logFileName = EventUtils.getEventLogDir(cellId, owner);
    logFileName.append(logCollection);
    logFileName.append(File.separator);
    logFileName.append(fileName);
    return getLog(logCollection, logFileName.toString());
}
 
Example 11
Source File: DavFileResource.java    From io with Apache License 2.0 5 votes vote down vote up
/**
 * process GET Method and retrieve the file content.
 * @param ifNoneMatch If-None-Match Header
 * @param rangeHeaderField Range header
 * @return JAX-RS response object
 */
@GET
public Response get(
        @HeaderParam(HttpHeaders.IF_NONE_MATCH) final String ifNoneMatch,
        @HeaderParam("Range") final String rangeHeaderField
        ) {

    // Access Control
    this.davRsCmp.checkAccessContext(this.davRsCmp.getAccessContext(), BoxPrivilege.READ);

    ResponseBuilder rb = this.davRsCmp.get(ifNoneMatch, rangeHeaderField);
    return rb.build();
}
 
Example 12
Source File: AbstractClient.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Client match(EntityTag tag, boolean ifNot) {
    String hName = ifNot ? HttpHeaders.IF_NONE_MATCH : HttpHeaders.IF_MATCH;
    state.getRequestHeaders().putSingle(hName, tag.toString());
    return this;
}
 
Example 13
Source File: APIEndpointLatest.java    From microprofile-starter with Apache License 2.0 4 votes vote down vote up
@Path("/")
@GET
@Produces({"text/x-markdown"})
public Response readme(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch) {
    return api.readme(ifNoneMatch);
}
 
Example 14
Source File: APIEndpointLatest.java    From microprofile-starter with Apache License 2.0 4 votes vote down vote up
@Path("/supportMatrix")
@GET
@Produces({"application/json"})
public Response supportMatrix(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch) {
    return api.supportMatrix(ifNoneMatch);
}
 
Example 15
Source File: APIEndpointLatest.java    From microprofile-starter with Apache License 2.0 4 votes vote down vote up
@Path("/supportMatrix/servers")
@GET
@Produces({"application/json"})
public Response supportMatrixServers(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch) {
    return api.supportMatrixServers(ifNoneMatch);
}
 
Example 16
Source File: ODataEntityResource.java    From io with Apache License 2.0 4 votes vote down vote up
/**
 * GETメソッドの処理.
 * @param uriInfo UriInfo
 * @param accept Accept ヘッダ
 * @param ifNoneMatch If-None-Match ヘッダ
 * @param format $format パラメタ
 * @param expand $expand パラメタ
 * @param select $select パラメタ
 * @return JAX-RSResponse
 */
@GET
public Response get(
        @Context final UriInfo uriInfo,
        @HeaderParam(HttpHeaders.ACCEPT) String accept,
        @HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch,
        @QueryParam("$format") String format,
        @QueryParam("$expand") String expand,
        @QueryParam("$select") String select) {
    // アクセス制御
    this.odataResource.checkAccessContext(this.accessContext,
            this.odataResource.getNecessaryReadPrivilege(getEntitySetName()));

    UriInfo resUriInfo = DcCoreUtils.createUriInfo(uriInfo, 1);

    // $formatとAcceptヘッダの値から出力形式を決定
    MediaType contentType = decideOutputFormat(accept, format);
    String outputFormat = FORMAT_JSON;
    if (MediaType.APPLICATION_ATOM_XML_TYPE.equals(contentType)) {
        outputFormat = FORMAT_ATOM;
    }

    // Entityの取得をProducerに依頼
    EntityResponse entityResp = getEntity(expand, select, resUriInfo);
    String respStr = renderEntityResponse(resUriInfo, entityResp, outputFormat, null);

    // 制御コードのエスケープ処理
    respStr = escapeResponsebody(respStr);

    ResponseBuilder rb = Response.ok().type(contentType);
    rb.header(ODataConstants.Headers.DATA_SERVICE_VERSION, ODataVersion.V2.asString);
    // ETagを正式実装するときに、返却する必要がある
    OEntity entity = entityResp.getEntity();
    String etag = null;
    // 基本的にこのIF文に入る。
    if (entity instanceof OEntityWrapper) {
        OEntityWrapper oew = (OEntityWrapper) entity;

        // エンティティごとのアクセス可否判断
        this.odataResource.checkAccessContextPerEntity(this.accessContext, oew);

        etag = oew.getEtag();
        // 基本的にこのIF文に入る。
        if (etag != null) {
            // If-None-Matchヘッダの指定があるとき
            if (ifNoneMatch != null && ifNoneMatch.equals(ODataResource.renderEtagHeader(etag))) {
                return Response.notModified().build();
            }
            // ETagヘッダの付与
            rb.header(HttpHeaders.ETAG, ODataResource.renderEtagHeader(etag));
        }
    }
    return rb.entity(respStr).build();
}