added exception for storages
This commit is contained in:
parent
bc25fa9f33
commit
62c06a0633
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package org.gcube.common.storagehub.model.storages;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Map;
|
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.Content;
|
||||||
import org.gcube.common.storagehub.model.items.nodes.PayloadBackend;
|
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 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 Map<String, String> getFileMetadata(String id);
|
||||||
|
|
||||||
|
public abstract MetaInfo upload(InputStream stream, String relativePath, String name, String storageId, Long size);
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public abstract String getTotalSizeStored();
|
public abstract String getTotalSizeStored();
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
|
Loading…
Reference in New Issue