atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject [30/39] atlas git commit: ATLAS-1968: updated import documentation for fileName option usage
Date Mon, 24 Jul 2017 15:57:35 GMT
ATLAS-1968: updated import documentation for fileName option usage

Signed-off-by: Madhan Neethiraj <madhan@apache.org>


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

Branch: refs/heads/feature-odf
Commit: 3d3be40848775b43c97f4f94df47591762e78d0b
Parents: 02e4e86
Author: ashutoshm <amestry@hortonworks.com>
Authored: Thu Jul 20 09:56:04 2017 -0700
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Thu Jul 20 10:41:27 2017 -0700

----------------------------------------------------------------------
 docs/src/site/twiki/Import-API-Options.twiki    | 22 ++++++++++++++++++++
 docs/src/site/twiki/Import-API.twiki            |  6 +++---
 .../atlas/model/impexp/AtlasImportRequest.java  | 18 +++++++++++++---
 .../atlas/repository/impexp/ImportService.java  |  2 +-
 4 files changed, 41 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/3d3be408/docs/src/site/twiki/Import-API-Options.twiki
----------------------------------------------------------------------
diff --git a/docs/src/site/twiki/Import-API-Options.twiki b/docs/src/site/twiki/Import-API-Options.twiki
index 8588784..cc09fc7 100644
--- a/docs/src/site/twiki/Import-API-Options.twiki
+++ b/docs/src/site/twiki/Import-API-Options.twiki
@@ -111,3 +111,25 @@ To use the option, set the contents of _importOptions.json_ to:
   }
 }
 </verbatim>
+
+---++++ Specifying File to be Imported From Server Location
+
+In scenario where the file to be imported is present at a location on the server, the _importfile_
API can be used. It behaves like the Import API.
+
+To use the option, set the contents of _importOptions.json_ to:
+<verbatim>
+{
+
+  "options": {
+    "fileName": "/root/fileToBeImported.zip"
+  }
+}
+</verbatim>
+
+_CURL_
+<verbatim>
+curl -g -X POST -u adminuser:password -H "Content-Type: application/json"
+            -H "Cache-Control: no-cache"
+            -d r@importOptions.json
+            "http://localhost:21000/api/atlas/admin/importfile"
+</verbatim>

http://git-wip-us.apache.org/repos/asf/atlas/blob/3d3be408/docs/src/site/twiki/Import-API.twiki
----------------------------------------------------------------------
diff --git a/docs/src/site/twiki/Import-API.twiki b/docs/src/site/twiki/Import-API.twiki
index b5de113..00ac9c4 100644
--- a/docs/src/site/twiki/Import-API.twiki
+++ b/docs/src/site/twiki/Import-API.twiki
@@ -24,7 +24,7 @@ The general approach is:
 | _Description_|Provide the path of the file to be imported.|
 | _URL_ |_api/atlas/admin/importfile_ |
 | _Method_ |_POST_ |
-| _URL Parameters_ |_?FILENAME=<path of file>_  Specify the options as name-value pairs.
Use _FILENAME_ to specify the file path. |
+| _URL Parameters_ |_None_ |
 | _Data Parameters_|_None_|
 | _Success Response_ | _!AtlasImporResult_ is returned as JSON. See details below.|
 |_Error Response_|Errors that are handled within the system will be returned as _!AtlasBaseException_.
|
@@ -68,8 +68,8 @@ curl -g -X POST -u adminuser:password -H "Content-Type: multipart/form-data"
 
 The call below performs Import of _!QuickStart_ database using a ZIP file available on server.
 <verbatim>
-curl -X POST -u adminuser:password -H "Cache-Control: no-cache"
-"http://localhost:21000/api/atlas/admin/importFile?FILENAME=/root/quickStartDB.zip" >
quickStartDB-import-result.json
+curl -X POST -u adminuser:password -H "Cache-Control: no-cache" -d ./importOptions.json
+"http://localhost:21000/api/atlas/admin/importFile" > quickStartDB-import-result.json
 </verbatim>
 
 Below is the _!AtlasImportResult_ JSON for an import that contains _hive_db_.

http://git-wip-us.apache.org/repos/asf/atlas/blob/3d3be408/intg/src/main/java/org/apache/atlas/model/impexp/AtlasImportRequest.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/impexp/AtlasImportRequest.java b/intg/src/main/java/org/apache/atlas/model/impexp/AtlasImportRequest.java
index 4d2ac62..304ec5d 100644
--- a/intg/src/main/java/org/apache/atlas/model/impexp/AtlasImportRequest.java
+++ b/intg/src/main/java/org/apache/atlas/model/impexp/AtlasImportRequest.java
@@ -36,9 +36,11 @@ import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONL
 @JsonIgnoreProperties(ignoreUnknown=true)
 public class AtlasImportRequest implements Serializable {
     private static final long   serialVersionUID = 1L;
-    public  static final String TRANSFORMS_KEY   = "transforms";
-    private static final String START_POSITION_KEY = "startPosition";
-    private static final String START_GUID_KEY = "startGuid";
+
+    public  static final String TRANSFORMS_KEY             = "transforms";
+    private static final String START_POSITION_KEY         = "startPosition";
+    private static final String START_GUID_KEY             = "startGuid";
+    private static final String FILE_NAME_KEY              = "fileName";
     private static final String UPDATE_TYPE_DEFINITION_KEY = "updateTypeDefinition";
 
     private Map<String, String> options;
@@ -76,6 +78,16 @@ public class AtlasImportRequest implements Serializable {
     }
 
     @JsonIgnore
+    public String getFileName() {
+        return getOptionForKey(FILE_NAME_KEY);
+    }
+
+    @JsonIgnore
+    public void setFileName(String fileName) {
+        setOption(FILE_NAME_KEY, fileName);
+    }
+
+    @JsonIgnore
     public String getStartPosition() {
         return getOptionForKey(START_POSITION_KEY);
     }

http://git-wip-us.apache.org/repos/asf/atlas/blob/3d3be408/repository/src/main/java/org/apache/atlas/repository/impexp/ImportService.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/impexp/ImportService.java
b/repository/src/main/java/org/apache/atlas/repository/impexp/ImportService.java
index 9221717..bdeed7d 100644
--- a/repository/src/main/java/org/apache/atlas/repository/impexp/ImportService.java
+++ b/repository/src/main/java/org/apache/atlas/repository/impexp/ImportService.java
@@ -99,7 +99,7 @@ public class ImportService {
 
     public AtlasImportResult run(AtlasImportRequest request, String userName, String hostName,
String requestingIP)
             throws AtlasBaseException {
-        String fileName = (String) request.getOptions().get("FILENAME");
+        String fileName = (String) request.getFileName();
 
         if (StringUtils.isBlank(fileName)) {
             throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, "FILENAME parameter
not found");


Mime
View raw message