/* (non-Javadoc)
   * @see org.sagebionetworks.repo.web.service.S3TokenService#createEntityS3Token(java.lang.String, java.lang.String, org.sagebionetworks.repo.model.S3Token, javax.servlet.http.HttpServletRequest)
   */
  @Override
  public S3Token createEntityS3Token(
      String userId, String id, S3Token s3Token, HttpServletRequest request)
      throws DatastoreException, NotFoundException, UnauthorizedException, InvalidModelException {

    // Infer one more parameter
    UserInfo userInfo = userManager.getUserInfo(userId);
    EntityType entityType = entityManager.getEntityType(userInfo, id);
    return s3TokenManager.createS3Token(userId, id, s3Token, entityType);
  }
  /**
   * Create a security token for use for a particular with a particular locationable entity to be
   * stored in AWS S3
   *
   * @param userId
   * @param id
   * @param etag
   * @param s3Token
   * @param request
   * @return a filled-in S3Token
   * @throws NotFoundException
   * @throws DatastoreException
   * @throws UnauthorizedException
   * @throws InvalidModelException
   */
  @Transactional(readOnly = false)
  @ResponseStatus(HttpStatus.CREATED)
  @RequestMapping(
      value = {UrlHelpers.ENTITY_S3TOKEN},
      method = RequestMethod.POST)
  public @ResponseBody S3Token createEntityS3Token(
      @RequestParam(value = AuthorizationConstants.USER_ID_PARAM, required = false) String userId,
      @PathVariable String id,
      @RequestBody S3Token s3Token,
      HttpServletRequest request)
      throws DatastoreException, NotFoundException, UnauthorizedException, InvalidModelException {

    // Infer one more parameter
    UserInfo userInfo = userManager.getUserInfo(userId);
    EntityType entityType = entityManager.getEntityType(userInfo, id);
    return s3TokenManager.createS3Token(userId, id, s3Token, entityType);
  }