mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 05:57:57 +01:00
Fix string list parameters
This commit is contained in:
parent
0f75faeccc
commit
19db8f2445
@ -109,7 +109,7 @@ public class DocumentResource extends BaseResource {
|
||||
@QueryParam("search") String search,
|
||||
@QueryParam("create_date_min") String createDateMinStr,
|
||||
@QueryParam("create_date_max") String createDateMaxStr,
|
||||
@QueryParam("tags[]") List<String> tagIdList) throws JSONException {
|
||||
@QueryParam("tags") List<String> tagIdList) throws JSONException {
|
||||
if (!authenticate()) {
|
||||
throw new ForbiddenClientException();
|
||||
}
|
||||
@ -161,7 +161,7 @@ public class DocumentResource extends BaseResource {
|
||||
public Response add(
|
||||
@FormParam("title") String title,
|
||||
@FormParam("description") String description,
|
||||
@FormParam("tags[]") List<String> tagList,
|
||||
@FormParam("tags") List<String> tagList,
|
||||
@FormParam("create_date") String createDateStr) throws JSONException {
|
||||
if (!authenticate()) {
|
||||
throw new ForbiddenClientException();
|
||||
@ -208,7 +208,7 @@ public class DocumentResource extends BaseResource {
|
||||
@PathParam("id") String id,
|
||||
@FormParam("title") String title,
|
||||
@FormParam("description") String description,
|
||||
@FormParam("tags[]") List<String> tagList,
|
||||
@FormParam("tags") List<String> tagList,
|
||||
@FormParam("create_date") String createDateStr) throws JSONException {
|
||||
if (!authenticate()) {
|
||||
throw new ForbiddenClientException();
|
||||
|
@ -107,6 +107,7 @@ var App = angular.module('docs', ['ui.state', 'ui.bootstrap', 'ui.route', 'ui.ke
|
||||
|
||||
// Configuring $http
|
||||
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
|
||||
$httpProvider.defaults.headers.put['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
|
||||
$httpProvider.defaults.transformRequest = [function(data) {
|
||||
var param = function(obj) {
|
||||
var query = '';
|
||||
@ -118,7 +119,7 @@ var App = angular.module('docs', ['ui.state', 'ui.bootstrap', 'ui.route', 'ui.ke
|
||||
if(value instanceof Array) {
|
||||
for(i=0; i<value.length; ++i) {
|
||||
subValue = value[i];
|
||||
fullSubName = name + '[]';
|
||||
fullSubName = name;
|
||||
innerObj = {};
|
||||
innerObj[fullSubName] = subValue;
|
||||
query += param(innerObj) + '&';
|
||||
|
@ -40,7 +40,7 @@ App.controller('Document', function($scope, $state, Restangular) {
|
||||
search: $scope.search.query,
|
||||
create_date_min: $scope.isAdvancedSearchCollapsed || !$scope.search.createDateMin ? null : $scope.search.createDateMin.getTime(),
|
||||
create_date_max: $scope.isAdvancedSearchCollapsed || !$scope.search.createDateMax ? null : $scope.search.createDateMax.getTime(),
|
||||
'tags[]': $scope.isAdvancedSearchCollapsed ? null : _.pluck($scope.search.tags, 'id')
|
||||
'tags': $scope.isAdvancedSearchCollapsed ? null : _.pluck($scope.search.tags, 'id')
|
||||
})
|
||||
.then(function(data) {
|
||||
$scope.documents = data.documents;
|
||||
|
@ -45,7 +45,7 @@ App.controller('DocumentEdit', function($scope, $q, $http, $state, $stateParams,
|
||||
}
|
||||
|
||||
// Extract ids from tags
|
||||
document['tags[]'] = _.pluck(document.tags, 'id');
|
||||
document.tags = _.pluck(document.tags, 'id');
|
||||
|
||||
if ($scope.isEdit()) {
|
||||
promise = Restangular
|
||||
|
@ -50,7 +50,7 @@ public class TestDocumentResource extends BaseJerseyTest {
|
||||
postParams = new MultivaluedMapImpl();
|
||||
postParams.add("title", "My super document 1");
|
||||
postParams.add("description", "My super description for document 1");
|
||||
postParams.add("tags[]", tag1Id);
|
||||
postParams.add("tags", tag1Id);
|
||||
long create1Date = new Date().getTime();
|
||||
postParams.add("create_date", create1Date);
|
||||
response = documentResource.put(ClientResponse.class, postParams);
|
||||
@ -102,7 +102,7 @@ public class TestDocumentResource extends BaseJerseyTest {
|
||||
documentResource = resource().path("/document/list");
|
||||
documentResource.addFilter(new CookieAuthenticationFilter(document1Token));
|
||||
getParams = new MultivaluedMapImpl();
|
||||
getParams.putSingle("tags[]", tag1Id);
|
||||
getParams.putSingle("tags", tag1Id);
|
||||
response = documentResource.queryParams(getParams).get(ClientResponse.class);
|
||||
json = response.getEntity(JSONObject.class);
|
||||
Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus()));
|
||||
@ -149,7 +149,7 @@ public class TestDocumentResource extends BaseJerseyTest {
|
||||
postParams = new MultivaluedMapImpl();
|
||||
postParams.add("title", "My new super document 1");
|
||||
postParams.add("description", "My new super description for document 1");
|
||||
postParams.add("tags[]", tag2Id);
|
||||
postParams.add("tags", tag2Id);
|
||||
response = documentResource.post(ClientResponse.class, postParams);
|
||||
Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus()));
|
||||
json = response.getEntity(JSONObject.class);
|
||||
|
Loading…
Reference in New Issue
Block a user