org.apache.jackrabbit.oak.spi.blob.BlobStore.getBlobId()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中org.apache.jackrabbit.oak.spi.blob.BlobStore.getBlobId()方法的一些代码示例,展示了BlobStore.getBlobId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BlobStore.getBlobId()方法的具体详情如下:
包路径:org.apache.jackrabbit.oak.spi.blob.BlobStore
类名称:BlobStore
方法名:getBlobId

BlobStore.getBlobId介绍

[英]Returns the blobId that referred by the given binary reference. Returns null if the reference is invalid, for example if it points to a blob that does not exist.
[中]返回给定二进制引用引用的blobId。如果引用无效(例如,如果它指向不存在的blob),则返回null。

代码示例

代码示例来源:origin: apache/jackrabbit-oak

@Override
public String getBlobId(String reference) {
  if (reference.startsWith(NEW_BLOBSTORE_PREFIX)) {
    return newBlobStore.getBlobId(reference.substring(NEW_BLOBSTORE_PREFIX.length()));
  } else if (reference.startsWith(OLD_BLOBSTORE_PREFIX)) {
    return oldBlobStore.getBlobId(reference.substring(OLD_BLOBSTORE_PREFIX.length()));
  } else {
    log.error("Invalid reference: {}", reference);
    return null;
  }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

@Override
public String getBlobId(String reference) {
  if (reference.startsWith(NEW_BLOBSTORE_PREFIX)) {
    return newBlobStore.getBlobId(reference.substring(NEW_BLOBSTORE_PREFIX.length()));
  } else if (reference.startsWith(OLD_BLOBSTORE_PREFIX)) {
    return oldBlobStore.getBlobId(reference.substring(OLD_BLOBSTORE_PREFIX.length()));
  } else {
    log.error("Invalid reference: {}", reference);
    return null;
  }
}

代码示例来源:origin: org.apache.jackrabbit/oak-blob

@Override
public String getBlobId(String reference) {
  if (reference.startsWith(NEW_BLOBSTORE_PREFIX)) {
    return newBlobStore.getBlobId(reference.substring(NEW_BLOBSTORE_PREFIX.length()));
  } else if (reference.startsWith(OLD_BLOBSTORE_PREFIX)) {
    return oldBlobStore.getBlobId(reference.substring(OLD_BLOBSTORE_PREFIX.length()));
  } else {
    log.error("Invalid reference: {}", reference);
    return null;
  }
}

代码示例来源:origin: org.apache.jackrabbit/oak-store-document

/**
 * Returns the {@link Blob} with the given reference. Note that this method is meant to
 * be used with secure reference obtained from Blob#reference which is different from blobId
 *
 * @param reference the reference of the blob.
 * @return the blob.
 */
@Override
public Blob getBlob(@NotNull String reference) {
  String blobId = blobStore.getBlobId(reference);
  if(blobId != null){
    return new BlobStoreBlob(blobStore, blobId);
  }
  LOG.debug("No blobId found matching reference [{}]", reference);
  return null;
}

代码示例来源:origin: apache/jackrabbit-oak

@Override
public Blob getBlob(@NotNull String reference) {
  //Use of 'reference' here is bit overloaded. In terms of NodeStore API
  //a blob reference refers to the secure reference obtained from Blob#getReference()
  //However in SegmentStore terminology a blob is referred via 'external reference'
  //That 'external reference' would map to blobId obtained from BlobStore#getBlobId
  if (blobStore != null) {
    String blobId = blobStore.getBlobId(reference);
    if (blobId != null) {
      return new BlobStoreBlob(blobStore, blobId);
    }
    return null;
  }
  throw new IllegalStateException("Attempt to read external blob with blobId [" + reference + "] " +
      "without specifying BlobStore");
}

代码示例来源:origin: apache/jackrabbit-oak

/**
 * Returns the {@link Blob} with the given reference. Note that this method is meant to
 * be used with secure reference obtained from Blob#reference which is different from blobId
 *
 * @param reference the reference of the blob.
 * @return the blob.
 */
@Override
public Blob getBlob(@NotNull String reference) {
  String blobId = blobStore.getBlobId(reference);
  if(blobId != null){
    return new BlobStoreBlob(blobStore, blobId);
  }
  LOG.debug("No blobId found matching reference [{}]", reference);
  return null;
}

代码示例来源:origin: apache/jackrabbit-oak

@SuppressWarnings("ConstantConditions")
@Test(expected = NullPointerException.class)
public void getBlobIdShouldThrowAnExceptionWhenNullIsPassed() {
  given:
  {
    final BlobStore blobStore = new LoopbackBlobStore();
    when:
    {
      blobStore.getBlobId(null);
    }
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Override
  public String serialize(Blob blob) {
    if (blob instanceof BlobStoreBlob) {
      BlobStoreBlob bsb = (BlobStoreBlob) blob;
      BlobStore bsbBlobStore = bsb.getBlobStore();
      //see if the blob has been created from another store
      if (bsbBlobStore != null && bsbBlobStore.equals(blobStore)) {
        return bsb.getBlobId();
      }
    }
    String id;
    String reference = blob.getReference();
    if(reference != null){
      id = blobStore.getBlobId(reference);
      if(id != null){
        return id;
      }
    }
    try {
      id = createBlob(blob.getNewStream()).getBlobId();
    } catch (IOException e) {
      throw new IllegalStateException(e);
    }
    return id;
  }
};

代码示例来源:origin: org.apache.jackrabbit/oak-store-document

@Override
  public String serialize(Blob blob) {
    if (blob instanceof BlobStoreBlob) {
      BlobStoreBlob bsb = (BlobStoreBlob) blob;
      BlobStore bsbBlobStore = bsb.getBlobStore();
      //see if the blob has been created from another store
      if (bsbBlobStore != null && bsbBlobStore.equals(blobStore)) {
        return bsb.getBlobId();
      }
    }
    String id;
    String reference = blob.getReference();
    if(reference != null){
      id = blobStore.getBlobId(reference);
      if(id != null){
        return id;
      }
    }
    try {
      id = createBlob(blob.getNewStream()).getBlobId();
    } catch (IOException e) {
      throw new IllegalStateException(e);
    }
    return id;
  }
};

代码示例来源:origin: apache/jackrabbit-oak

@Test
@Parameters(method = "blobIds")
public void getBlobIdShouldReturnTheSameValuePassedExceptOfNull(
    final String blobId) {
  given:
  {
    final BlobStore blobStore = new LoopbackBlobStore();
    expect:
    {
      assertEquals(blobId, blobStore.getBlobId(blobId));
    }
  }
}

代码示例来源:origin: apache/jackrabbit-oak

private RecordId writeBlob(@NotNull Blob blob) throws IOException {
  if (sameStore(blob)) {
    SegmentBlob segmentBlob = (SegmentBlob) blob;
    if (!isOldGeneration(segmentBlob.getRecordId())) {
      return segmentBlob.getRecordId();
    }
    if (segmentBlob.isExternal()) {
      return writeBlobId(segmentBlob.getBlobId());
    }
  }
  String reference = blob.getReference();
  if (reference != null && blobStore != null) {
    String blobId = blobStore.getBlobId(reference);
    if (blobId != null) {
      return writeBlobId(blobId);
    } else {
      LOG.debug("No blob found for reference {}, inlining...", reference);
    }
  }
  return writeStream(blob.getNewStream());
}

相关文章