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/LICENSE b/webconsole-plugins/deppack/LICENSE
new file mode 100644
index 0000000..75b5248
--- /dev/null
+++ b/webconsole-plugins/deppack/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
diff --git a/webconsole-plugins/deppack/NOTICE b/webconsole-plugins/deppack/NOTICE
new file mode 100644
index 0000000..3a3923a
--- /dev/null
+++ b/webconsole-plugins/deppack/NOTICE
@@ -0,0 +1,21 @@
+Apache Felix OSGi Web Console Event Plugin
+Copyright 2007-2010 The Apache Software Foundation
+
+
+I. Included Software
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+
+II. Used Software
+
+This product uses software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright (c) OSGi Alliance (2000, 2009).
+Licensed under the Apache License 2.0.
+
+
+III. License Summary
+- Apache License 2.0
diff --git a/webconsole-plugins/deppack/pom.xml b/webconsole-plugins/deppack/pom.xml
new file mode 100644
index 0000000..0c764e6
--- /dev/null
+++ b/webconsole-plugins/deppack/pom.xml
@@ -0,0 +1,115 @@
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>felix-parent</artifactId>
+ <version>1.2.0</version>
+ <relativePath>../../../pom/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>org.apache.felix.webconsole.plugins.deppack</artifactId>
+ <packaging>bundle</packaging>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <name>Apache Felix Web Console Deployment Packages Plugin</name>
+ <description>
+ This is a plugin for the Apache Felix OSGi web console for displaying Deployment Packages.
+ </description>
+
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/felix/trunk/webconsole-plugins/deppack</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/felix/trunk/webconsole-plugins/deppack</developerConnection>
+ <url>http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/deppack</url>
+ </scm>
+
+ <build>
+ <plugins>
+ <!-- translate UTF-8 encoded properties files to ISO-8859-1 -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>native2ascii-maven-plugin</artifactId>
+ <version>1.0-alpha-1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>native2ascii</goal>
+ </goals>
+ <configuration>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.0.1</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>
+ ${artifactId}
+ </Bundle-SymbolicName>
+ <Bundle-Activator>
+ org.apache.felix.webconsole.plugins.deppack.internal.Activator
+ </Bundle-Activator>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ <version>1.1.1</version>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>4.1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.webconsole</artifactId>
+ <version>3.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <version>20070829</version>
+ <scope>compile</scope>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
+</project>
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);
+ }
+});
+