當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpHeaders.CONTENT_TYPE屬性代碼示例

本文整理匯總了Java中javax.ws.rs.core.HttpHeaders.CONTENT_TYPE屬性的典型用法代碼示例。如果您正苦於以下問題:Java HttpHeaders.CONTENT_TYPE屬性的具體用法?Java HttpHeaders.CONTENT_TYPE怎麽用?Java HttpHeaders.CONTENT_TYPE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.ws.rs.core.HttpHeaders的用法示例。


在下文中一共展示了HttpHeaders.CONTENT_TYPE屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: put

/**
 * このパスに新たなファイルを配置する.
 * @param contentType Content-Typeヘッダ
 * @param inputStream リクエストボディ
 * @return Jax-RS Responseオブジェクトト
 */
@WriteAPI
@PUT
public final Response put(
        @HeaderParam(HttpHeaders.CONTENT_TYPE) final String contentType,
        final InputStream inputStream) {

    // アクセス製禦
    this.davRsCmp.checkAccessContext(this.davRsCmp.getAccessContext(), BoxPrivilege.WRITE);

    // 途中のパスが存在しないときは409エラー
    /*
     * A PUT that would result in the creation of a resource without an
     * appropriately scoped parent collection MUST fail with a 409 (Conflict).
     */

    if (!DavCommon.isValidResourceName(this.davRsCmp.getDavCmp().getName())) {
        throw PersoniumCoreException.Dav.RESOURCE_NAME_INVALID;
    }

    if (this.isParentNull) {
        throw PersoniumCoreException.Dav.HAS_NOT_PARENT.params(this.davRsCmp.getParent().getUrl());
    }

    return this.davRsCmp.getDavCmp().putForCreate(contentType, inputStream).build();
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:31,代碼來源:NullResource.java

示例2: put

/**
 * process PUT Method and update the file.
 * @param contentType Content-Type Header
 * @param ifMatch If-Match Header
 * @param inputStream Request Body
 * @return JAX-RS response object
 */
@WriteAPI
@PUT
public Response put(@HeaderParam(HttpHeaders.CONTENT_TYPE) final String contentType,
        @HeaderParam(HttpHeaders.IF_MATCH) final String ifMatch,
        final InputStream inputStream) {
    // Access Control
    this.davRsCmp.checkAccessContext(this.davRsCmp.getAccessContext(), BoxPrivilege.WRITE);

    ResponseBuilder rb = this.davRsCmp.getDavCmp().putForUpdate(contentType, inputStream, ifMatch);
    return rb.build();
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:18,代碼來源:DavFileResource.java

示例3: mkcol

/**
 * このパスに新たなCollectionを作成する.
 * @param contentType Content-Type ヘッダ
 * @param contentLength Content-Length ヘッダ
 * @param transferEncoding Transfer-Encoding ヘッダ
 * @param inputStream リクエストボディ
 * @return JAX-RS Response
 */
@Override
@WebDAVMethod.MKCOL
public Response mkcol(@HeaderParam(HttpHeaders.CONTENT_TYPE) final String contentType,
        @HeaderParam("Content-Length") final Long contentLength,
        @HeaderParam("Transfer-Encoding") final String transferEncoding,
        final InputStream inputStream) {
    // アクセス製禦
    this.davRsCmp.checkAccessContext(this.davRsCmp.getAccessContext(), BoxPrivilege.WRITE);
    throw PersoniumCoreException.Dav.METHOD_NOT_ALLOWED;
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:18,代碼來源:PersoniumEngineSourceNullResource.java

示例4: mkcol

/**
 * MKCOLメソッドの処理. boxインストールを行う.
 * @param uriInfo UriInfo
 * @param pCredHeader dcCredHeader
 * @param contentType Content-Typeヘッダの値
 * @param contentLength Content-Lengthヘッダの値
 * @param requestKey イベントログに出力するRequestKeyフィールドの値
 * @param inStream HttpリクエストのInputStream
 * @return JAX-RS Response
 */
@WriteAPI
@WebDAVMethod.MKCOL
public Response mkcol(
        @Context final UriInfo uriInfo,
        @HeaderParam(PersoniumCoreUtils.HttpHeaders.X_PERSONIUM_CREDENTIAL) final String pCredHeader,
        @HeaderParam(HttpHeaders.CONTENT_TYPE) final String contentType,
        @HeaderParam(HttpHeaders.CONTENT_LENGTH) final String contentLength,
        @HeaderParam(PersoniumCoreUtils.HttpHeaders.X_PERSONIUM_REQUESTKEY) String requestKey,
        final InputStream inStream) {

    PersoniumEventBus eventBus = new PersoniumEventBus(this.cell);
    Event event = null;
    Response res = null;
    try {
        // ログファイル出力
        JSONEvent reqBody = new JSONEvent();
        reqBody.setAction(WebDAVMethod.MKCOL.toString());
        reqBody.setLevel(LEVEL.INFO);
        reqBody.setObject(this.cell.getUrl() + boxName);
        reqBody.setResult("");
        // X-Personium-RequestKeyの解析(指定なしの場合にデフォルト値を補充)
        requestKey = EventResource.validateXPersoniumRequestKey(requestKey);
        // TODO findBugs対策↓
        log.debug(requestKey);

        event = EventResource.createEvent(reqBody, requestKey, this.accessContext);
        // eventBus.outputEventLog(event);

        if (Box.DEFAULT_BOX_NAME.equals(this.boxName)) {
            throw PersoniumCoreException.Misc.METHOD_NOT_ALLOWED;
        }

        // Boxを作成するためにCellCtlResource、ODataEntityResource(ODataProducer)が必要
        // この時點では "X-Personium-Credential" ヘッダーは不要なのでnullを指定する
        CellCtlResource cellctl = new CellCtlResource(this.accessContext, null, this.cellRsCmp);
        String keyName = "'" + this.boxName + "'";
        ODataEntityResource odataEntity = new ODataEntityResource(cellctl, Box.EDM_TYPE_NAME, keyName);

        Map<String, String> headers = new HashMap<String, String>();
        headers.put(HttpHeaders.CONTENT_TYPE, contentType);
        headers.put(HttpHeaders.CONTENT_LENGTH, contentLength);

        // X-Personium-RequestKeyの解析(指定なしの場合にデフォルト値を補充)
        BarFileInstaller installer =
                new BarFileInstaller(this.cell, this.boxName, odataEntity, uriInfo);

        res = installer.barFileInstall(headers, inStream, event.getRequestKey());
        event.setResult(Integer.toString(res.getStatus()));
    } catch (RuntimeException e) {
        // TODO 內部イベントの正式対応が必要
        if (e instanceof PersoniumCoreException) {
            event.setResult(Integer.toString(((PersoniumCoreException) e).getStatus()));
            if (((PersoniumCoreException) e).getStatus() < HttpStatus.SC_INTERNAL_SERVER_ERROR) {
                event.setLevel(LEVEL.INFO);
            } else {
                event.setLevel(LEVEL.ERROR);
            }
        } else {
            event.setResult(Integer.toString(HttpStatus.SC_INTERNAL_SERVER_ERROR));
            event.setLevel(LEVEL.ERROR);
        }
        throw e;
    } finally {
        // 終了ログファイル出力
        eventBus.outputEventLog(event);
    }
    return res;
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:78,代碼來源:BoxResource.java

示例5: put

/**
 * process PUT Method and update the file.
 * <p>
 * TODO Security considerations.
 * Implementing PUT makes it possible to perform Import with the snapshot file modified by the user.
 * Does malicious tampering with snapshot file cause problems?
 * It is necessary to carefully verify.
 *
 * @param contentType Content-Type Header
 * @param ifMatch If-Match Header
 * @param inputStream Request Body
 * @return JAX-RS response object
 */
@WriteAPI
@PUT
public Response put(@HeaderParam(HttpHeaders.CONTENT_TYPE) final String contentType,
        @HeaderParam(HttpHeaders.IF_MATCH) final String ifMatch,
        final InputStream inputStream) {
    // Access Control
    davRsCmp.getParent().checkAccessContext(davRsCmp.getAccessContext(), CellPrivilege.ROOT);

    ResponseBuilder rb = davRsCmp.getDavCmp().putForUpdate(contentType, inputStream, ifMatch);
    return rb.build();
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:24,代碼來源:CellSnapshotDavFileResource.java


注:本文中的javax.ws.rs.core.HttpHeaders.CONTENT_TYPE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。