diff --git a/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java b/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java index 845cafa0..d7e0cea0 100644 --- a/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java +++ b/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java @@ -44,8 +44,8 @@ public class ConnectorBean extends ConfigurableBean { // to represent the config and inputs with values - public static final String CONNECTOR_LINK_CONFIG_VALUES = "link-config-values"; - public static final String CONNECTOR_JOB_CONFIG_VALUES = "job-config-values"; + public static final String CONNECTOR_LINK_CONFIG = "link-config"; + public static final String CONNECTOR_JOB_CONFIG = "job-config"; private static final String CONNECTOR = "connector"; private List connectors; @@ -88,28 +88,28 @@ protected JSONArray extractConnectors(boolean skipSensitive) { connectorJsonObject.put(CLASS, connector.getClassName()); connectorJsonObject.put(CONFIGURABLE_VERSION, connector.getVersion()); connectorJsonObject.put( - CONNECTOR_LINK_CONFIG_VALUES, + CONNECTOR_LINK_CONFIG, extractConfigList(connector.getLinkConfig().getConfigs(), connector.getLinkConfig() .getType(), skipSensitive)); - connectorJsonObject.put(CONNECTOR_JOB_CONFIG_VALUES, new JSONObject()); + connectorJsonObject.put(CONNECTOR_JOB_CONFIG, new JSONObject()); // add sub fields to the job config for from and to if (connector.getFromConfig() != null) { - ((JSONObject) connectorJsonObject.get(CONNECTOR_JOB_CONFIG_VALUES)).put( + ((JSONObject) connectorJsonObject.get(CONNECTOR_JOB_CONFIG)).put( Direction.FROM, extractConfigList(connector.getFromConfig().getConfigs(), connector.getFromConfig() .getType(), skipSensitive)); } if (connector.getToConfig() != null) { - ((JSONObject) connectorJsonObject.get(CONNECTOR_JOB_CONFIG_VALUES)).put( + ((JSONObject) connectorJsonObject.get(CONNECTOR_JOB_CONFIG)).put( Direction.TO, extractConfigList(connector.getToConfig().getConfigs(), connector.getToConfig() .getType(), skipSensitive)); } // add the config-param inside each connector - connectorJsonObject.put(ALL_CONFIGS, new JSONObject()); + connectorJsonObject.put(ALL_CONFIG_RESOURCES, new JSONObject()); if (connectorConfigBundles != null && !connectorConfigBundles.isEmpty()) { - connectorJsonObject.put(ALL_CONFIGS, + connectorJsonObject.put(ALL_CONFIG_RESOURCES, extractConfigParamBundle(connectorConfigBundles.get(connector.getPersistenceId()))); } connectorArray.add(connectorJsonObject); @@ -136,10 +136,10 @@ protected void restoreConnectors(JSONArray array) { String version = (String) object.get(CONFIGURABLE_VERSION); List linkConfigs = restoreConfigList((JSONArray) object - .get(CONNECTOR_LINK_CONFIG_VALUES)); + .get(CONNECTOR_LINK_CONFIG)); // parent that encapsulates both the from/to configs - JSONObject jobConfigJson = (JSONObject) object.get(CONNECTOR_JOB_CONFIG_VALUES); + JSONObject jobConfigJson = (JSONObject) object.get(CONNECTOR_JOB_CONFIG); JSONArray fromJobConfigJson = (JSONArray) jobConfigJson.get(Direction.FROM.name()); JSONArray toJobConfigJson = (JSONArray) jobConfigJson.get(Direction.TO.name()); @@ -161,9 +161,9 @@ protected void restoreConnectors(JSONArray array) { toConfig); connector.setPersistenceId(connectorId); - if (object.containsKey(ALL_CONFIGS)) { + if (object.containsKey(ALL_CONFIG_RESOURCES)) { - JSONObject jsonConfigBundle = (JSONObject) object.get(ALL_CONFIGS); + JSONObject jsonConfigBundle = (JSONObject) object.get(ALL_CONFIG_RESOURCES); connectorConfigBundles.put(connectorId, restoreConfigParamBundle(jsonConfigBundle)); } connectors.add(connector); diff --git a/common/src/main/java/org/apache/sqoop/json/DriverBean.java b/common/src/main/java/org/apache/sqoop/json/DriverBean.java index f2002685..0e3f872f 100644 --- a/common/src/main/java/org/apache/sqoop/json/DriverBean.java +++ b/common/src/main/java/org/apache/sqoop/json/DriverBean.java @@ -36,7 +36,7 @@ public class DriverBean extends ConfigurableBean { public static final String CURRENT_DRIVER_VERSION = "1"; - static final String DRIVER_JOB_CONFIG_VALUES = "job-config-values"; + static final String DRIVER_JOB_CONFIG = "job-config"; private MDriver driver; private ResourceBundle driverConfigBundle; @@ -68,8 +68,8 @@ public JSONObject extract(boolean skipSensitive) { JSONObject result = new JSONObject(); result.put(ID, driver.getPersistenceId()); result.put(CONFIGURABLE_VERSION, driver.getVersion()); - result.put(DRIVER_JOB_CONFIG_VALUES, configs); - result.put(ALL_CONFIGS, extractConfigParamBundle(driverConfigBundle)); + result.put(DRIVER_JOB_CONFIG, configs); + result.put(ALL_CONFIG_RESOURCES, extractConfigParamBundle(driverConfigBundle)); return result; } @@ -77,9 +77,9 @@ public JSONObject extract(boolean skipSensitive) { public void restore(JSONObject jsonObject) { long id = (Long) jsonObject.get(ID); String driverVersion = (String) jsonObject.get(CONFIGURABLE_VERSION); - List driverConfig = restoreConfigList((JSONArray) jsonObject.get(DRIVER_JOB_CONFIG_VALUES)); + List driverConfig = restoreConfigList((JSONArray) jsonObject.get(DRIVER_JOB_CONFIG)); driver = new MDriver(new MDriverConfig(driverConfig), driverVersion); driver.setPersistenceId(id); - driverConfigBundle = restoreConfigParamBundle((JSONObject) jsonObject.get(ALL_CONFIGS)); + driverConfigBundle = restoreConfigParamBundle((JSONObject) jsonObject.get(ALL_CONFIG_RESOURCES)); } } diff --git a/common/src/main/java/org/apache/sqoop/json/JobBean.java b/common/src/main/java/org/apache/sqoop/json/JobBean.java index efc2efcd..0c258aac 100644 --- a/common/src/main/java/org/apache/sqoop/json/JobBean.java +++ b/common/src/main/java/org/apache/sqoop/json/JobBean.java @@ -45,9 +45,9 @@ public class JobBean implements JsonBean { static final String TO_LINK_ID = "to-link-id"; static final String FROM_CONNECTOR_ID = "from-connector-id"; static final String TO_CONNECTOR_ID = "to-connector-id"; - static final String FROM_CONFIG = "from-config"; - static final String TO_CONFIG = "to-config"; - static final String DRIVER_CONFIG = "driver-config"; + static final String FROM_CONFIG_VALUES = "from-config-values"; + static final String TO_CONFIG_VALUES = "to-config-values"; + static final String DRIVER_CONFIG_VALUES = "driver-config-values"; private static final String JOB = "job"; // Required @@ -129,14 +129,14 @@ protected JSONArray extractJobs(boolean skipSensitive) { object.put(TO_LINK_ID, job.getLinkId(Direction.TO)); // job configs MFromConfig fromConfigList = job.getFromJobConfig(); - object.put(FROM_CONFIG, + object.put(FROM_CONFIG_VALUES, extractConfigList(fromConfigList.getConfigs(), fromConfigList.getType(), skipSensitive)); MToConfig toConfigList = job.getToJobConfig(); - object.put(TO_CONFIG, + object.put(TO_CONFIG_VALUES, extractConfigList(toConfigList.getConfigs(), toConfigList.getType(), skipSensitive)); MDriverConfig driverConfigList = job.getDriverConfig(); object.put( - DRIVER_CONFIG, + DRIVER_CONFIG_VALUES, extractConfigList(driverConfigList.getConfigs(), driverConfigList.getType(), skipSensitive)); @@ -161,9 +161,9 @@ protected void restoreJobs(JSONArray array) { long toConnectorId = (Long) object.get(TO_CONNECTOR_ID); long fromConnectionId = (Long) object.get(FROM_LINK_ID); long toConnectionId = (Long) object.get(TO_LINK_ID); - JSONArray fromConfigJson = (JSONArray) object.get(FROM_CONFIG); - JSONArray toConfigJson = (JSONArray) object.get(TO_CONFIG); - JSONArray driverConfigJson = (JSONArray) object.get(DRIVER_CONFIG); + JSONArray fromConfigJson = (JSONArray) object.get(FROM_CONFIG_VALUES); + JSONArray toConfigJson = (JSONArray) object.get(TO_CONFIG_VALUES); + JSONArray driverConfigJson = (JSONArray) object.get(DRIVER_CONFIG_VALUES); List fromConfig = restoreConfigList(fromConfigJson); List toConfig = restoreConfigList(toConfigJson); diff --git a/common/src/main/java/org/apache/sqoop/json/JsonBean.java b/common/src/main/java/org/apache/sqoop/json/JsonBean.java index 164b6047..8797015d 100644 --- a/common/src/main/java/org/apache/sqoop/json/JsonBean.java +++ b/common/src/main/java/org/apache/sqoop/json/JsonBean.java @@ -23,7 +23,7 @@ public interface JsonBean { // common JSON constants for the rest-api response static final String CONFIGURABLE_VERSION = "version"; - static final String ALL_CONFIGS = "all-configs"; + static final String ALL_CONFIG_RESOURCES= "all-config-resources"; @Deprecated // should not be used anymore in the rest api static final String ALL = "all"; diff --git a/common/src/main/java/org/apache/sqoop/json/LinkBean.java b/common/src/main/java/org/apache/sqoop/json/LinkBean.java index ae3a4ff4..368a56c5 100644 --- a/common/src/main/java/org/apache/sqoop/json/LinkBean.java +++ b/common/src/main/java/org/apache/sqoop/json/LinkBean.java @@ -42,7 +42,7 @@ public class LinkBean implements JsonBean { static final String CONNECTOR_ID = "connector-id"; - static final String LINK_CONFIG = "link-config"; + static final String LINK_CONFIG_VALUES = "link-config-values"; static final String LINK = "link"; @@ -108,7 +108,7 @@ protected JSONArray extractLinks(boolean skipSensitive) { linkJsonObject.put(UPDATE_USER, link.getLastUpdateUser()); linkJsonObject.put(UPDATE_DATE, link.getLastUpdateDate().getTime()); linkJsonObject.put(CONNECTOR_ID, link.getConnectorId()); - linkJsonObject.put(LINK_CONFIG, + linkJsonObject.put(LINK_CONFIG_VALUES, extractConfigList(link.getConnectorLinkConfig().getConfigs(), link.getConnectorLinkConfig().getType(), skipSensitive)); linkArray.add(linkJsonObject); } @@ -126,7 +126,7 @@ protected void restoreLinks(JSONArray array) { for (Object obj : array) { JSONObject object = (JSONObject) obj; long connectorId = (Long) object.get(CONNECTOR_ID); - JSONArray connectorLinkConfig = (JSONArray) object.get(LINK_CONFIG); + JSONArray connectorLinkConfig = (JSONArray) object.get(LINK_CONFIG_VALUES); List linkConfig = restoreConfigList(connectorLinkConfig); MLink link = new MLink(connectorId, new MLinkConfig(linkConfig)); link.setPersistenceId((Long) object.get(ID)); diff --git a/common/src/test/java/org/apache/sqoop/json/TestLinkBean.java b/common/src/test/java/org/apache/sqoop/json/TestLinkBean.java index 7c3c921d..7c7d2abb 100644 --- a/common/src/test/java/org/apache/sqoop/json/TestLinkBean.java +++ b/common/src/test/java/org/apache/sqoop/json/TestLinkBean.java @@ -61,7 +61,7 @@ public void testSerialization() { // Check for sensitivity JSONArray linkArray = (JSONArray)json.get(LinkBean.LINK); JSONObject linkItem = (JSONObject)linkArray.get(0); - JSONArray connectors = (JSONArray)linkItem.get(LinkBean.LINK_CONFIG); + JSONArray connectors = (JSONArray)linkItem.get(LinkBean.LINK_CONFIG_VALUES); JSONObject connector = (JSONObject)connectors.get(0); JSONArray inputs = (JSONArray)connector.get(ConfigInputConstants.CONFIG_INPUTS); for (Object input1 : inputs) { @@ -118,7 +118,7 @@ public void testSensitivityFilter() { // Sensitive values should exist JSONArray all = (JSONArray)json.get(LinkBean.LINK); JSONObject allItem = (JSONObject)all.get(0); - JSONArray connectors = (JSONArray)allItem.get(LinkBean.LINK_CONFIG); + JSONArray connectors = (JSONArray)allItem.get(LinkBean.LINK_CONFIG_VALUES); JSONObject connector = (JSONObject)connectors.get(0); JSONArray inputs = (JSONArray)connector.get(ConfigInputConstants.CONFIG_INPUTS); assertEquals(3, inputs.size()); @@ -129,7 +129,7 @@ public void testSensitivityFilter() { // Sensitive values should not exist all = (JSONArray)jsonFiltered.get(LinkBean.LINK); allItem = (JSONObject)all.get(0); - connectors = (JSONArray)allItem.get(LinkBean.LINK_CONFIG); + connectors = (JSONArray)allItem.get(LinkBean.LINK_CONFIG_VALUES); connector = (JSONObject)connectors.get(0); inputs = (JSONArray)connector.get(ConfigInputConstants.CONFIG_INPUTS); assertEquals(3, inputs.size());