@@ -22,8 +22,7 @@ import java.util.concurrent.atomic.AtomicReference; | |||||
import static bubble.ApiConstants.*; | import static bubble.ApiConstants.*; | ||||
import static javax.ws.rs.core.MediaType.MULTIPART_FORM_DATA; | import static javax.ws.rs.core.MediaType.MULTIPART_FORM_DATA; | ||||
import static org.cobbzilla.util.daemon.ZillaRuntime.die; | |||||
import static org.cobbzilla.util.daemon.ZillaRuntime.empty; | |||||
import static org.cobbzilla.util.daemon.ZillaRuntime.*; | |||||
import static org.cobbzilla.util.http.HttpContentTypes.*; | import static org.cobbzilla.util.http.HttpContentTypes.*; | ||||
import static org.cobbzilla.util.io.FileUtil.basename; | import static org.cobbzilla.util.io.FileUtil.basename; | ||||
import static org.cobbzilla.wizard.resources.ResourceUtil.*; | import static org.cobbzilla.wizard.resources.ResourceUtil.*; | ||||
@@ -70,7 +69,11 @@ public class StorageResource { | |||||
if (in == null) return notFound(key); | if (in == null) return notFound(key); | ||||
final String contentType = metadata.hasContentType() ? metadata.getContentType() : APPLICATION_OCTET_STREAM; | final String contentType = metadata.hasContentType() ? metadata.getContentType() : APPLICATION_OCTET_STREAM; | ||||
return stream(contentType, in); | |||||
try { | |||||
return stream(contentType, in); | |||||
} catch (Exception e) { | |||||
return invalid("err.read.failed", "read failed for prefix: "+key, key); | |||||
} | |||||
} | } | ||||
@GET @Path(EP_LIST+"/{key : .+}") | @GET @Path(EP_LIST+"/{key : .+}") | ||||
@@ -82,7 +85,7 @@ public class StorageResource { | |||||
try { | try { | ||||
return ok(driver.list(thisNodeUuid(), key)); | return ok(driver.list(thisNodeUuid(), key)); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
return invalid("err.list.failed", "listing failed for prefix: "+key); | |||||
return invalid("err.list.failed", "listing failed for prefix: "+key, key); | |||||
} | } | ||||
} | } | ||||
@@ -95,7 +98,7 @@ public class StorageResource { | |||||
try { | try { | ||||
return ok(driver.listNext(thisNodeUuid(), id)); | return ok(driver.listNext(thisNodeUuid(), id)); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
return invalid("err.listNext.failed", "listing failed for id: "+id); | |||||
return invalid("err.listNext.failed", "listing failed for id: "+id, id); | |||||
} | } | ||||
} | } | ||||
@@ -125,8 +128,8 @@ public class StorageResource { | |||||
if (key.equals("*")) key = ""; | if (key.equals("*")) key = ""; | ||||
try { | try { | ||||
return ok(getStorageDriver().get().delete(thisNodeUuid(), key)); | return ok(getStorageDriver().get().delete(thisNodeUuid(), key)); | ||||
} catch (IOException e) { | |||||
return die("delete: "+e, e); | |||||
} catch (Exception e) { | |||||
return invalid("err.delete.failed", "delete operation failed for key: "+key+": "+shortError(e), key); | |||||
} | } | ||||
} | } | ||||
@@ -333,8 +333,6 @@ err.key.required=Key is required | |||||
err.label.invalid=Label is invalid | err.label.invalid=Label is invalid | ||||
err.label.length=Label is too long | err.label.length=Label is too long | ||||
err.latlon.invalid=lat/lon is invalid | err.latlon.invalid=lat/lon is invalid | ||||
err.list.failed=listing failed for prefix | |||||
err.listNext.failed=listing next batch failed for id | |||||
err.name.invalid=Name is invalid | err.name.invalid=Name is invalid | ||||
err.name.regexFailed=Name must start with a letter and can only contain letters, numbers, hyphens, periods and underscores | err.name.regexFailed=Name must start with a letter and can only contain letters, numbers, hyphens, periods and underscores | ||||
err.node.name.alreadyExists=A node already exists with the same FQDN | err.node.name.alreadyExists=A node already exists with the same FQDN | ||||
@@ -450,7 +448,6 @@ err.user.exists=A user with this name already exists | |||||
err.user.noContact=No contact information provided for user | err.user.noContact=No contact information provided for user | ||||
err.value.required=Value is required | err.value.required=Value is required | ||||
err.version.mismatch=Version in URL does not match version in object | err.version.mismatch=Version in URL does not match version in object | ||||
err.write.failed=Write operation failed for key | |||||
err.entity.classInFilename.invalid=Type of object could not be determined from filename. The part before the first dot or underscore should be a valid type name | err.entity.classInFilename.invalid=Type of object could not be determined from filename. The part before the first dot or underscore should be a valid type name | ||||
err.entity.filenameExtension.invalid=The object file must be a JSON file containing one or more objects, or a Model Archive File (ending in .zip, .tar.gz, or .tgz) containing a manifest and corresponding object files. | err.entity.filenameExtension.invalid=The object file must be a JSON file containing one or more objects, or a Model Archive File (ending in .zip, .tar.gz, or .tgz) containing a manifest and corresponding object files. | ||||
err.entity.fileZipFormat.invalid=The Model Archive File was not in a readable format | err.entity.fileZipFormat.invalid=The Model Archive File was not in a readable format | ||||
@@ -148,6 +148,13 @@ err.storage.noneSpecified=No Storage service was configured | |||||
err.compute.noneSpecified=No Compute service was configured | err.compute.noneSpecified=No Compute service was configured | ||||
err.cloud.localStorageIsReservedName=LocalStorage is a reserved name | err.cloud.localStorageIsReservedName=LocalStorage is a reserved name | ||||
# Storage driver errors | |||||
err.read.failed=read failed for key | |||||
err.list.failed=listing failed for prefix | |||||
err.listNext.failed=listing next batch failed for id | |||||
err.write.failed=Write operation failed for key | |||||
err.delete.failed=Delete operation failed for key | |||||
# Entity config errors | # Entity config errors | ||||
err.ec.param.invalid=Parameter is invalid | err.ec.param.invalid=Parameter is invalid | ||||
err.ec.fieldType.none_set=Field type was not set | err.ec.fieldType.none_set=Field type was not set | ||||