ATLAS-1968: updated import documentation for fileName option usage
Signed-off-by: Madhan Neethiraj <madhan@apache.org>
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 @@
}
}
</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>
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 @@
| _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 @@
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_.
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 @@
@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 @@
}
@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);
}
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 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");