Author: vvalchev
Date: Tue Apr 13 11:01:11 2010
New Revision: 933542
URL: http://svn.apache.org/viewvc?rev=933542&view=rev
Log: (empty)
Modified:
felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
felix/trunk/webconsole/src/main/native2ascii/OSGI-INF/l10n/bundle_bg.properties
felix/trunk/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
felix/trunk/webconsole/src/main/resources/res/ui/bundles.js
felix/trunk/webconsole/src/main/resources/templates/bundles.html
Modified:
felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
URL:
http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java?rev=933542&r1=933541&r2=933542&view=diff
==============================================================================
---
felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
(original)
+++
felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
Tue Apr 13 11:01:11 2010
@@ -179,7 +179,7 @@ public class BundlesServlet extends Simp
try
{
StringWriter w = new StringWriter();
- writeJSON( w, null, null, null, true, Locale.ENGLISH, null );
+ writeJSON( w, null, null, null, true, Locale.ENGLISH, null, null );
String jsonString = w.toString();
JSONObject json = new JSONObject( jsonString );
@@ -261,7 +261,7 @@ public class BundlesServlet extends Simp
final String servicesRoot = getServicesRoot( request );
try
{
- this.renderJSON(response, reqInfo.bundle, pluginRoot,
servicesRoot, request.getLocale(), request.getParameter(FILTER_PARAM) );
+ this.renderJSON(response, reqInfo.bundle, pluginRoot,
servicesRoot, request.getLocale(), request.getParameter(FILTER_PARAM), null );
}
catch (InvalidSyntaxException e)
{
@@ -281,6 +281,7 @@ public class BundlesServlet extends Simp
protected void doPost( HttpServletRequest req, HttpServletResponse resp )
throws ServletException, IOException
{
boolean success = false;
+ BundleException bundleException = null;
final String action = WebConsoleUtil.getParameter( req, "action" );
if ( "refreshPackages".equals( action ) )
{
@@ -327,6 +328,7 @@ public class BundlesServlet extends Simp
}
catch ( BundleException be )
{
+ bundleException = be;
log( "Cannot start", be );
}
}
@@ -340,6 +342,7 @@ public class BundlesServlet extends Simp
}
catch ( BundleException be )
{
+ bundleException = be;
log( "Cannot stop", be );
}
}
@@ -365,9 +368,23 @@ public class BundlesServlet extends Simp
}
catch ( BundleException be )
{
+ bundleException = be;
log( "Cannot uninstall", be );
}
}
+
+ // let's wait a little bit to give the framework time
+ // to process our request
+ try {
+ Thread.sleep(800);
+ } catch (InterruptedException e) {
+ // we ignore this
+ }
+
+ // write the state only
+ resp.getWriter().print("{fragment:" + isFragmentBundle(bundle)
//
+ + ",stateRaw:" + bundle.getState() + "}");
+ return;
}
}
@@ -384,7 +401,7 @@ public class BundlesServlet extends Simp
final String servicesRoot = getServicesRoot( req );
try
{
- this.renderJSON( resp, null, pluginRoot, servicesRoot,
req.getLocale(), req.getParameter(FILTER_PARAM) );
+ this.renderJSON( resp, null, pluginRoot, servicesRoot,
req.getLocale(), req.getParameter(FILTER_PARAM), bundleException );
}
catch (InvalidSyntaxException e)
{
@@ -483,7 +500,7 @@ public class BundlesServlet extends Simp
StringWriter w = new StringWriter();
try
{
- writeJSON(w, reqInfo.bundle, pluginRoot, servicesRoot,
request.getLocale(), request.getParameter(FILTER_PARAM) );
+ writeJSON(w, reqInfo.bundle, pluginRoot, servicesRoot,
request.getLocale(), request.getParameter(FILTER_PARAM), null );
}
catch (InvalidSyntaxException e)
{
@@ -495,26 +512,26 @@ public class BundlesServlet extends Simp
response.getWriter().print(TEMPLATE_MAIN);
}
- private void renderJSON( final HttpServletResponse response, final Bundle
bundle, final String pluginRoot, final String servicesRoot, final Locale
locale, final String filter )
+ private void renderJSON( final HttpServletResponse response, final Bundle
bundle, final String pluginRoot, final String servicesRoot, final Locale
locale, final String filter, final BundleException be )
throws IOException, InvalidSyntaxException
{
response.setContentType( "application/json" );
response.setCharacterEncoding( "UTF-8" );
final PrintWriter pw = response.getWriter();
- writeJSON(pw, bundle, pluginRoot, servicesRoot, locale, filter);
+ writeJSON(pw, bundle, pluginRoot, servicesRoot, locale, filter, be);
}
- private void writeJSON( final Writer pw, final Bundle bundle, final String
pluginRoot, final String servicesRoot, final Locale locale, final String filter
)
+ private void writeJSON( final Writer pw, final Bundle bundle, final String
pluginRoot, final String servicesRoot, final Locale locale, final String
filter, final BundleException be )
throws IOException, InvalidSyntaxException
{
- writeJSON( pw, bundle, pluginRoot, servicesRoot, false, locale, filter
);
+ writeJSON( pw, bundle, pluginRoot, servicesRoot, false, locale,
filter, be );
}
private void writeJSON( final Writer pw, final Bundle bundle, final String
pluginRoot,
- final String servicesRoot, final boolean fullDetails, final Locale
locale, final String filter ) throws IOException, InvalidSyntaxException
+ final String servicesRoot, final boolean fullDetails, final Locale
locale, final String filter, final BundleException be ) throws IOException,
InvalidSyntaxException
{
final Bundle[] allBundles = this.getBundles();
final Object[] status = getStatusLine(allBundles);
@@ -553,9 +570,18 @@ public class BundlesServlet extends Simp
{
jw.object();
+ if (null != be)
+ {
+ final StringWriter s = new StringWriter();
+ final Throwable t = be.getNestedException() != null ?
be.getNestedException() : be;
+ t.printStackTrace( new PrintWriter(s) );
+ jw.key( "error" );
+ jw.value( s.toString() );
+ }
+
jw.key( "status" );
jw.value( statusLine );
-
+
// add raw status
jw.key( "s" );
jw.array();
@@ -1059,7 +1085,7 @@ public class BundlesServlet extends Simp
{
JSONArray val = new JSONArray();
- Dictionary headers = bundle.getHeaders();
+ Dictionary headers = bundle.getHeaders(""); // don't localize at all -
raw headers
Enumeration he = headers.keys();
while ( he.hasMoreElements() )
{
Modified:
felix/trunk/webconsole/src/main/native2ascii/OSGI-INF/l10n/bundle_bg.properties
URL:
http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/native2ascii/OSGI-INF/l10n/bundle_bg.properties?rev=933542&r1=933541&r2=933542&view=diff
==============================================================================
---
felix/trunk/webconsole/src/main/native2ascii/OSGI-INF/l10n/bundle_bg.properties
[UTF-8] (original)
+++
felix/trunk/webconsole/src/main/native2ascii/OSGI-INF/l10n/bundle_bg.properties
[UTF-8] Tue Apr 13 11:01:11 2010
@@ -158,6 +158,8 @@ bundles.state.16=Спрян
bundles.state.32=Активен
bundles.state.unknown=Непознат статус: {0}
bundles.state.fragment=Фрагмент
+# action error
+bundles.error.title=Грешка при изпълнение на операцията!
# Components plugin
Modified:
felix/trunk/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
URL:
http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties?rev=933542&r1=933541&r2=933542&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
(original)
+++ felix/trunk/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
Tue Apr 13 11:01:11 2010
@@ -157,6 +157,8 @@ bundles.state.16=Stopping
bundles.state.32=Active
bundles.state.unknown=Unknown State: {0}
bundles.state.fragment=Fragment
+# action error
+bundles.error.title=Error while executing bundle operation!
# Components plugin
Modified: felix/trunk/webconsole/src/main/resources/res/ui/bundles.js
URL:
http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/resources/res/ui/bundles.js?rev=933542&r1=933541&r2=933542&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/resources/res/ui/bundles.js (original)
+++ felix/trunk/webconsole/src/main/resources/res/ui/bundles.js Tue Apr 13
11:01:11 2010
@@ -19,6 +19,7 @@ var uploadDialog = false;
var bundlesTable = false;
var bundlesBody = false;
var bundlesTemplate = false;
+var bundleOpError = false;
function renderData( eventData, filter ) {
lastBundleData = eventData;
@@ -39,6 +40,9 @@ function renderData( eventData, filter )
showDetails(id);
}
initStaticWidgets();
+
+ // show dialog on error
+ if (eventData.error)
bundleOpError.dialog('open').find('pre').text(eventData.error)
}
function entry( /* Object */ bundle, filter ) {
@@ -69,34 +73,46 @@ function entryInternal( /* Object */ bun
tr.find('td:eq(1) span:eq(1)').html( drawDetails ? name : '<a href="' +
pluginRoot + '/' + id + '">' + name + '</a>' );
tr.find('td:eq(2)').text( bundle.version );
tr.find('td:eq(3)').text( bundle.category );
- tr.find('td:eq(4)').text( stateString(bundle) );
if (id == 0) { // system bundle has no actions
+ tr.find('td:eq(4)').text( stateString(bundle) );
tr.find('td:eq(5) ul').addClass('ui-helper-hidden');
} else {
- var start = tr.find('td:eq(5) ul li:eq(0)');
- var stop = tr.find('td:eq(5) ul li:eq(1)');
- var refresh = tr.find('td:eq(5) ul li:eq(2)').click(function()
{changeDataEntryState(id, 'refresh')});
- var update = tr.find('td:eq(5) ul li:eq(3)').click(function()
{changeDataEntryState(id, 'update')});
- var remove = tr.find('td:eq(5) ul li:eq(4)');
- start = hasStart(bundle) ?
- start.click(function() {changeDataEntryState(id,
'start')}) :
- start.addClass('ui-helper-hidden');
- stop = hasStop(bundle) ?
- stop.click(function() {changeDataEntryState(id,
'stop')}) :
- stop.addClass('ui-helper-hidden');
- remove = hasUninstall(bundle) ?
- remove.click(function() {changeDataEntryState(id,
'uninstall')}) :
- remove.addClass('ui-helper-hidden');
+ entrySetupState( bundle, tr, id );
}
return tr;
}
+function entrySetupState( /* Object */ bundle, tr, id) {
+ var start = tr.find('td:eq(5) ul
li:eq(0)').removeClass('ui-helper-hidden').unbind('click');
+ var stop = tr.find('td:eq(5) ul
li:eq(1)').removeClass('ui-helper-hidden').unbind('click');
+ var refresh = tr.find('td:eq(5) ul
li:eq(2)').unbind('click').click(function() {return changeDataEntryState(id,
'refresh')});
+ var update = tr.find('td:eq(5) ul
li:eq(3)').unbind('click').click(function() {return changeDataEntryState(id,
'update')});
+ var remove = tr.find('td:eq(5) ul
li:eq(4)').removeClass('ui-helper-hidden').unbind('click');
+ start = hasStart(bundle) ?
+ start.click(function() {return changeDataEntryState(id,
'start')}) :
+ start.addClass('ui-helper-hidden');
+ stop = hasStop(bundle) ?
+ stop.click(function() {return changeDataEntryState(id,
'stop')}) :
+ stop.addClass('ui-helper-hidden');
+ remove = hasUninstall(bundle) ?
+ remove.click(function() {return changeDataEntryState(id,
'uninstall')}) :
+ remove.addClass('ui-helper-hidden');
+ tr.find('td:eq(4)').text( stateString(bundle) );
+}
function loadData() {
$.get(pluginRoot + "/.json", null, renderData, "json");
}
function changeDataEntryState(/* long */ id, /* String */ action) {
- $.post(pluginRoot + "/" + id, {"action":action}, renderData, "json");
+ $.post(pluginRoot + '/' + id, {'action':action}, function(b) {
+ var _tr = bundlesBody.find('#entry' + id);
+ if (1 == b.stateRaw) { // uninstalled
+ _tr.remove();
+ } else {
+ entrySetupState( b, _tr, id );
+ }
+ }, 'json');
+ return false;
}
function refreshPackages() {
@@ -184,6 +200,13 @@ $(document).ready(function(){
return false;
});
+ bundleOpError = $('#bundleOpError').dialog({
+ autoOpen: false,
+ modal : true,
+ width : '80%'
+ });
+ bundleOpError.parent().addClass('ui-state-error');
+
// filter
$('.filterApply').click(function() {
if ($(this).hasClass('ui-state-disabled')) return;
Modified: felix/trunk/webconsole/src/main/resources/templates/bundles.html
URL:
http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/resources/templates/bundles.html?rev=933542&r1=933541&r2=933542&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/resources/templates/bundles.html [UTF-8]
(original)
+++ felix/trunk/webconsole/src/main/resources/templates/bundles.html [UTF-8]
Tue Apr 13 11:01:11 2010
@@ -140,3 +140,5 @@ var i18n = {
</table>
</form>
</div>
+
+<div id="bundleOpError" class="ui-helper-hidden"
title="${bundles.error.title}"><pre> </pre></div>