Commit de174460 by Shwetha GS

extract getGuidFromDSLResponse to function

parent f73dab3e
...@@ -40,6 +40,7 @@ import org.apache.hadoop.metadata.typesystem.json.Serialization; ...@@ -40,6 +40,7 @@ import org.apache.hadoop.metadata.typesystem.json.Serialization;
import org.apache.hadoop.metadata.typesystem.persistence.Id; import org.apache.hadoop.metadata.typesystem.persistence.Id;
import org.apache.hadoop.metadata.typesystem.types.TypeSystem; import org.apache.hadoop.metadata.typesystem.types.TypeSystem;
import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONArray;
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;
...@@ -119,7 +120,7 @@ public class HiveMetaStoreBridge { ...@@ -119,7 +120,7 @@ public class HiveMetaStoreBridge {
if (results.length() == 0) { if (results.length() == 0) {
return null; return null;
} else { } else {
String guid = results.getJSONObject(0).getJSONObject("$id$").getString("id"); String guid = getGuidFromDSLResponse(results.getJSONObject(0));
return new Referenceable(guid, typeName, null); return new Referenceable(guid, typeName, null);
} }
} }
...@@ -198,12 +199,16 @@ public class HiveMetaStoreBridge { ...@@ -198,12 +199,16 @@ public class HiveMetaStoreBridge {
return null; return null;
} else { } else {
//There should be just one instance with the given name //There should be just one instance with the given name
String guid = results.getJSONObject(0).getJSONObject("$id$").getString("id"); String guid = getGuidFromDSLResponse(results.getJSONObject(0));
LOG.debug("Got reference for table {}.{} = {}", dbRef, tableName, guid); LOG.debug("Got reference for table {}.{} = {}", dbRef, tableName, guid);
return new Referenceable(guid, typeName, null); return new Referenceable(guid, typeName, null);
} }
} }
private String getGuidFromDSLResponse(JSONObject jsonObject) throws JSONException {
return jsonObject.getJSONObject("$id$").getString("id");
}
private Referenceable getSDForTable(Referenceable dbRef, String tableName) throws Exception { private Referenceable getSDForTable(Referenceable dbRef, String tableName) throws Exception {
Referenceable tableRef = getTableReference(dbRef, tableName); Referenceable tableRef = getTableReference(dbRef, tableName);
if (tableRef == null) { if (tableRef == null) {
......
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