Java Code Examples for org.sonatype.nexus.repository.storage.Component#version()
The following examples show how to use
org.sonatype.nexus.repository.storage.Component#version() .
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: Maven2BrowseNodeGeneratorTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Test public void computeAssetPathForAssetWithComponent() { String baseVersion = "1.0.0"; NestedAttributesMap attributes = new NestedAttributesMap("attributes", singletonMap("maven2", singletonMap("baseVersion", baseVersion))); Asset asset = createAsset("com/sonatype/example/1.0.0/example-1.0.0.jar"); Component component = new DefaultComponent(); component.group("com.sonatype"); component.name("example"); component.version(baseVersion); component.attributes(attributes); List<BrowsePaths> paths = generator.computeAssetPaths(asset, component); assertPaths(asList("com", "sonatype", "example", "1.0.0", "example-1.0.0.jar"), paths); }
Example 2
Source File: Maven2BrowseNodeGeneratorTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Test public void computeAssetPathForSnapshotAssetWithComponent() { String baseVersion = "1.0-SNAPSHOT"; NestedAttributesMap attributes = new NestedAttributesMap("attributes", singletonMap("maven2", singletonMap("baseVersion", baseVersion))); Asset asset = createAsset("org/foo/bar/example/1.0-SNAPSHOT/example-1.0-20171213.212030-158.jar"); Component component = new DefaultComponent(); component.group("org.foo.bar"); component.name("example"); component.version("1.0-20171213.212030-158"); component.attributes(attributes); List<BrowsePaths> paths = generator.computeAssetPaths(asset, component); assertSNAPSHOTPaths(asList("org", "foo", "bar", "example", "1.0-SNAPSHOT", "1.0-20171213.212030-158", "example-1.0-20171213.212030-158.jar"), paths, false); }
Example 3
Source File: Maven2BrowseNodeGeneratorTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Test public void computeComponentPathNoGroup() { String baseVersion = "1.0.0"; NestedAttributesMap attributes = new NestedAttributesMap("attributes", singletonMap("maven2", singletonMap("baseVersion", baseVersion))); Asset asset = createAsset("name/1.0.0/name-1.0.0.jar"); Component component = new DefaultComponent(); component.name("name"); component.version("1.0.0"); component.attributes(attributes); List<BrowsePaths> paths = generator.computeComponentPaths(asset, component); assertPaths(asList(component.name(), component.version()), paths, true); }
Example 4
Source File: Maven2BrowseNodeGeneratorTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Test public void computeComponentPath() { String baseVersion = "1.0.0"; NestedAttributesMap attributes = new NestedAttributesMap("attributes", singletonMap("maven2", singletonMap("baseVersion", baseVersion))); Asset asset = createAsset("group/name/1.0.0/name-1.0.0.jar"); Component component = new DefaultComponent(); component.group("group"); component.name("name"); component.version(baseVersion); component.attributes(attributes); List<BrowsePaths> paths = generator.computeComponentPaths(asset, component); assertPaths(asList(component.group(), component.name(), component.version()), paths, true); }
Example 5
Source File: Maven2BrowseNodeGeneratorTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Test public void computeSnapshotComponentPath() { String baseVersion = "1.0.0-SNAPSHOT"; NestedAttributesMap attributes = new NestedAttributesMap("attributes", singletonMap("maven2", singletonMap("baseVersion", baseVersion))); Asset asset = createAsset("group/name/1.0.0-SNAPSHOT/name-1.0.0-20171213.212030-158.jar"); Component component = new DefaultComponent(); component.group("group"); component.name("name"); component.version("1.0.0-20171213.212030-158"); component.attributes(attributes); List<BrowsePaths> paths = generator.computeComponentPaths(asset, component); assertSNAPSHOTPaths(asList(component.group(), component.name(), baseVersion, component.version()), paths, true); }
Example 6
Source File: DefaultComponentMetadataProducer.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
public String getNormalizedVersion(Component component) { String version = component.version(); if (StringUtils.isBlank(version)) { return ""; } Matcher matcher = Pattern.compile("\\d+").matcher(version); StringBuilder replacementBuilder = new StringBuilder(); int position = 0; while (matcher.find()) { replacementBuilder.append(version, position, matcher.start()); position = matcher.end(); try { replacementBuilder.append(String.format("%09d", Long.parseLong(matcher.group()))); } catch (NumberFormatException e) { log.debug("Unable to parse number as long '{}'", matcher.group()); replacementBuilder.append(matcher.group()); } } return replacementBuilder.toString(); }
Example 7
Source File: OrientBrowseNodeManagerTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
private Component createComponent(final String name, final String group, final String version, final String componentId) { EntityMetadata metadata = mock(EntityMetadata.class); when(metadata.getId()).thenReturn(new DetachedEntityId(componentId)); Component component = new DefaultComponent(); component.name(name); component.group(group); component.version(version); component.setEntityMetadata(metadata); when(componentStore.read(EntityHelper.id(component))).thenReturn(component); return component; }
Example 8
Source File: BrowseTestSupport.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
protected Component createComponent(final String name, final String group, final String version) { Component component = new DefaultComponent(); component.name(name); component.group(group); component.version(version); return component; }
Example 9
Source File: OrientPyPiFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
@Override public Asset putPackage(final String path, final AssetBlob assetBlob) throws IOException { final StorageTx tx = UnitOfWork.currentTx(); final Bucket bucket = tx.findBucket(getRepository()); Asset asset = findAsset(tx, bucket, path); if (asset == null) { final String filename = extractFilenameFromPath(path); Map<String, String> attributes; try (InputStream is = assetBlob.getBlob().getInputStream()) { attributes = extractMetadata(is); } if (!attributes.containsKey(P_NAME)) { log.debug("No name found in metadata for {}, extracting from filename.", filename); attributes.put(P_NAME, normalizeName(extractNameFromFilename(filename))); } if (!attributes.containsKey(P_VERSION)) { log.debug("No version found in metadata for {}, extracting from filename.", filename); attributes.put(P_VERSION, extractVersionFromFilename(filename)); } final String name = attributes.get(P_NAME); final String version = attributes.get(P_VERSION); Component component = findComponent(tx, getRepository(), name, version); if (component == null) { component = tx.createComponent(bucket, getRepository().getFormat()); component.name(name); component.version(version); component.formatAttributes().set(P_SUMMARY, attributes.get(P_SUMMARY)); tx.saveComponent(component); } asset = tx.createAsset(bucket, component); asset.name(path); copyAttributes(asset, attributes); saveAsset(tx, asset, assetBlob, AssetKind.PACKAGE); } return asset; }