コード例 #1
0
  @RequestMapping(
      value = MODIFY_COLLECTION_REQUEST,
      method = {RequestMethod.POST})
  public void modifyCollection(
      HttpServletRequest request,
      HttpServletResponse response,
      @RequestParam(value = "api", required = false) boolean api)
      throws IOException {

    if (apiRequested(response, api, MODIFY_COLLECTION_REQUEST)) return;

    com.c9a.buffers.CatalogServiceRequestProtocalBuffer.ModifyCatalogCollectionRequest
        modifyCollectionRequest =
            com.c9a.buffers.CatalogServiceRequestProtocalBuffer.ModifyCatalogCollectionRequest
                .parseFrom(GoogleProtoclBufferRequestContentUtils.getContentForRequest(request));
    try {
      CatalogCollection catalogCollection =
          catalogService.modifyCollection(
              modifyCollectionRequest.getUserId(),
              modifyCollectionRequest.getPartitionId(),
              modifyCollectionRequest.getCollectionUniqueId(),
              modifyCollectionRequest.getCollectionName(),
              modifyCollectionRequest.getParentCollectionUniqueId(),
              createPermissionListFromProtoBufEnumList(
                  modifyCollectionRequest.getPermissionsList()),
              createNewMap(modifyCollectionRequest.getAttributesList()));
      CatalogGPBUtils.generateCatalogCollectionResponseProtoBuf(
              com.c9a.buffers.CatalogServiceResponseProtocalBuffer.ResponseCode.SUCCESS,
              "",
              catalogCollection)
          .build()
          .writeTo(response.getOutputStream());
      return;
    } catch (CollectionNotFoundException e) {
      CatalogGPBUtils.generateResponseProtoBuf(
              com.c9a.buffers.CatalogServiceResponseProtocalBuffer.ResponseCode
                  .COLLECTION_NOT_FOUND,
              "The collection can not be found with unique id : "
                  + modifyCollectionRequest.getCollectionUniqueId())
          .build()
          .writeTo(response.getOutputStream());
      return;
    } catch (CollectionModificationException e) {
      CatalogGPBUtils.generateResponseProtoBuf(
              com.c9a.buffers.CatalogServiceResponseProtocalBuffer.ResponseCode
                  .COLLECTION_CAN_NOT_BE_MODIFIED,
              "You do not have the needed permissions to modify this collection.")
          .build()
          .writeTo(response.getOutputStream());
      return;
    } catch (InvalidCatalogNameException e) {
      CatalogGPBUtils.generateResponseProtoBuf(
              com.c9a.buffers.CatalogServiceResponseProtocalBuffer.ResponseCode
                  .CATALOG_NAME_INVALID,
              "You can not store the name \""
                  + modifyCollectionRequest.getCollectionName()
                  + "\" in the catalog.")
          .build()
          .writeTo(response.getOutputStream());
      return;
    }
  }