Esempio n. 1
0
        {
          put(
              ROOT_APPLICATION_COLLECTION_FOR_USER_REQUEST,
              new RequestResponse(
                  com.c9a.buffers.CatalogServiceRequestProtocalBuffer
                      .GetRootApplicationCollectionForUserRequest.newBuilder(),
                  com.c9a.buffers.CatalogServiceResponseProtocalBuffer.CatalogCollectionResponse
                      .newBuilder()));

          put(
              ROOT_PARTITION_COLLECTION_REQUEST,
              new RequestResponse(
                  com.c9a.buffers.CatalogServiceRequestProtocalBuffer
                      .GetRootPartitionCollectionRequest.newBuilder(),
                  com.c9a.buffers.CatalogServiceResponseProtocalBuffer.CatalogCollectionResponse
                      .newBuilder()));

          put(
              ROOT_USER_COLLECTION_REQUEST,
              new RequestResponse(
                  com.c9a.buffers.CatalogServiceRequestProtocalBuffer.GetUserRootCollectionRequest
                      .newBuilder(),
                  com.c9a.buffers.CatalogServiceResponseProtocalBuffer.CatalogCollectionResponse
                      .newBuilder()));

          put(
              GET_COLLECTION_REQUEST,
              new RequestResponse(
                  com.c9a.buffers.CatalogServiceRequestProtocalBuffer.GetCollectionRequest
                      .newBuilder(),
                  com.c9a.buffers.CatalogServiceResponseProtocalBuffer.CatalogCollectionResponse
                      .newBuilder()));

          put(
              ADD_COLLECTION_REQUEST,
              new RequestResponse(
                  com.c9a.buffers.CatalogServiceRequestProtocalBuffer.AddCollectionRequest
                      .newBuilder(),
                  com.c9a.buffers.CatalogServiceResponseProtocalBuffer.CatalogCollectionResponse
                      .newBuilder()));

          put(
              SHARE_COLLECTION_REQUEST,
              new RequestResponse(
                  com.c9a.buffers.CatalogServiceRequestProtocalBuffer.ShareCollectionRequest
                      .newBuilder(),
                  com.c9a.buffers.CatalogServiceResponseProtocalBuffer.Response.newBuilder()));

          put(
              SHARE_REFERENCE_REQUEST,
              new RequestResponse(
                  com.c9a.buffers.CatalogServiceRequestProtocalBuffer.ShareReferenceRequest
                      .newBuilder(),
                  com.c9a.buffers.CatalogServiceResponseProtocalBuffer.Response.newBuilder()));

          put(
              DELETE_COLLECTION_REQUEST,
              new RequestResponse(
                  com.c9a.buffers.CatalogServiceRequestProtocalBuffer.DeleteCatalogCollectionRequest
                      .newBuilder(),
                  com.c9a.buffers.CatalogServiceResponseProtocalBuffer.Response.newBuilder()));

          put(
              GET_REFERENCE_REQUEST,
              new RequestResponse(
                  com.c9a.buffers.CatalogServiceRequestProtocalBuffer.GetReferenceRequest
                      .newBuilder(),
                  com.c9a.buffers.CatalogServiceResponseProtocalBuffer.ReferenceResponse
                      .newBuilder()));

          put(
              ADD_DOCUMENT_REQUEST,
              new RequestResponse(
                  com.c9a.buffers.CatalogServiceRequestProtocalBuffer.AddDocumentRequest
                      .newBuilder(),
                  com.c9a.buffers.CatalogServiceResponseProtocalBuffer.ReferenceResponse
                      .newBuilder()));

          put(
              DELETE_REFERENCE_REQUEST,
              new RequestResponse(
                  com.c9a.buffers.CatalogServiceRequestProtocalBuffer.DeleteReferenceRequest
                      .newBuilder(),
                  com.c9a.buffers.CatalogServiceResponseProtocalBuffer.Response.newBuilder()));

          put(
              MODIFY_COLLECTION_REQUEST,
              new RequestResponse(
                  com.c9a.buffers.CatalogServiceRequestProtocalBuffer.ModifyCatalogCollectionRequest
                      .newBuilder(),
                  com.c9a.buffers.CatalogServiceResponseProtocalBuffer.CatalogCollectionResponse
                      .newBuilder()));

          put(
              MODIFY_REFERENCE_REQUEST,
              new RequestResponse(
                  com.c9a.buffers.CatalogServiceRequestProtocalBuffer.ModifyReferenceRequest
                      .newBuilder(),
                  com.c9a.buffers.CatalogServiceResponseProtocalBuffer.ReferenceResponse
                      .newBuilder()));
        }
Esempio n. 2
0
  @RequestMapping(
      value = SHARE_COLLECTION_REQUEST,
      method = {RequestMethod.POST})
  public void shareCollection(
      HttpServletRequest request,
      HttpServletResponse response,
      @RequestParam(value = "api", required = false) boolean api)
      throws IOException {

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

    com.c9a.buffers.CatalogServiceRequestProtocalBuffer.ShareCollectionRequest
        shareCollectionForUserRequest =
            com.c9a.buffers.CatalogServiceRequestProtocalBuffer.ShareCollectionRequest.parseFrom(
                GoogleProtoclBufferRequestContentUtils.getContentForRequest(request));

    try {
      Map<String, String> userAndPartitionsToShareWith =
          createNewMap(shareCollectionForUserRequest.getUsersAndPartitionsToShareWithList());
      Set<Long> sharePermissionIds =
          createPermissionListFromProtoBufEnumList(
              shareCollectionForUserRequest.getPermissionsList());
      catalogService.shareCollection(
          shareCollectionForUserRequest.getUserId(),
          shareCollectionForUserRequest.getPartitionId(),
          shareCollectionForUserRequest.getApplicationName(),
          shareCollectionForUserRequest.getCollectionUniqueId(),
          userAndPartitionsToShareWith,
          sharePermissionIds);
      CatalogGPBUtils.generateResponseProtoBuf(
              com.c9a.buffers.CatalogServiceResponseProtocalBuffer.ResponseCode.SUCCESS, "")
          .build()
          .writeTo(response.getOutputStream());
      return;
    } catch (CollectionNotFoundException e) {
      CatalogGPBUtils.generateResponseProtoBuf(
              com.c9a.buffers.CatalogServiceResponseProtocalBuffer.ResponseCode
                  .COLLECTION_NOT_FOUND,
              "The collection was not found with the give unique id : "
                  + shareCollectionForUserRequest.getCollectionUniqueId())
          .build()
          .writeTo(response.getOutputStream());
      return;
    } catch (CollectionSharingException e) {
      CatalogGPBUtils.generateResponseProtoBuf(
              com.c9a.buffers.CatalogServiceResponseProtocalBuffer.ResponseCode
                  .COLLECTION_CAN_NOT_BE_SHARED,
              "The collection does not have the needed permissions to be shared.")
          .build()
          .writeTo(response.getOutputStream());
      return;
    } catch (InvalidCatalogNameException e) {
      CatalogGPBUtils.generateResponseProtoBuf(
              com.c9a.buffers.CatalogServiceResponseProtocalBuffer.ResponseCode
                  .CATALOG_NAME_INVALID,
              "Invalid catalog name.")
          .build()
          .writeTo(response.getOutputStream());
      return;
    }
  }