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
7763fd0d
Commit
7763fd0d
authored
Oct 03, 2018
by
Ashutosh Mestry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2897: Elegant handling of empty zip files. Part 2.
parent
f6acb086
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
12 deletions
+27
-12
ZipSource.java
...in/java/org/apache/atlas/repository/impexp/ZipSource.java
+9
-6
ExportServiceTest.java
...org/apache/atlas/repository/impexp/ExportServiceTest.java
+0
-1
ZipFileResourceTestUtils.java
...che/atlas/repository/impexp/ZipFileResourceTestUtils.java
+0
-4
AdminResource.java
...in/java/org/apache/atlas/web/resources/AdminResource.java
+18
-1
No files found.
repository/src/main/java/org/apache/atlas/repository/impexp/ZipSource.java
View file @
7763fd0d
...
...
@@ -64,13 +64,20 @@ public class ZipSource implements EntityImportStream {
this
.
importTransform
=
importTransform
;
updateGuidZipEntryMap
();
if
(
MapUtils
.
isEmpty
(
guidEntityJsonMap
))
{
if
(
isZipFileEmpty
(
))
{
throw
new
AtlasBaseException
(
IMPORT_ATTEMPTING_EMPTY_ZIP
,
"Attempting to import empty ZIP."
);
}
setCreationOrder
();
}
private
boolean
isZipFileEmpty
()
{
return
MapUtils
.
isEmpty
(
guidEntityJsonMap
)
||
(
guidEntityJsonMap
.
containsKey
(
ZipExportFileNames
.
ATLAS_EXPORT_ORDER_NAME
.
toString
())
&&
(
guidEntityJsonMap
.
get
(
ZipExportFileNames
.
ATLAS_EXPORT_ORDER_NAME
.
toString
())
==
null
)
);
}
public
ImportTransforms
getImportTransform
()
{
return
this
.
importTransform
;
}
public
void
setImportTransform
(
ImportTransforms
importTransform
)
{
...
...
@@ -136,7 +143,7 @@ public class ZipSource implements EntityImportStream {
zipInputStream
.
close
();
}
public
List
<
String
>
getCreationOrder
()
throws
AtlasBaseException
{
public
List
<
String
>
getCreationOrder
()
{
return
this
.
creationOrder
;
}
...
...
@@ -234,12 +241,8 @@ public class ZipSource implements EntityImportStream {
@Override
public
void
reset
()
{
try
{
getCreationOrder
();
this
.
iterator
=
this
.
creationOrder
.
iterator
();
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"reset"
,
e
);
}
}
@Override
...
...
repository/src/test/java/org/apache/atlas/repository/impexp/ExportServiceTest.java
View file @
7763fd0d
...
...
@@ -314,7 +314,6 @@ public class ExportServiceTest extends ExportImportTestBase {
assertNotNull
(
zipSource
.
getCreationOrder
());
assertEquals
(
zipSource
.
getCreationOrder
().
size
(),
0
);
assertEquals
(
AtlasExportResult
.
OperationStatus
.
FAIL
,
zipSource
.
getExportResult
().
getOperationStatus
());
}
@Test
...
...
repository/src/test/java/org/apache/atlas/repository/impexp/ZipFileResourceTestUtils.java
View file @
7763fd0d
...
...
@@ -255,7 +255,6 @@ public class ZipFileResourceTestUtils {
public
static
AtlasEntity
.
AtlasEntityWithExtInfo
getEntities
(
ZipSource
source
,
int
expectedCount
)
{
AtlasEntity
.
AtlasEntityWithExtInfo
entityWithExtInfo
=
new
AtlasEntity
.
AtlasEntityWithExtInfo
();
try
{
int
count
=
0
;
for
(
String
s
:
source
.
getCreationOrder
())
{
AtlasEntity
entity
=
source
.
getByGuid
(
s
);
...
...
@@ -265,9 +264,6 @@ public class ZipFileResourceTestUtils {
assertEquals
(
count
,
expectedCount
);
return
entityWithExtInfo
;
}
catch
(
AtlasBaseException
e
)
{
throw
new
SkipException
(
"getEntities: failed!"
);
}
}
public
static
void
loadModelFromJson
(
String
fileName
,
AtlasTypeDefStore
typeDefStore
,
AtlasTypeRegistry
typeRegistry
)
throws
IOException
,
AtlasBaseException
{
...
...
webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java
View file @
7763fd0d
...
...
@@ -391,7 +391,7 @@ public class AdminResource {
AtlasAuthorizationUtils
.
verifyAccess
(
new
AtlasAdminAccessRequest
(
AtlasPrivilege
.
ADMIN_IMPORT
),
"importData"
);
acquireExportImportLock
(
"import"
);
AtlasImportResult
result
;
AtlasImportResult
result
=
null
;
try
{
AtlasImportRequest
request
=
AtlasType
.
fromJson
(
jsonData
,
AtlasImportRequest
.
class
);
...
...
@@ -400,6 +400,15 @@ public class AdminResource {
result
=
importService
.
run
(
zipSource
,
request
,
Servlets
.
getUserName
(
httpServletRequest
),
Servlets
.
getHostName
(
httpServletRequest
),
AtlasAuthorizationUtils
.
getRequestIpAddress
(
httpServletRequest
));
}
catch
(
AtlasBaseException
excp
)
{
if
(
excp
.
getAtlasErrorCode
().
equals
(
AtlasErrorCode
.
IMPORT_ATTEMPTING_EMPTY_ZIP
))
{
LOG
.
info
(
excp
.
getMessage
());
}
else
{
LOG
.
error
(
"importData(binary) failed"
,
excp
);
}
throw
excp
;
}
catch
(
Exception
excp
)
{
LOG
.
error
(
"importData(binary) failed"
,
excp
);
...
...
@@ -434,6 +443,14 @@ public class AdminResource {
result
=
importService
.
run
(
request
,
Servlets
.
getUserName
(
httpServletRequest
),
Servlets
.
getHostName
(
httpServletRequest
),
AtlasAuthorizationUtils
.
getRequestIpAddress
(
httpServletRequest
));
}
catch
(
AtlasBaseException
excp
)
{
if
(
excp
.
getAtlasErrorCode
().
getErrorCode
().
equals
(
AtlasErrorCode
.
IMPORT_ATTEMPTING_EMPTY_ZIP
))
{
LOG
.
info
(
excp
.
getMessage
());
}
else
{
LOG
.
error
(
"importData(binary) failed"
,
excp
);
}
throw
excp
;
}
catch
(
Exception
excp
)
{
LOG
.
error
(
"importFile() failed"
,
excp
);
...
...
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