Skip to content

Commit 2e871f4

Browse files
committed
FELIX-6392 : Webconsole configadmin javascript error: Uncaught TypeError: parsers is undefined
1 parent 8ca4a3b commit 2e871f4

File tree

6 files changed

+44
-15
lines changed

6 files changed

+44
-15
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Changes in 4.6.2
22
----------------
33
** Bug
44
* [FELIX-6375] - Configuration Admin Service not available with org.apache.felix.webconsole_4.6.0.all
5+
* [FELIX-6392] - Webconsole configadmin javascript error: Uncaught TypeError: parsers is undefined
56

67

78
Changes in 4.6.0

src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigAdminSupport.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public BundleContext getBundleContext()
9999
return bundleContext;
100100
}
101101

102-
private MetaTypeServiceSupport getMetaTypeSupport()
102+
MetaTypeServiceSupport getMetaTypeSupport()
103103
{
104104
Object metaTypeService = configManager.getService( ConfigManager.META_TYPE_NAME );
105105
if ( metaTypeService != null )
@@ -556,8 +556,9 @@ private final Bundle getBoundBundle(Configuration config)
556556
}
557557

558558

559-
final void listConfigurations( JSONWriter jw, String pidFilter, String locale, Locale loc )
559+
final boolean listConfigurations( JSONWriter jw, String pidFilter, String locale, Locale loc )
560560
{
561+
boolean hasConfigurations = false;
561562
try
562563
{
563564
// start with ManagedService instances
@@ -613,6 +614,7 @@ final void listConfigurations( JSONWriter jw, String pidFilter, String locale, L
613614
jw.array();
614615
for ( Iterator<String> ii = optionsPlain.keySet().iterator(); ii.hasNext(); )
615616
{
617+
hasConfigurations = true;
616618
String id = ii.next();
617619
Object name = optionsPlain.get( id );
618620

@@ -652,6 +654,7 @@ final void listConfigurations( JSONWriter jw, String pidFilter, String locale, L
652654
{
653655
configManager.log("listConfigurations: Unexpected problem encountered", e);
654656
}
657+
return hasConfigurations;
655658
}
656659

657660
/**

src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,21 @@ protected void renderContent( HttpServletRequest request, HttpServletResponse re
400400
@SuppressWarnings("unchecked")
401401
final Map<String, Object> labelMap = (Map<String, Object>) request.getAttribute(WebConsoleConstants.ATTR_LABEL_MAP);
402402
jw.key("jsonsupport").value( labelMap.containsKey("osgi-installer-config-printer") ); //$NON-NLS-1$
403+
final boolean hasMetatype = ca.getMetaTypeSupport() != null;
403404
jw.key("status").value( ca != null ? Boolean.TRUE : Boolean.FALSE); //$NON-NLS-1$
405+
jw.key("metatype").value( hasMetatype ? Boolean.TRUE : Boolean.FALSE); //$NON-NLS-1$
406+
boolean hasConfigs = true;
404407
if ( ca != null )
405408
{
406-
ca.listConfigurations( jw, pidFilter, locale, loc );
409+
hasConfigs = ca.listConfigurations( jw, pidFilter, locale, loc );
407410
ca.listFactoryConfigurations( jw, pidFilter, locale );
408411
}
412+
if ( !hasConfigs && !hasMetatype && ca != null ) {
413+
jw.key("noconfigs").value(true); //$NON-NLS-1$
414+
} else {
415+
jw.key("noconfigs").value(false); //$NON-NLS-1$
416+
}
417+
409418
jw.endObject();
410419

411420
// if a configuration is addressed, display it immediately

src/main/resources/OSGI-INF/l10n/bundle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ bundles.error.title=Error while executing bundle operation!
174174
configMgr.pluginTitle=Configuration
175175
config.status.ok=Configuration Admin Service is running.
176176
config.status.missing=Configuration Admin Service is not installed/running.
177+
config.metatype.ok=Metatype Service is available.
178+
config.metatype.missing=Metatype service is missing.
179+
config.noconfigs=No configurations available.
177180
config.properties=Properties
178181
config.properties.enter=Enter Name-Value pairs of configuration properties
179182
config.info.title=Configuration Information

src/main/resources/res/ui/config.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -698,12 +698,19 @@ $(document).ready(function() {
698698
jsonSupport = configData.jsonsupport;
699699

700700
// display the configuration data
701-
$(".statline").html(configData.status ? i18n.stat_ok : i18n.stat_missing);
701+
var line = configData.status ? i18n.stat_ok : i18n.stat_missing;
702+
line = line + " " + (configData.metatype ? i18n.metatype_ok : i18n.metatype_missing);
703+
if ( configData.noconfigs ) {
704+
line = line + " " + i18n.noconfigs;
705+
}
706+
$(".statline").html(line);
702707
if (configData.status) {
708+
var hasData = false;
703709
configBody.empty();
704710
var factories = {};
705711

706712
for(var i in configData.pids) {
713+
hasData = true;
707714
var c = configData.pids[i];
708715
if (c.fpid) {
709716
if (!factories[c.fpid]) factories[c.fpid] = new Array();
@@ -713,6 +720,7 @@ $(document).ready(function() {
713720
}
714721
}
715722
for(var i in configData.fpids) {
723+
hasData = true;
716724
addFactoryConfig(configData.fpids[i]);
717725

718726
var fpid = configData.fpids[i].id;
@@ -733,17 +741,19 @@ $(document).ready(function() {
733741
}
734742
initStaticWidgets(configTable);
735743

736-
// init tablesorte
737-
configTable.tablesorter({
738-
headers: {
739-
0: { sorter: false },
740-
3: { sorter: false }
741-
},
742-
sortList: [[1,1]],
743-
textExtraction: treetableExtraction
744-
}).bind('sortStart', function() { // clear cache, otherwise extraction will not work
745-
var table = $(this).trigger('update');
746-
}).find('th:eq(1)').click();
744+
// init tablesorter
745+
if ( hasData ) {
746+
configTable.tablesorter({
747+
headers: {
748+
0: { sorter: false },
749+
3: { sorter: false }
750+
},
751+
sortList: [[1,1]],
752+
textExtraction: treetableExtraction
753+
}).bind('sortStart', function() { // clear cache, otherwise extraction will not work
754+
var table = $(this).trigger('update');
755+
}).find('th:eq(1)').click();
756+
}
747757
} else {
748758
configContent.addClass('ui-helper-hidden');
749759
}

src/main/resources/templates/config.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
var i18n = { // i18n
1010
stat_ok : '${config.status.ok}', // "Configuration Admin Service is running.";
1111
stat_missing : '${config.status.missing}', //"Configuration Admin Service is not installed/running."
12+
metatype_ok : '${config.metatype.ok}',
13+
metatype_missing : '${config.metatype.missing}',
14+
noconfigs : '${config.noconfigs}',
1215
save : '${save}',
1316
reset : '${reset}',
1417
del : '${delete}',

0 commit comments

Comments
 (0)