org.sonatype.nexus.repository.storage.TempBlob Java Examples
The following examples show how to use
org.sonatype.nexus.repository.storage.TempBlob.
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: AttributesParserManifest.java From nexus-repository-p2 with Eclipse Public License 1.0 | 6 votes |
@Override public P2Attributes getAttributesFromBlob(final TempBlob tempBlob, final String extension) throws IOException, AttributeParsingException { Builder p2AttributesBuilder = P2Attributes.builder(); Optional<Manifest> manifestJarEntity = manifestJarExtractor.getSpecificEntity(tempBlob, extension, MANIFEST_FILE_PREFIX); if (manifestJarEntity.isPresent()) { Attributes mainManifestAttributes = manifestJarEntity.get().getMainAttributes(); String bundleLocalizationValue = mainManifestAttributes.getValue("Bundle-Localization"); Optional<PropertyResourceBundle> propertiesOpt = propertyParser.getBundleProperties(tempBlob, extension, bundleLocalizationValue == null ? BUNDLE_PROPERTIES : bundleLocalizationValue); p2AttributesBuilder .componentName(normalizeName(propertyParser .extractValueFromProperty(mainManifestAttributes.getValue("Bundle-SymbolicName"), propertiesOpt))) .pluginName( propertyParser.extractValueFromProperty(mainManifestAttributes.getValue("Bundle-Name"), propertiesOpt)) .componentVersion( propertyParser .extractValueFromProperty(mainManifestAttributes.getValue("Bundle-Version"), propertiesOpt)); } return p2AttributesBuilder.build(); }
Example #2
Source File: MavenFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@TransactionalStoreBlob protected Content doPut(final MavenPath path, final Payload payload, final TempBlob tempBlob) throws IOException { final StorageTx tx = UnitOfWork.currentTx(); final AssetBlob assetBlob = tx.createBlob( path.getPath(), tempBlob, null, payload.getContentType(), false ); AttributesMap contentAttributes = null; if (payload instanceof Content) { contentAttributes = ((Content) payload).getAttributes(); } return doPutAssetBlob(path, contentAttributes, tx, assetBlob); }
Example #3
Source File: OrientNpmHostedFacet.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
private void putTarball(final StorageTx tx, final NpmPackageId packageId, final NestedAttributesMap packageVersion, final NestedAttributesMap attachment, final NpmPublishRequest request) throws IOException { String tarballName = NpmMetadataUtils.extractTarballName(attachment.getKey()); log.debug("Storing tarball: {}@{} ({})", packageId, packageVersion.get(NpmMetadataUtils.VERSION, String.class), tarballName); TempBlob tempBlob = request.requireBlob(attachment.require("data", String.class)); AssetBlob assetBlob = NpmFacetUtils.createTarballAssetBlob(tx, packageId, tarballName, tempBlob); NpmFacet npmFacet = facet(NpmFacet.class); npmFacet.putTarball(packageId.id(), tarballName, assetBlob, new AttributesMap()); }
Example #4
Source File: P2TempBlobUtils.java From nexus-repository-p2 with Eclipse Public License 1.0 | 6 votes |
@VisibleForTesting public P2Attributes mergeAttributesFromTempBlob(final TempBlob tempBlob, final P2Attributes sourceP2Attributes) throws IOException { checkNotNull(sourceP2Attributes.getExtension()); P2Attributes p2Attributes = null; try { // first try Features XML p2Attributes = featureXmlParser.getAttributesFromBlob(tempBlob, sourceP2Attributes.getExtension()); // second try Manifest if (p2Attributes.isEmpty()) { p2Attributes = manifestParser.getAttributesFromBlob(tempBlob, sourceP2Attributes.getExtension()); } } catch (AttributeParsingException ex) { log.warn("Could not get attributes from feature.xml due to following exception: {}", ex.getMessage()); } return Optional.ofNullable(p2Attributes) .filter(jarP2Attributes -> !jarP2Attributes.isEmpty()) .map(jarP2Attributes -> P2Attributes.builder().merge(sourceP2Attributes, jarP2Attributes).build()) .orElse(sourceP2Attributes); }
Example #5
Source File: AttributesParserFeatureXml.java From nexus-repository-p2 with Eclipse Public License 1.0 | 6 votes |
@Override public P2Attributes getAttributesFromBlob(final TempBlob tempBlob, final String extension) throws IOException, AttributeParsingException { Builder p2AttributesBuilder = P2Attributes.builder(); Optional<Document> featureXmlOpt = documentJarExtractor.getSpecificEntity(tempBlob, extension, XML_FILE_NAME); Optional<PropertyResourceBundle> propertiesOpt = propertyParser.getBundleProperties(tempBlob, extension, FEATURE_PROPERTIES); if (featureXmlOpt.isPresent()) { Document document = featureXmlOpt.get(); String pluginId = extractValueFromDocument(XML_PLUGIN_NAME_PATH, document); if (pluginId == null) { pluginId = extractValueFromDocument(XML_PLUGIN_ID_PATH, document); } String componentName = normalizeComponentName(propertyParser.extractValueFromProperty(pluginId, propertiesOpt)); p2AttributesBuilder .componentName(componentName) .pluginName( propertyParser.extractValueFromProperty(extractValueFromDocument(XML_NAME_PATH, document), propertiesOpt)) .componentVersion(extractValueFromDocument(XML_VERSION_PATH, document)); } return p2AttributesBuilder.build(); }
Example #6
Source File: RHostedFacetImpl.java From nexus-repository-r with Eclipse Public License 1.0 | 6 votes |
@Override @TransactionalTouchMetadata public Content buildAndPutPackagesGz(final String basePath) throws IOException { checkNotNull(basePath); StorageTx tx = UnitOfWork.currentTx(); RPackagesBuilder packagesBuilder = new RPackagesBuilder(); Iterable<Asset> archiveAssets = browseAllAssetsByKind(tx, tx.findBucket(getRepository()), ARCHIVE); StreamSupport.stream(archiveAssets.spliterator(), false) // packageInfoBuilder doesn't support multithreading .filter(asset -> basePath.equals(getBasePath(asset.name()))) .forEach(packagesBuilder::append); byte[] packagesBytes = packagesBuilder.buildPackagesGz(); StorageFacet storageFacet = getRepository().facet(StorageFacet.class); try (InputStream is = new ByteArrayInputStream(packagesBytes)) { TempBlob tempPackagesGz = storageFacet.createTempBlob(is, RFacetUtils.HASH_ALGORITHMS); return doPutPackagesGz(tx, basePath, tempPackagesGz); } }
Example #7
Source File: JarExtractor.java From nexus-repository-p2 with Eclipse Public License 1.0 | 6 votes |
protected Optional<T> getSpecificEntity( final TempBlob tempBlob, final String extension, @Nullable final String startNameForSearch) throws IOException, AttributeParsingException { try (JarInputStream jis = getJarStreamFromBlob(tempBlob, extension)) { JarEntry jarEntry; while ((jarEntry = jis.getNextJarEntry()) != null) { if (startNameForSearch != null && jarEntry.getName().startsWith(startNameForSearch)) { return Optional.ofNullable(createSpecificEntity(jis, jarEntry)); } } } return Optional.empty(); }
Example #8
Source File: OrientNpmProxyFacet.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
private Content putPackageRoot(final NpmPackageId packageId, final TempBlob tempBlob, final Content payload) throws IOException { checkNotNull(packageId); checkNotNull(payload); checkNotNull(tempBlob); NestedAttributesMap packageRoot = NpmFacetUtils.parse(tempBlob); try { return doPutPackageRoot(packageId, packageRoot, payload, true); } catch (RetryDeniedException | MissingBlobException e) { return maybeHandleMissingBlob(e, packageId, packageRoot, payload); } }
Example #9
Source File: OrientNpmHostedFacet.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@TransactionalStoreBlob protected Asset putPackage(final NpmPackageId packageId, final NestedAttributesMap requestPackageRoot, final TempBlob tarballTempBlob) throws IOException { checkNotNull(packageId); checkNotNull(requestPackageRoot); checkNotNull(tarballTempBlob); log.debug("Storing package: {}", packageId); StorageTx tx = UnitOfWork.currentTx(); String tarballName = NpmMetadataUtils.extractTarballName(requestPackageRoot); AssetBlob assetBlob = NpmFacetUtils.createTarballAssetBlob(tx, packageId, tarballName, tarballTempBlob); NpmFacet npmFacet = facet(NpmFacet.class); Asset asset = npmFacet.putTarball(packageId.id(), tarballName, assetBlob, new AttributesMap()); putPackageRoot(packageId, null, requestPackageRoot); return asset; }
Example #10
Source File: ConanProxyFacet.java From nexus-repository-conan with Eclipse Public License 1.0 | 6 votes |
private Content putMetadata(final Context context, final Content content, final AssetKind assetKind, final ConanCoords coords) throws IOException { StorageFacet storageFacet = facet(StorageFacet.class); try (TempBlob tempBlob = storageFacet.createTempBlob(content.openInputStream(), HASH_ALGORITHMS)) { if (assetKind == DOWNLOAD_URL || assetKind == DIGEST) { Content saveMetadata = doSaveMetadata(tempBlob, content, assetKind, coords); return new Content( new StringPayload( conanUrlIndexer.updateAbsoluteUrls(context, saveMetadata, getRepository()), ContentTypes.APPLICATION_JSON) ); } return doSaveMetadata(tempBlob, content, assetKind, coords); } }
Example #11
Source File: NpmRequestParser.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
/** * Parses an incoming "npm publish" or "npm unpublish" request, returning the results. Note that you should probably * call this from within a try-with-resources block to manage the lifecycle of any temp blobs created during the * operation. */ public NpmPublishRequest parsePublish(final Repository repository, final Payload payload) throws IOException { checkNotNull(repository); checkNotNull(payload); StorageFacet storageFacet = repository.facet(StorageFacet.class); try (TempBlob tempBlob = storageFacet.createTempBlob(payload, NpmFacetUtils.HASH_ALGORITHMS)) { try { return parseNpmPublish(storageFacet, tempBlob, UTF_8); } catch (JsonParseException e) { // fallback if (e.getMessage().contains("Invalid UTF-8")) { // try again, but assume ISO8859-1 encoding now, that is illegal for JSON return parseNpmPublish(storageFacet, tempBlob, ISO_8859_1); } throw new InvalidContentException("Invalid JSON input", e); } } }
Example #12
Source File: ConanProxyFacet.java From nexus-repository-conan with Eclipse Public License 1.0 | 6 votes |
@TransactionalStoreBlob protected Content doSaveMetadata(final TempBlob metadataContent, final Payload payload, final AssetKind assetKind, final ConanCoords coords) throws IOException { HashCode hash = null; StorageTx tx = UnitOfWork.currentTx(); Bucket bucket = tx.findBucket(getRepository()); Component component = getOrCreateComponent(tx, bucket, coords); String assetPath = getProxyAssetPath(coords, assetKind); Asset asset = findAsset(tx, bucket, assetPath); if (asset == null) { asset = tx.createAsset(bucket, component); asset.name(assetPath); asset.formatAttributes().set(P_ASSET_KIND, assetKind.name()); hash = hashVerifier.lookupHashFromAsset(tx, bucket, assetPath); } else if (!asset.componentId().equals(EntityHelper.id(component))) { asset.componentId(EntityHelper.id(component)); } return saveAsset(tx, asset, metadataContent, payload, hash); }
Example #13
Source File: OrientNpmUploadHandlerTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Before public void setup() throws IOException, URISyntaxException { when(contentPermissionChecker.isPermitted(eq(REPO_NAME), eq(NpmFormat.NAME), eq(BreadActions.EDIT), any())) .thenReturn(true); underTest = new OrientNpmUploadHandler(contentPermissionChecker, new SimpleVariableResolverAdapter(), new NpmPackageParser(), emptySet()); when(repository.facet(NpmHostedFacet.class)).thenReturn(npmFacet); packageJson = new File(OrientNpmUploadHandlerTest.class.getResource("../internal/package.json").toURI()); when(storageFacet.createTempBlob(any(PartPayload.class), any())).thenAnswer(invocation -> { TempBlob blob = mock(TempBlob.class); when(blob.get()).thenAnswer(i -> ArchiveUtils.pack(tempFolder.newFile(), packageJson, "package/package.json")); return blob; }); when(storageFacet.txSupplier()).thenReturn(() -> storageTx); when(repository.facet(StorageFacet.class)).thenReturn(storageFacet); when(repository.getName()).thenReturn(REPO_NAME); Asset asset = mock(Asset.class); when(asset.componentId()).thenReturn(new DetachedEntityId("nuId")); when(asset.name()).thenReturn("@foo/bar/-/bar/bar-123.gz"); when(npmFacet.putPackage(any(), any())).thenReturn(asset); }
Example #14
Source File: MavenFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Override public Content put(final MavenPath path, final Payload payload) throws IOException { log.debug("PUT {} : {}", getRepository().getName(), path.getPath()); try (TempBlob tempBlob = storageFacet.createTempBlob(payload, HashType.ALGORITHMS)) { if (path.getFileName().equals(METADATA_FILENAME) && mavenMetadataValidationEnabled) { log.debug("Validating maven-metadata.xml before storing"); try { metadataValidator.validate(path.getPath(), tempBlob.get()); } catch (InvalidContentException e) { log.warn(e.toString()); return Optional.ofNullable(get(path)).orElseThrow(() -> e); } } return doPut(path, payload, tempBlob); } }
Example #15
Source File: GolangDataAccess.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
/** * Save an asset and create blob. * * @return blob content */ @TransactionalStoreBlob public Content maybeCreateAndSaveAsset(final Repository repository, final String assetPath, final AssetKind assetKind, final TempBlob tempBlob, final Payload payload) throws IOException { StorageTx tx = UnitOfWork.currentTx(); Bucket bucket = tx.findBucket(repository); Asset asset = findAsset(tx, bucket, assetPath); if (asset == null) { asset = tx.createAsset(bucket, repository.getFormat()); asset.name(assetPath); asset.formatAttributes().set(P_ASSET_KIND, assetKind.name()); } return saveAsset(tx, asset, tempBlob, payload); }
Example #16
Source File: CreateIndexServiceImplTest.java From nexus-repository-helm with Eclipse Public License 1.0 | 6 votes |
@Test public void testBuildIndexYaml() throws Exception { List<Asset> list = Arrays.asList(asset); when(asset.formatAttributes()).thenReturn(formatAttributes); when(asset.attributes()).thenReturn(assetAttributes); when(asset.componentId()).thenReturn(entityId); Map<String, String> shaMap = new HashMap<>(); shaMap.put("sha256", "12345"); when(assetAttributes.get("checksum", Map.class)).thenReturn(shaMap); when(helmFacet.browseComponentAssets(storageTx, AssetKind.HELM_PACKAGE)).thenReturn(list); when(indexYamlBuilder.build(anyObject(), anyObject())).thenReturn(tempBlob); TempBlob result = underTest.buildIndexYaml(repository); assertThat(result, is(notNullValue())); }
Example #17
Source File: P2ProxyFacetImpl.java From nexus-repository-p2 with Eclipse Public License 1.0 | 6 votes |
@TransactionalStoreBlob protected Content saveMetadataAsAsset(final String assetPath, final TempBlob metadataContent, final Payload payload, final AssetKind assetKind) throws IOException { StorageTx tx = UnitOfWork.currentTx(); Bucket bucket = tx.findBucket(getRepository()); Asset asset = facet(P2Facet.class).findAsset(tx, bucket, assetPath); if (asset == null) { asset = tx.createAsset(bucket, getRepository().getFormat()); asset.name(assetPath); asset.formatAttributes().set(P_ASSET_KIND, assetKind.name()); } return facet(P2Facet.class).saveAsset(tx, asset, metadataContent, payload); }
Example #18
Source File: HelmHostedFacetImpl.java From nexus-repository-helm with Eclipse Public License 1.0 | 6 votes |
@Override @TransactionalStoreBlob public Asset upload(String path, TempBlob tempBlob, Payload payload, AssetKind assetKind) throws IOException { checkNotNull(path); checkNotNull(tempBlob); if (assetKind != HELM_PACKAGE && assetKind != HELM_PROVENANCE) { throw new IllegalArgumentException("Unsupported assetKind: " + assetKind); } StorageTx tx = UnitOfWork.currentTx(); InputStream inputStream = tempBlob.get(); HelmAttributes attributes = helmAttributeParser.getAttributes(assetKind, inputStream); final Asset asset = helmFacet.findOrCreateAsset(tx, path, assetKind, attributes); helmFacet.saveAsset(tx, asset, tempBlob, payload); return asset; }
Example #19
Source File: OrientPyPiHostedFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
private Asset createIndexAsset(final String name, final StorageTx tx, final String indexPath, final Bucket bucket) throws IOException { String html = buildIndex(name, tx); Asset savedIndex = tx.createAsset(bucket, getRepository().getFormat()); savedIndex.name(indexPath); savedIndex.formatAttributes().set(P_ASSET_KIND, AssetKind.INDEX.name()); StorageFacet storageFacet = getRepository().facet(StorageFacet.class); TempBlob tempBlob = storageFacet.createTempBlob(new ByteArrayInputStream(html.getBytes(UTF_8)), HASH_ALGORITHMS); saveAsset(tx, savedIndex, tempBlob, TEXT_HTML, new AttributesMap()); return savedIndex; }
Example #20
Source File: NpmFacetUtils.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
/** * Creates an {@link AssetBlob} out of passed in temporary blob and attaches it to passed in {@link Asset}. */ @Nonnull static AssetBlob storeContent(final StorageTx tx, final Asset asset, final TempBlob tempBlob, final AssetKind assetKind) throws IOException { asset.formatAttributes().set(P_ASSET_KIND, assetKind.name()); AssetBlob result = tx.createBlob( asset.name(), tempBlob, null, assetKind.getContentType(), assetKind.isSkipContentVerification() ); tx.attachBlob(asset, result); return result; }
Example #21
Source File: OrientMavenTestHelper.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Override public void writeWithoutValidation( final Repository repository, final String path, final Payload payload) throws IOException { final MavenFacet mavenFacet = repository.facet(MavenFacet.class); final StorageFacet storageFacet = repository.facet(StorageFacet.class); final MavenPath mavenPath = mavenFacet.getMavenPathParser().parsePath(path); UnitOfWork.begin(repository.facet(StorageFacet.class).txSupplier()); try { try (TempBlob tempBlob = storageFacet.createTempBlob(payload, HashType.ALGORITHMS)) { mavenFacet.put(mavenPath, tempBlob, MavenMimeRulesSource.METADATA_TYPE, new AttributesMap()); } } finally { UnitOfWork.end(); } }
Example #22
Source File: NpmPublishParser.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
/** * Parses the {@code JsonParser}'s content into a {@code NpmPublishOrDeleteRequest}. Temp blobs will be created if * necessary using the {@code StorageFacet} and with the provided {@code HashAlgorithm}s. * * This method will manage the temp blobs for the lifetime of the parse operation (and will dispose accordingly in * event of a failure). After returning, the parsed result must be managed carefully so as not to leak temp blobs. * @param currentUserId currently logged in userId */ public NpmPublishRequest parse(@Nullable final String currentUserId) throws IOException { try { NestedAttributesMap packageRoot = parsePackageRoot(); if(currentUserId != null && !currentUserId.isEmpty()) { updateMaintainer(packageRoot, currentUserId); } return new NpmPublishRequest(packageRoot, tempBlobs); } catch (Throwable t) { //NOSONAR for (TempBlob tempBlob : tempBlobs.values()) { tempBlob.close(); } throw t; } }
Example #23
Source File: OrientPyPiProxyFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@TransactionalStoreBlob protected Content doPutIndex(final String name, final TempBlob tempBlob, final Payload payload, final Map<String, Object> attributes) throws IOException { StorageTx tx = UnitOfWork.currentTx(); Bucket bucket = tx.findBucket(getRepository()); Asset asset = findAsset(tx, bucket, name); if (asset == null) { asset = tx.createAsset(bucket, getRepository().getFormat()); asset.name(name); } if (attributes != null) { for (Entry<String, Object> entry : attributes.entrySet()) { asset.formatAttributes().set(entry.getKey(), entry.getValue()); } } return saveAsset(tx, asset, tempBlob, payload); }
Example #24
Source File: NpmTokenFacetImplTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void failedLoginTest() throws Exception { // mocks final Context contextMocked = mock(Context.class); final Request requestMocked = mock(Request.class); final Payload payloadMocked = mock(Payload.class); final TempBlob tempBlob = mock(TempBlob.class); // data final String someJson = "{\"name\":\"name\",\"password\":\"password\"}"; // behaviors when(contextMocked.getRequest()).thenReturn(requestMocked); when(requestMocked.getPayload()).thenReturn(payloadMocked); when(storageFacet.createTempBlob(eq(payloadMocked), any())).thenReturn(tempBlob); when(tempBlob.get()).thenReturn(new ByteArrayInputStream(someJson.getBytes(StandardCharsets.UTF_8))); when(npmTokenManager.login("name", "password")).thenReturn(null); // test Response response = underTest.login(contextMocked); // checks assertThat("login call should have returned a value", response, notNullValue() ); verify(npmTokenManager).login("name", "password"); assertThat("expecting a 401 for the status", response.getStatus().getCode(), is(401)); }
Example #25
Source File: IndexYamlAbsoluteUrlRewriterTest.java From nexus-repository-helm with Eclipse Public License 1.0 | 5 votes |
@Test public void checkCustomUrls() throws Exception { setupIndexMock(INDEX_YAML_WITH_CUSTOM_URL); TempBlob newTempBlob = underTest.removeUrlsFromIndexYamlAndWriteToTempBlob(tempBlob, repository); assertThat(newTempBlob.get(), is(instanceOf(InputStream.class))); checkThatAbsoluteUrlRemoved(newTempBlob.get()); }
Example #26
Source File: CreateIndexServiceImplTest.java From nexus-repository-helm with Eclipse Public License 1.0 | 5 votes |
@Test public void testIndexYamlBuiltEvenWhenNoAssets() throws Exception { when(assets.iterator()).thenReturn(assetIterator); when(assetIterator.next()).thenReturn(asset); when(asset.componentId()).thenReturn(null); when(helmFacet.browseComponentAssets(storageTx, AssetKind.HELM_PACKAGE)).thenReturn(assets); when(indexYamlBuilder.build(anyObject(), anyObject())).thenReturn(tempBlob); TempBlob result = underTest.buildIndexYaml(repository); assertThat(result, is(notNullValue())); }
Example #27
Source File: OrientNpmProxyFacet.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
private Content putTarball(final NpmPackageId packageId, final String tarballName, final TempBlob tempBlob, final Content content, final Context context) throws IOException { checkNotNull(packageId); checkNotNull(tarballName); checkNotNull(tempBlob); checkNotNull(content); checkNotNull(context); return doPutTarball(packageId, tarballName, tempBlob, content); }
Example #28
Source File: IndexYamlBuilderTest.java From nexus-repository-helm with Eclipse Public License 1.0 | 5 votes |
@Test public void testChartIndexPassedCorrectly() throws Exception { ArgumentCaptor<InputStream> captorStorage = ArgumentCaptor.forClass(InputStream.class); ArgumentCaptor<ChartIndex> captor = ArgumentCaptor.forClass(ChartIndex.class); TempBlob tempBlob = underTest.build(index, storageFacet); verify(storageFacet).createTempBlob(captorStorage.capture(), eq(HASH_ALGORITHMS)); verify(yamlParser).write(any(OutputStream.class), captor.capture()); assertEquals(index, captor.getValue()); }
Example #29
Source File: NpmFacetUtils.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
/** * Creates an {@code AssetBlob} from a tarball's {@code TempBlob}. * * @since 3.7 */ static AssetBlob createTarballAssetBlob(final StorageTx tx, final NpmPackageId packageId, final String tarballName, final TempBlob tempBlob) throws IOException { return tx.createBlob( tarballAssetName(packageId, tarballName), tempBlob, null, TARBALL.getContentType(), TARBALL.isSkipContentVerification() ); }
Example #30
Source File: OrientPyPiHostedFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
protected Asset savePyPiWheelPayload( final String filename, final Map<String, String> attributes, final TempBlobPartPayload wheelPayload) throws IOException { checkNotNull(filename); TempBlob tempBlob = wheelPayload.getTempBlob(); final String name = checkNotNull(attributes.get(P_NAME)); final String version = checkNotNull(attributes.get(P_VERSION)); final String normalizedName = normalizeName(name); validateMd5Hash(attributes, tempBlob); PyPiIndexFacet indexFacet = facet(PyPiIndexFacet.class); // A package has been added or redeployed and therefore the cached index is no longer relevant indexFacet.deleteIndex(name); StorageTx tx = UnitOfWork.currentTx(); Bucket bucket = tx.findBucket(getRepository()); String packagePath = createPackagePath(name, version, filename); Component component = findOrCreateComponent(name, version, normalizedName, indexFacet, tx, bucket); component.formatAttributes().set(P_SUMMARY, attributes.get(P_SUMMARY)); // use the most recent summary received? tx.saveComponent(component); Asset asset = findOrCreateAsset(tx, bucket, packagePath, component, AssetKind.PACKAGE.name()); copyAttributes(asset, attributes); saveAsset(tx, asset, tempBlob, wheelPayload); return asset; }