org.sonatype.nexus.repository.storage.AssetBlob Java Examples

The following examples show how to use org.sonatype.nexus.repository.storage.AssetBlob. 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: NpmRestoreBlobStrategy.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@TransactionalStoreMetadata
@Override
protected void createAssetFromBlob(@Nonnull final AssetBlob assetBlob, @Nonnull final NpmRestoreBlobData data)
    throws IOException
{
  NpmFacet facet = data.getBlobData().getRepository().facet(NpmFacet.class);

  switch (data.getType()) {
    case REPOSITORY_ROOT:
      facet.putRepositoryRoot(assetBlob, null);
      break;
    case TARBALL:
      facet.putTarball(data.getPackageId(), data.getTarballName(), assetBlob, null);
      break;
    case PACKAGE_ROOT:
      facet.putPackageRoot(data.getPackageId(), assetBlob, null);
      break;
    default: // all the cases are covered
      throw new IllegalStateException("Unexpected case encountered");
  }
}
 
Example #2
Source File: OrientNpmHostedFacet.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@TransactionalStoreBlob
protected Asset putPackage(final NpmPackageId packageId,
                           final NestedAttributesMap requestPackageRoot,
                           final TempBlob tarballTempBlob)
    throws IOException
{
  checkNotNull(packageId);
  checkNotNull(requestPackageRoot);
  checkNotNull(tarballTempBlob);

  log.debug("Storing package: {}", packageId);

  StorageTx tx = UnitOfWork.currentTx();

  String tarballName = NpmMetadataUtils.extractTarballName(requestPackageRoot);
  AssetBlob assetBlob = NpmFacetUtils.createTarballAssetBlob(tx, packageId, tarballName, tarballTempBlob);

  NpmFacet npmFacet = facet(NpmFacet.class);
  Asset asset = npmFacet.putTarball(packageId.id(), tarballName, assetBlob, new AttributesMap());

  putPackageRoot(packageId, null, requestPackageRoot);

  return asset;
}
 
Example #3
Source File: OrientNpmHostedFacet.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
private void putTarball(final StorageTx tx,
                        final NpmPackageId packageId,
                        final NestedAttributesMap packageVersion,
                        final NestedAttributesMap attachment,
                        final NpmPublishRequest request) throws IOException
{
  String tarballName = NpmMetadataUtils.extractTarballName(attachment.getKey());
  log.debug("Storing tarball: {}@{} ({})",
      packageId,
      packageVersion.get(NpmMetadataUtils.VERSION, String.class),
      tarballName);

  TempBlob tempBlob = request.requireBlob(attachment.require("data", String.class));
  AssetBlob assetBlob = NpmFacetUtils.createTarballAssetBlob(tx, packageId, tarballName, tempBlob);

  NpmFacet npmFacet = facet(NpmFacet.class);
  npmFacet.putTarball(packageId.id(), tarballName, assetBlob, new AttributesMap());
}
 
Example #4
Source File: NpmFacetUtils.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates an {@link AssetBlob} out of passed in content and attaches it to passed in {@link Asset}.
 */
@Nonnull
static AssetBlob storeContent(final StorageTx tx,
                              final Asset asset,
                              final Supplier<InputStream> content,
                              final AssetKind assetKind) throws IOException
{
  asset.formatAttributes().set(P_ASSET_KIND, assetKind.name());

  final AssetBlob result = tx.createBlob(
      asset.name(),
      content,
      HASH_ALGORITHMS,
      null,
      assetKind.getContentType(),
      assetKind.isSkipContentVerification()
  );
  tx.attachBlob(asset, result);
  return result;
}
 
Example #5
Source File: MavenFacetImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@TransactionalStoreBlob
protected Content doPut(final MavenPath path,
                        final Payload payload,
                        final TempBlob tempBlob)
    throws IOException
{
  final StorageTx tx = UnitOfWork.currentTx();

  final AssetBlob assetBlob = tx.createBlob(
      path.getPath(),
      tempBlob,
      null,
      payload.getContentType(),
      false
  );
  AttributesMap contentAttributes = null;
  if (payload instanceof Content) {
    contentAttributes = ((Content) payload).getAttributes();
  }

  return doPutAssetBlob(path, contentAttributes, tx, assetBlob);
}
 
Example #6
Source File: AptSnapshotFacetSupport.java    From nexus-repository-apt with Eclipse Public License 1.0 6 votes vote down vote up
@Transactional(retryOn = { ONeedRetryException.class })
@Override
public void createSnapshot(String id, SnapshotComponentSelector selector) throws IOException {
  StorageTx tx = UnitOfWork.currentTx();
  StorageFacet storageFacet = facet(StorageFacet.class);
  Bucket bucket = tx.findBucket(getRepository());
  Component component = tx.createComponent(bucket, getRepository().getFormat()).name(id);
  tx.saveComponent(component);
  for (SnapshotItem item : collectSnapshotItems(selector)) {
    String assetName = createAssetPath(id, item.specifier.path);
    Asset asset = tx.createAsset(bucket, component).name(assetName);
    try (final TempBlob streamSupplier = storageFacet.createTempBlob(item.content.openInputStream(), FacetHelper.hashAlgorithms)) {
      AssetBlob blob = tx.createBlob(item.specifier.path, streamSupplier, FacetHelper.hashAlgorithms, null,
          FacetHelper.determineContentType(item), true);
      tx.attachBlob(asset, blob);
    }
    finally {
      item.content.close();
    }
    tx.saveAsset(asset);
  }
}
 
Example #7
Source File: MavenFacetImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@TransactionalStoreBlob
protected Content doPut(final MavenPath path,
                        final Path sourceFile,
                        final String contentType,
                        final AttributesMap contentAttributes,
                        final Map<HashAlgorithm, HashCode> hashes,
                        final long size)
    throws IOException
{
  final StorageTx tx = UnitOfWork.currentTx();

  final AssetBlob assetBlob = tx.createBlob(
      path.getPath(),
      sourceFile,
      hashes,
      null,
      contentType,
      size
  );

  return doPutAssetBlob(path, contentAttributes, tx, assetBlob);
}
 
Example #8
Source File: NpmFacetUtils.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates an {@link AssetBlob} out of passed in temporary blob and attaches it to passed in {@link Asset}.
 */
@Nonnull
static AssetBlob storeContent(final StorageTx tx,
                              final Asset asset,
                              final TempBlob tempBlob,
                              final AssetKind assetKind) throws IOException
{
  asset.formatAttributes().set(P_ASSET_KIND, assetKind.name());
  AssetBlob result = tx.createBlob(
      asset.name(),
      tempBlob,
      null,
      assetKind.getContentType(),
      assetKind.isSkipContentVerification()
  );
  tx.attachBlob(asset, result);
  return result;
}
 
Example #9
Source File: ConanProxyFacet.java    From nexus-repository-conan with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Save an asset and create a blob
 *
 * @return blob content
 */
private Content saveAsset(final StorageTx tx,
                          final Asset asset,
                          final Supplier<InputStream> contentSupplier,
                          final String contentType,
                          final AttributesMap contentAttributes,
                          final HashCode hash) throws IOException
{
  Content.applyToAsset(asset, maintainLastModified(asset, contentAttributes));
  AssetBlob assetBlob = tx.setBlob(
      asset, asset.name(), contentSupplier, HASH_ALGORITHMS, null, contentType, false
  );

  if (!hashVerifier.verify(hash, assetBlob.getHashes().get(MD5))) {
    return null;
  }
  asset.markAsDownloaded();
  tx.saveAsset(asset);
  return toContent(asset, assetBlob.getBlob());
}
 
Example #10
Source File: RawContentFacetImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@TransactionalStoreBlob
protected Content doPutContent(final String path, final TempBlob tempBlob, final Payload payload)
    throws IOException
{
  StorageTx tx = UnitOfWork.currentTx();

  Asset asset = getOrCreateAsset(getRepository(), path, RawCoordinatesHelper.getGroup(path), path);

  AttributesMap contentAttributes = null;
  if (payload instanceof Content) {
    contentAttributes = ((Content) payload).getAttributes();
  }
  Content.applyToAsset(asset, Content.maintainLastModified(asset, contentAttributes));
  AssetBlob assetBlob = tx.setBlob(
      asset,
      path,
      tempBlob,
      null,
      payload.getContentType(),
      false
  );

  tx.saveAsset(asset);

  return toContent(asset, assetBlob.getBlob());
}
 
Example #11
Source File: RFacetUtils.java    From nexus-repository-r with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Save an asset && create blob.
 *
 * @return blob content
 */
public static Content saveAsset(final StorageTx tx,
                                final Asset asset,
                                final Supplier<InputStream> contentSupplier,
                                final String contentType,
                                @Nullable final AttributesMap contentAttributes) throws IOException
{
  Content.applyToAsset(asset, Content.maintainLastModified(asset, contentAttributes));
  AssetBlob assetBlob = tx.setBlob(
      asset, asset.name(), contentSupplier, HASH_ALGORITHMS, null, contentType, false
  );

  asset.markAsDownloaded();
  tx.saveAsset(asset);
  return toContent(asset, assetBlob.getBlob());
}
 
Example #12
Source File: RRestoreFacetImpl.java    From nexus-repository-r with Eclipse Public License 1.0 6 votes vote down vote up
@Override
@TransactionalTouchBlob
public void restore(final AssetBlob assetBlob, final String path) throws IOException {
  StorageTx tx = UnitOfWork.currentTx();
  RFacet facet = facet(RFacet.class);

  Asset asset;
  if (componentRequired(path)) {
    Map<String, String> attributes;

    try (InputStream is = assetBlob.getBlob().getInputStream()) {
      attributes = extractDescriptionFromArchive(path, is);
    }

    Component component = facet.findOrCreateComponent(tx, path, attributes);
    asset = facet.findOrCreateAsset(tx, component, path, attributes);
  }
  else {
    asset = facet.findOrCreateAsset(tx, path);
  }
  tx.attachBlob(asset, assetBlob);

  Content.applyToAsset(asset, Content.maintainLastModified(asset, new AttributesMap()));
  tx.saveAsset(asset);
}
 
Example #13
Source File: MavenFacetImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
private Asset putFile(final StorageTx tx,
                      final MavenPath path,
                      final AssetBlob assetBlob,
                      @Nullable final AttributesMap contentAttributes)
    throws IOException
{
  final Bucket bucket = tx.findBucket(getRepository());
  Asset asset = findAsset(tx, bucket, path);
  if (asset == null) {
    asset = tx.createAsset(bucket, getRepository().getFormat());
    asset.name(path.getPath());
    asset.formatAttributes().set(P_ASSET_KIND, fileAssetKindFor(path));
  }

  putAssetPayload(tx, asset, assetBlob, contentAttributes);

  tx.saveAsset(asset);

  return asset;
}
 
Example #14
Source File: NpmFacetImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Nullable
@Override
public Asset putRepositoryRoot(final AssetBlob assetBlob, @Nullable final AttributesMap contentAttributes)
    throws IOException
{
  final Repository repository = getRepository();
  final StorageTx tx = UnitOfWork.currentTx();
  final Bucket bucket = tx.findBucket(repository);
  Asset asset = NpmFacetUtils.findRepositoryRootAsset(tx, bucket);

  if (asset == null) {
    asset = tx.createAsset(bucket, repository.getFormat()).name(REPOSITORY_ROOT_ASSET);
    getEventManager().post(new NpmSearchIndexInvalidatedEvent(repository));
    saveAsset(tx, asset, assetBlob, REPOSITORY_ROOT, contentAttributes);
  }

  return asset;
}
 
Example #15
Source File: HelmFacetImpl.java    From nexus-repository-helm with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Save an asset and create blob.
 *
 * @return blob content
 */
@Override
public Content saveAsset(final StorageTx tx,
                         final Asset asset,
                         final Supplier<InputStream> contentSupplier,
                         @Nullable final String contentType,
                         @Nullable final AttributesMap contentAttributes) throws IOException
{
  Content.applyToAsset(asset, Content.maintainLastModified(asset, contentAttributes));
  AssetBlob assetBlob = tx.setBlob(
      asset, asset.name(), contentSupplier, HASH_ALGORITHMS, null, contentType, false
  );
  asset.markAsDownloaded();
  tx.saveAsset(asset);
  return toContent(asset, assetBlob.getBlob());
}
 
Example #16
Source File: NpmFacetImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Nullable
@Override
public Asset putPackageRoot(final String packageId,
                            final AssetBlob assetBlob,
                            @Nullable final AttributesMap contentAttributes)
    throws IOException
{
  final Repository repository = getRepository();
  final StorageTx tx = UnitOfWork.currentTx();
  final Bucket bucket = tx.findBucket(repository);
  Asset asset = NpmFacetUtils.findPackageRootAsset(tx, bucket, NpmPackageId.parse(packageId));

  if (asset == null) {
    asset = tx.createAsset(bucket, repository.getFormat()).name(packageId);
    saveAsset(tx, asset, assetBlob, PACKAGE_ROOT, contentAttributes);
  }

  return asset;
}
 
Example #17
Source File: AptRestoreFacetImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Override
@TransactionalStoreBlob
public Content restore(final AssetBlob assetBlob, final String path) throws IOException {
  StorageTx tx = UnitOfWork.currentTx();
  Asset asset;
  AptFacet aptFacet = facet(AptFacet.class);
  if (isDebPackageContentType(path)) {
    ControlFile controlFile = AptPackageParser.getDebControlFile(assetBlob.getBlob());
    asset = aptFacet.findOrCreateDebAsset(tx, path, new PackageInfo(controlFile));
  }
  else {
    asset = aptFacet.findOrCreateMetadataAsset(tx, path);
  }

  tx.attachBlob(asset, assetBlob);
  Content.applyToAsset(asset, Content.maintainLastModified(asset, new AttributesMap()));
  tx.saveAsset(asset);
  return FacetHelper.toContent(asset, assetBlob.getBlob());
}
 
Example #18
Source File: AptSnapshotFacetSupport.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Transactional(retryOn = {ONeedRetryException.class})
protected void createSnapshot(final String id, final Iterable<SnapshotItem> snapshots) throws IOException {
  StorageTx tx = UnitOfWork.currentTx();
  StorageFacet storageFacet = facet(StorageFacet.class);
  Bucket bucket = tx.findBucket(getRepository());
  for (SnapshotItem item : snapshots) {
    String assetName = createAssetPath(id, item.specifier.path);
    Asset asset = tx.createAsset(bucket, getRepository().getFormat()).name(assetName);
    try (final TempBlob streamSupplier = storageFacet
        .createTempBlob(item.content.openInputStream(), FacetHelper.hashAlgorithms)) {
      AssetBlob blob = tx.createBlob(item.specifier.path, streamSupplier, FacetHelper.hashAlgorithms, null,
          item.specifier.role.getMimeType(), true);
      tx.attachBlob(asset, blob);
    }
    finally {
      item.content.close();
    }
    tx.saveAsset(asset);
  }
}
 
Example #19
Source File: OrientPyPiGroupFacet.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@TransactionalStoreBlob
protected AssetBlob updateAsset(final StorageTx tx, final Asset asset, final Content content) throws IOException {
  AttributesMap contentAttributes = Content.maintainLastModified(asset, content.getAttributes());
  Content.applyToAsset(asset, contentAttributes);

  InputStream inputStream = content.openInputStream();
  AssetBlob blob = tx.setBlob(asset,
      asset.name(),
      () -> inputStream,
      HASH_ALGORITHMS,
      null,
      ContentTypes.TEXT_HTML,
      true);

  tx.saveAsset(asset);

  return blob;
}
 
Example #20
Source File: OrientPyPiGroupFacet.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@TransactionalStoreBlob
public Content saveToCache(final String name, final Content content) throws IOException {
  StorageTx tx = UnitOfWork.currentTx();

  Asset asset = getAsset(tx, name);
  AttributesMap contentAttributes = Content.maintainLastModified(asset, null);
  contentAttributes.set(CacheInfo.class, cacheController.current());
  Content.applyToAsset(asset, contentAttributes);

  AssetBlob blob = updateAsset(tx, asset, content);

  Content response = new Content(new BlobPayload(blob.getBlob(), ContentTypes.TEXT_HTML));
  Content.extractFromAsset(asset, HASH_ALGORITHMS, response.getAttributes());

  return response;
}
 
Example #21
Source File: OrientPyPiRestoreBlobStrategy.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@TransactionalStoreMetadata
@Override
protected void createAssetFromBlob(final AssetBlob assetBlob, final PyPiRestoreBlobData data)
    throws IOException
{
  data.getBlobData().getRepository().facet(PyPiFacet.class).put(getAssetPath(data), assetBlob);
}
 
Example #22
Source File: RawRestoreBlobStrategyTest.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testRestoreCreatesAssetFromBlobWithExpectedHashes() throws Exception {
  ArgumentCaptor<AssetBlob> assetBlobCaptor = ArgumentCaptor.forClass(AssetBlob.class);

  Map<HashAlgorithm, HashCode> expectedHashes = Stream.of(SHA1, MD5)
      .collect(toMap(identity(), algorithm -> algorithm.function().hashBytes(BLOB_BYTES)));

  underTest.restore(properties, blob, BLOB_STORE_NAME, !DRY_RUN);

  verify(rawContentFacet).put(eq(BLOB_NAME), assetBlobCaptor.capture(), eq(NO_CONTENT_ATTRIBUTES));
  assertThat(assetBlobCaptor.getValue().getHashes(), equalTo(expectedHashes));
  assertThat(assetBlobCaptor.getValue().getContentType(), equalTo(CONTENT_TYPE));
}
 
Example #23
Source File: AptFacetImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
@TransactionalStoreBlob
public Content put(final String path, final Payload content, final PackageInfo info) throws IOException {
  StorageFacet storageFacet = facet(StorageFacet.class);
  try (final TempBlob tempBlob = storageFacet.createTempBlob(content, FacetHelper.hashAlgorithms)) {
    StorageTx tx = UnitOfWork.currentTx();
    Asset asset = isDebPackageContentType(path)
        ? findOrCreateDebAsset(tx, path,
        info != null ? info : new PackageInfo(AptPackageParser.getDebControlFile(tempBlob.getBlob())))
        : findOrCreateMetadataAsset(tx, path);

    AttributesMap contentAttributes = null;
    if (content instanceof Content) {
      contentAttributes = ((Content) content).getAttributes();
    }
    Content.applyToAsset(asset, Content.maintainLastModified(asset, contentAttributes));
    AssetBlob blob = tx.setBlob(
        asset,
        path,
        tempBlob,
        FacetHelper.hashAlgorithms,
        null,
        content.getContentType(),
        false);
    tx.saveAsset(asset);
    return FacetHelper.toContent(asset, blob.getBlob());
  }
}
 
Example #24
Source File: CocoapodsFacetImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
@TransactionalStoreBlob
public Content getOrCreateAsset(final String path, final Content content, boolean toAttachComponent)
    throws IOException
{
  StorageFacet storageFacet = facet(StorageFacet.class);
  try (final TempBlob tempBlob = storageFacet.createTempBlob(content, HASH_ALGORITHMS)) {
    StorageTx tx = UnitOfWork.currentTx();
    Bucket bucket = tx.findBucket(getRepository());

    Asset asset = tx.findAssetWithProperty(P_NAME, path, bucket);
    if (asset == null) {
      if (toAttachComponent) {
        Component component = findOrCreateComponent(tx, bucket, path);
        asset = tx.createAsset(bucket, component).name(path);
      }
      else {
        asset = tx.createAsset(bucket, getRepository().getFormat()).name(path);
      }
    }
    Content.applyToAsset(asset, content.getAttributes());
    AssetBlob blob = tx.setBlob(asset, path, tempBlob, HASH_ALGORITHMS, null, null, false);
    tx.saveAsset(asset);

    final Content updatedContent = new Content(new BlobPayload(blob.getBlob(), asset.requireContentType()));
    Content.extractFromAsset(asset, HASH_ALGORITHMS, updatedContent.getAttributes());
    return updatedContent;
  }
}
 
Example #25
Source File: OrientPyPiFacetImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
@Nullable
public Asset put(final String path, final AssetBlob assetBlob) throws IOException {
  if (isRootIndexPath(path)) {
    log.info("Not repairing root index");
    return null;
  }
  else if (isIndexPath(path)) {
    return putIndex(path, assetBlob);
  }
  else {
    // PEP503 contains no restrictions to packages excluding rules for index and root index so assume rest is package
    return putPackage(path, assetBlob);
  }
}
 
Example #26
Source File: GolangDataAccess.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Save an asset and create blob.
 *
 * @return blob content
 */
private Content saveAsset(final StorageTx tx,
                          final Asset asset,
                          final Supplier<InputStream> contentSupplier,
                          final String contentType,
                          @Nullable final AttributesMap contentAttributes) throws IOException
{
  Content.applyToAsset(asset, Content.maintainLastModified(asset, contentAttributes));
  AssetBlob assetBlob = tx.setBlob(
      asset, asset.name(), contentSupplier, HASH_ALGORITHMS, null, contentType, false
  );
  tx.saveAsset(asset);
  return toContent(asset, assetBlob.getBlob());
}
 
Example #27
Source File: RawContentFacetImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
@TransactionalStoreBlob
public Asset put(final String path, final AssetBlob assetBlob, @Nullable final AttributesMap contentAttributes) {
  StorageTx tx = UnitOfWork.currentTx();
  Asset asset = getOrCreateAsset(getRepository(), path, RawCoordinatesHelper.getGroup(path), path);
  tx.attachBlob(asset, assetBlob);
  Content.applyToAsset(asset, Content.maintainLastModified(asset, contentAttributes));
  tx.saveAsset(asset);
  return asset;
}
 
Example #28
Source File: OrientPyPiDataUtils.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Save an asset and create a blob with the specified content attributes.
 *
 * @return blob content
 */
static Content saveAsset(
    final StorageTx tx,
    final Asset asset,
    final TempBlob tempBlob,
    @Nullable final String contentType,
    @Nullable final AttributesMap contentAttributes) throws IOException
{
  Content.applyToAsset(asset, Content.maintainLastModified(asset, contentAttributes));
  AssetBlob assetBlob = tx.setBlob(asset, asset.name(), tempBlob, null, contentType, false);

  tx.saveAsset(asset);
  return toContent(asset, assetBlob.getBlob());
}
 
Example #29
Source File: OrientPyPiFacetImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Asset putIndex(final String path, final AssetBlob assetBlob) {
  final StorageTx tx = UnitOfWork.currentTx();
  final Bucket bucket = tx.findBucket(getRepository());

  Asset asset = findAsset(tx, bucket, path);

  if (asset == null) {
    asset = tx.createAsset(bucket, getRepository().getFormat());
    asset.name(path);
    saveAsset(tx, asset, assetBlob, AssetKind.INDEX);
  }

  return asset;
}
 
Example #30
Source File: MavenRestoreBlobStrategy.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
@TransactionalStoreMetadata
protected void createAssetFromBlob(@Nonnull final AssetBlob assetBlob, @Nonnull final MavenRestoreBlobData data)
    throws IOException
{
  data.getBlobData().getRepository().facet(MavenFacet.class).put(data.getMavenPath(), assetBlob, null);
}