FELIX-3111 : Separate OBR Plugin
FELIX-3107 : Separate Shell Plugin
FELIX-3099 : Separate Deployment Admin plugin
FELIX-3100 : Separate SCR plugin
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1169777 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole-plugins/deppack/src/main/java/org/apache/felix/webconsole/plugins/deppack/internal/Activator.java b/webconsole-plugins/deppack/src/main/java/org/apache/felix/webconsole/plugins/deppack/internal/Activator.java
new file mode 100644
index 0000000..5bf71d4
--- /dev/null
+++ b/webconsole-plugins/deppack/src/main/java/org/apache/felix/webconsole/plugins/deppack/internal/Activator.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.felix.webconsole.plugins.deppack.internal;
+
+import org.apache.felix.webconsole.SimpleWebConsolePlugin;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.deploymentadmin.DeploymentAdmin;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+/**
+ * Activator is the main starting class.
+ */
+public class Activator implements BundleActivator, ServiceTrackerCustomizer
+{
+
+ private ServiceTracker tracker;
+ private BundleContext context;
+
+ private SimpleWebConsolePlugin plugin;
+
+ /**
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public final void start(BundleContext context) throws Exception
+ {
+ this.context = context;
+ this.tracker = new ServiceTracker(context, DeploymentAdmin.class.getName(), this);
+ this.tracker.open();
+ }
+
+ /**
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public final void stop(BundleContext context) throws Exception
+ {
+ if (tracker != null)
+ {
+ tracker.close();
+ tracker = null;
+ }
+ }
+
+ // - begin tracker
+ /**
+ * @see org.osgi.util.tracker.ServiceTrackerCustomizer#modifiedService(org.osgi.framework.ServiceReference,
+ * java.lang.Object)
+ */
+ public final void modifiedService(ServiceReference reference, Object service)
+ {/* unused */
+ }
+
+ /**
+ * @see org.osgi.util.tracker.ServiceTrackerCustomizer#addingService(org.osgi.framework.ServiceReference)
+ */
+ public final Object addingService(ServiceReference reference)
+ {
+ SimpleWebConsolePlugin plugin = this.plugin;
+ if (plugin == null)
+ {
+ this.plugin = plugin = new WebConsolePlugin(tracker).register(context);
+ }
+
+ return context.getService(reference);
+ }
+
+ /**
+ * @see org.osgi.util.tracker.ServiceTrackerCustomizer#removedService(org.osgi.framework.ServiceReference,
+ * java.lang.Object)
+ */
+ public final void removedService(ServiceReference reference, Object service)
+ {
+ SimpleWebConsolePlugin plugin = this.plugin;
+
+ if (tracker.getTrackingCount() == 0 && plugin != null)
+ {
+ plugin.unregister();
+ this.plugin = null;
+ }
+
+ }
+}
diff --git a/webconsole-plugins/deppack/src/main/java/org/apache/felix/webconsole/plugins/deppack/internal/WebConsolePlugin.java b/webconsole-plugins/deppack/src/main/java/org/apache/felix/webconsole/plugins/deppack/internal/WebConsolePlugin.java
new file mode 100644
index 0000000..b47f071
--- /dev/null
+++ b/webconsole-plugins/deppack/src/main/java/org/apache/felix/webconsole/plugins/deppack/internal/WebConsolePlugin.java
@@ -0,0 +1,248 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.felix.webconsole.plugins.deppack.internal;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.fileupload.FileItem;
+import org.apache.felix.webconsole.AbstractWebConsolePlugin;
+import org.apache.felix.webconsole.DefaultVariableResolver;
+import org.apache.felix.webconsole.SimpleWebConsolePlugin;
+import org.apache.felix.webconsole.WebConsoleUtil;
+import org.apache.felix.webconsole.internal.Util;
+import org.json.JSONException;
+import org.json.JSONWriter;
+import org.osgi.service.deploymentadmin.DeploymentAdmin;
+import org.osgi.service.deploymentadmin.DeploymentPackage;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * DepPackServlet provides a plugin for managing deployment admin packages.
+ */
+class WebConsolePlugin extends SimpleWebConsolePlugin
+{
+
+ private static final String LABEL = "deppack"; //$NON-NLS-1$
+ private static final String TITLE = "%deppack.pluginTitle"; //$NON-NLS-1$
+ private static final String CSS[] = { "/" + LABEL + "/res/plugin.css" }; //$NON-NLS-1$ //$NON-NLS-2$
+
+ //
+ private static final String ACTION_DEPLOY = "deploydp"; //$NON-NLS-1$
+ private static final String ACTION_UNINSTALL = "uninstalldp"; //$NON-NLS-1$
+ private static final String PARAMETER_PCK_FILE = "pckfile"; //$NON-NLS-1$
+
+ private static final String DEPL_SERVICE = "org.osgi.service.deploymentadmin.DeploymentAdmin"; //$NON-NLS-1$
+
+ // templates
+ private final String TEMPLATE;
+
+ private final ServiceTracker adminTracker;
+
+ /** Default constructor */
+ WebConsolePlugin(ServiceTracker adminTracker)
+ {
+ super(LABEL, TITLE, CSS);
+
+ // load templates
+ TEMPLATE = readTemplateFile("/res/plugin.html"); //$NON-NLS-1$
+ this.adminTracker = adminTracker;
+ }
+
+ /**
+ * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException
+ {
+ // get the uploaded data
+ final String action = WebConsoleUtil.getParameter(req, Util.PARAM_ACTION);
+ if (ACTION_DEPLOY.equals(action))
+ {
+ Map params = (Map) req.getAttribute(AbstractWebConsolePlugin.ATTR_FILEUPLOAD);
+ if (params != null)
+ {
+ final FileItem pck = getFileItem(params, PARAMETER_PCK_FILE, false);
+ final DeploymentAdmin admin = (DeploymentAdmin) adminTracker.getService();
+ if (admin != null)
+ {
+ try
+ {
+ admin.installDeploymentPackage(pck.getInputStream());
+
+ final String uri = req.getRequestURI();
+ resp.sendRedirect(uri);
+ return;
+ }
+ catch ( /*Deployment*/Exception e)
+ {
+ throw new ServletException("Unable to deploy package.", e);
+ }
+ }
+ }
+ throw new ServletException("Upload file or deployment admin missing.");
+ }
+ else if (ACTION_UNINSTALL.equals(action))
+ {
+ final String pckId = req.getPathInfo().substring(
+ req.getPathInfo().lastIndexOf('/') + 1);
+ if (pckId != null && pckId.length() > 0)
+ {
+ final DeploymentAdmin admin = (DeploymentAdmin) this.getService(DEPL_SERVICE);
+ if (admin != null)
+ {
+ try
+ {
+ final DeploymentPackage pck = admin.getDeploymentPackage(pckId);
+ if (pck != null)
+ {
+ pck.uninstall();
+ }
+ }
+ catch ( /*Deployment*/Exception e)
+ {
+ throw new ServletException("Unable to undeploy package.", e);
+ }
+ }
+
+ }
+
+ final PrintWriter pw = resp.getWriter();
+ pw.println("{ \"reload\":true }");
+ return;
+ }
+ throw new ServletException("Unknown action: " + action);
+ }
+
+ private static final FileItem getFileItem(Map params, String name, boolean isFormField)
+ {
+ FileItem[] items = (FileItem[]) params.get(name);
+ if (items != null)
+ {
+ for (int i = 0; i < items.length; i++)
+ {
+ if (items[i].isFormField() == isFormField)
+ {
+ return items[i];
+ }
+ }
+ }
+
+ // nothing found, fail
+ return null;
+ }
+
+ /**
+ * @see org.apache.felix.webconsole.AbstractWebConsolePlugin#renderContent(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ protected void renderContent(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+
+ final DeploymentAdmin admin = (DeploymentAdmin) this.getService(DEPL_SERVICE);
+
+ StringWriter w = new StringWriter();
+ PrintWriter w2 = new PrintWriter(w);
+ JSONWriter jw = new JSONWriter(w2);
+ try
+ {
+ jw.object();
+ if (null == admin)
+ {
+ jw.key("error"); //$NON-NLS-1$
+ jw.value(true);
+ }
+ else
+ {
+ final DeploymentPackage[] packages = admin.listDeploymentPackages();
+ jw.key("data"); //$NON-NLS-1$
+
+ jw.array();
+ for (int i = 0; i < packages.length; i++)
+ {
+ packageInfoJson(jw, packages[i]);
+ }
+ jw.endArray();
+
+ }
+ jw.endObject();
+
+ }
+ catch (JSONException je)
+ {
+ throw new IOException(je.toString());
+ }
+
+ // prepare variables
+ DefaultVariableResolver vars = ((DefaultVariableResolver) WebConsoleUtil.getVariableResolver(request));
+ vars.put("__data__", w.toString()); //$NON-NLS-1$
+
+ response.getWriter().print(TEMPLATE);
+ }
+
+ private static final void packageInfoJson(JSONWriter jw, DeploymentPackage pack)
+ throws JSONException
+ {
+ jw.object();
+ jw.key("id"); //$NON-NLS-1$
+ jw.value(pack.getName());
+ jw.key("name"); //$NON-NLS-1$
+ jw.value(pack.getName());
+ jw.key("state"); //$NON-NLS-1$
+ jw.value(pack.getVersion());
+
+ jw.key("actions"); //$NON-NLS-1$
+ jw.array();
+
+ jw.object();
+ jw.key("enabled"); //$NON-NLS-1$
+ jw.value(true);
+ jw.key("name"); //$NON-NLS-1$
+ jw.value("Uninstall");
+ jw.key("link"); //$NON-NLS-1$
+ jw.value(ACTION_UNINSTALL);
+ jw.endObject();
+
+ jw.endArray();
+
+ jw.key("props"); //$NON-NLS-1$
+ jw.array();
+ WebConsoleUtil.keyVal(jw, "Package Name", pack.getName());
+ WebConsoleUtil.keyVal(jw, "Version", pack.getVersion());
+
+ final StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < pack.getBundleInfos().length; i++)
+ {
+ buffer.append(pack.getBundleInfos()[i].getSymbolicName());
+ buffer.append(" - "); //$NON-NLS-1$
+ buffer.append(pack.getBundleInfos()[i].getVersion());
+ buffer.append("<br/>"); //$NON-NLS-1$
+ }
+ WebConsoleUtil.keyVal(jw, "Bundles", buffer.toString());
+
+ jw.endArray();
+
+ jw.endObject();
+ }
+
+}
diff --git a/webconsole-plugins/deppack/src/main/native2ascii/OSGI-INF/l10n/bundle_bg.properties b/webconsole-plugins/deppack/src/main/native2ascii/OSGI-INF/l10n/bundle_bg.properties
new file mode 100644
index 0000000..89c20a2
--- /dev/null
+++ b/webconsole-plugins/deppack/src/main/native2ascii/OSGI-INF/l10n/bundle_bg.properties
@@ -0,0 +1,40 @@
+#Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Web Console strings for reference all strings here are commented.
+# This file may be used to produce a translation of the strings
+#
+# Note that properties files are ISO-8859-1 encoded. To provide translations
+# for languages requiring different character encodings, you may use the
+# native2ascii Maven Plugin from http://mojo.codehaus.org/native2ascii-maven-plugin/
+# to translate the natively encoded files to ISO-8859-1 during bundle build
+#
+# Translations requiring non-ISO-8859-1 encoding are placed in the
+# src/main/native2ascii/OSGI-INF/l10n folder and are converted using said
+# plugin while building the bundle
+# native2ascii -encoding utf-8 bundle_bg.raw_properties bundle_bg.properties
+
+# Deployment Admin plugin
+deppack.pluginTitle=Управление на пакети
+deppack.status.no_data=Няма инсталирани пакети!
+deppack.status.no_service=Услугата Deployment Admin не е налична в момента!
+deppack.status.ok=Deployment Admin е наличен и по-долу е показан списъка с пакет
+deppack.details=Детайли
+deppack.actions=Действия
+deppack.install_update=Инсталиране/обновяване
+deppack.package.name=Име на пакет
+deppack.bundles=Бъндъли
+deppack.uninstall=Премахване
diff --git a/webconsole-plugins/deppack/src/main/native2ascii/OSGI-INF/l10n/bundle_de.properties b/webconsole-plugins/deppack/src/main/native2ascii/OSGI-INF/l10n/bundle_de.properties
new file mode 100644
index 0000000..864181f
--- /dev/null
+++ b/webconsole-plugins/deppack/src/main/native2ascii/OSGI-INF/l10n/bundle_de.properties
@@ -0,0 +1,40 @@
+#Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Web Console strings for reference all strings here are commented.
+# This file may be used to produce a translation of the strings
+#
+# Note that properties files are ISO-8859-1 encoded. To provide translations
+# for languages requiring different character encodings, you may use the
+# native2ascii Maven Plugin from http://mojo.codehaus.org/native2ascii-maven-plugin/
+# to translate the natively encoded files to ISO-8859-1 during bundle build
+#
+# Translations requiring non-ISO-8859-1 encoding are placed in the
+# src/main/native2ascii/OSGI-INF/l10n folder and are converted using said
+# plugin while building the bundle
+#
+
+# Deployment Admin plugin
+deppack.pluginTitle=Deployment Packages
+deppack.status.no_data=Kein Deployment Package ist installiert!
+deppack.status.no_service=Deployment Admin Dienst ist nicht instaliert/aktiv!
+deppack.status.ok=Deployment Admin Dienst ist aktiv
+deppack.details=Details
+deppack.actions=Aktionen
+deppack.install_update=Installieren oder Aktualisieren
+deppack.package.name=Package Name
+deppack.bundles=Bundles
+deppack.uninstall=Deinstallieren
diff --git a/webconsole-plugins/deppack/src/main/native2ascii/OSGI-INF/l10n/bundle_ru.properties b/webconsole-plugins/deppack/src/main/native2ascii/OSGI-INF/l10n/bundle_ru.properties
new file mode 100644
index 0000000..6895031
--- /dev/null
+++ b/webconsole-plugins/deppack/src/main/native2ascii/OSGI-INF/l10n/bundle_ru.properties
@@ -0,0 +1,40 @@
+#Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Web Console strings for reference all strings here are commented.
+# This file may be used to produce a translation of the strings
+#
+# Note that properties files are ISO-8859-1 encoded. To provide translations
+# for languages requiring different character encodings, you may use the
+# native2ascii Maven Plugin from http://mojo.codehaus.org/native2ascii-maven-plugin/
+# to translate the natively encoded files to ISO-8859-1 during bundle build
+#
+# Translations requiring non-ISO-8859-1 encoding are placed in the
+# src/main/native2ascii/OSGI-INF/l10n folder and are converted using said
+# plugin while building the bundle
+#
+
+# Deployment Admin plugin
+deppack.pluginTitle=Управление пакетами
+deppack.status.no_data=Нет установочных пакетов!
+deppack.status.no_service=Сервис Deployment Admin не установлен или не запущен.
+deppack.status.ok=Сервис Deployment Admin работает
+deppack.details=Подробно
+deppack.actions=Действия
+deppack.install_update=Установить/обновить
+deppack.package.name=Имя пакета
+deppack.bundles=Модули
+deppack.uninstall=Удалить
diff --git a/webconsole-plugins/deppack/src/main/resources/OSGI-INF/l10n/bundle.properties b/webconsole-plugins/deppack/src/main/resources/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 0000000..1a0f302
--- /dev/null
+++ b/webconsole-plugins/deppack/src/main/resources/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,40 @@
+#Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Web Console strings for reference all strings here are commented.
+# This file may be used to produce a translation of the strings
+#
+# Note that properties files are ISO-8859-1 encoded. To provide translations
+# for languages requiring different character encodings, you may use the
+# native2ascii Maven Plugin from http://mojo.codehaus.org/native2ascii-maven-plugin/
+# to translate the natively encoded files to ISO-8859-1 during bundle build
+#
+# Translations requiring non-ISO-8859-1 encoding are placed in the
+# src/main/native2ascii/OSGI-INF/l10n folder and are converted using said
+# plugin while building the bundle
+#
+
+# Deployment Admin plugin
+deppack.pluginTitle=Deployment Packages
+deppack.status.no_data=No deployment packages installed!
+deppack.status.no_service=Deployment Admin is not installed/running!
+deppack.status.ok=Deployment Admin service is running
+deppack.details=Details
+deppack.actions=Actions
+deppack.install_update=Install or Update
+deppack.package.name=Package Name
+deppack.bundles=Bundles
+deppack.uninstall=Uninstall
diff --git a/webconsole-plugins/deppack/src/main/resources/res/plugin.css b/webconsole-plugins/deppack/src/main/resources/res/plugin.css
new file mode 100644
index 0000000..c767846
--- /dev/null
+++ b/webconsole-plugins/deppack/src/main/resources/res/plugin.css
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+.pkgname { cursor:pointer }
+.pkgname span { float:left }
diff --git a/webconsole-plugins/deppack/src/main/resources/res/plugin.html b/webconsole-plugins/deppack/src/main/resources/res/plugin.html
new file mode 100644
index 0000000..ba16fcd
--- /dev/null
+++ b/webconsole-plugins/deppack/src/main/resources/res/plugin.html
@@ -0,0 +1,55 @@
+<script type="text/javascript" src="${pluginRoot}/res/plugin.js"></script>
+<script type="text/javascript">
+// <![CDATA[
+var i18n = {
+ status_no_data : "${deppack.status.no_data}",
+ status_no_serv : "${deppack.status.no_service}",
+ status_ok : "${deppack.status.ok}",
+ package_name : "${deppack.package.name}",
+ version : "${version}",
+ bundles : "${deppack.bundles}",
+ uninstall : "${deppack.uninstall}"
+}
+var packageListData = ${__data__};
+// ]]>
+</script>
+
+<p class="statline"> </p>
+
+<div id="dps1"> <!-- will be hidden if no DP service available -->
+<!-- top header -->
+<form method="post" enctype="multipart/form-data" action="${pluginRoot}">
+ <div class="ui-widget-header ui-corner-top buttonGroup" style="text-align: right">
+ <input name="action" type="hidden" value="deploydp" />
+ <input name="pckfile" type="file" size="50" />
+ <input type="submit" value="${deppack.install_update}" />
+ </div>
+</form>
+
+<div id="dps2"> <!-- will be hidden if no data available -->
+ <table id="plugin_table" class="nicetable">
+ <thead>
+ <tr>
+ <th>${id}</th>
+ <th style="width:100%">${deppack.details}</th>
+ <th>${version}</th>
+ <th colspan="1">${deppack.actions}</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td colspan="5"> </td>
+ </tr>
+ </tbody>
+ </table>
+
+ <!-- bottom header -->
+ <form method="post" enctype="multipart/form-data" action="${pluginRoot}">
+ <div class="ui-widget-header ui-corner-bottom buttonGroup" style="text-align: right">
+ <input name="action" type="hidden" value="deploydp" />
+ <input name="pckfile" type="file" size="50" />
+ <input type="submit" value="${deppack.install_update}" />
+ </div>
+ </form>
+</div><!--dps2-->
+</div><!--dps1-->
diff --git a/webconsole-plugins/deppack/src/main/resources/res/plugin.js b/webconsole-plugins/deppack/src/main/resources/res/plugin.js
new file mode 100644
index 0000000..149590e
--- /dev/null
+++ b/webconsole-plugins/deppack/src/main/resources/res/plugin.js
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+function fixId(id) { return id.replace('.', '_'); }
+
+function data( /* Array of Object */ dataArray ) { // render components
+ plugin_table.find('tbody').empty();
+ if (dataArray.length == 1) {
+ entry( dataArray[0], true );
+ } else {
+ for ( var idx in dataArray ) {
+ entry( dataArray[idx] );
+ }
+ }
+}
+
+function entry( /* Object */ dataEntry, /* boolean */ singleEntry ) {
+ var id = fixId(dataEntry.id);
+ var trElement = tr( 'ui-state-active', { 'id': 'entry' + id });
+
+ // entry brief
+ entryInternal( trElement, dataEntry, singleEntry );
+ plugin_table.append(trElement);
+
+ // dataEntry detailed properties
+ trElement = tr( 'ui-helper-hidden', {
+ 'id' : 'entry' + id + '_details'
+ });
+ if (dataEntry.props) {
+ getDataEntryDetails( trElement, dataEntry.props );
+ }
+ plugin_table.append(trElement);
+}
+
+function entryInternal( /* Element */ parent, /* Object */ dataEntry, /* boolean */ singleEntry ) {
+ var id = dataEntry.id;
+ var _id = fixId(id);
+
+ parent.appendChild( td( null, null, [ text( id ) ] ) );
+ parent.appendChild( td( null,
+ {
+ 'onclick': 'toggleDetails("#entry' + _id + '")',
+ 'class': 'pkgname'
+ },
+ [
+ createElement( 'span', 'ui-icon ui-icon-triangle-1-e', { id: 'entry' + _id + '_icon'} ),
+ text(dataEntry.name)
+ ]
+ )
+ );
+ parent.appendChild( td( null, null, [ text( dataEntry.state ) ] ) );
+
+ for ( var aidx in dataEntry.actions ) {
+ var action = dataEntry.actions[aidx];
+ parent.appendChild( actionButton( action.enabled, id, action.link, action.name ) );
+ }
+}
+
+
+/* Element */ function actionButton( /* boolean */ enabled, /* long */ id, /* String */ op, /* String */ opLabel ) {
+ var buttonTd = td( "content", { align: "right" } );
+ if ( op ) {
+ switch (opLabel) {
+ case "Uninstall" : opLabel = i18n.uninstall; break;
+ }
+ var input = createElement( "input", null, {
+ type: 'button',
+ value: opLabel,
+ onclick: 'changeDataEntryState("' + id + '", "' + op + '");'
+ });
+ if (!enabled) {
+ input.setAttribute( "disabled", true );
+ $(input).addClass('ui-state-disabled');
+ }
+ buttonTd.appendChild( input );
+ } else {
+ addText( buttonTd, "\u00a0" );
+ }
+ return buttonTd;
+}
+
+
+function getDataEntryDetails( /* Element */ parent, /* Array of Object */ details )
+{
+ parent.appendChild( addText( td( "content"), "\u00a0" ) );
+
+ var tdEl = td( null, { colspan: 4 } );
+ parent.appendChild( tdEl );
+
+ var tableEl = createElement( "table", null, { border: 0 } );
+ tdEl.appendChild( tableEl );
+
+ var tbody = createElement( "tbody" );
+ tableEl.appendChild( tbody );
+ for (var idx in details) {
+ var prop = details[idx];
+ var trEl = tr();
+ var key = prop.key;
+ switch (key) {
+ case 'Package Name': key = i18n.package_name; break;
+ case 'Version' : key = i18n.version; break;
+ case 'Bundles' : key = i18n.bundles; break;
+ }
+ trEl.appendChild( addText( td( null, { noWrap: true } ), key ) );
+
+ var proptd = td();
+ trEl.appendChild( proptd );
+ $(proptd).html( prop.value ? prop.value : "\u00a0");
+
+ tbody.appendChild( trEl );
+ }
+ }
+
+
+function changeDataEntryState(/* long */ id, /* String */ action) {
+ var parm = pluginRoot + "/" + id + "?action=" + action;
+ $.post(parm, null, function() { // always reload
+ document.location.reload();
+ }, "text");
+}
+
+
+function toggleDetails(name) {
+ var icon = $(name + '_icon');
+ var details = $(name + '_details');
+ var show = icon.attr('show');
+ if (typeof show == 'undefined') show = '';
+ icon.attr('show', show ? '' : 'true');
+
+ if (show == 'true') {
+ icon.removeClass('ui-icon-triangle-1-s').addClass('ui-icon-triangle-1-e');
+ details.addClass('ui-helper-hidden');
+ } else {
+ icon.removeClass('ui-icon-triangle-1-e').addClass('ui-icon-triangle-1-s');
+ details.removeClass('ui-helper-hidden');
+ }
+}
+
+var plugin_table = false;
+$(document).ready(function() {
+ plugin_table = $('#plugin_table');
+ var /* Array of Data Objects */ bundleData = packageListData;
+ if (bundleData.error) {
+ $('.statline').text(i18n.status_no_serv);
+ $('#dps1').addClass('ui-helper-hidden');
+ } else if (!bundleData.data || bundleData.data.length == 0) {
+ $('.statline').text(i18n.status_no_data);
+ $('#dps1').removeClass('ui-helper-hidden');
+ $('#dps2').addClass('ui-helper-hidden');
+ } else {
+ data( bundleData.data );
+ $('.statline').text(i18n.status_ok);
+ $('#dps1').removeClass('ui-helper-hidden');
+ $('#dps2').removeClass('ui-helper-hidden');
+ initStaticWidgets(plugin_table);
+ }
+});
+