Java Code Examples for org.sonatype.nexus.repository.storage.Asset#format()
The following examples show how to use
org.sonatype.nexus.repository.storage.Asset#format() .
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: PurgeUnusedSnapshotsFacetImplTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
private Asset createMetadataAsset(String name, String cacheToken) { Asset asset = new Asset(); asset.contentType(TEXT_XML); asset.name(name); asset.format(Maven2Format.NAME); asset.attributes(new NestedAttributesMap(P_ATTRIBUTES, new HashMap<>())); asset.formatAttributes().set(P_ASSET_KIND, REPOSITORY_METADATA.name()); asset.attributes().child(CHECKSUM).set(HashType.SHA1.getExt(), HashAlgorithm.SHA1.function().hashString("foobar", StandardCharsets.UTF_8).toString()); asset.attributes().child(CHECKSUM).set(HashType.MD5.getExt(), HashAlgorithm.MD5.function().hashString("foobar", StandardCharsets.UTF_8).toString()); asset.attributes().child(CONTENT).set(P_LAST_MODIFIED, new Date()); asset.attributes().child(CONTENT).set(P_ETAG, "ETAG"); asset.attributes().child(CACHE).set(LAST_VERIFIED, new Date()); asset.attributes().child(CACHE).set(CACHE_TOKEN, cacheToken); asset.blobRef(new BlobRef("node", "store", "blobid")); return asset; }
Example 2
Source File: MavenFacetImplTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
private Asset createMetadataAsset(String name, String cacheToken) { Asset asset = new Asset(); asset.contentType(TEXT_XML); asset.name(name); asset.format(Maven2Format.NAME); asset.attributes(new NestedAttributesMap(P_ATTRIBUTES, new HashMap<>())); asset.formatAttributes().set(P_ASSET_KIND, REPOSITORY_METADATA.name()); asset.attributes().child(CHECKSUM).set(HashType.SHA1.getExt(), HashAlgorithm.SHA1.function().hashString("foobar", StandardCharsets.UTF_8).toString()); asset.attributes().child(CHECKSUM).set(HashType.MD5.getExt(), HashAlgorithm.MD5.function().hashString("foobar", StandardCharsets.UTF_8).toString()); asset.attributes().child(CONTENT).set(P_LAST_MODIFIED, new Date()); asset.attributes().child(CONTENT).set(P_ETAG, "ETAG"); asset.attributes().child(CACHE).set(LAST_VERIFIED, new Date()); asset.attributes().child(CACHE).set(CACHE_TOKEN, cacheToken); asset.blobRef(new BlobRef("node", "store", "blobid")); return asset; }
Example 3
Source File: BrowseNodeEntityAdapterTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
private void createEntities(final ODatabaseDocumentTx db) { bucket = new Bucket(); bucket.setRepositoryName(REPOSITORY_NAME); bucket.attributes(new NestedAttributesMap(P_ATTRIBUTES, new HashMap<>())); bucketEntityAdapter.addEntity(db, bucket); component = new DefaultComponent(); component.bucketId(EntityHelper.id(bucket)); component.attributes(new NestedAttributesMap(P_ATTRIBUTES, new HashMap<>())); component.format(FORMAT_NAME); component.group("org").name("foo").version("1.0"); componentEntityAdapter.addEntity(db, component); asset = new Asset(); asset.bucketId(EntityHelper.id(bucket)); asset.componentId(EntityHelper.id(component)); asset.attributes(new NestedAttributesMap(P_ATTRIBUTES, new HashMap<>())); asset.format(FORMAT_NAME); asset.name("/org/foo/1.0/foo-1.0.jar"); assetEntityAdapter.addEntity(db, asset); }
Example 4
Source File: CreateIndexFacetImpl.java From nexus-repository-helm with Eclipse Public License 1.0 | 5 votes |
private void maybeInvalidateIndex(final AssetEvent event) { Asset asset = event.getAsset(); String formatName = asset.format(); if (HelmFormat.NAME.equals(formatName)) { String assetKindString = (String) asset.formatAttributes().get(P_ASSET_KIND); AssetKind assetKind = AssetKind.valueOf(assetKindString); if (assetKind == HELM_PACKAGE && matchesRepository(event) && isEventRelevant(event)) { invalidateIndex(); } } }
Example 5
Source File: BrowseNodeEntityAdapterTest.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
@SuppressWarnings("unchecked") @Test public void browseNestedAssets() throws Exception { List<String> path = Splitter.on('/').omitEmptyStrings().splitToList(asset.name()); try (ODatabaseDocumentTx db = database.getInstance().acquire()) { Asset parentAsset = new Asset(); parentAsset.bucketId(EntityHelper.id(bucket)); parentAsset.componentId(EntityHelper.id(component)); parentAsset.attributes(new NestedAttributesMap(P_ATTRIBUTES, new HashMap<>())); parentAsset.format(FORMAT_NAME); parentAsset.name("/org/foo"); assetEntityAdapter.addEntity(db, parentAsset); underTest.createAssetNode(db, REPOSITORY_NAME, FORMAT_NAME, toBrowsePaths(path.subList(0, 2)), parentAsset); underTest.createAssetNode(db, REPOSITORY_NAME, FORMAT_NAME, toBrowsePaths(path), asset); assertThat(underTest.getByPath(db, REPOSITORY_NAME, path.subList(0, 0), 1, "", emptyMap()), contains( allOf( hasProperty("repositoryName", is(REPOSITORY_NAME)), hasProperty("parentPath", is("/")), hasProperty("name", is("org")), hasProperty("leaf", is(false)), hasProperty("componentId", nullValue()), hasProperty("assetId", nullValue()), hasProperty("path", is("org/"))) )); assertThat(underTest.getByPath(db, REPOSITORY_NAME, path.subList(0, 1), 1, "", emptyMap()), contains( allOf( hasProperty("repositoryName", is(REPOSITORY_NAME)), hasProperty("parentPath", is("/org/")), hasProperty("name", is("foo")), hasProperty("leaf", is(false)), hasProperty("componentId", nullValue()), hasProperty("assetId", is(EntityHelper.id(parentAsset))), hasProperty("path", is("org/foo/"))) )); assertThat(underTest.getByPath(db, REPOSITORY_NAME, path.subList(0, 2), 1, "", emptyMap()), contains( allOf( hasProperty("repositoryName", is(REPOSITORY_NAME)), hasProperty("parentPath", is("/org/foo/")), hasProperty("name", is("1.0")), hasProperty("leaf", is(false)), hasProperty("componentId", nullValue()), hasProperty("assetId", nullValue()), hasProperty("path", is("org/foo/1.0/"))) )); assertThat(underTest.getByPath(db, REPOSITORY_NAME, path.subList(0, 3), 1, "", emptyMap()), contains( allOf( hasProperty("repositoryName", is(REPOSITORY_NAME)), hasProperty("parentPath", is("/org/foo/1.0/")), hasProperty("name", is("foo-1.0.jar")), hasProperty("leaf", is(true)), hasProperty("componentId", nullValue()), hasProperty("assetId", is(EntityHelper.id(asset))), hasProperty("path", is("org/foo/1.0/foo-1.0.jar"))) )); assertThat(underTest.getByPath(db, REPOSITORY_NAME, path, 1, "", emptyMap()), is(empty())); } }