Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Devrim Gunyel
core
Commits
051815d4
Commit
051815d4
authored
May 10, 2019
by
Piotr Gawron
Browse files
glyph input is processed properly and proper exception returned when there is a problem with input
parent
21b28450
Changes
2
Hide whitespace changes
Inline
Side-by-side
rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java
View file @
051815d4
...
...
@@ -30,6 +30,7 @@ import lcsb.mapviewer.api.projects.models.publications.PublicationsRestImpl;
import
lcsb.mapviewer.common.exception.InvalidArgumentException
;
import
lcsb.mapviewer.common.exception.NotImplementedException
;
import
lcsb.mapviewer.converter.Converter
;
import
lcsb.mapviewer.converter.zip.GlyphZipEntryFile
;
import
lcsb.mapviewer.converter.zip.ImageZipEntryFile
;
import
lcsb.mapviewer.converter.zip.LayoutZipEntryFile
;
import
lcsb.mapviewer.converter.zip.ModelZipEntryFile
;
...
...
@@ -429,7 +430,7 @@ public class ProjectRestImpl extends BaseRestImpl {
return
path
+
"/../map_images/"
+
md5
(
projectId
+
"-"
+
id
)
+
"/"
;
}
protected
List
<
ZipEntryFile
>
extractZipEntries
(
MultiValueMap
<
String
,
Object
>
data
)
{
protected
List
<
ZipEntryFile
>
extractZipEntries
(
MultiValueMap
<
String
,
Object
>
data
)
throws
QueryException
{
int
fileIndex
=
0
;
List
<
ZipEntryFile
>
result
=
new
ArrayList
<>();
while
(
data
.
get
(
"zip-entries["
+
fileIndex
+
"][_filename]"
)
!=
null
)
{
...
...
@@ -455,8 +456,10 @@ public class ProjectRestImpl extends BaseRestImpl {
entry
=
new
LayoutZipEntryFile
(
filename
,
name
,
description
);
}
else
if
(
"IMAGE"
.
equalsIgnoreCase
(
entryType
))
{
entry
=
new
ImageZipEntryFile
(
filename
);
}
else
if
(
"GLYPH"
.
equalsIgnoreCase
(
entryType
))
{
entry
=
new
GlyphZipEntryFile
(
filename
);
}
else
{
throw
new
Error
(
"Unknown entry type: "
+
entryType
);
throw
new
QueryException
(
"Unknown entry type: "
+
entryType
);
}
fileIndex
++;
result
.
add
(
entry
);
...
...
rest-api/src/test/java/lcsb/mapviewer/api/projects/ProjectRestImplTest.java
View file @
051815d4
...
...
@@ -25,6 +25,7 @@ import org.springframework.util.MultiValueMap;
import
com.google.gson.Gson
;
import
lcsb.mapviewer.api.ObjectNotFoundException
;
import
lcsb.mapviewer.api.QueryException
;
import
lcsb.mapviewer.api.RestTestFunctions
;
import
lcsb.mapviewer.converter.zip.ImageZipEntryFile
;
import
lcsb.mapviewer.converter.zip.LayoutZipEntryFile
;
...
...
@@ -57,8 +58,9 @@ public class ProjectRestImplTest extends RestTestFunctions {
public
void
before
()
{
_projectRestImpl
.
setModelService
(
modelService
);
_projectRestImpl
.
setProjectService
(
projectService
);
}
@Test
public
void
testGetModelDataDependencies
()
throws
Exception
{
try
{
...
...
@@ -91,9 +93,9 @@ public class ProjectRestImplTest extends RestTestFunctions {
project
.
setProjectId
(
projectId
);
projectDao
.
add
(
project
);
User
user
=
userService
.
getUserByToken
(
token
);
userService
.
setUserPrivilege
(
user
,
PrivilegeType
.
VIEW_PROJECT
,
1
,
project
.
getId
(),
adminToken
);
userService
.
setUserPrivilege
(
user
,
PrivilegeType
.
VIEW_PROJECT
,
1
,
project
.
getId
(),
adminToken
);
userService
.
setUserPrivilege
(
user
,
PrivilegeType
.
PROJECT_MANAGEMENT
,
1
);
//
userService.setUserPrivilege(user, PrivilegeType.VIEW_PROJECT, 1);
//
userService.setUserPrivilege(user, PrivilegeType.VIEW_PROJECT, 1);
_projectRestImpl
.
removeProject
(
token
,
projectId
,
null
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -236,6 +238,20 @@ public class ProjectRestImplTest extends RestTestFunctions {
}
}
@Test
(
expected
=
QueryException
.
class
)
public
void
testExtractZipEntriesWithInvalidType
()
throws
Exception
{
try
{
MultiValueMap
<
String
,
Object
>
data
=
new
LinkedMultiValueMap
<>();
data
.
put
(
"zip-entries[0][_type]"
,
createLinkedList
(
"MAPX"
));
data
.
put
(
"zip-entries[0][_filename]"
,
createLinkedList
(
"main.xml"
));
_projectRestImpl
.
extractZipEntries
(
data
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
@Test
public
void
testExtractZipEntriesWithNoMapType
()
throws
Exception
{
try
{
...
...
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