use of org.sonatype.nexus.repository.storage.Component in project nexus-repository-r by sonatype-nexus-community.
the class RProxyFacetImpl method doPutArchive.
@TransactionalStoreBlob
protected Content doPutArchive(final String path, final TempBlob archiveContent, final Content content) throws IOException {
RFacet rFacet = facet(RFacet.class);
StorageTx tx = UnitOfWork.currentTx();
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);
return saveAsset(tx, asset, archiveContent, content);
}
use of org.sonatype.nexus.repository.storage.Component in project nexus-repository-r by sonatype-nexus-community.
the class RBrowseNodeGeneratorTest method shouldComputeAssetAndComponentPath.
@Test
public void shouldComputeAssetAndComponentPath() {
final String commonPath = "bin/macosx/el-capitan/contrib/3.6";
final String lastSegment = "devtools_2.2.1.tgz";
final String assetPath = commonPath + "/" + lastSegment;
final String componentName = "devtools";
final String componentVersion = "2.2.1";
final String componentBrowsePath = commonPath + "/" + componentName + "/" + componentVersion;
final String assetBrowsePath = componentBrowsePath + "/" + lastSegment;
Component component = createComponent(componentName, commonPath, componentVersion);
Asset asset = createAsset(assetPath);
List<BrowsePaths> pathsAsset = generator.computeAssetPaths(asset, component);
List<BrowsePaths> pathsComponent = generator.computeComponentPaths(asset, component);
assertPaths(Arrays.asList(assetBrowsePath.split("/")), pathsAsset);
assertPaths(Arrays.asList(componentBrowsePath.split("/")), pathsComponent, true);
}
use of org.sonatype.nexus.repository.storage.Component in project nexus-repository-r by sonatype-nexus-community.
the class RHostedIT method testDeletingRemainingAssetAlsoDeletesComponent.
@Test
public void testDeletingRemainingAssetAlsoDeletesComponent() {
final Asset asset = findAsset(repository, AGRICOLAE_121_TARGZ.fullPath);
assertNotNull(asset);
assertNotNull(asset.componentId());
final Component component = findComponentById(repository, asset.componentId());
assertNotNull(component);
assertThat(findAssetsByComponent(repository, component).size(), is(1));
componentAssetTestHelper.removeAsset(repository, AGRICOLAE_121_TARGZ.fullPath);
assertThat(componentAssetTestHelper.assetExists(repository, AGRICOLAE_121_TARGZ.fullPath), is(false));
assertThat(componentAssetTestHelper.componentExists(repository, AGRICOLAE_121_TARGZ.packageName, AGRICOLAE_121_TARGZ.packageVersion), is(false));
}
use of org.sonatype.nexus.repository.storage.Component in project nexus-repository-r by sonatype-nexus-community.
the class RHostedIT method testMetadataProcessing.
@Test
public void testMetadataProcessing() throws Exception {
// Uploading package with same name and lower version that should be skipped in src metadata
uploadSinglePackage(AGRICOLAE_101_TARGZ);
Thread.sleep(METADATA_PROCESSING_WAIT_INTERVAL_MILLIS);
final String agricolae121Content = new String(Files.readAllBytes(testData.resolveFile(PACKAGES_AGRICOLAE_121_FILENAME).toPath()));
final String agricolae131Content = new String(Files.readAllBytes(testData.resolveFile(PACKAGES_AGRICOLAE_131_FILENAME).toPath()));
// Verify PACKAGES(metadata) contain appropriate content about source R package (version 1.0-1 is skipped)
final InputStream contentSrc = client.fetch(PACKAGES_SRC_GZ.fullPath).getEntity().getContent();
verifyTextGzipContent(is(equalTo(agricolae121Content)), contentSrc);
assertThat(componentAssetTestHelper.assetExists(repository, PACKAGES_SRC_GZ.fullPath), is(true));
// Verify PACKAGES(metadata) contain appropriate content about bin R package
final InputStream contentBin = client.fetch(PACKAGES_BIN_GZ.fullPath).getEntity().getContent();
verifyTextGzipContent(is(equalTo(agricolae131Content)), contentBin);
assertThat(componentAssetTestHelper.assetExists(repository, PACKAGES_BIN_GZ.fullPath), is(true));
// Verify PACKAGES(metadata) is clean if component has been deleted
ComponentMaintenance maintenanceFacet = repository.facet(ComponentMaintenance.class);
final List<Component> allComponents = RITSupport.getAllComponents(repository);
allComponents.stream().forEach(component -> maintenanceFacet.deleteComponent(component.getEntityMetadata().getId(), true));
Thread.sleep(METADATA_PROCESSING_WAIT_INTERVAL_MILLIS);
final InputStream contentSrcAfterDelete = client.fetch(PACKAGES_SRC_GZ.fullPath).getEntity().getContent();
verifyTextGzipContent(is(equalTo("")), contentSrcAfterDelete);
assertThat(componentAssetTestHelper.assetExists(repository, PACKAGES_SRC_GZ.fullPath), is(true));
final InputStream contentBinAfterDelete = client.fetch(PACKAGES_BIN_GZ.fullPath).getEntity().getContent();
verifyTextGzipContent(is(equalTo("")), contentBinAfterDelete);
assertThat(componentAssetTestHelper.assetExists(repository, PACKAGES_BIN_GZ.fullPath), is(true));
}
use of org.sonatype.nexus.repository.storage.Component in project nexus-repository-r by sonatype-nexus-community.
the class RHostedIT method testPackageUpload.
@Test
public void testPackageUpload() throws Exception {
// Verify DB contains data about uploaded component and asset
Component component = findComponent(repository, AGRICOLAE_121_TARGZ.packageName);
assertThat(component.name(), is(equalTo(AGRICOLAE_121_TARGZ.packageName)));
assertThat(component.version(), is(equalTo(AGRICOLAE_121_TARGZ.packageVersion)));
assertThat(component.group(), is(equalTo(AGRICOLAE_121_TARGZ.basePath)));
// Verify Asset is created.
Asset asset = findAsset(repository, AGRICOLAE_121_TARGZ.fullPath);
assertThat(asset.name(), is(equalTo(AGRICOLAE_121_TARGZ.fullPath)));
assertThat(asset.format(), is(equalTo(R_FORMAT_NAME)));
}
Aggregations