Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

DSB update

  • Loading branch information...
commit 553cd17a3201b97c0a9697b80c4c9611b76f02b7 1 parent 1793f08
@chamerling chamerling authored
View
118 app/controllers/DSBController.java
@@ -0,0 +1,118 @@
+/**
+ *
+ * Copyright (c) 2012, PetalsLink
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+package controllers;
+
+import java.util.List;
+
+import org.ow2.play.governance.api.TopicAware;
+import org.ow2.play.governance.api.bean.Topic;
+import org.petalslink.dsb.jbi.se.wsn.api.Subscription;
+import org.petalslink.dsb.jbi.se.wsn.api.SubscriptionManagementService;
+
+import utils.Locator;
+
+/**
+ * @author chamerling
+ *
+ */
+public class DSBController extends PlayController {
+
+ /**
+ * Remove the Topic from the DSB runtime
+ *
+ * @param name
+ * @param ns
+ * @param prefix
+ */
+ public static void deleteTopic(String name, String ns, String prefix) {
+ validation.required(name);
+ validation.required(prefix);
+
+ // validation url does not allow IP address...
+ validation.isTrue(ns != null
+ && (ns.startsWith("http://") || ns.startsWith("https://")));
+
+ validation.required(name);
+ validation.url(ns);
+ validation.required(prefix);
+
+ if (validation.hasErrors()) {
+ params.flash();
+ validation.keep();
+ topics();
+ }
+
+ try {
+ TopicAware ta = Locator.getDSBTopicManagement(getNode());
+ Topic topic = new Topic();
+ topic.setName(name);
+ topic.setNs(ns);
+ topic.setPrefix(prefix);
+ ta.delete(topic);
+ flash.success("Topic has been deleted from the DSB %s",
+ topic.toString());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ handleException("Can not delete topic", e);
+ }
+ topics();
+ }
+
+ /**
+ * Get the topic details with all the subscriptions
+ *
+ * @param name
+ * @param ns
+ * @param prefix
+ */
+ public static void topic(String name, String ns, String prefix) {
+ org.petalslink.dsb.jbi.se.wsn.api.Topic topic = new org.petalslink.dsb.jbi.se.wsn.api.Topic();
+ topic.name = name;
+ topic.ns = ns;
+ topic.prefix = prefix;
+
+ List<Subscription> subscriptions = null;
+ try {
+ SubscriptionManagementService client = Locator.getSubscriptionManagementService(getNode());
+ subscriptions = client.getSubscriptionsForTopic(topic);
+ } catch (Exception e) {
+ handleException("Can not get client", e);
+ }
+
+ render(topic, subscriptions);
+ }
+
+ /**
+ * Get all the DSB topics GET
+ */
+ public static void topics() {
+ List<Topic> topics = null;
+ try {
+ TopicAware ta = Locator.getDSBTopicManagement(getNode());
+ topics = ta.get();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ render(topics);
+ }
+
+
+}
View
26 app/utils/Locator.java
@@ -20,6 +20,7 @@
import org.ow2.play.service.registry.api.Constants;
import org.ow2.play.service.registry.api.Registry;
import org.petalslink.dsb.jbi.se.wsn.api.StatsService;
+import org.petalslink.dsb.jbi.se.wsn.api.SubscriptionManagementService;
/**
*
@@ -232,6 +233,31 @@ public static StatsService getDSBStatsService(Node node) throws Exception {
Object o = factory.create();
return StatsService.class.cast(o);
}
+
+ /**
+ * @param node
+ * @return
+ */
+ public static SubscriptionManagementService getSubscriptionManagementService(
+ Node node) throws Exception {
+
+ Registry registry = getServiceRegistry(node);
+
+ // TDOO : Add org.ow2.play.dsb.topic.business.subscriptionmanagement
+
+ String url = registry.get("org.ow2.play.dsb.topic.business.subscriptionmanagement");
+
+ if (url == null) {
+ throw new Exception(
+ "Can not find the DSB Topic Stats service endpoint in the registry");
+ }
+
+ JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+ factory.setAddress(url);
+ factory.setServiceClass(SubscriptionManagementService.class);
+ Object o = factory.create();
+ return SubscriptionManagementService.class.cast(o);
+ }
}
View
33 app/views/DSBController/topic.html
@@ -0,0 +1,33 @@
+#{extends 'main.html' /}
+#{set title:'Topic details' /}
+
+<div class="page-header">
+ <h1>Topic details&nbsp;<small>{${topic.ns}}${topic.prefix}:${topic.name}</small></h1>
+</div>
+
+#{if subscriptions}
+ <table class="table table-striped">
+ <thead>
+ <tr>
+ <th>#</th>
+ <th>UUID</th>
+ <th>Subscriber</th>
+ <th>Actions</th>
+ </tr>
+ </thead>
+ <tbody>
+ %{int i = 0}%
+ #{list subscriptions, as : 's'}
+ <tr>
+ <td align="left">${i++}</td>
+ <td><b>${s.uuid}</b></td>
+ <td><a href="${s.subscriber}" target="_blank">${s.subscriber}</a></td>
+ <td><a href="#" class="btn">Remove</a>&nbsp;<a class="btn danger" href="#">Unsubscribe</a></td>
+ </tr>
+ #{/list}
+ </tbody>
+ </table>
+#{/if}
+#{else}
+ <h3>No subscriptions for this topic</h3>
+#{/else}
View
75 app/views/DSBController/topics.html
@@ -0,0 +1,75 @@
+#{extends 'main.html' /}
+#{set title:'DSB Topics' /}
+
+<div class="page-header">
+ <h1>DSB Topics</h1>
+</div>
+
+#{ifErrors}
+ <div class="alert-message error">
+ <a class="close" href="#">&times;</a>
+ <p><strong>Some values are invalid, please fix them...</strong></p>
+ <ul>
+ #{errors}
+ <li>${error}</li>
+ #{/errors}
+ </ul>
+ </div>
+#{/ifErrors}
+
+<div class="well">
+#{form @TopicsController.createDSB()}
+ <fieldset>
+ <div class="clearfix">
+ <label for="name">Topic Name</label>
+ <div class="input">
+ <input type="text" name="name" id="name" class="xlarge" size="50" value="${flash.name}"/>
+ </div>
+ </div>
+ <div class="clearfix">
+ <label for="ns">Topic NS</label>
+ <div class="input">
+ <input type="text" name="ns" id="ns" class="xlarge" size="50" value="${flash.ns}"/>
+ </div>
+ </div>
+ <div class="clearfix">
+ <label for="prefix">Topic Prefix</label>
+ <div class="input">
+ <input type="text" name="prefix" id="prefix" class="xlarge" size="50" value="${flash.prefix}"/>
+ </div>
+ </div>
+ <div class="actions">
+ <input class="btn primary" type="submit" value="Create" />
+ </div>
+ </fieldset>
+#{/form}
+</div>
+
+#{if topics}
+ <table class="table table-striped">
+ <thead>
+ <tr>
+ <th>#</th>
+ <th>Name</th>
+ <th>Namespace</th>
+ <th>Prefix</th>
+ <th>Actions</th>
+ </tr>
+ </thead>
+ <tbody>
+ %{int i = 0}%
+ #{list topics, as : 't'}
+ <tr>
+ <td align="left">${i++}</td>
+ <td><b>${t.name}</b></td>
+ <td><a href="${t.ns}" target="_blank">${t.ns}</a></td>
+ <td>${t.prefix}</td>
+ <td><a href="@{DSBController.topic(t.name, t.ns, t.prefix)}" class="btn">Details</a>&nbsp;<a class="btn danger" href="@{TopicsController.deleteDSB(t.name, t.ns, t.prefix)}">Delete</a></a></td>
+ </tr>
+ #{/list}
+ </tbody>
+ </table>
+#{/if}
+#{else}
+ <h3>No topics</h3>
+#{/else}
View
6 app/views/main.html
@@ -90,6 +90,12 @@
</ul>
</li>
<li class="dropdown"><a class="dropdown-toggle"
+ data-toggle="dropdown" href="#">DSB <b class="caret"></b></a>
+ <ul class="dropdown-menu" id="swatch-menu">
+ <li><a href="@{DSBController.topics()}">Topics</a></li>
+ </ul>
+ </li>
+ <li class="dropdown"><a class="dropdown-toggle"
data-toggle="dropdown" href="#">EventCloud <b class="caret"></b></a>
<ul class="dropdown-menu" id="swatch-menu">
<li><a href="@{EventCloudController.list()}">List</a></li>
View
6 conf/routes
@@ -57,9 +57,15 @@ GET /monitoring/dsb MonitoringController.dsb
GET /pattern/list PatternsController.list
GET /pattern/runtime PatternsController.listDeployed
+# EC
+
GET /ec/list EventCloudController.list
GET /ec/info EventCloudController.ec
+# DSB
+GET /dsb/topics DSBController.topics
+GET /dsb/topic DSBController.topic
+
# Websocket
WS /websocket/backgroundMessage BackgroundTaskWebSocket.pushNewMessage
Please sign in to comment.
Something went wrong with that request. Please try again.