Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Genesys Backend
Commits
b7c71acd
Commit
b7c71acd
authored
Mar 18, 2015
by
Matija Obreza
Browse files
webapi: x-csrf-token, webapi.js and webapi-min.js
parent
322bf2d9
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/genesys2/server/servlet/controller/webapi/WebApiController.java
View file @
b7c71acd
...
...
@@ -79,8 +79,8 @@ public class WebApiController extends RestController {
}
public
static
class
JsonData
{
public
String
filter
;
public
Integer
startAt
;
public
Integer
maxRecords
;
public
String
filter
=
""
;
public
Integer
startAt
=
1
;
public
Integer
maxRecords
=
50
;
}
}
src/main/webapp/WEB-INF/web.xml
View file @
b7c71acd
...
...
@@ -121,7 +121,7 @@
</init-param>
<init-param>
<param-name>
allowedHeaders
</param-name>
<param-value>
authorization,content-type
</param-value>
<param-value>
authorization,content-type
,x-csrf-token
</param-value>
</init-param>
<!-- Do not chain preflight request to application -->
<init-param>
...
...
src/main/webapp/html/js/webapi.js
0 → 100644
View file @
b7c71acd
/**
* Copyright 2015 Global Crop Diversity Trust
* jQuery $ and $.ajax() required.
*/
GenesysPGR
=
function
(
baseUrl
,
clientId
)
{
this
.
clientId
=
clientId
;
this
.
baseUrl
=
baseUrl
;
this
.
clientSecret
=
null
;
this
.
defaultOptions
=
{
startAt
:
1
,
maxRecords
:
50
,
success
:
new
Function
(),
error
:
new
Function
()
};
};
GenesysPGR
.
prototype
.
getUrl
=
function
(
apiCall
)
{
return
this
.
baseUrl
+
'
/webapi
'
+
apiCall
+
'
?client_id=
'
+
this
.
clientId
+
(
this
.
clientSecret
!==
null
?
'
&client_secret=
'
+
this
.
clientSecret
:
''
);
};
GenesysPGR
.
prototype
.
listAccessions
=
function
(
filter
,
opts
)
{
var
o
=
$
.
extend
({},
GenesysPGR
.
defaultOptions
,
opts
);
var
json
=
{
filter
:
JSON
.
stringify
(
filter
),
startAt
:
Math
.
max
(
1
,
o
.
startAt
),
maxRecords
:
o
.
maxRecords
};
$
.
ajax
(
this
.
getUrl
(
'
/v0/acn/filter
'
),
{
dataType
:
'
json
'
,
type
:
'
POST
'
,
contentType
:
'
application/json; charset=utf-8
'
,
data
:
JSON
.
stringify
(
json
),
success
:
function
(
accessions
)
{
o
.
success
(
accessions
);
},
error
:
function
(
errorAsync
)
{
o
.
error
(
errorAsync
);
}
});
};
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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