Commit 3d3be408 by ashutoshm Committed by Madhan Neethiraj

ATLAS-1968: updated import documentation for fileName option usage

parent 02e4e86b
......@@ -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>
......@@ -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_.
......
......@@ -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);
}
......
......@@ -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");
......
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