Skipping file management for files not persisted
This commit is contained in:
parent
62a852ca40
commit
c6f8ffa4fa
|
@ -12,9 +12,13 @@ import org.gcube.gcat.utils.Constants;
|
|||
import org.gcube.storagehub.ApplicationMode;
|
||||
import org.gcube.storagehub.StorageHubManagement;
|
||||
import org.glassfish.jersey.media.multipart.ContentDisposition;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class CatalogueStorageHubManagement {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CatalogueStorageHubManagement.class);
|
||||
|
||||
protected StorageHubManagement storageHubManagement;
|
||||
|
||||
protected String originalFilename;
|
||||
|
@ -76,12 +80,18 @@ public class CatalogueStorageHubManagement {
|
|||
|
||||
protected void internalAddRevisionID(String resourceID, String revisionID) throws Exception {
|
||||
FileContainer fileContainer = storageHubManagement.getPersistedFile();
|
||||
Metadata metadata = fileContainer.get().getMetadata();
|
||||
Map<String,Object> map = metadata.getMap();
|
||||
map.put(CatalogueMetadata.CATALOGUE_RESOURCE_ID, resourceID);
|
||||
map.put(CatalogueMetadata.CATALOGUE_RESOURCE_REVISION_ID, revisionID);
|
||||
metadata.setMap(map);
|
||||
fileContainer.setMetadata(metadata);
|
||||
if(fileContainer != null) {
|
||||
Metadata metadata = fileContainer.get().getMetadata();
|
||||
Map<String,Object> map = metadata.getMap();
|
||||
map.put(CatalogueMetadata.CATALOGUE_RESOURCE_ID, resourceID);
|
||||
map.put(CatalogueMetadata.CATALOGUE_RESOURCE_REVISION_ID, revisionID);
|
||||
metadata.setMap(map);
|
||||
fileContainer.setMetadata(metadata);
|
||||
} else {
|
||||
logger.warn(
|
||||
"Unable to set revision id {} to the file of resource with id {} because the file was NOT found on storage-hub. This could be related to an item not created via gCat. Skipping it.",
|
||||
revisionID, resourceID);
|
||||
}
|
||||
}
|
||||
|
||||
public void renameFile(String resourceID, String revisionID) throws Exception {
|
||||
|
@ -106,7 +116,7 @@ public class CatalogueStorageHubManagement {
|
|||
applicationMode.end();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void getPersistedFile(String id, String mimeType) throws Exception {
|
||||
ApplicationMode applicationMode = new ApplicationMode(Constants.getCatalogueApplicationToken());
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue