added exception for storages

This commit is contained in:
Lucio Lelii 2022-11-24 14:28:46 +01:00
parent bc25fa9f33
commit 62c06a0633
2 changed files with 33 additions and 2 deletions

View File

@ -0,0 +1,28 @@
package org.gcube.common.storagehub.model.exceptions;
public class StorageIdNotFoundException extends StorageHubException {
/**
*
*/
private static final long serialVersionUID = 7225259271771357699L;
public StorageIdNotFoundException(String id, String storageName, Throwable cause) {
super(String.format("id %s not found in %s", id, storageName), cause);
}
public StorageIdNotFoundException(String id, String storageName) {
super(String.format("id %s not found in %s", id, storageName));
}
@Override
public String getErrorMessage() {
return null;
}
@Override
public int getStatus() {
return 404;
}
}

View File

@ -3,6 +3,7 @@ package org.gcube.common.storagehub.model.storages;
import java.io.InputStream;
import java.util.Map;
import org.gcube.common.storagehub.model.exceptions.StorageIdNotFoundException;
import org.gcube.common.storagehub.model.items.nodes.Content;
import org.gcube.common.storagehub.model.items.nodes.PayloadBackend;
@ -36,12 +37,14 @@ public abstract class StorageBackend {
public abstract MetaInfo upload(InputStream stream, String relativePath, String name, Long size);
public abstract InputStream download(Content item);
public abstract InputStream download(Content item) throws StorageIdNotFoundException;
public abstract InputStream download(String id);
public abstract InputStream download(String id) throws StorageIdNotFoundException;
public abstract Map<String, String> getFileMetadata(String id);
public abstract MetaInfo upload(InputStream stream, String relativePath, String name, String storageId, Long size);
@Deprecated
public abstract String getTotalSizeStored();
@Deprecated