use of org.sonatype.nexus.repository.content.facet.ContentFacet in project nexus-public by sonatype.
the class MavenContentFacetImpl method collectGavs.
private Set<List<String>> collectGavs(final int[] componentIds) {
ContentFacetSupport contentFacet = (ContentFacetSupport) facet(ContentFacet.class);
ComponentStore<?> componentStore = contentFacet.stores().componentStore;
return Arrays.stream(componentIds).mapToObj(componentStore::readComponent).filter(Optional::isPresent).map(Optional::get).map(this::collectGabv).map(Arrays::asList).collect(toSet());
}
use of org.sonatype.nexus.repository.content.facet.ContentFacet in project nexus-public by sonatype.
the class ReplicationFacetSupport method doReplicateDelete.
public boolean doReplicateDelete(final String path) {
ContentFacet contentFacet = facet(ContentFacet.class);
ContentMaintenanceFacet componentMaintenance = facet(ContentMaintenanceFacet.class);
FluentAssets fluentAssets = contentFacet.assets();
Optional<FluentAsset> result = fluentAssets.path(path).find();
result.ifPresent(componentMaintenance::deleteAsset);
return result.isPresent();
}
use of org.sonatype.nexus.repository.content.facet.ContentFacet in project nexus-public by sonatype.
the class ContentDirector method copyComponent.
/**
* This is a hook that allows format implementations to customize how a component is copied.
*
* @param source the component to copy
* @param destination the repository to copy the component to
* @return a reference to the component
*
* @since 3.38
*/
default FluentComponent copyComponent(final Component source, final Repository destination) {
ContentFacet content = destination.facet(ContentFacet.class);
FluentComponentBuilder destComponentBuilder = content.components().name(source.name()).namespace(source.namespace()).version(source.version());
source.attributes().forEach(attribute -> destComponentBuilder.attributes(attribute.getKey(), attribute.getValue()));
return destComponentBuilder.getOrCreate();
}
use of org.sonatype.nexus.repository.content.facet.ContentFacet in project nexus-public by sonatype.
the class PurgeUnusedFacetImpl method purgeUnused.
@Override
@Guarded(by = STARTED)
public void purgeUnused(final int numberOfDays) {
checkArgument(numberOfDays > 0, "Number of days must be greater then zero");
log.info("Purging unused components from repository {}", getRepository().getName());
ContentFacetSupport contentFacet = (ContentFacetSupport) getRepository().facet(ContentFacet.class);
ComponentStore<?> componentStore = contentFacet.stores().componentStore;
AssetStore<?> assetStore = contentFacet.stores().assetStore;
int contentRepositoryId = contentFacet.contentRepositoryId();
int purgedAssets = assetStore.purgeNotRecentlyDownloaded(contentRepositoryId, numberOfDays);
log.debug("Deleted {} unused assets without components", purgedAssets);
int purgedComponents = componentStore.purgeNotRecentlyDownloaded(contentRepositoryId, numberOfDays);
log.debug("Deleted {} unused components and their assets", purgedComponents);
log.info("Purged {} unused components from repository {}", purgedComponents, getRepository().getName());
}
use of org.sonatype.nexus.repository.content.facet.ContentFacet in project nexus-public by sonatype.
the class MaintenanceServiceImpl method canDeleteComponent.
@Override
public boolean canDeleteComponent(final Repository repository, final Component component) {
boolean canDeleteComponent = true;
ContentFacet contentFacet = repository.facet(ContentFacet.class);
String repositoryName = repository.getName();
String format = repository.getFormat().getValue();
VariableResolverAdapter variableResolverAdapter = variableResolverAdapterManager.get(format);
for (Asset asset : contentFacet.components().with(component).assets()) {
if (!canDeleteAssetInRepository(repositoryName, format, variableResolverAdapter, asset)) {
canDeleteComponent = false;
break;
}
}
return canDeleteComponent;
}
Aggregations