Sfoglia il codice sorgente

normalize storage errors

tags/v0.1.6
Jonathan Cobb 4 anni fa
parent
commit
4bc8ec55f7
3 ha cambiato i file con 17 aggiunte e 10 eliminazioni
  1. +10
    -7
      bubble-server/src/main/java/bubble/resources/cloud/StorageResource.java
  2. +0
    -3
      bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties
  3. +7
    -0
      bubble-server/src/main/resources/message_templates/en_US/server/pre_auth/ResourceMessages.properties

+ 10
- 7
bubble-server/src/main/java/bubble/resources/cloud/StorageResource.java Vedi File

@@ -22,8 +22,7 @@ import java.util.concurrent.atomic.AtomicReference;

import static bubble.ApiConstants.*;
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.io.FileUtil.basename;
import static org.cobbzilla.wizard.resources.ResourceUtil.*;
@@ -70,7 +69,11 @@ public class StorageResource {
if (in == null) return notFound(key);

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 : .+}")
@@ -82,7 +85,7 @@ public class StorageResource {
try {
return ok(driver.list(thisNodeUuid(), key));
} 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 {
return ok(driver.listNext(thisNodeUuid(), id));
} 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 = "";
try {
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);
}
}



+ 0
- 3
bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties Vedi File

@@ -333,8 +333,6 @@ err.key.required=Key is required
err.label.invalid=Label is invalid
err.label.length=Label is too long
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.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
@@ -450,7 +448,6 @@ err.user.exists=A user with this name already exists
err.user.noContact=No contact information provided for user
err.value.required=Value is required
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.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


+ 7
- 0
bubble-server/src/main/resources/message_templates/en_US/server/pre_auth/ResourceMessages.properties Vedi File

@@ -148,6 +148,13 @@ err.storage.noneSpecified=No Storage service was configured
err.compute.noneSpecified=No Compute service was configured
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
err.ec.param.invalid=Parameter is invalid
err.ec.fieldType.none_set=Field type was not set


Caricamento…
Annulla
Salva