You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by up...@apache.org on 2015/07/12 23:40:10 UTC
svn commit: r1690536 - in /lucene/dev/branches/branch_5x: ./ solr/
solr/webapp/ solr/webapp/web/js/angular/controllers/documents.js
solr/webapp/web/js/angular/services.js
Author: upayavira
Date: Sun Jul 12 21:40:10 2015
New Revision: 1690536
URL: http://svn.apache.org/r1690536
Log:
SOLR-7782 Allow non-JSON and JSON array uploads
Modified:
lucene/dev/branches/branch_5x/ (props changed)
lucene/dev/branches/branch_5x/solr/ (props changed)
lucene/dev/branches/branch_5x/solr/webapp/ (props changed)
lucene/dev/branches/branch_5x/solr/webapp/web/js/angular/controllers/documents.js
lucene/dev/branches/branch_5x/solr/webapp/web/js/angular/services.js
Modified: lucene/dev/branches/branch_5x/solr/webapp/web/js/angular/controllers/documents.js
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/webapp/web/js/angular/controllers/documents.js?rev=1690536&r1=1690535&r2=1690536&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/webapp/web/js/angular/controllers/documents.js (original)
+++ lucene/dev/branches/branch_5x/solr/webapp/web/js/angular/controllers/documents.js Sun Jul 12 21:40:10 2015
@@ -85,35 +85,43 @@ solrAdminApp.controller('DocumentsContro
if ($scope.type == "json" || $scope.type == "wizard") {
postData = "[" + $scope.document + "]";
- contentType = "application/json";
+ contentType = "json";
} else if ($scope.type == "csv") {
postData = $scope.document;
- contentType = "application/csv";
+ contentType = "csv";
} else if ($scope.type == "xml") {
postData = "<add>" + $scope.document + "</add>";
- contentType = "text/xml";
+ contentType = "xml";
} else if ($scope.type == "upload") {
doingFileUpload = true;
params.raw = $scope.literalParams;
} else if ($scope.type == "solr") {
postData = $scope.document;
if (postData[0] == "<") {
- contentType = "text/xml";
- } else if (postData[0] == "{") {
- contentType = "application/json";
+ contentType = "xml";
+ } else if (postData[0] == "{" || postData[0] == '[') {
+ contentType = "json";
} else {
alert("Cannot identify content type")
}
}
if (!doingFileUpload) {
- Update.post(params, postData).then(function (success) {
- $scope.responseStatus = "success";
- delete success.$promise;
- delete success.$resolved;
- $scope.response = JSON.stringify(success, null, ' ');
- }).fail(function (failure) {
+ var callback = function (success) {
+ $scope.responseStatus = "success";
+ delete success.$promise;
+ delete success.$resolved;
+ $scope.response = JSON.stringify(success, null, ' ');
+ };
+ var failure = function (failure) {
$scope.responseStatus = failure;
- });
+ };
+ if (contentType == "json") {
+ Update.postJson(params, postData, callack, failure);
+ } else if (contentType == "xml") {
+ Update.postXml(params, postData, callback, failure);
+ } else if (contentType == "csv") {
+ Update.postCsv(params, postData, callback, failure);
+ }
} else {
var file = $scope.fileUpload;
console.log('file is ' + JSON.stringify(file));
Modified: lucene/dev/branches/branch_5x/solr/webapp/web/js/angular/services.js
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/webapp/web/js/angular/services.js?rev=1690536&r1=1690535&r2=1690536&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/webapp/web/js/angular/services.js (original)
+++ lucene/dev/branches/branch_5x/solr/webapp/web/js/angular/services.js Sun Jul 12 21:40:10 2015
@@ -78,10 +78,13 @@ solrAdminServices.factory('System',
}])
.factory('Update',
['$resource', function($resource) {
- return $resource('/solr/:core/:handler', {core: '@core', wt:'json', _:Date.now(), handler:'/update'}, {
+ return $resource('/solr/:core/:handler', {core: '@core', wt:'json', _:Date.now(), handler:'update'}, {
"optimize": {params: { optimize: "true"}},
"commit": {params: {commit: "true"}},
- "post": {method: "POST", params: {handler: '@handler'}}
+ "post": {headers: {'Content-type': 'application/json'}, method: "POST", params: {handler: '@handler'}},
+ "postJson": {headers: {'Content-type': 'application/json'}, method: "POST", params: {handler: '@handler'}},
+ "postXml": {headers: {'Content-type': 'text/xml'}, method: "POST", params: {handler: '@handler'}},
+ "postCsv": {headers: {'Content-type': 'application/csv'}, method: "POST", params: {handler: '@handler'}}
});
}])
.service('FileUpload', function ($http) {