Repository: atlas
Updated Branches:
  refs/heads/branch-1.0 283d2aeab -> 1c9963746


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

Signed-off-by: nixonrodrigues <ni...@apache.org>
(cherry picked from commit a5f971a322b75a7cc2bd9e8bdf021be46e03b63d)


Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/1c996374
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/1c996374
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/1c996374

Branch: refs/heads/branch-1.0
Commit: 1c9963746ad50538f951b232d9f74f9f751fef08
Parents: 283d2ae
Author: Kapildeo Nayak <kapildeo.na...@freestoneinfotech.com>
Authored: Thu Jan 3 18:14:16 2019 +0530
Committer: nixonrodrigues <ni...@apache.org>
Committed: Fri Jan 4 17:08:47 2019 +0530

----------------------------------------------------------------------
 .../atlas/model/impexp/AtlasExportRequest.java  | 52 +++++++++++---------
 .../repository/impexp/ImportTransforms.java     |  6 ++-
 2 files changed, 34 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/1c996374/intg/src/main/java/org/apache/atlas/model/impexp/AtlasExportRequest.java
----------------------------------------------------------------------
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 0e93744..b03b386 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 
com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
 import static 
com.fasterxml.jackson.annotation.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) {

http://git-wip-us.apache.org/repos/asf/atlas/blob/1c996374/repository/src/main/java/org/apache/atlas/repository/impexp/ImportTransforms.java
----------------------------------------------------------------------
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);
+                    }
                 }
             }
         }

Reply via email to