Java Code Examples for org.sonatype.nexus.repository.storage.TempBlob#close()
The following examples show how to use
org.sonatype.nexus.repository.storage.TempBlob#close() .
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: 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 2
Source File: NpmPublishRequest.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
@Override public void close() { for (TempBlob tempBlob : tempBlobs.values()) { tempBlob.close(); } }
Example 3
Source File: MavenUploadHandler.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
private UploadResponse doUpload(final Repository repository, final ComponentUpload componentUpload) throws IOException { MavenFacet facet = repository.facet(MavenFacet.class); StorageFacet storageFacet = repository.facet(StorageFacet.class); if (VersionPolicy.SNAPSHOT.equals(facet.getVersionPolicy())) { throw new ValidationErrorsException("Upload to snapshot repositories not supported, use the maven client."); } ContentAndAssetPathResponseData responseData; AssetUpload pomAsset = findPomAsset(componentUpload); //purposefully not using a try with resources, as this will only be used in case of an included pom file, which //isn't required TempBlob pom = null; try { if (pomAsset != null) { PartPayload payload = pomAsset.getPayload(); pom = storageFacet.createTempBlob(payload, HashType.ALGORITHMS); pomAsset.setPayload(new TempBlobPartPayload(payload, pom)); } String basePath = getBasePath(componentUpload, pom); doValidation(repository, basePath, componentUpload.getAssetUploads()); UnitOfWork.begin(storageFacet.txSupplier()); try { responseData = createAssets(repository, basePath, componentUpload.getAssetUploads()); if (isGeneratePom(componentUpload.getField(GENERATE_POM))) { String pomPath = generatePom(repository, basePath, componentUpload.getFields().get(GROUP_ID), componentUpload.getFields().get(ARTIFACT_ID), componentUpload.getFields().get(VERSION), componentUpload.getFields().get(PACKAGING)); responseData.addAssetPath(pomPath); } updateMetadata(repository, responseData.coordinates); } finally { UnitOfWork.end(); } return new UploadResponse(responseData.getContent(), responseData.getAssetPaths()); } finally { if (pom != null) { pom.close(); } } }