use of org.sonatype.nexus.repository.content.fluent.FluentComponent in project nexus-public by sonatype.
the class DataStoreMavenTestHelper method deleteComponents.
@Override
public void deleteComponents(final Repository repository, final String version, final int expectedNumber) {
MavenContentFacet mavenContentFacet = repository.facet(MavenContentFacet.class);
List<FluentComponent> components = findComponents(mavenContentFacet, version).collect(Collectors.toList());
assertThat(components, hasSize(expectedNumber));
ContentMaintenanceFacet contentMaintenanceFacet = repository.facet(ContentMaintenanceFacet.class);
for (FluentComponent component : components) {
contentMaintenanceFacet.deleteComponent(component);
}
}
use of org.sonatype.nexus.repository.content.fluent.FluentComponent in project nexus-public by sonatype.
the class DataStoreMavenTestHelper method loadComponents.
@Override
public List<MavenTestComponent> loadComponents(final Repository repository) {
List<MavenTestComponent> components = new ArrayList<>();
MavenContentFacet mavenContentFacet = repository.facet(MavenContentFacet.class);
Iterable<FluentComponent> fluentComponents = iterableOf(mavenContentFacet.components()::browse);
for (FluentComponent fluentComponent : fluentComponents) {
components.add(new MavenTestComponent(fluentComponent.name(), fluentComponent.attributes().child("maven2").get("baseVersion").toString(), fluentComponent.version(), new DateTime(Date.from(fluentComponent.lastUpdated().toInstant()))));
}
return components;
}
use of org.sonatype.nexus.repository.content.fluent.FluentComponent in project nexus-public by sonatype.
the class DatastoreRawTestHelper method createAsset.
@Override
public EntityId createAsset(final Repository repository, final String componentName, final String componentGroup, final String assetName) {
try {
String path = getGroupAndAsset(componentGroup, assetName);
repository.facet(RawContentFacet.class).put(path, new StringPayload("Test", "text/plain"));
Optional<FluentComponent> fluentComponent = repository.facet(RawContentFacet.class).components().name(path).namespace("/" + componentGroup).find();
assertTrue(fluentComponent.isPresent());
return InternalIds.toExternalId(InternalIds.internalComponentId(fluentComponent.get()));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.sonatype.nexus.repository.content.fluent.FluentComponent in project nexus-public by sonatype.
the class MavenContentFacetImpl method createComponentAndAsset.
@Override
public FluentAsset createComponentAndAsset(final MavenPath mavenPath) {
String assetName = "/" + mavenPath.getPath();
String assetKind = assetKind(mavenPath, mavenPathParser);
if (mavenPath.getCoordinates() == null) {
return assets().path(assetName).kind(assetKind).save();
} else {
Coordinates coordinates = checkNotNull(mavenPath.getCoordinates());
FluentComponent component = createOrGetComponent(coordinates);
FluentAsset asset = component.asset(assetName).kind(assetKind).save();
configureAssetAttributes(asset, coordinates);
return asset;
}
}
use of org.sonatype.nexus.repository.content.fluent.FluentComponent in project nexus-public by sonatype.
the class MavenContentFacetImpl method createOrGetComponent.
private FluentComponent createOrGetComponent(final MavenPath mavenPath, final Optional<Model> model) {
Optional<String> optionalKind = model.map(MavenAttributesHelper::getPackaging);
Coordinates coordinates = mavenPath.getCoordinates();
FluentComponent component = components().name(coordinates.getArtifactId()).namespace(coordinates.getGroupId()).version(coordinates.getVersion()).kind(optionalKind).getOrCreate();
boolean isNew = isNewRepositoryContent(component);
MavenAttributesHelper.setMavenAttributes((Maven2ComponentStore) stores().componentStore, component, coordinates, model, contentRepositoryId());
if (isNew) {
publishEvents(component);
} else {
// kind isn't set for existing components
optionalKind.ifPresent(component::kind);
}
return component;
}
Aggregations