Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
dd00c859
Commit
dd00c859
authored
7 years ago
by
ashutoshm
Committed by
Madhan Neethiraj
7 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2017: updated import API to make request parameter optional
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
38297a84
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
12 deletions
+33
-12
Import-API.twiki
docs/src/site/twiki/Import-API.twiki
+9
-0
ImportService.java
...ava/org/apache/atlas/repository/impexp/ImportService.java
+11
-4
ImportServiceTest.java
...org/apache/atlas/repository/impexp/ImportServiceTest.java
+1
-2
ZipFileResourceTestUtils.java
...che/atlas/repository/impexp/ZipFileResourceTestUtils.java
+10
-0
AdminResource.java
...in/java/org/apache/atlas/web/resources/AdminResource.java
+2
-6
No files found.
docs/src/site/twiki/Import-API.twiki
View file @
dd00c859
...
...
@@ -66,6 +66,15 @@ curl -g -X POST -u adminuser:password -H "Content-Type: multipart/form-data"
"http://localhost:21000/api/atlas/admin/import"
</verbatim>
The _request_ parameter is optional. If import has to be run without any options use:
<verbatim>
curl -g -X POST -u adminuser:password -H "Content-Type: multipart/form-data"
-H "Cache-Control: no-cache"
-F data=@quickStartDB.zip
"http://localhost:21000/api/atlas/admin/import"
</verbatim>
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" -d ./importOptions.json
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/impexp/ImportService.java
View file @
dd00c859
...
...
@@ -55,13 +55,20 @@ public class ImportService {
this
.
typeRegistry
=
typeRegistry
;
}
public
AtlasImportResult
run
(
ZipSource
source
,
String
userName
,
String
hostName
,
String
requestingIP
)
throws
AtlasBaseException
{
return
run
(
source
,
null
,
userName
,
hostName
,
requestingIP
);
}
public
AtlasImportResult
run
(
ZipSource
source
,
AtlasImportRequest
request
,
String
userName
,
String
hostName
,
String
requestingIP
)
throws
AtlasBaseException
{
AtlasImportResult
result
=
new
AtlasImportResult
(
request
,
userName
,
requestingIP
,
hostName
,
System
.
currentTimeMillis
());
try
{
LOG
.
info
(
"==> import(user={}, from={})"
,
userName
,
requestingIP
);
if
(
request
==
null
)
{
request
=
new
AtlasImportRequest
();
}
String
transforms
=
MapUtils
.
isNotEmpty
(
request
.
getOptions
())
?
request
.
getOptions
().
get
(
AtlasImportRequest
.
TRANSFORMS_KEY
)
:
null
;
...
...
@@ -90,9 +97,9 @@ public class ImportService {
}
private
void
setStartPosition
(
AtlasImportRequest
request
,
ZipSource
source
)
throws
AtlasBaseException
{
if
(
request
.
getStartGuid
()
!=
null
)
{
if
(
request
.
getStartGuid
()
!=
null
)
{
source
.
setPositionUsingEntityGuid
(
request
.
getStartGuid
());
}
else
if
(
request
.
getStartPosition
()
!=
null
)
{
}
else
if
(
request
.
getStartPosition
()
!=
null
)
{
source
.
setPosition
(
Integer
.
parseInt
(
request
.
getStartPosition
()));
}
}
...
...
@@ -136,7 +143,7 @@ public class ImportService {
}
private
void
processTypes
(
AtlasTypesDef
typeDefinitionMap
,
AtlasImportResult
result
)
throws
AtlasBaseException
{
if
(
result
.
getRequest
().
getUpdateTypeDefs
()
!=
null
&&
!
result
.
getRequest
().
getUpdateTypeDefs
().
equals
(
"true"
))
{
if
(
result
.
getRequest
().
getUpdateTypeDefs
()
!=
null
&&
!
result
.
getRequest
().
getUpdateTypeDefs
().
equals
(
"true"
))
{
return
;
}
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java
View file @
dd00c859
...
...
@@ -153,8 +153,7 @@ public class ImportServiceTest {
loadModelFromJson
(
"0010-base_model.json"
,
typeDefStore
,
typeRegistry
);
loadModelFromJson
(
"0030-hive_model.json"
,
typeDefStore
,
typeRegistry
);
AtlasImportRequest
request
=
getDefaultImportRequest
();
runImportWithParameters
(
getImportService
(),
getDefaultImportRequest
(),
zipSource
);
runImportWithNoParameters
(
getImportService
(),
zipSource
);
}
private
ImportService
getImportService
()
{
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/repository/impexp/ZipFileResourceTestUtils.java
View file @
dd00c859
...
...
@@ -147,6 +147,16 @@ public class ZipFileResourceTestUtils {
return
result
;
}
public
static
AtlasImportResult
runImportWithNoParameters
(
ImportService
importService
,
ZipSource
source
)
throws
AtlasBaseException
,
IOException
{
final
String
requestingIP
=
"1.0.0.0"
;
final
String
hostName
=
"localhost"
;
final
String
userName
=
"admin"
;
AtlasImportResult
result
=
importService
.
run
(
source
,
userName
,
hostName
,
requestingIP
);
assertEquals
(
result
.
getOperationStatus
(),
AtlasImportResult
.
OperationStatus
.
SUCCESS
);
return
result
;
}
public
static
void
runAndVerifyQuickStart_v1_Import
(
ImportService
importService
,
ZipSource
zipSource
)
throws
AtlasBaseException
,
IOException
{
AtlasExportResult
exportResult
=
zipSource
.
getExportResult
();
List
<
String
>
creationOrder
=
zipSource
.
getCreationOrder
();
...
...
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
View file @
dd00c859
...
...
@@ -61,6 +61,7 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.DELETE
;
import
javax.ws.rs.DefaultValue
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.POST
;
import
javax.ws.rs.Path
;
...
...
@@ -359,21 +360,16 @@ public class AdminResource {
@Path
(
"/import"
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
(
MediaType
.
MULTIPART_FORM_DATA
)
public
AtlasImportResult
importData
(
@FormDataParam
(
"request"
)
String
jsonData
,
public
AtlasImportResult
importData
(
@
DefaultValue
(
"{}"
)
@
FormDataParam
(
"request"
)
String
jsonData
,
@FormDataParam
(
"data"
)
InputStream
inputStream
)
throws
AtlasBaseException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> AdminResource.importData(jsonData={}, inputStream={})"
,
jsonData
,
(
inputStream
!=
null
));
}
acquireExportImportLock
(
"import"
);
AtlasImportResult
result
;
try
{
if
(
StringUtils
.
isEmpty
(
jsonData
))
{
jsonData
=
"{}"
;
}
AtlasImportRequest
request
=
AtlasType
.
fromJson
(
jsonData
,
AtlasImportRequest
.
class
);
ZipSource
zipSource
=
new
ZipSource
(
inputStream
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment