You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ni...@apache.org on 2019/02/05 14:12:04 UTC
[atlas] branch branch-0.8 updated: ATLAS-3019 Handle NPE while
transform and adding replicatedTo in import-export
This is an automated email from the ASF dual-hosted git repository.
nixon pushed a commit to branch branch-0.8
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/branch-0.8 by this push:
new cf8d57b ATLAS-3019 Handle NPE while transform and adding replicatedTo in import-export
cf8d57b is described below
commit cf8d57bec01d50343bbdc08efb1e431a708f8799
Author: Kapildeo Nayak <ka...@freestoneinfotech.com>
AuthorDate: Thu Jan 3 18:14:16 2019 +0530
ATLAS-3019 Handle NPE while transform and adding replicatedTo in import-export
Signed-off-by: nixonrodrigues <ni...@apache.org>
---
.../atlas/model/impexp/AtlasExportRequest.java | 52 ++++++++++++----------
.../atlas/repository/impexp/ImportTransforms.java | 6 ++-
2 files changed, 34 insertions(+), 24 deletions(-)
diff --git a/intg/src/main/java/org/apache/atlas/model/impexp/AtlasExportRequest.java b/intg/src/main/java/org/apache/atlas/model/impexp/AtlasExportRequest.java
index 6e7d7f3..3f399cd 100644
--- a/intg/src/main/java/org/apache/atlas/model/impexp/AtlasExportRequest.java
+++ b/intg/src/main/java/org/apache/atlas/model/impexp/AtlasExportRequest.java
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ * <p>
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,31 +40,31 @@ import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
-@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown=true)
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasExportRequest implements Serializable {
private static final long serialVersionUID = 1L;
- public static final String OPTION_FETCH_TYPE = "fetchType";
- public static final String OPTION_ATTR_MATCH_TYPE = "matchType";
- public static final String OPTION_SKIP_LINEAGE = "skipLineage";
- public static final String OPTION_KEY_REPLICATED_TO = "replicatedTo";
- public static final String FETCH_TYPE_FULL = "full";
- public static final String FETCH_TYPE_CONNECTED = "connected";
- public static final String FETCH_TYPE_INCREMENTAL = "incremental";
+ public static final String OPTION_FETCH_TYPE = "fetchType";
+ public static final String OPTION_ATTR_MATCH_TYPE = "matchType";
+ public static final String OPTION_SKIP_LINEAGE = "skipLineage";
+ public static final String OPTION_KEY_REPLICATED_TO = "replicatedTo";
+ public static final String FETCH_TYPE_FULL = "full";
+ public static final String FETCH_TYPE_CONNECTED = "connected";
+ public static final String FETCH_TYPE_INCREMENTAL = "incremental";
public static final String FETCH_TYPE_INCREMENTAL_CHANGE_MARKER = "changeMarker";
- public static final String MATCH_TYPE_STARTS_WITH = "startsWith";
- public static final String MATCH_TYPE_ENDS_WITH = "endsWith";
- public static final String MATCH_TYPE_CONTAINS = "contains";
- public static final String MATCH_TYPE_MATCHES = "matches";
- public static final String MATCH_TYPE_FOR_TYPE = "forType";
+ public static final String MATCH_TYPE_STARTS_WITH = "startsWith";
+ public static final String MATCH_TYPE_ENDS_WITH = "endsWith";
+ public static final String MATCH_TYPE_CONTAINS = "contains";
+ public static final String MATCH_TYPE_MATCHES = "matches";
+ public static final String MATCH_TYPE_FOR_TYPE = "forType";
private List<AtlasObjectId> itemsToExport = new ArrayList<>();
- private Map<String, Object> options = new HashMap<>();
+ private Map<String, Object> options = new HashMap<>();
public List<AtlasObjectId> getItemsToExport() {
return itemsToExport;
@@ -83,7 +83,7 @@ public class AtlasExportRequest implements Serializable {
}
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;
}
@@ -96,17 +96,17 @@ public class AtlasExportRequest implements Serializable {
}
public boolean getSkipLineageOptionValue() {
- if(MapUtils.isEmpty(getOptions()) ||
+ if (MapUtils.isEmpty(getOptions()) ||
!getOptions().containsKey(AtlasExportRequest.OPTION_SKIP_LINEAGE)) {
return false;
}
Object o = getOptions().get(AtlasExportRequest.OPTION_SKIP_LINEAGE);
- if(o instanceof String) {
+ if (o instanceof String) {
return Boolean.parseBoolean((String) o);
}
- if(o instanceof Boolean) {
+ if (o instanceof Boolean) {
return (Boolean) o;
}
@@ -142,7 +142,13 @@ public class AtlasExportRequest implements Serializable {
@JsonIgnore
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) {
diff --git a/repository/src/main/java/org/apache/atlas/repository/impexp/ImportTransforms.java b/repository/src/main/java/org/apache/atlas/repository/impexp/ImportTransforms.java
index 72b684b..a2f592c 100644
--- a/repository/src/main/java/org/apache/atlas/repository/impexp/ImportTransforms.java
+++ b/repository/src/main/java/org/apache/atlas/repository/impexp/ImportTransforms.java
@@ -64,7 +64,11 @@ public class ImportTransforms {
getTransforms().put(subType, attribtueTransformMap);
} else {
for (Map.Entry<String, List<ImportTransformer>> entry : attribtueTransformMap.entrySet()) {
- getTransforms().get(subType).get(entry.getKey()).addAll(entry.getValue());
+ if((getTransforms().get(subType).containsKey(entry.getKey()))){
+ getTransforms().get(subType).get(entry.getKey()).addAll(entry.getValue());
+ } else {
+ LOG.warn("Attribute {} does not exist for Type : {}", entry.getKey(), parentType);
+ }
}
}
}