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
735b6e4e
Commit
735b6e4e
authored
Aug 30, 2018
by
Piotr Gawron
Browse files
removing default project returns 405 status code (NOT ALLOWED)
parent
a44fffe2
Changes
3
Hide whitespace changes
Inline
Side-by-side
rest-api/src/main/java/lcsb/mapviewer/api/BaseController.java
View file @
735b6e4e
...
...
@@ -36,6 +36,8 @@ public abstract class BaseController {
return
createErrorResponse
(
"Object not found."
,
e
.
getMessage
(),
new
HttpHeaders
(),
HttpStatus
.
NOT_FOUND
);
}
else
if
(
e
instanceof
ObjectExistsException
)
{
return
createErrorResponse
(
"Object already exists."
,
e
.
getMessage
(),
new
HttpHeaders
(),
HttpStatus
.
CONFLICT
);
}
else
if
(
e
instanceof
OperationNotAllowedException
)
{
return
createErrorResponse
(
"Query server error."
,
e
.
getMessage
(),
new
HttpHeaders
(),
HttpStatus
.
METHOD_NOT_ALLOWED
);
}
else
if
(
e
instanceof
QueryException
)
{
logger
.
error
(
e
,
e
);
return
createErrorResponse
(
"Query server error."
,
e
.
getMessage
(),
new
HttpHeaders
(),
HttpStatus
.
BAD_REQUEST
);
...
...
rest-api/src/main/java/lcsb/mapviewer/api/OperationNotAllowedException.java
0 → 100644
View file @
735b6e4e
package
lcsb.mapviewer.api
;
/**
* Thrown when API operation is not allowed, but operation is valid. This can
* happen when user tries to remove default map.
*
* @author Piotr Gawron
*
*/
public
class
OperationNotAllowedException
extends
QueryException
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
/**
* Default constructor.
*
* @param message
* error message
*/
public
OperationNotAllowedException
(
String
message
)
{
super
(
message
);
}
/**
* Constructor with error message and parent exception.
*
* @param message
* error message
* @param reason
* parent exception that caused this one
*/
public
OperationNotAllowedException
(
String
message
,
Exception
reason
)
{
super
(
message
,
reason
);
}
}
rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java
View file @
735b6e4e
...
...
@@ -31,6 +31,7 @@ import org.springframework.util.MultiValueMap;
import
lcsb.mapviewer.api.BaseRestImpl
;
import
lcsb.mapviewer.api.ObjectExistsException
;
import
lcsb.mapviewer.api.ObjectNotFoundException
;
import
lcsb.mapviewer.api.OperationNotAllowedException
;
import
lcsb.mapviewer.api.QueryException
;
import
lcsb.mapviewer.api.projects.models.publications.PublicationsRestImpl
;
import
lcsb.mapviewer.commands.ClearColorModelCommand
;
...
...
@@ -739,7 +740,7 @@ public class ProjectRestImpl extends BaseRestImpl {
throws
SecurityException
,
QueryException
{
Project
project
=
getProjectService
().
getProjectByProjectId
(
projectId
,
token
);
if
(
getConfigurationService
().
getConfigurationValue
(
ConfigurationElementType
.
DEFAULT_MAP
).
equals
(
project
.
getProjectId
()))
{
throw
new
Query
Exception
(
"You cannot remove default map"
);
throw
new
OperationNotAllowed
Exception
(
"You cannot remove default map"
);
}
getProjectService
().
removeProject
(
project
,
path
,
true
,
token
);
return
getProject
(
projectId
,
token
);
...
...
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