@Test public void whenBuildMergedPackageRootOnMissingBlob_Should_DeleteAsset_And_GetBlobInputStream() throws IOException { when(proxyResponse.getPayload()).thenReturn(toContent(createSimplePackageRoot("1.0"))); when(hostedResponse.getPayload()).thenReturn(toContent(createSimplePackageRoot("2.0"))); Map<Repository, Response> responses = ImmutableMap .of(proxyRepository, proxyResponse, hostedRepository, hostedResponse); underTest.buildMergedPackageRootOnMissingBlob(responses, context, missingAssetBlobException); verify(storageTx).deleteAsset(eq(asset), eq(false)); verify(blob).getInputStream(); }
protected InputStream buildMergedPackageRootOnMissingBlob(final Map<Repository, Response> responses, final Context context, final MissingAssetBlobException e) throws IOException { if (log.isTraceEnabled()) { log.info("Missing blob {} containing cached metadata {}, deleting asset and triggering rebuild.", e.getBlobRef(), e.getAsset(), e); } else { log.info("Missing blob {} containing cached metadata {}, deleting asset and triggering rebuild.", e.getBlobRef(), e.getAsset().name()); } cleanupPackageRootAssetOnlyFromCache(e.getAsset()); Content content = buildMergedPackageRoot(responses, context); return nonNull(content) ? content.openInputStream() : errorInputStream("Unable to retrieve merged package root on recovery for missing blob"); }
OrientNpmGroupDataFacet extends FacetSupport { protected InputStream buildMergedPackageRootOnMissingBlob(final Map<Repository, Response> responses, final Context context, final MissingAssetBlobException e) throws IOException { if (log.isTraceEnabled()) { log.info("Missing blob {} containing cached metadata {}, deleting asset and triggering rebuild.", e.getBlobRef(), e.getAsset(), e); } else { log.info("Missing blob {} containing cached metadata {}, deleting asset and triggering rebuild.", e.getBlobRef(), e.getAsset().name()); } cleanupPackageRootAssetOnlyFromCache(e.getAsset()); Content content = buildMergedPackageRoot(responses, context); return nonNull(content) ? content.openInputStream() : errorInputStream("Unable to retrieve merged package root on recovery for missing blob"); } }
OrientNpmGroupDataFacet extends FacetSupport { protected InputStream buildMergedPackageRootOnMissingBlob(final Map<Repository, Response> responses, final Context context, final MissingAssetBlobException e) throws IOException { if (log.isTraceEnabled()) { log.info("Missing blob {} containing cached metadata {}, deleting asset and triggering rebuild.", e.getBlobRef(), e.getAsset(), e); } else { log.info("Missing blob {} containing cached metadata {}, deleting asset and triggering rebuild.", e.getBlobRef(), e.getAsset().name()); } cleanupPackageRootAssetOnlyFromCache(e.getAsset()); Content content = buildMergedPackageRoot(responses, context); return nonNull(content) ? content.openInputStream() : errorInputStream("Unable to retrieve merged package root on recovery for missing blob"); } @Inject  OrientNpmGroupDataFacet(
      @Named("${nexus.npm.mergeGroupMetadata:-true}") final boolean mergeMetadata); }
OrientNpmGroupDataFacet extends FacetSupport { protected InputStream buildMergedPackageRootOnMissingBlob(final Map<Repository, Response> responses, final Context context, final MissingAssetBlobException e) throws IOException { if (log.isTraceEnabled()) { log.info("Missing blob {} containing cached metadata {}, deleting asset and triggering rebuild.", e.getBlobRef(), e.getAsset(), e); } else { log.info("Missing blob {} containing cached metadata {}, deleting asset and triggering rebuild.", e.getBlobRef(), e.getAsset().name()); } cleanupPackageRootAssetOnlyFromCache(e.getAsset()); Content content = buildMergedPackageRoot(responses, context); return nonNull(content) ? content.openInputStream() : errorInputStream("Unable to retrieve merged package root on recovery for missing blob"); } @Inject  OrientNpmGroupDataFacet(
      @Named("${nexus.npm.mergeGroupMetadata:-true}") final boolean mergeMetadata); @Nullable Content buildPackageRoot(final Map<Repository, Response> responses, final Context context); @Nullable NpmContent getFromCache(final Map<Repository, Response> responses, final Context context); @Nullable NpmContent getFromCache(final Context context); @Subscribe @Guarded(by = STARTED) @AllowConcurrentEvents void on(final AssetDeletedEvent deleted); @Subscribe @Guarded(by = STARTED) @AllowConcurrentEvents void on(final AssetUpdatedEvent updated); Iterable<Repository> members(); }
OrientNpmGroupDataFacet extends FacetSupport { protected InputStream buildMergedPackageRootOnMissingBlob(final Map<Repository, Response> responses, final Context context, final MissingAssetBlobException e) throws IOException { if (log.isTraceEnabled()) { log.info("Missing blob {} containing cached metadata {}, deleting asset and triggering rebuild.", e.getBlobRef(), e.getAsset(), e); } else { log.info("Missing blob {} containing cached metadata {}, deleting asset and triggering rebuild.", e.getBlobRef(), e.getAsset().name()); } cleanupPackageRootAssetOnlyFromCache(e.getAsset()); Content content = buildMergedPackageRoot(responses, context); return nonNull(content) ? content.openInputStream() : errorInputStream("Unable to retrieve merged package root on recovery for missing blob"); } @Inject  OrientNpmGroupDataFacet(
      @Named("${nexus.npm.mergeGroupMetadata:-true}") final boolean mergeMetadata); @Nullable Content buildPackageRoot(final Map<Repository, Response> responses, final Context context); @Nullable NpmContent getFromCache(final Map<Repository, Response> responses, final Context context); @Nullable NpmContent getFromCache(final Context context); @Subscribe @Guarded(by = STARTED) @AllowConcurrentEvents void on(final AssetDeletedEvent deleted); @Subscribe @Guarded(by = STARTED) @AllowConcurrentEvents void on(final AssetUpdatedEvent updated); Iterable<Repository> members();  }