Commit 58dce4c6 by Aaron Dossett

add check for empty string

parent 589c2a65
...@@ -43,6 +43,7 @@ import org.codehaus.jettison.json.JSONException; ...@@ -43,6 +43,7 @@ import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject; import org.codehaus.jettison.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import scala.tools.cmd.Meta;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
...@@ -90,14 +91,14 @@ public class DefaultMetadataService implements MetadataService { ...@@ -90,14 +91,14 @@ public class DefaultMetadataService implements MetadataService {
public JSONObject createType(String typeDefinition) throws MetadataException { public JSONObject createType(String typeDefinition) throws MetadataException {
try { try {
Preconditions.checkNotNull(typeDefinition, "type definition cannot be null"); Preconditions.checkNotNull(typeDefinition, "type definition cannot be null");
Preconditions.checkArgument(!typeDefinition.equals(""), "type definition cannot be an empty string");
TypesDef typesDef = TypesSerialization.fromJson(typeDefinition); TypesDef typesDef = TypesSerialization.fromJson(typeDefinition);
Map<String, IDataType> typesAdded = typeSystem.defineTypes(typesDef); if(typesDef.classTypesAsJavaList().size() == 0)
//TODO A more elegant way to detect failures?
if (typesAdded.size() == 0)
throw new MetadataException("Invalid type definition"); throw new MetadataException("Invalid type definition");
Map<String, IDataType> typesAdded = typeSystem.defineTypes(typesDef);
//TODO how do we handle transaction - store failure?? //TODO how do we handle transaction - store failure??
typeStore.store(typeSystem, ImmutableList.copyOf(typesAdded.keySet())); typeStore.store(typeSystem, ImmutableList.copyOf(typesAdded.keySet()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment