org.sonatype.nexus.orient.OIndexNameBuilder Java Examples

The following examples show how to use org.sonatype.nexus.orient.OIndexNameBuilder. 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: ConanUpgrade_1_1.java    From nexus-repository-conan with Eclipse Public License 1.0 6 votes vote down vote up
private Stream<ODocument> findAssets(
    final ODatabaseDocumentTx db,
    final List<String> repositoryNames,
    final String SQL)
{
  return repositoryNames
      .stream()
      .flatMap(repositoryName -> {
        OIndex<?> bucketIdx = db.getMetadata().getIndexManager().getIndex(new OIndexNameBuilder()
            .type("bucket")
            .property(P_REPOSITORY_NAME)
            .build());
        OIdentifiable bucket = (OIdentifiable) bucketIdx.get(repositoryName);
        if (bucket == null) {
          log.debug("Unable to find bucket for {}", repositoryName);
          return Stream.empty();
        }
        List<ODocument> assets =
            db.query(new OSQLSynchQuery<ODocument>(SQL), bucket.getIdentity());
        return assets.stream();
      });
}
 
Example #2
Source File: ConanUpgrade_1_1.java    From nexus-repository-conan with Eclipse Public License 1.0 6 votes vote down vote up
private void deleteDownloadUrls(final List<String> repositoryNames) {
  log.debug("Deleting DOWNLOAD_URLS assets from conan repositories ({}).", repositoryNames);

  DatabaseUpgradeSupport.withDatabaseAndClass(componentDatabaseInstance, ASSET_CLASS_NAME, (db, type) -> {
    OSchemaProxy schema = db.getMetadata().getSchema();
    if (schema.existsClass(ASSET_CLASS_NAME)) {
      repositoryNames.forEach(repositoryName -> {
        OIndex<?> bucketIdx = db.getMetadata().getIndexManager().getIndex(new OIndexNameBuilder()
            .type("bucket")
            .property(P_REPOSITORY_NAME)
            .build());
        OIdentifiable bucket = (OIdentifiable) bucketIdx.get(repositoryName);

        db.command(new OCommandSQL(DELETE_FROM_ASSET_WHERE_BUCKET_AND_ASSET_KIND))
            .execute(bucket, AssetKind.DOWNLOAD_URL.name());
      });
    }
  });
}