Java Code Examples for org.sonatype.nexus.repository.storage.StorageTx#findComponents()

The following examples show how to use org.sonatype.nexus.repository.storage.StorageTx#findComponents() . 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: P2FacetImpl.java    From nexus-repository-p2 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
public 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 2
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 3
Source File: ConanFacetUtils.java    From nexus-repository-conan with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Find a component by its name and tag (version)
 *
 * @return found component or null if not found
 */
@Nullable
public static Component findComponent(final StorageTx tx,
                                      final Repository repository,
                                      final ConanCoords coords)
{
  Iterable<Component> components = tx.findComponents(
      Query.builder()
          .where(P_GROUP).eq(coords.getGroup())
          .and(P_NAME).eq(coords.getProject())
          .and(P_VERSION).eq(getComponentVersion(coords))
          .build(),
      singletonList(repository)
  );
  if (components.iterator().hasNext()) {
    return components.iterator().next();
  }
  return null;
}
 
Example 4
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 5
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 6
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 7
Source File: GolangDataAccess.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 or null if not found
 */
@Nullable
private 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: MavenFacetUtils.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Finds component in given repository by maven path.
 */
@Nullable
public static Component findComponent(final StorageTx tx,
    final Repository repository,
    final MavenPath mavenPath)
{
  final Coordinates coordinates = mavenPath.getCoordinates();
  final Iterable<Component> components = tx.findComponents(
      Query.builder()
          .where(P_GROUP).eq(coordinates.getGroupId())
          .and(P_NAME).eq(coordinates.getArtifactId())
          .and(P_VERSION).eq(coordinates.getVersion())
          .build(),
      singletonList(repository)
  );
  if (components.iterator().hasNext()) {
    return components.iterator().next();
  }
  return null;
}
 
Example 9
Source File: AptFacetImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
private Component findOrCreateComponent(final StorageTx tx, final Bucket bucket, final PackageInfo info) {
  String name = info.getPackageName();
  String version = info.getVersion();
  String architecture = info.getArchitecture();

  Iterable<Component> components = tx.findComponents(
      builder()
          .where(P_NAME).eq(name)
          .and(P_VERSION).eq(version)
          .and(P_GROUP).eq(architecture)
          .build(),
      singletonList(getRepository())
  );

  Component component = Iterables.getFirst(components, null);
  if (component == null) {
    component = tx.createComponent(bucket, getRepository().getFormat())
        .name(name)
        .version(version)
        .group(architecture);
    tx.saveComponent(component);
  }

  return component;
}
 
Example 10
Source File: CocoapodsFacetImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
private Component findOrCreateComponent(final StorageTx tx, final Bucket bucket, final String path) {
  PodInfo podInfo = podPathParser.parse(path);

  Iterable<Component> components = tx.findComponents(
      builder()
          .where(P_NAME).eq(podInfo.getName())
          .and(P_VERSION).eq(podInfo.getVersion())
          .build(),
      singletonList(getRepository())
  );

  Component component = Iterables.getFirst(components, null); // NOSONAR
  if (component == null) {
    component = tx.createComponent(bucket, getRepository().getFormat())
        .name(podInfo.getName())
        .version(podInfo.getVersion());
    tx.saveComponent(component);
  }
  return component;
}
 
Example 11
Source File: ComposerContentFacetImpl.java    From nexus-repository-composer with Eclipse Public License 1.0 5 votes vote down vote up
@Nullable
private Component findComponent(final StorageTx tx, final String group, final String name, final String version) {
  Iterable<Component> components = tx.findComponents(Query.builder()
          .where(P_GROUP).eq(group)
          .and(P_NAME).eq(name)
          .and(P_VERSION).eq(version)
          .build(),
      singletonList(getRepository()));
  if (components.iterator().hasNext()) {
    return components.iterator().next();
  }
  return null;
}
 
Example 12
Source File: NpmFacetUtils.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Find all tarball component by package name in repository.
 */
@Nonnull
static Iterable<Component> findPackageTarballComponents(final StorageTx tx,
                                                        final Repository repository,
                                                        final NpmPackageId packageId)
{
  return tx.findComponents(query(packageId).build(), singletonList(repository));
}