Java Code Examples for org.sonatype.nexus.blobstore.api.BlobAttributes#getDeletedReason()

The following examples show how to use org.sonatype.nexus.blobstore.api.BlobAttributes#getDeletedReason() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: S3BlobAttributes.java    From nexus-blobstore-s3 with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void updateFrom(final BlobAttributes blobAttributes) {
  headers = blobAttributes.getHeaders();
  metrics = blobAttributes.getMetrics();
  deleted = blobAttributes.isDeleted();
  deletedReason = blobAttributes.getDeletedReason();
}
 
Example 2
Source File: BlobStoreSupport.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
@Guarded(by = STARTED)
public boolean undelete(@Nullable final BlobStoreUsageChecker inUseChecker, final BlobId blobId,
                        final BlobAttributes attributes,
                        final boolean isDryRun)
{
  checkNotNull(attributes);
  String logPrefix = isDryRun ? dryRunPrefix.get() : "";
  Optional<String> blobName = Optional.of(attributes)
      .map(BlobAttributes::getProperties)
      .map(p -> p.getProperty(HEADER_PREFIX + BLOB_NAME_HEADER));
  if (!blobName.isPresent()) {
    log.error("Property not present: {}, for blob id: {}, at path: {}", HEADER_PREFIX + BLOB_NAME_HEADER,
        blobId, attributePathString(blobId)); // NOSONAR
    return false;
  }
  if (attributes.isDeleted() && inUseChecker != null && inUseChecker.test(this, blobId, blobName.get())) {
    String deletedReason = attributes.getDeletedReason();
    if (!isDryRun) {
      attributes.setDeleted(false);
      attributes.setDeletedReason(null);
      try {
        doUndelete(blobId, attributes);
        attributes.store();
      }
      catch (IOException e) {
        log.error("Error while un-deleting blob id: {}, deleted reason: {}, blob store: {}, blob name: {}",
            blobId, deletedReason, blobStoreConfiguration.getName(), blobName.get(), e);
      }
    }
    log.warn(
        "{}Soft-deleted blob still in use, un-deleting blob id: {}, deleted reason: {}, blob store: {}, blob name: {}",
        logPrefix, blobId, deletedReason, blobStoreConfiguration.getName(), blobName.get());
    return true;
  }
  return false;
}
 
Example 3
Source File: BlobAttributesSupport.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void updateFrom(final BlobAttributes blobAttributes) {
  headers = blobAttributes.getHeaders();
  metrics = blobAttributes.getMetrics();
  deleted = blobAttributes.isDeleted();
  deletedReason = blobAttributes.getDeletedReason();
  deletedDateTime = blobAttributes.getDeletedDateTime();
}