Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-6992: Fix Files UI to show the managed-schema file as well

Varun Thacker5e03927a8c3a
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 55ec0390a85..9433dea8820 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -239,6 +239,9 @@ Bug Fixes
* SOLR-8401: Windows start script fails when executed from a different drive.
(Nicolas Gavalda via Erick Erickson)
+* SOLR-6992: Fix "Files" UI to show the managed-schema file as well.
+ (Shawn Heisey, Varun Thacker)
+
Other Changes
----------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java
index 9c80be4e377..64dae3ab756 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java
@@ -275,19 +275,6 @@ public class ShowFileRequestHandler extends RequestHandlerBase
}
return true;
}
-
- // Make sure that if the schema is managed, we don't allow editing. Don't really want to put
- // this in the init since we're not entirely sure when the managed schema will get initialized relative to this
- // handler.
- SolrCore core = req.getCore();
- IndexSchema schema = core.getLatestSchema();
- if (schema instanceof ManagedIndexSchema) {
- String managed = schema.getResourceName();
-
- if (fname.equalsIgnoreCase(managed)) {
- return true;
- }
- }
return false;
}
diff --git a/solr/webapp/web/js/angular/controllers/files.js b/solr/webapp/web/js/angular/controllers/files.js
index c4fb53ad40d..1cb9e5cd55e 100644
--- a/solr/webapp/web/js/angular/controllers/files.js
+++ b/solr/webapp/web/js/angular/controllers/files.js
@@ -71,7 +71,12 @@ solrAdminApp.controller('FilesController',
process("", $scope.tree);
if ($scope.file && $scope.file != '' && $scope.file.split('').pop()!='/') {
- var extension = $scope.file.match( /\.(\w+)$/)[1] || '';
+ var extension;
+ if ($scope.file == "managed-schema") {
+ extension = contentTypeMap['xml'];
+ } else {
+ extension = $scope.file.match( /\.(\w+)$/)[1] || '';
+ }
var contentType = (contentTypeMap[extension] || 'text/plain' ) + ';charset=utf-8';
Files.get({core: $routeParams.core, file: $scope.file, contentType: contentType}, function(data) {
diff --git a/solr/webapp/web/js/scripts/files.js b/solr/webapp/web/js/scripts/files.js
index 358412d3e8b..c6b19519cfa 100644
--- a/solr/webapp/web/js/scripts/files.js
+++ b/solr/webapp/web/js/scripts/files.js
@@ -163,8 +163,13 @@ sammy.get
var endpoint = file_endpoint + '?file=' + selected_file;
var content_type_map = { xml : 'text/xml', html : 'text/html', js : 'text/javascript', json : 'application/json', 'css' : 'text/css' };
- var file_ext = selected_file.match( /\.(\w+)$/ );
- endpoint += '&contentType=' + ( content_type_map[ file_ext[1] || '' ] || 'text/plain' ) + ';charset=utf-8';
+ if (selected_file == 'managed-schema') {
+ endpoint += '&contentType=' + 'text/xml' + ';charset=utf-8';
+ } else {
+ var file_ext = selected_file.match( /\.(\w+)$/ );
+ endpoint += '&contentType=' + ( content_type_map[ file_ext[1] || '' ] || 'text/plain' ) + ';charset=utf-8';
+ }
+
var public_url = window.location.protocol + '//' + window.location.host + endpoint;