Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Genesys Backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
12
Issues
12
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
Genesys Backend
Commits
0097c5d8
Commit
0097c5d8
authored
Oct 06, 2017
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Spring's mappers instead of parsing Strings
parent
cc7b1af0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
19 deletions
+11
-19
src/main/java/org/genesys2/server/servlet/controller/admin/OAuthManagementController.java
...r/servlet/controller/admin/OAuthManagementController.java
+4
-3
src/main/java/org/genesys2/server/servlet/controller/rest/AccessionController.java
...2/server/servlet/controller/rest/AccessionController.java
+5
-4
src/main/java/org/genesys2/server/servlet/controller/rest/DatasetController.java
...ys2/server/servlet/controller/rest/DatasetController.java
+2
-12
No files found.
src/main/java/org/genesys2/server/servlet/controller/admin/OAuthManagementController.java
View file @
0097c5d8
...
...
@@ -132,12 +132,13 @@ public class OAuthManagementController extends BaseController {
@PreAuthorize
(
"hasAnyRole('VETTEDUSER','ADMINISTRATOR')"
)
@RequestMapping
(
value
=
"/save-client"
,
method
=
RequestMethod
.
POST
,
params
=
"newClient=new"
)
public
String
createClientEntry
(
Model
model
,
@RequestParam
(
"title"
)
String
title
,
@RequestParam
(
"description"
)
String
description
,
@RequestParam
(
value
=
"redirectUris"
,
required
=
false
)
String
redirectUris
,
@RequestParam
(
"accessTokenValiditySeconds"
)
Integer
accessTokenValiditySeconds
,
@RequestParam
(
"refreshTokenValiditySeconds"
)
Integer
refreshTokenValiditySeconds
,
@RequestParam
(
valu
e
=
"clientType"
,
required
=
false
)
String
clientType
)
{
@RequestParam
(
value
=
"redirectUris"
,
required
=
false
)
String
redirectUris
,
@RequestParam
(
name
=
"accessTokenValidity"
,
required
=
false
)
Integer
accessTokenValiditySeconds
,
@RequestParam
(
name
=
"refreshTokenValidity"
,
required
=
false
)
Integer
refreshTokenValiditySeconds
,
@RequestParam
(
nam
e
=
"clientType"
,
required
=
false
)
String
clientType
)
{
OAuthClient
oauthClient
=
clientDetailsService
.
addClient
(
title
,
description
,
redirectUris
,
accessTokenValiditySeconds
,
refreshTokenValiditySeconds
);
_logger
.
info
(
"Created OAuth client with clientId="
+
oauthClient
.
getClientId
());
return
"redirect:"
+
CONTROLLER_PATH
+
"/"
+
oauthClient
.
getId
()
+
"/edit"
;
return
"redirect:"
+
CONTROLLER_PATH
+
"/"
;
}
@PreAuthorize
(
"hasAnyRole('VETTEDUSER','ADMINISTRATOR')"
)
...
...
src/main/java/org/genesys2/server/servlet/controller/rest/AccessionController.java
View file @
0097c5d8
...
...
@@ -133,14 +133,13 @@ public class AccessionController extends RestController {
* @throws NonUniqueAccessionException
*/
@RequestMapping
(
value
=
"/{instCode}/check"
,
method
=
{
RequestMethod
.
POST
,
RequestMethod
.
PUT
},
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
public
@ResponseBody
JsonNode
check
(
@PathVariable
(
"instCode"
)
String
instCode
,
@RequestBody
String
content
)
throws
JsonProcessingException
,
IOException
,
RESTApiValueException
,
public
@ResponseBody
JsonNode
check
(
@PathVariable
(
"instCode"
)
String
instCode
,
@RequestBody
JsonNode
json
)
throws
JsonProcessingException
,
IOException
,
RESTApiValueException
,
NonUniqueAccessionException
{
final
FaoInstitute
institute
=
instituteService
.
getInstitute
(
instCode
);
if
(
institute
==
null
)
{
throw
new
ResourceNotFoundException
(
"No institute "
+
instCode
);
}
final
JsonNode
json
=
mapper
.
readTree
(
content
);
final
List
<
String
>
batch
=
new
ArrayList
<
String
>();
if
(
json
.
isArray
())
{
...
...
@@ -194,8 +193,10 @@ public class AccessionController extends RestController {
* @throws RESTApiException
*/
@RequestMapping
(
value
=
"/{instCode}/upsert"
,
method
=
{
RequestMethod
.
POST
,
RequestMethod
.
PUT
},
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
public
@ResponseBody
Object
upsertInstituteAccession
(
@PathVariable
(
"instCode"
)
String
instCode
,
@RequestBody
String
content
)
throws
JsonProcessingException
,
IOException
,
public
@ResponseBody
Object
upsertInstituteAccession
(
@PathVariable
(
"instCode"
)
String
instCode
,
@RequestBody
JsonNode
json
)
throws
JsonProcessingException
,
IOException
,
RESTApiException
{
LOG
.
debug
(
"Received:\n"
+
json
);
// User's permission to WRITE to this WIEWS institute are checked in
// BatchRESTService.
...
...
@@ -204,7 +205,7 @@ public class AccessionController extends RestController {
throw
new
ResourceNotFoundException
();
}
final
JsonNode
json
=
mapper
.
readTree
(
content
);
//
final JsonNode json = mapper.readTree(content);
final
Map
<
AccessionHeaderJson
,
ObjectNode
>
batch
=
new
HashMap
<
AccessionHeaderJson
,
ObjectNode
>();
if
(
json
.
isArray
())
{
...
...
src/main/java/org/genesys2/server/servlet/controller/rest/DatasetController.java
View file @
0097c5d8
...
...
@@ -160,7 +160,7 @@ public class DatasetController extends RestController {
*/
@RequestMapping
(
value
=
"/{metadataId:.+}/data"
,
method
=
{
RequestMethod
.
PUT
,
RequestMethod
.
POST
},
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
public
@ResponseBody
Object
upsertMetadataData
(
@PathVariable
(
"metadataId"
)
Long
metadataId
,
@RequestBody
String
data
)
throws
AuthorizationException
,
IOException
,
NonUniqueAccessionException
{
Object
upsertMetadataData
(
@PathVariable
(
"metadataId"
)
Long
metadataId
,
@RequestBody
JsonNode
json
)
throws
AuthorizationException
,
IOException
,
NonUniqueAccessionException
{
final
Metadata
metadata
=
datasetService
.
getDataset
(
metadataId
);
if
(
metadata
==
null
)
{
throw
new
ResourceNotFoundException
();
...
...
@@ -169,17 +169,7 @@ public class DatasetController extends RestController {
// Check for 'WRITE' permission
datasetService
.
touch
(
metadata
);
LOG
.
debug
(
data
);
final
ObjectMapper
objectMapper
=
new
ObjectMapper
();
JsonNode
json
=
null
;
try
{
json
=
objectMapper
.
readTree
(
data
);
LOG
.
debug
(
json
);
}
catch
(
final
IOException
e
)
{
LOG
.
error
(
e
);
throw
e
;
}
LOG
.
debug
(
json
);
if
(
json
.
isArray
())
{
for
(
final
JsonNode
jo
:
json
)
{
...
...
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