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

The following examples show how to use org.sonatype.nexus.repository.storage.StorageTx. 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: ComposerContentFacetImpl.java    From nexus-repository-composer with Eclipse Public License 1.0 6 votes vote down vote up
@Nullable
@Override
@TransactionalTouchBlob
public Content get(final String path) throws IOException {
  StorageTx tx = UnitOfWork.currentTx();

  final Asset asset = findAsset(tx, path);
  if (asset == null) {
    return null;
  }
  if (asset.markAsDownloaded()) {
    tx.saveAsset(asset);
  }

  final Blob blob = tx.requireBlob(asset.requireBlobRef());
  return toContent(asset, blob);
}
 
Example #2
Source File: CocoapodsProxyFacet.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@TransactionalTouchMetadata
public void setCacheInfo(final Content content, final CacheInfo cacheInfo) throws IOException {
  StorageTx tx = UnitOfWork.currentTx();

  Asset asset = Content.findAsset(tx, tx.findBucket(getRepository()), content);
  if (asset == null) {
    log.debug(
        "Attempting to set cache info for non-existent Cocoapods asset {}",
        content.getAttributes().require(Asset.class)
    );
    return;
  }

  log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo);
  CacheInfo.applyToAsset(asset, cacheInfo);
  tx.saveAsset(asset);
}
 
Example #3
Source File: P2FacetImpl.java    From nexus-repository-p2 with Eclipse Public License 1.0 6 votes vote down vote up
@TransactionalStoreBlob
@Override
public Content doCreateOrSaveComponent(final P2Attributes p2Attributes,
                                       final TempBlob componentContent,
                                       final Payload payload,
                                       final AssetKind assetKind) throws IOException
{
  StorageTx tx = UnitOfWork.currentTx();
  Bucket bucket = tx.findBucket(getRepository());

  Component component = findOrCreateComponent(tx, p2Attributes);

  Asset asset = findAsset(tx, bucket, p2Attributes.getPath());
  if (asset == null) {
    asset = tx.createAsset(bucket, component);
    asset.name(p2Attributes.getPath());
    //add human readable plugin or feature name in asset attributes
    asset.formatAttributes().set(PLUGIN_NAME,  p2Attributes.getPluginName());
    asset.formatAttributes().set(P_ASSET_KIND, assetKind.name());
  }
  return saveAsset(tx, asset, componentContent, payload);
}
 
Example #4
Source File: P2FacetImpl.java    From nexus-repository-p2 with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Component findOrCreateComponent(final StorageTx tx, final P2Attributes attributes) {
  String name = attributes.getComponentName();
  String version = attributes.getComponentVersion();

  Component component = findComponent(tx, getRepository(), name, version);
  if (component == null) {
    Bucket bucket = tx.findBucket(getRepository());
    component = tx.createComponent(bucket, getRepository().getFormat())
        .name(name)
        .version(version);
    if (attributes.getPluginName() != null) {
      component.formatAttributes().set(PLUGIN_NAME, attributes.getPluginName());
    }

    tx.saveComponent(component);
  }

  return component;
}
 
Example #5
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 #6
Source File: OrientNpmHostedFacet.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@TransactionalTouchBlob
protected void upgradeRevisionOnPackageRoot(final Asset packageRootAsset, final String revision) {
  StorageTx tx = UnitOfWork.currentTx();

  NpmPackageId packageId = NpmPackageId.parse(packageRootAsset.name());
  Asset asset = findPackageRootAsset(tx, tx.findBucket(getRepository()), packageId);

  if (asset == null) {
    log.error("Failed to update revision on package root. Asset for id '{}' didn't exist", packageId.id());
    return;
  }

  // if there is a transaction failure and we fail to upgrade the package root with _rev
  // then the user who fetched the package root will not be able to run a delete command
  try {
    NestedAttributesMap packageRoot = NpmFacetUtils.loadPackageRoot(tx, asset);
    packageRoot.set(META_REV, revision);
    savePackageRoot(UnitOfWork.currentTx(), packageRootAsset, packageRoot);
  }
  catch (IOException e) {
    log.warn("Failed to update revision in package root. Revision '{}' was not set" +
            " and might cause delete for that revision to fail for Asset {}",
        revision, packageRootAsset, e);
  }
}
 
Example #7
Source File: OrientPyPiDataUtils.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Find a component by its name and tag (version)
 *
 * @return found component of null if not found
 */
@Nullable
static Component findComponent(
    final StorageTx tx,
    final Repository repository,
    final String name,
    final String version)
{
  Iterable<Component> components = tx.findComponents(
      Query.builder()
          .where(P_NAME).eq(name)
          .and(P_VERSION).eq(version)
          .build(),
      singletonList(repository)
  );
  if (components.iterator().hasNext()) {
    return components.iterator().next();
  }
  return null;
}
 
Example #8
Source File: NpmFacetUtils.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Find a tarball component by package name and version in repository.
 */
@Nullable
static Component findPackageTarballComponent(final StorageTx tx,
                                             final Repository repository,
                                             final NpmPackageId packageId,
                                             final String version)
{
  Iterable<Component> components = tx.findComponents(
      query(packageId)
          .and(P_VERSION).eq(version)
          .build(),
      singletonList(repository)
  );
  if (components.iterator().hasNext()) {
    return components.iterator().next();
  }
  return null;
}
 
Example #9
Source File: OrientPyPiIndexFacetImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@TransactionalDeleteBlob
public void deleteIndex(final String packageName)
{
  StorageTx tx = UnitOfWork.currentTx();
  Bucket bucket = tx.findBucket(getRepository());

  String indexPath = PyPiPathUtils.indexPath(normalizeName(packageName));
  Asset cachedIndex = findAsset(tx, bucket, indexPath);
  
  /*
    There is a chance that the index wasn't found because of package name normalization. For example '.' 
    characters are normalized to '-' so jts.python would have an index at /simple/jts-python/. It is possible that 
    we could just check for the normalized name but we check for both just in case. Searching for an index with a
    normalized name first means that most, if not all, index deletions will only perform a single search.
    
    See https://issues.sonatype.org/browse/NEXUS-19303 for additional context. 
   */
  if (cachedIndex == null) {
    indexPath = PyPiPathUtils.indexPath(packageName);
    cachedIndex = findAsset(tx, bucket, indexPath);
  }
  
  if (cachedIndex != null) {
    tx.deleteAsset(cachedIndex);
  }
}
 
Example #10
Source File: RFacetUtils.java    From nexus-repository-r with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Find a component by its name, tag (version) and group
 *
 * @return found component of null if not found
 */
@Nullable
public static Component findComponent(final StorageTx tx,
                                      final Repository repository,
                                      final String name,
                                      final String version,
                                      final String group)
{
  Iterable<Component> components = tx.findComponents(
      Query.builder()
          .where(P_NAME).eq(name)
          .and(P_VERSION).eq(version)
          .and(P_GROUP).eq(group)
          .build(),
      singletonList(repository)
  );
  if (components.iterator().hasNext()) {
    return components.iterator().next();
  }
  return null;
}
 
Example #11
Source File: OrientNpmUploadHandler.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Content handle(
    final Repository repository,
    final File content,
    final String path)
    throws IOException
{
  NpmHostedFacet npmFacet = repository.facet(NpmHostedFacet.class);
  StorageFacet storageFacet = repository.facet(StorageFacet.class);

  Path contentPath = content.toPath();
  Payload payload =
      new StreamPayload(() -> new FileInputStream(content), content.length(), Files.probeContentType(contentPath));
  TempBlob tempBlob = storageFacet.createTempBlob(payload, NpmFacetUtils.HASH_ALGORITHMS);
  final Map<String, Object> packageJson = npmPackageParser.parsePackageJson(tempBlob);
  ensureNpmPermitted(repository, packageJson);
  StorageTx tx = UnitOfWork.currentTx();
  Asset asset = npmFacet.putPackage(packageJson, tempBlob);
  return toContent(asset, tx.requireBlob(asset.requireBlobRef()));
}
 
Example #12
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 #13
Source File: NpmFacetUtils.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns the tarball content.
 */
@Nullable
static Content getTarballContent(final StorageTx tx,
                                 final Bucket bucket,
                                 final NpmPackageId packageId,
                                 final String tarballName)
{
  Asset asset = findTarballAsset(tx, bucket, packageId, tarballName);
  if (asset == null) {
    return null;
  }

  Blob blob = tx.requireBlob(asset.requireBlobRef());
  Content content = new Content(new BlobPayload(blob, asset.requireContentType()));
  Content.extractFromAsset(asset, HASH_ALGORITHMS, content.getAttributes());
  return content;
}
 
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: OrientPyPiHostedFacetImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Override
@TransactionalStoreBlob
public Content getIndex(final String name) throws IOException {
  checkNotNull(name);
  StorageTx tx = UnitOfWork.currentTx();

  // If we don't even have a single component entry, then nothing has been uploaded yet
  if (!findComponentExists(tx, getRepository(), name)) {
    return null;
  }

  String indexPath = indexPath(name);
  Bucket bucket = tx.findBucket(getRepository());
  Asset savedIndex = findAsset(tx, bucket, indexPath);

  if (savedIndex == null) {
    savedIndex = createIndexAsset(name, tx, indexPath, bucket);
  }

  return toContent(savedIndex, tx.requireBlob(savedIndex.requireBlobRef()));
}
 
Example #16
Source File: OrientNpmHostedFacet.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@TransactionalStoreMetadata
@Override
public void deleteDistTags(final NpmPackageId packageId, final String tag, final Payload payload) throws IOException
{
  checkNotNull(packageId);
  checkNotNull(tag);
  log.debug("Deleting distTags: {}", packageId);

  if ("latest".equals(tag)) {
    throw new IOException("Unable to delete latest");
  }

  StorageTx tx = UnitOfWork.currentTx();
  Asset packageRootAsset = findPackageRootAsset(tx, tx.findBucket(getRepository()), packageId);
  if (packageRootAsset == null) {
    return;
  }

  try {
    NpmFacetUtils.deleteDistTags(tx, packageRootAsset, tag);
  }
  catch (IOException e) {
    log.info("Unable to obtain dist-tags for {}", packageId.id(), e);
  }
}
 
Example #17
Source File: CondaFacetImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Override
@Nullable
public Component findComponent(final StorageTx tx,
                               final Repository repository,
                               final String arch,
                               final String name,
                               final String version)
{
  Iterable<Component> components = tx.findComponents(
      Query.builder()
          .where(P_NAME).eq(name)
          .and(P_GROUP).eq(arch)
          .and(P_VERSION).eq(version)
          .build(),
      singletonList(repository)
  );
  if (components.iterator().hasNext()) {
    return components.iterator().next();
  }
  return null;
}
 
Example #18
Source File: NpmPackageRootMetadataUtils.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
private static String getPackageRootLatestVersion(final NestedAttributesMap packageJson,
                                                  final Repository repository)
{
  StorageTx tx = UnitOfWork.currentTx();
  NpmPackageId packageId = NpmPackageId.parse((String) packageJson.get(P_NAME));

  try {
    NestedAttributesMap packageRoot = getPackageRoot(tx, repository, packageId);
    if(nonNull(packageRoot)) {

      String latestVersion = getLatestVersionFromPackageRoot(packageRoot);
      if (nonNull(latestVersion)) {
        return latestVersion;
      }
    }
  }
  catch (IOException ignored) { // NOSONAR
  }
  return "";
}
 
Example #19
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 #20
Source File: RemoveSnapshotsFacetImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Find all GAVs that qualify for deletion.
 */
@VisibleForTesting
Set<GAV> findSnapshotCandidates(final StorageTx tx, final Repository repository)
{
  log.info(PROGRESS, "Searching for GAVS with snapshots that qualify for deletion on repository '{}'",
      repository.getName());

  final Bucket bucket = tx.findBucket(repository);
  final OResultSet<ODocument> result = tx.getDb().command(new OSQLSynchQuery<>(GAVS_WITH_SNAPSHOTS))
      .execute(AttachedEntityHelper.id(bucket));
  return result.stream().map((doc) -> {
    String group = doc.field(P_GROUP, String.class);
    String name = doc.field(P_NAME, String.class);
    String baseVersion = doc.field("baseVersion", String.class);
    Integer count = doc.field("cnt", Integer.class);
    return new GAV(group, name, baseVersion, count);
  }).collect(Collectors.toSet());
}
 
Example #21
Source File: P2RestoreBlobIT.java    From nexus-repository-p2 with Eclipse Public License 1.0 6 votes vote down vote up
private void runBlobRestore(final boolean isDryRun) {
  Asset asset;
  Blob blob;
  try (StorageTx tx = getStorageTx(proxyRepository)) {
    tx.begin();
    asset = tx.findAssetWithProperty(AssetEntityAdapter.P_NAME, VALID_PACKAGE_URL,
        tx.findBucket(proxyRepository));
    assertThat(asset, Matchers.notNullValue());
    blob = tx.getBlob(asset.blobRef());
  }
  testHelper.simulateAssetMetadataLoss();
  Properties properties = new Properties();
  properties.setProperty(HEADER_PREFIX + REPO_NAME_HEADER, proxyRepository.getName());
  properties.setProperty(HEADER_PREFIX + BLOB_NAME_HEADER, asset.name());
  properties.setProperty(HEADER_PREFIX + CONTENT_TYPE_HEADER, asset.contentType());

  p2RestoreBlobStrategy.restore(properties, blob, BlobStoreManager.DEFAULT_BLOBSTORE_NAME, isDryRun);
}
 
Example #22
Source File: MavenIndexPublisher.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Publishes MI index into {@code target}, sourced from repository's own CMA structures.
 */
public static void publishHostedIndex(final Repository repository,
                                      final DuplicateDetectionStrategy<Record> duplicateDetectionStrategy)
    throws IOException
{
  checkNotNull(repository);
  Transactional.operation.throwing(IOException.class).call(
      () -> {
        final StorageTx tx = UnitOfWork.currentTx();
        try (Maven2WritableResourceHandler resourceHandler = new Maven2WritableResourceHandler(repository)) {
          try (IndexWriter indexWriter = new IndexWriter(resourceHandler, repository.getName(), false)) {
            indexWriter.writeChunk(
                transform(
                    decorate(
                        filter(getHostedRecords(tx, repository), duplicateDetectionStrategy),
                        repository.getName()
                    ),
                    RECORD_COMPACTOR::apply
                ).iterator()
            );
          }
        }
        return null;
      }
  );
}
 
Example #23
Source File: HelmComponentMaintenanceFacet.java    From nexus-repository-helm with Eclipse Public License 1.0 6 votes vote down vote up
@Transactional(retryOn = ONeedRetryException.class)
@Override
protected Set<String> deleteAssetTx(final EntityId assetId, final boolean deleteBlobs) {
  StorageTx tx = UnitOfWork.currentTx();
  Bucket bucket = tx.findBucket(getRepository());
  Asset asset = tx.findAsset(assetId, bucket);

  if (asset == null) {
    return Collections.emptySet();
  }

  tx.deleteAsset(asset, deleteBlobs);

  if (asset.componentId() != null) {
    Component component = tx.findComponentInBucket(asset.componentId(), bucket);

    if (!tx.browseAssets(component).iterator().hasNext()) {
      log.debug("Deleting component: {}", component);
      tx.deleteComponent(component, deleteBlobs);
    }
  }
  return Collections.singleton(asset.name());
}
 
Example #24
Source File: NpmFacetUtils.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Saves the package root JSON content by persisting content into root asset's blob. It also removes some transient
 * fields from JSON document.
 */
static void savePackageRoot(final StorageTx tx,
                            final Asset packageRootAsset,
                            final NestedAttributesMap packageRoot) throws IOException
{
  packageRoot.remove(NpmMetadataUtils.META_ID);
  packageRoot.remove("_attachments");
  packageRootAsset.formatAttributes().set(
      NpmAttributes.P_NPM_LAST_MODIFIED, NpmMetadataUtils.maintainTime(packageRoot).toDate()
  );
  storeContent(
      tx,
      packageRootAsset,
      new StreamCopier<Supplier<InputStream>>(
          outputStream -> serialize(new OutputStreamWriter(outputStream, UTF_8), packageRoot),
          inputStream -> () -> inputStream).read(),
      AssetKind.PACKAGE_ROOT
  );
  tx.saveAsset(packageRootAsset);
}
 
Example #25
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 #26
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 #27
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 #28
Source File: ConanHashVerifier.java    From nexus-repository-conan with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Retrieves the hash maps which are stored as key, value pairs within the conanmanifest file
 * @param tx
 * @param bucket
 * @param assetPath
 * @return hashcode of the file
 */
public HashCode lookupHashFromAsset(final StorageTx tx, final Bucket bucket, final String assetPath) {
  checkNotNull(tx);
  checkNotNull(bucket);
  checkNotNull(assetPath);

  AttributesMap attributes = getConanmanifestHashes(tx, bucket, assetPath);

  if(attributes != null) {
    String filename = getFilenameFromPath(assetPath);
    if (attributes.contains(filename)) {
      return HashCode.fromString((String) attributes.get(filename));
    }
  }
  return null;
}
 
Example #29
Source File: OrientPyPiHostedFacetImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@TransactionalStoreMetadata
protected Asset createRootIndexAsset(final Bucket bucket) {
  StorageTx tx = UnitOfWork.currentTx();
  Asset asset = tx.createAsset(bucket, getRepository().getFormat());
  asset.name(INDEX_PATH_PREFIX);
  asset.formatAttributes().set(P_ASSET_KIND, ROOT_INDEX.name());
  return asset;
}
 
Example #30
Source File: MavenFacetImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
private boolean deleteFile(final MavenPath path, final StorageTx tx) {
  final Asset asset = findAsset(tx, tx.findBucket(getRepository()), path);
  if (asset == null) {
    return false;
  }
  tx.deleteAsset(asset);
  return true;
}