Java Code Examples for org.sonatype.nexus.repository.view.Content#extractFromAsset()
The following examples show how to use
org.sonatype.nexus.repository.view.Content#extractFromAsset() .
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: NpmFacetUtils.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
/** * Returns the tarball content. */ @Nullable static Content getTarballContent(final StorageTx tx, final Bucket bucket, final NpmPackageId packageId, final String tarballName) { Asset asset = findTarballAsset(tx, bucket, packageId, tarballName); if (asset == null) { return null; } Blob blob = tx.requireBlob(asset.requireBlobRef()); Content content = new Content(new BlobPayload(blob, asset.requireContentType())); Content.extractFromAsset(asset, HASH_ALGORITHMS, content.getAttributes()); return content; }
Example 2
Source File: OrientPyPiGroupFacet.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@TransactionalStoreBlob public Content saveToCache(final String name, final Content content) throws IOException { StorageTx tx = UnitOfWork.currentTx(); Asset asset = getAsset(tx, name); AttributesMap contentAttributes = Content.maintainLastModified(asset, null); contentAttributes.set(CacheInfo.class, cacheController.current()); Content.applyToAsset(asset, contentAttributes); AssetBlob blob = updateAsset(tx, asset, content); Content response = new Content(new BlobPayload(blob.getBlob(), ContentTypes.TEXT_HTML)); Content.extractFromAsset(asset, HASH_ALGORITHMS, response.getAttributes()); return response; }
Example 3
Source File: P2FacetImpl.java From nexus-repository-p2 with Eclipse Public License 1.0 | 5 votes |
/** * Convert an asset blob to {@link Content}. * * @return content of asset blob */ @Override public Content toContent(final Asset asset, final Blob blob) { Content content = new Content(new BlobPayload(blob, asset.requireContentType())); Content.extractFromAsset(asset, HASH_ALGORITHMS, content.getAttributes()); return content; }
Example 4
Source File: CocoapodsFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Override @TransactionalStoreBlob public Content getOrCreateAsset(final String path, final Content content, boolean toAttachComponent) throws IOException { StorageFacet storageFacet = facet(StorageFacet.class); try (final TempBlob tempBlob = storageFacet.createTempBlob(content, HASH_ALGORITHMS)) { StorageTx tx = UnitOfWork.currentTx(); Bucket bucket = tx.findBucket(getRepository()); Asset asset = tx.findAssetWithProperty(P_NAME, path, bucket); if (asset == null) { if (toAttachComponent) { Component component = findOrCreateComponent(tx, bucket, path); asset = tx.createAsset(bucket, component).name(path); } else { asset = tx.createAsset(bucket, getRepository().getFormat()).name(path); } } Content.applyToAsset(asset, content.getAttributes()); AssetBlob blob = tx.setBlob(asset, path, tempBlob, HASH_ALGORITHMS, null, null, false); tx.saveAsset(asset); final Content updatedContent = new Content(new BlobPayload(blob.getBlob(), asset.requireContentType())); Content.extractFromAsset(asset, HASH_ALGORITHMS, updatedContent.getAttributes()); return updatedContent; } }
Example 5
Source File: CocoapodsFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Override @Nullable @TransactionalTouchBlob public Content get(final String path) { final StorageTx tx = UnitOfWork.currentTx(); final Asset asset = tx.findAssetWithProperty(P_NAME, path, tx.findBucket(getRepository())); if (asset == null) { return null; } Content content = new Content(new BlobPayload(tx.requireBlob(asset.requireBlobRef()), asset.requireContentType())); Content.extractFromAsset(asset, HASH_ALGORITHMS, content.getAttributes()); return content; }
Example 6
Source File: CondaFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Override public Content toContent(final Asset asset, final Blob blob) { Content content = new Content(new BlobPayload(blob, asset.requireContentType())); Content.extractFromAsset(asset, HASH_ALGORITHMS, content.getAttributes()); return content; }
Example 7
Source File: DeconflictAssetMetadataTest.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
private DateTime getLastModified(final Asset asset) { AttributesMap contentAttributes = new AttributesMap(); Content.extractFromAsset(asset, ImmutableList.of(), contentAttributes); return contentAttributes.get(CONTENT_LAST_MODIFIED, DateTime.class); }
Example 8
Source File: ComposerContentFacetImpl.java From nexus-repository-composer with Eclipse Public License 1.0 | 4 votes |
private Content toContent(final Asset asset, final Blob blob) { final Content content = new Content(new BlobPayload(blob, asset.requireContentType())); Content.extractFromAsset(asset, hashAlgorithms, content.getAttributes()); return content; }
Example 9
Source File: DeconflictAssetMetadataTest.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
@Before public void setUp() { BucketEntityAdapter bucketEntityAdapter = new BucketEntityAdapter(); ComponentFactory componentFactory = new ComponentFactory(emptySet()); componentEntityAdapter = new ComponentEntityAdapter(bucketEntityAdapter, componentFactory, emptySet()); assetEntityAdapter = new AssetEntityAdapter(bucketEntityAdapter, componentEntityAdapter); ConflictHook conflictHook = new ConflictHook(true); componentEntityAdapter.enableConflictHook(conflictHook); assetEntityAdapter.enableConflictHook(conflictHook); assetEntityAdapter.setDeconflictSteps(asList(new DeconflictAssetMetadata())); try (ODatabaseDocumentTx db = database.getInstance().connect()) { bucketEntityAdapter.register(db); componentEntityAdapter.register(db); assetEntityAdapter.register(db); bucket = new Bucket(); bucket.attributes(new NestedAttributesMap(P_ATTRIBUTES, new HashMap<>())); bucket.setRepositoryName("test-repo"); bucketEntityAdapter.addEntity(db, bucket); } // first create our test component+asset with some default values try (ODatabaseDocumentTx db = database.getInstance().acquire()) { db.begin(); component = createComponent(bucket, "some-group", "some-component", "1.0"); componentEntityAdapter.addEntity(db, component); asset = createAsset(bucket, "some-asset", component); initialAssetRecord = assetEntityAdapter.addEntity(db, asset); db.commit(); } // update the asset, so it moves on from the initial record try (ODatabaseDocumentTx db = database.getInstance().acquire()) { db.begin(); Content.extractFromAsset(asset, ImmutableList.of(), new AttributesMap()); CacheInfo.extractFromAsset(asset); asset.attributes().child("test").set("test-asset-key", "test-asset-value"); assetEntityAdapter.readFields(assetEntityAdapter.editEntity(db, asset), asset); db.commit(); } }
Example 10
Source File: FacetHelper.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
public static Content toContent(final Asset asset, final Blob blob) { final Content content = new Content(new BlobPayload(blob, asset.requireContentType())); Content.extractFromAsset(asset, hashAlgorithms, content.getAttributes()); return content; }
Example 11
Source File: MavenFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
private Content toContent(final Asset asset, final Blob blob) { final String contentType = asset.contentType(); final Content content = new Content(new BlobPayload(blob, contentType)); Content.extractFromAsset(asset, HashType.ALGORITHMS, content.getAttributes()); return content; }
Example 12
Source File: GolangDataAccess.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
/** * Convert an asset blob to {@link Content}. * * @return content of asset blob */ public Content toContent(final Asset asset, final Blob blob) { Content content = new Content(new BlobPayload(blob, asset.requireContentType())); Content.extractFromAsset(asset, HASH_ALGORITHMS, content.getAttributes()); return content; }
Example 13
Source File: RawContentFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
private Content toContent(final Asset asset, final Blob blob) { final Content content = new Content(new BlobPayload(blob, asset.requireContentType())); Content.extractFromAsset(asset, hashAlgorithms, content.getAttributes()); return content; }
Example 14
Source File: OrientPyPiDataUtils.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
/** * Convert an asset blob to {@link Content}. * * @return content of asset blob */ static Content toContent(final Asset asset, final Blob blob) { Content content = new Content(new BlobPayload(blob, asset.requireContentType())); Content.extractFromAsset(asset, HASH_ALGORITHMS, content.getAttributes()); return content; }
Example 15
Source File: NpmFacetUtils.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
/** * Convert an asset blob to {@link Content}. * * @return content of asset blob */ public static Content toContent(final Asset asset, final Blob blob) { Content content = new Content(new BlobPayload(blob, asset.requireContentType())); Content.extractFromAsset(asset, HASH_ALGORITHMS, content.getAttributes()); return content; }
Example 16
Source File: FacetHelper.java From nexus-repository-apt with Eclipse Public License 1.0 | 4 votes |
public static Content toContent(final Asset asset, final Blob blob) { final Content content = new Content(new BlobPayload(blob, asset.requireContentType())); Content.extractFromAsset(asset, hashAlgorithms, content.getAttributes()); return content; }
Example 17
Source File: ConanProxyFacet.java From nexus-repository-conan with Eclipse Public License 1.0 | 4 votes |
static Content toContent(final Asset asset, final Blob blob) { Content content = new Content(new BlobPayload(blob, asset.requireContentType())); Content.extractFromAsset(asset, HASH_ALGORITHMS, content.getAttributes()); return content; }
Example 18
Source File: RFacetUtils.java From nexus-repository-r with Eclipse Public License 1.0 | 4 votes |
/** * Convert an asset blob to {@link Content}. * * @return content of asset blob */ public static Content toContent(final Asset asset, final Blob blob) { Content content = new Content(new BlobPayload(blob, asset.requireContentType())); Content.extractFromAsset(asset, HASH_ALGORITHMS, content.getAttributes()); return content; }
Example 19
Source File: HelmFacetImpl.java From nexus-repository-helm with Eclipse Public License 1.0 | 4 votes |
/** * Convert an asset blob to {@link Content}. * * @return content of asset blob */ public Content toContent(final Asset asset, final Blob blob) { Content content = new Content(new BlobPayload(blob, asset.requireContentType())); Content.extractFromAsset(asset, HASH_ALGORITHMS, content.getAttributes()); return content; }
Example 20
Source File: NpmFacetUtils.java From nexus-public with Eclipse Public License 1.0 | 3 votes |
/** * Convert an {@link Asset} representing a package root to a {@link Content} via a {@link StreamPayload}. * * @param repository {@link Repository} to look up package root from. * @param packageRootAsset {@link Asset} associated with blob holding package root. * @return Content of asset blob */ public static NpmContent toContent(final Repository repository, final Asset packageRootAsset) { NpmContent content = new NpmContent(toPayload(repository, packageRootAsset)); Content.extractFromAsset(packageRootAsset, HASH_ALGORITHMS, content.getAttributes()); return content; }