Skip to content

Commit

Permalink
Rollback for JCloud
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerjmchugh committed Dec 30, 2024
1 parent c5193fa commit cd7418e
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
import jeeves.server.context.ServiceContext;

import org.apache.commons.collections.MapUtils;
import org.apache.commons.io.input.CountingInputStream;
import org.fao.geonet.ApplicationContextHolder;
import org.fao.geonet.api.exception.GeonetMaxUploadSizeExceededException;
import org.fao.geonet.api.exception.ResourceNotFoundException;
import org.fao.geonet.constants.Geonet;
import org.fao.geonet.domain.MetadataResource;
Expand All @@ -41,6 +43,7 @@
import org.fao.geonet.languages.IsoLanguagesMapper;
import org.fao.geonet.lib.Lib;
import org.fao.geonet.resources.JCloudConfiguration;
import org.fao.geonet.util.FileUtil;
import org.fao.geonet.utils.IO;
import org.fao.geonet.utils.Log;
import org.jclouds.blobstore.ContainerNotFoundException;
Expand Down Expand Up @@ -312,6 +315,14 @@ protected MetadataResource putResource(final ServiceContext context, final Strin
jCloudConfiguration.getClient().getBlobStore().putBlob(jCloudConfiguration.getContainerName(), blob, multipart());
Blob blobResults = jCloudConfiguration.getClient().getBlobStore().getBlob(jCloudConfiguration.getContainerName(), key);

if (is instanceof LimitedInputStream && ((LimitedInputStream) is).isLimitExceeded()) {
delResource(context, metadataUuid, visibility, filename, approved);
throw new GeonetMaxUploadSizeExceededException("uploadedResourceSizeExceededException")
.withMessageKey("exception.maxUploadSizeExceeded",
new String[]{FileUtil.humanizeFileSize(maxUploadSize)})
.withDescriptionKey("exception.maxUploadSizeExceededUnknownSize.description",
new String[]{FileUtil.humanizeFileSize(maxUploadSize)});
}
return createResourceDescription(context, metadataUuid, visibility, filename, blobResults.getMetadata(), metadataId, approved);
} finally {
locks.remove(key);
Expand Down

0 comments on commit cd7418e

Please sign in to comment.