Search in sources :

Example 6 with Component

use of org.sonatype.nexus.repository.storage.Component in project nexus-repository-r by sonatype-nexus-community.

the class RHostedIT method testDeletingComponentDeletesAllAssociatedAssets.

@Test
public void testDeletingComponentDeletesAllAssociatedAssets() {
    final Asset asset = findAsset(repository, AGRICOLAE_121_TARGZ.fullPath);
    assertNotNull(asset);
    assertNotNull(asset.componentId());
    final Component component = findComponentById(repository, asset.componentId());
    assertNotNull(component);
    ComponentMaintenance maintenanceFacet = repository.facet(ComponentMaintenance.class);
    maintenanceFacet.deleteComponent(component.getEntityMetadata().getId(), true);
    assertThat(componentAssetTestHelper.assetExists(repository, AGRICOLAE_121_TARGZ.fullPath), is(false));
    assertNull(findComponentById(repository, asset.componentId()));
}
Also used : ComponentMaintenance(org.sonatype.nexus.repository.storage.ComponentMaintenance) Asset(org.sonatype.nexus.repository.storage.Asset) Component(org.sonatype.nexus.repository.storage.Component) Test(org.junit.Test)

Example 7 with Component

use of org.sonatype.nexus.repository.storage.Component in project nexus-repository-r by sonatype-nexus-community.

the class RFacetUtilsTest method findNoComponents.

@Test
public void findNoComponents() throws Exception {
    components.clear();
    Component component = findComponent(tx, repository, "name", "version");
    assertThat(component, is(equalTo(component)));
}
Also used : RFacetUtils.findComponent(org.sonatype.nexus.repository.r.internal.RFacetUtils.findComponent) Component(org.sonatype.nexus.repository.storage.Component) Test(org.junit.Test)

Example 8 with Component

use of org.sonatype.nexus.repository.storage.Component in project nexus-repository-r by sonatype-nexus-community.

the class RFacetUtilsTest method returnFirstComponent.

@Test
public void returnFirstComponent() throws Exception {
    Component component = findComponent(tx, repository, "name", "version", "group");
    assertThat(component, is(notNullValue()));
}
Also used : Component(org.sonatype.nexus.repository.storage.Component) RFacetUtils.findComponent(org.sonatype.nexus.repository.r.internal.util.RFacetUtils.findComponent) Test(org.junit.Test)

Example 9 with Component

use of org.sonatype.nexus.repository.storage.Component in project nexus-repository-r by sonatype-nexus-community.

the class RFacetUtilsTest method findNoComponents.

@Test
public void findNoComponents() throws Exception {
    components.clear();
    Component component = findComponent(tx, repository, "name", "version", "group");
    assertThat(component, is(equalTo(component)));
}
Also used : Component(org.sonatype.nexus.repository.storage.Component) RFacetUtils.findComponent(org.sonatype.nexus.repository.r.internal.util.RFacetUtils.findComponent) Test(org.junit.Test)

Example 10 with Component

use of org.sonatype.nexus.repository.storage.Component in project nexus-repository-r by sonatype-nexus-community.

the class RHostedFacetImpl method doPutArchive.

@TransactionalStoreBlob
protected Asset doPutArchive(final String path, final TempBlob archiveContent, final Payload payload) throws IOException {
    StorageTx tx = UnitOfWork.currentTx();
    RFacet rFacet = facet(RFacet.class);
    Map<String, String> attributes;
    try (InputStream is = archiveContent.get()) {
        attributes = extractDescriptionFromArchive(path, is);
    }
    Component component = rFacet.findOrCreateComponent(tx, path, attributes);
    Asset asset = rFacet.findOrCreateAsset(tx, component, path, attributes);
    saveAsset(tx, asset, archiveContent, payload);
    return asset;
}
Also used : RFacet(org.sonatype.nexus.repository.r.RFacet) StorageTx(org.sonatype.nexus.repository.storage.StorageTx) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) RFacetUtils.saveAsset(org.sonatype.nexus.repository.r.internal.util.RFacetUtils.saveAsset) RFacetUtils.findAsset(org.sonatype.nexus.repository.r.internal.util.RFacetUtils.findAsset) Asset(org.sonatype.nexus.repository.storage.Asset) Component(org.sonatype.nexus.repository.storage.Component) TransactionalStoreBlob(org.sonatype.nexus.repository.transaction.TransactionalStoreBlob)

Aggregations

Component (org.sonatype.nexus.repository.storage.Component)19 Test (org.junit.Test)12 Asset (org.sonatype.nexus.repository.storage.Asset)12 InputStream (java.io.InputStream)6 StorageTx (org.sonatype.nexus.repository.storage.StorageTx)6 RFacetUtils.findComponent (org.sonatype.nexus.repository.r.internal.RFacetUtils.findComponent)4 TransactionalStoreBlob (org.sonatype.nexus.repository.transaction.TransactionalStoreBlob)4 RFacet (org.sonatype.nexus.repository.r.RFacet)3 RFacetUtils.findComponent (org.sonatype.nexus.repository.r.internal.util.RFacetUtils.findComponent)3 Bucket (org.sonatype.nexus.repository.storage.Bucket)3 ComponentMaintenance (org.sonatype.nexus.repository.storage.ComponentMaintenance)3 BrowsePaths (org.sonatype.nexus.repository.browse.BrowsePaths)2 RFacetUtils.findAsset (org.sonatype.nexus.repository.r.internal.RFacetUtils.findAsset)2 RFacetUtils.saveAsset (org.sonatype.nexus.repository.r.internal.RFacetUtils.saveAsset)2 RFacetUtils.findAsset (org.sonatype.nexus.repository.r.internal.util.RFacetUtils.findAsset)2 RFacetUtils.saveAsset (org.sonatype.nexus.repository.r.internal.util.RFacetUtils.saveAsset)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 AttributesMap (org.sonatype.nexus.common.collect.AttributesMap)1 EntityId (org.sonatype.nexus.common.entity.EntityId)1 TransactionalDeleteBlob (org.sonatype.nexus.repository.transaction.TransactionalDeleteBlob)1