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
minerva
core
Commits
f5f8b54c
Commit
f5f8b54c
authored
Sep 17, 2019
by
Piotr Gawron
Browse files
project version cannot be changed to string above 20 characters
parent
2ae2c51d
Changes
2
Hide whitespace changes
Inline
Side-by-side
rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java
View file @
f5f8b54c
...
...
@@ -261,14 +261,13 @@ public class ProjectRestImpl extends BaseRestImpl {
stringValue
=
(
String
)
value
;
}
if
(
fieldName
.
equalsIgnoreCase
(
"version"
))
{
if
(
value
!=
null
&&
((
String
)
value
).
length
()
>
20
)
{
throw
new
QueryException
(
"version is too long (>20 characters)"
);
}
project
.
setVersion
((
String
)
value
);
}
else
if
(
fieldName
.
equalsIgnoreCase
(
"id"
))
{
try
{
int
id
=
Integer
.
parseInt
(
stringValue
);
if
(
id
!=
project
.
getId
())
{
throw
new
QueryException
(
"Invalid id: "
+
stringValue
);
}
}
catch
(
NumberFormatException
e
)
{
int
id
=
parseInteger
(
stringValue
,
"id"
);
if
(
id
!=
project
.
getId
())
{
throw
new
QueryException
(
"Invalid id: "
+
stringValue
);
}
}
else
if
(
fieldName
.
equalsIgnoreCase
(
"projectId"
))
{
...
...
@@ -277,7 +276,7 @@ public class ProjectRestImpl extends BaseRestImpl {
}
}
else
if
(
fieldName
.
equalsIgnoreCase
(
"name"
))
{
if
(
value
!=
null
&&
((
String
)
value
).
length
()
>
255
)
{
throw
new
QueryException
(
"name is too long"
);
throw
new
QueryException
(
"name is too long
(>255 characters)
"
);
}
project
.
setName
((
String
)
value
);
}
else
if
(
fieldName
.
equalsIgnoreCase
(
"notifyEmail"
))
{
...
...
web/src/test/java/lcsb/mapviewer/web/ProjectControllerIntegrationTest.java
View file @
f5f8b54c
...
...
@@ -206,6 +206,22 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest
}
@Test
public
void
testUpdateProjectWithTooLongVersion
()
throws
Exception
{
MockHttpSession
session
=
createSession
(
ADMIN_LOGIN
,
ADMIN_PASSWORD
);
createProject
(
TEST_PROJECT
);
String
content
=
"{\"project\":{\"version\":\"12345678901234567890123456\"}}"
;
RequestBuilder
request
=
patch
(
"/projects/"
+
TEST_PROJECT
+
"/"
)
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
.
content
(
content
)
.
session
(
session
);
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
isBadRequest
());
}
@Test
public
void
testUpdateProjectWithUndefinedProjectId
()
throws
Exception
{
MockHttpSession
session
=
createSession
(
ADMIN_LOGIN
,
ADMIN_PASSWORD
);
...
...
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