Commit a5f971a3 by Kapildeo Nayak Committed by nixonrodrigues

ATLAS-3019 Handle NPE while transform and adding replicatedTo in import-export

parent 22041f51
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...@@ -40,9 +40,9 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; ...@@ -40,9 +40,9 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) @JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL) @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true) @JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement @XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY) @XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasExportRequest implements Serializable { public class AtlasExportRequest implements Serializable {
...@@ -83,7 +83,7 @@ public class AtlasExportRequest implements Serializable { ...@@ -83,7 +83,7 @@ public class AtlasExportRequest implements Serializable {
} }
public String getFetchTypeOptionValue() { public String getFetchTypeOptionValue() {
if(MapUtils.isEmpty(getOptions()) || !getOptions().containsKey(OPTION_FETCH_TYPE)) { if (MapUtils.isEmpty(getOptions()) || !getOptions().containsKey(OPTION_FETCH_TYPE)) {
return FETCH_TYPE_FULL; return FETCH_TYPE_FULL;
} }
...@@ -96,17 +96,17 @@ public class AtlasExportRequest implements Serializable { ...@@ -96,17 +96,17 @@ public class AtlasExportRequest implements Serializable {
} }
public boolean getSkipLineageOptionValue() { public boolean getSkipLineageOptionValue() {
if(MapUtils.isEmpty(getOptions()) || if (MapUtils.isEmpty(getOptions()) ||
!getOptions().containsKey(AtlasExportRequest.OPTION_SKIP_LINEAGE)) { !getOptions().containsKey(AtlasExportRequest.OPTION_SKIP_LINEAGE)) {
return false; return false;
} }
Object o = getOptions().get(AtlasExportRequest.OPTION_SKIP_LINEAGE); Object o = getOptions().get(AtlasExportRequest.OPTION_SKIP_LINEAGE);
if(o instanceof String) { if (o instanceof String) {
return Boolean.parseBoolean((String) o); return Boolean.parseBoolean((String) o);
} }
if(o instanceof Boolean) { if (o instanceof Boolean) {
return (Boolean) o; return (Boolean) o;
} }
...@@ -142,7 +142,13 @@ public class AtlasExportRequest implements Serializable { ...@@ -142,7 +142,13 @@ public class AtlasExportRequest implements Serializable {
@JsonIgnore @JsonIgnore
public String getOptionKeyReplicatedTo() { public String getOptionKeyReplicatedTo() {
return isReplicationOptionSet() ? (String) options.get(OPTION_KEY_REPLICATED_TO) : StringUtils.EMPTY; String replicateToServerName = isReplicationOptionSet() ? (String) options.get(OPTION_KEY_REPLICATED_TO) : StringUtils.EMPTY;
if (replicateToServerName == null) {
return StringUtils.EMPTY;
} else {
return replicateToServerName;
}
} }
public StringBuilder toString(StringBuilder sb) { public StringBuilder toString(StringBuilder sb) {
......
...@@ -64,7 +64,11 @@ public class ImportTransforms { ...@@ -64,7 +64,11 @@ public class ImportTransforms {
getTransforms().put(subType, attribtueTransformMap); getTransforms().put(subType, attribtueTransformMap);
} else { } else {
for (Map.Entry<String, List<ImportTransformer>> entry : attribtueTransformMap.entrySet()) { for (Map.Entry<String, List<ImportTransformer>> entry : attribtueTransformMap.entrySet()) {
if((getTransforms().get(subType).containsKey(entry.getKey()))){
getTransforms().get(subType).get(entry.getKey()).addAll(entry.getValue()); getTransforms().get(subType).get(entry.getKey()).addAll(entry.getValue());
} else {
LOG.warn("Attribute {} does not exist for Type : {}", entry.getKey(), parentType);
}
} }
} }
} }
......
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