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.ApplicationMode;
|
||||||
import org.gcube.storagehub.StorageHubManagement;
|
import org.gcube.storagehub.StorageHubManagement;
|
||||||
import org.glassfish.jersey.media.multipart.ContentDisposition;
|
import org.glassfish.jersey.media.multipart.ContentDisposition;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class CatalogueStorageHubManagement {
|
public class CatalogueStorageHubManagement {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(CatalogueStorageHubManagement.class);
|
||||||
|
|
||||||
protected StorageHubManagement storageHubManagement;
|
protected StorageHubManagement storageHubManagement;
|
||||||
|
|
||||||
protected String originalFilename;
|
protected String originalFilename;
|
||||||
|
@ -76,12 +80,18 @@ public class CatalogueStorageHubManagement {
|
||||||
|
|
||||||
protected void internalAddRevisionID(String resourceID, String revisionID) throws Exception {
|
protected void internalAddRevisionID(String resourceID, String revisionID) throws Exception {
|
||||||
FileContainer fileContainer = storageHubManagement.getPersistedFile();
|
FileContainer fileContainer = storageHubManagement.getPersistedFile();
|
||||||
Metadata metadata = fileContainer.get().getMetadata();
|
if(fileContainer != null) {
|
||||||
Map<String,Object> map = metadata.getMap();
|
Metadata metadata = fileContainer.get().getMetadata();
|
||||||
map.put(CatalogueMetadata.CATALOGUE_RESOURCE_ID, resourceID);
|
Map<String,Object> map = metadata.getMap();
|
||||||
map.put(CatalogueMetadata.CATALOGUE_RESOURCE_REVISION_ID, revisionID);
|
map.put(CatalogueMetadata.CATALOGUE_RESOURCE_ID, resourceID);
|
||||||
metadata.setMap(map);
|
map.put(CatalogueMetadata.CATALOGUE_RESOURCE_REVISION_ID, revisionID);
|
||||||
fileContainer.setMetadata(metadata);
|
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 {
|
public void renameFile(String resourceID, String revisionID) throws Exception {
|
||||||
|
@ -106,7 +116,7 @@ public class CatalogueStorageHubManagement {
|
||||||
applicationMode.end();
|
applicationMode.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getPersistedFile(String id, String mimeType) throws Exception {
|
public void getPersistedFile(String id, String mimeType) throws Exception {
|
||||||
ApplicationMode applicationMode = new ApplicationMode(Constants.getCatalogueApplicationToken());
|
ApplicationMode applicationMode = new ApplicationMode(Constants.getCatalogueApplicationToken());
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue