public BlobKey getBlobKey(AppEngineFile file) {
    if (null == file) {
      throw new NullPointerException("file is null");
    }
    if (file.getFileSystem() != AppEngineFile.FileSystem.BLOBSTORE) {
      throw new IllegalArgumentException("file is not of type BLOBSTORE");
    }

    BlobKey cached = getCachedBlobKey(file);
    if (null != cached) {
      return cached;
    }

    String creationHandle = getCreationHandle(file);
    if (creationHandle == null) {
      return new BlobKey(file.getNamePart());
    }

    Entity blobInfoEntity = getBlobInfoEntity(creationHandle);
    if (blobInfoEntity == null) {
      return null;
    }

    BlobInfo blobInfo = new BlobInfoFactory().createBlobInfo(blobInfoEntity);
    return blobInfo.getBlobKey();
  }