From 28f92c6fc62f3bc0637ac77681aabcc8c0b5e42c Mon Sep 17 00:00:00 2001
From: lresende
Date: Thu, 11 Sep 2008 04:12:24 +0000
Subject: Renaming branch
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@694107 13f79535-47bb-0310-9956-ffa450edef68
---
.../sca/demos/aggregator/AlertTypeNonSDOImpl.java | 339 +++++++++++++
.../demos/aggregator/AlertsFeedServiceImpl.java | 106 ++++
.../sca/demos/aggregator/AlertsService.java | 40 ++
.../sca/demos/aggregator/AlertsServiceImpl.java | 126 +++++
.../sca/demos/aggregator/AlertsSourcesService.java | 69 +++
.../demos/aggregator/AlertsSourcesServiceImpl.java | 183 +++++++
.../sca/demos/aggregator/AlertsTypeNonSDOImpl.java | 74 +++
.../sca/demos/aggregator/ConfigTypeNonSDOImpl.java | 55 +++
.../sca/demos/aggregator/RSSCheckerService.java | 30 ++
.../demos/aggregator/RSSCheckerServiceImpl.java | 91 ++++
.../sca/demos/aggregator/SourceTypeNonSDOImpl.java | 536 +++++++++++++++++++++
.../src/main/resources/Alerts.wsdl | 88 ++++
.../src/main/resources/Alerts.xsd | 80 +++
.../src/main/resources/AlertsSources.wsdl | 124 +++++
.../src/main/resources/alerts-client.composite | 49 ++
.../src/main/resources/alerts.composite | 85 ++++
.../src/main/resources/sources.xml | 34 ++
.../src/main/webapp/AlertAggregator.html | 330 +++++++++++++
.../src/main/webapp/META-INF/sca-contribution.xml | 26 +
.../src/main/webapp/WEB-INF/geronimo-web.xml | 32 ++
.../src/main/webapp/WEB-INF/web.xml | 41 ++
.../src/main/webapp/pop.png | Bin 0 -> 244 bytes
.../src/main/webapp/rss.png | Bin 0 -> 689 bytes
.../src/main/webapp/service.smd | 1 +
.../src/main/webapp/sources.smd | 1 +
.../src/main/webapp/style.css | 176 +++++++
.../demos/aggregator/AlertsIntegrationTest.java | 97 ++++
27 files changed, 2813 insertions(+)
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertTypeNonSDOImpl.java
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsFeedServiceImpl.java
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsService.java
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsServiceImpl.java
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesService.java
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesServiceImpl.java
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsTypeNonSDOImpl.java
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/ConfigTypeNonSDOImpl.java
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerService.java
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerServiceImpl.java
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/SourceTypeNonSDOImpl.java
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/Alerts.wsdl
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/Alerts.xsd
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/AlertsSources.wsdl
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/alerts-client.composite
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/alerts.composite
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/sources.xml
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/AlertAggregator.html
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/web.xml
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/pop.png
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/rss.png
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/service.smd
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/sources.smd
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/style.css
create mode 100644 branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/test/java/org/apache/tuscany/sca/demos/aggregator/AlertsIntegrationTest.java
(limited to 'branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src')
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertTypeNonSDOImpl.java b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertTypeNonSDOImpl.java
new file mode 100644
index 0000000000..808374030c
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertTypeNonSDOImpl.java
@@ -0,0 +1,339 @@
+/*
+ * 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.tuscany.sca.demos.aggregator;
+
+import org.apache.tuscany.sca.demos.aggregator.types.AlertType;
+
+
+public class AlertTypeNonSDOImpl implements AlertType
+{
+ private static final long serialVersionUID = 670364038865656196L;
+
+/**
+ * The default value of the '{@link #getTitle() Title}' attribute.
+ *
+ *
+ * @see #getTitle()
+ * @generated
+ * @ordered
+ */
+ protected static final String TITLE_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getTitle() Title}' attribute.
+ *
+ *
+ * @see #getTitle()
+ * @generated
+ * @ordered
+ */
+ protected String title = TITLE_DEFAULT_;
+
+ /**
+ * The default value of the '{@link #getSummary() Summary}' attribute.
+ *
+ *
+ * @see #getSummary()
+ * @generated
+ * @ordered
+ */
+ protected static final String SUMMARY_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getSummary() Summary}' attribute.
+ *
+ *
+ * @see #getSummary()
+ * @generated
+ * @ordered
+ */
+ protected String summary = SUMMARY_DEFAULT_;
+
+ /**
+ * The default value of the '{@link #getAddress() Address}' attribute.
+ *
+ *
+ * @see #getAddress()
+ * @generated
+ * @ordered
+ */
+ protected static final String ADDRESS_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getAddress() Address}' attribute.
+ *
+ *
+ * @see #getAddress()
+ * @generated
+ * @ordered
+ */
+ protected String address = ADDRESS_DEFAULT_;
+
+ /**
+ * The default value of the '{@link #getDate() Date}' attribute.
+ *
+ *
+ * @see #getDate()
+ * @generated
+ * @ordered
+ */
+ protected static final String DATE_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getDate() Date}' attribute.
+ *
+ *
+ * @see #getDate()
+ * @generated
+ * @ordered
+ */
+ protected String date = DATE_DEFAULT_;
+
+ /**
+ * The default value of the '{@link #getSourceId() Source Id}' attribute.
+ *
+ *
+ * @see #getSourceId()
+ * @generated
+ * @ordered
+ */
+ protected static final String SOURCE_ID_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getSourceId() Source Id}' attribute.
+ *
+ *
+ * @see #getSourceId()
+ * @generated
+ * @ordered
+ */
+ protected String sourceId = SOURCE_ID_DEFAULT_;
+
+ /**
+ * The default value of the '{@link #isUnread() Unread}' attribute.
+ *
+ *
+ * @see #isUnread()
+ * @generated
+ * @ordered
+ */
+ protected static final boolean UNREAD_DEFAULT_ = false;
+
+ /**
+ * The cached value of the '{@link #isUnread() Unread}' attribute.
+ *
+ *
+ * @see #isUnread()
+ * @generated
+ * @ordered
+ */
+ protected boolean unread = UNREAD_DEFAULT_;
+
+ /**
+ * The default value of the '{@link #getId() Id}' attribute.
+ *
+ *
+ * @see #getId()
+ * @generated
+ * @ordered
+ */
+ protected static final String ID_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getId() Id}' attribute.
+ *
+ *
+ * @see #getId()
+ * @generated
+ * @ordered
+ */
+ protected String id = ID_DEFAULT_;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public AlertTypeNonSDOImpl()
+ {
+ super();
+ }
+
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getTitle()
+ {
+ return title;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setTitle(String newTitle)
+ {
+ title = newTitle;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getSummary()
+ {
+ return summary;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setSummary(String newSummary)
+ {
+ summary = newSummary;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getAddress()
+ {
+ return address;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setAddress(String newAddress)
+ {
+ address = newAddress;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getDate()
+ {
+ return date;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setDate(String newDate)
+ {
+ date = newDate;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getSourceId()
+ {
+ return sourceId;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setSourceId(String newSourceId)
+ {
+ sourceId = newSourceId;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public boolean isUnread()
+ {
+ return unread;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setUnread(boolean newUnread)
+ {
+ unread = newUnread;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getId()
+ {
+ return id;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setId(String newId)
+ {
+ id = newId;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public String toString()
+ {
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (Title: ");
+ result.append(title);
+ result.append(", Summary: ");
+ result.append(summary);
+ result.append(", Address: ");
+ result.append(address);
+ result.append(", Date: ");
+ result.append(date);
+ result.append(", SourceId: ");
+ result.append(sourceId);
+ result.append(", Unread: ");
+ result.append(unread);
+ result.append(", Id: ");
+ result.append(id);
+ result.append(')');
+ return result.toString();
+ }
+
+} //AlertTypeImpl
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsFeedServiceImpl.java b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsFeedServiceImpl.java
new file mode 100644
index 0000000000..e070e0b8f1
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsFeedServiceImpl.java
@@ -0,0 +1,106 @@
+/*
+ * 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.tuscany.sca.demos.aggregator;
+
+import java.text.DateFormat;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.tuscany.sca.binding.atom.collection.Collection;
+import org.apache.tuscany.sca.binding.atom.collection.NotFoundException;
+import org.apache.tuscany.sca.demos.aggregator.types.AlertType;
+import org.apache.tuscany.sca.demos.aggregator.types.AlertsType;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Read all new alerts from the specified sources
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(Collection.class)
+public class AlertsFeedServiceImpl implements Collection {
+
+ private AlertsService alerts;
+
+ @Reference
+ public void setAlerts(AlertsService alerts) {
+ this.alerts = alerts;
+ }
+
+ DateFormat dateFormatter = DateFormat.getDateTimeInstance();
+
+ /**
+ * Return the alerts as a feed.
+ *
+ * @return the structure containing alerts
+ */
+ public org.apache.abdera.model.Feed getFeed() {
+
+ // Create a new Feed
+ Factory factory = Abdera.getNewFactory();
+ Feed feed = factory.newFeed();
+ feed.setTitle("Apache Tuscany Feed Aggregator");
+ feed.setSubtitle("A sample showing an SCA application to aggregate various types of feeds");
+ feed.addAuthor("Apache Tuscany");
+ feed.addLink("http://tuscany.apache.org");
+
+ // Aggregate entries from feed1 and feed2
+ try {
+ AlertsType alerts = this.alerts.getAllNewAlerts("");
+
+ for( Object alertObject : alerts.getAlert() ){
+ AlertType alert = ((AlertType)alertObject);
+ Entry entry = factory.newEntry();
+ entry.setTitle(alert.getTitle());
+ //entry.(alert.getSummary());
+ entry.addLink(alert.getAddress());
+ entry.setPublished(dateFormatter.parse(alert.getDate()));
+
+ feed.addEntry(entry);
+ }
+ } catch(Exception ex) {
+ System.err.println("Exception " + ex.toString());
+ }
+
+ return feed;
+ }
+
+ public Feed query(String queryString) {
+ return getFeed();
+ }
+
+ public void delete(String id) throws NotFoundException {
+ }
+
+ public Entry get(String id) throws NotFoundException {
+ return null;
+ }
+
+ public Entry post(Entry entry) {
+ return null;
+ }
+
+ public void put(String id, Entry entry) throws NotFoundException {
+ }
+
+}
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsService.java b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsService.java
new file mode 100644
index 0000000000..c4bf13ce7a
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsService.java
@@ -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.
+ */
+
+package org.apache.tuscany.sca.demos.aggregator;
+
+import org.apache.tuscany.sca.demos.aggregator.types.AlertsType;
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Retrieve and manage alerts
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface AlertsService {
+
+ /**
+ * Return a structure holding all of the new alerts that have been found
+ *
+ * @return the structure containing alerts
+ */
+ public AlertsType getAllNewAlerts(String id);
+
+}
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsServiceImpl.java b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsServiceImpl.java
new file mode 100644
index 0000000000..28e27a9978
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsServiceImpl.java
@@ -0,0 +1,126 @@
+/*
+ * 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.tuscany.sca.demos.aggregator;
+
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.tuscany.sca.demos.aggregator.types.AlertType;
+import org.apache.tuscany.sca.demos.aggregator.types.AlertsType;
+import org.apache.tuscany.sca.demos.aggregator.types.ConfigType;
+import org.apache.tuscany.sca.demos.aggregator.types.SourceType;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Read all new alerts from the specified sources
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(AlertsService.class)
+public class AlertsServiceImpl implements AlertsService {
+
+ private RSSCheckerService rssChecker;
+
+ private AlertsSourcesService alertsSources;
+
+ @Reference
+ public void setRssChecker(RSSCheckerService rssChecker) {
+ this.rssChecker = rssChecker;
+ }
+
+ @Reference
+ public void setAlertsSources(AlertsSourcesService alertsSources) {
+ this.alertsSources = alertsSources;
+ }
+
+ DateFormat dateFormatter = DateFormat.getDateTimeInstance();
+
+ /**
+ * Return a structure holding all of the new alerts that have been found
+ *
+ * @return the structure containing alerts
+ */
+ public AlertsType getAllNewAlerts(String id)
+ {
+ System.err.println("getAllNewAlerts(" + id + ")");
+
+ //TypesFactory factory = TypesFactory.INSTANCE;
+ //AlertsType returnAlerts = factory.createAlertsType();
+ AlertsType returnAlerts = new AlertsTypeNonSDOImpl();
+ List returnAlertList = returnAlerts.getAlert();
+
+ // get the date/time now so that we can update the
+ // alert source record so that next time we
+ // only get the latest alerts
+ Date now = new Date();
+ String nowString = dateFormatter.format(now);
+
+ try {
+ ConfigType alertSourceConfig = alertsSources.getAlertSources(id);
+
+ for (Object source : alertSourceConfig.getSource()){
+ SourceType sourceType = (SourceType)source;
+
+ AlertsType alerts = null;
+
+ if ( sourceType.getFeedType().equals("rss")){
+ alerts = rssChecker.getNewAlerts(sourceType.getFeedAddress(),
+ sourceType.getLastChecked());
+ } else {
+
+ }
+
+ // extend return list with any alerts we found
+ for( Object alert : alerts.getAlert() ){
+
+ // set the id on the alert so we know which source it
+ // came from
+ ((AlertType)alert).setSourceId(sourceType.getId());
+
+ // convert from SDO to POJO so that the
+ // JSONRPC binding will work. It can't currently
+ // handle SDOs
+ AlertType newAlert = new AlertTypeNonSDOImpl();
+
+ newAlert.setSourceId(((AlertType)alert).getSourceId());
+ newAlert.setTitle(((AlertType)alert).getTitle());
+ newAlert.setSummary(((AlertType)alert).getSummary());
+ newAlert.setAddress(((AlertType)alert).getAddress());
+ newAlert.setDate(((AlertType)alert).getDate());
+ newAlert.setId(((AlertType)alert).getId());
+ newAlert.setUnread(((AlertType)alert).isUnread());
+
+ returnAlertList.add(newAlert);
+ }
+
+ // update the time last checked for this source
+ sourceType.setLastChecked(nowString);
+ //alertsSources.updateAlertSource(sourceType);
+ }
+ } catch(Exception ex) {
+ System.err.println("Exception " + ex.toString());
+ }
+
+ return returnAlerts ;
+
+ }
+}
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesService.java b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesService.java
new file mode 100644
index 0000000000..7b943b1b45
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesService.java
@@ -0,0 +1,69 @@
+/*
+ * 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.tuscany.sca.demos.aggregator;
+
+import org.apache.tuscany.sca.demos.aggregator.types.ConfigType;
+import org.apache.tuscany.sca.demos.aggregator.types.SourceType;
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Retrieve and manage alert sources
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface AlertsSourcesService {
+
+ /**
+ * Return all of the configured alert sources.
+ *
+ * @return the list of alert sources
+ */
+ public ConfigType getAlertSources (String id);
+
+ /**
+ * Return a single alert source.
+ * @param id not currently used
+ * @return the alert source
+ */
+ public SourceType getAlertSource (String id);
+
+ /**
+ * Update an alert source.
+ *
+ * @param updatedSource the alert source to update
+ */
+ public void updateAlertSource (SourceType updatedSource);
+
+ /**
+ * Add an alert source.
+ *
+ * @param newSource the alert source to add
+ */
+ public String addAlertSource (SourceType newSource);
+
+ /**
+ * Remove an alert source.
+ *
+ * @param oldSource the alert source to remove
+ */
+ public void removeAlertSource (String id);
+
+}
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesServiceImpl.java b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesServiceImpl.java
new file mode 100644
index 0000000000..ca2fc95b4a
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesServiceImpl.java
@@ -0,0 +1,183 @@
+/*
+ * 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.tuscany.sca.demos.aggregator;
+
+import java.io.InputStream;
+import java.text.DateFormat;
+import java.util.Date;
+
+import org.apache.tuscany.sca.demos.aggregator.types.ConfigType;
+import org.apache.tuscany.sca.demos.aggregator.types.SourceType;
+import org.apache.tuscany.sca.demos.aggregator.types.TypesFactory;
+import org.apache.tuscany.sca.demos.aggregator.types.impl.SourceTypeImpl;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.impl.HelperProvider;
+
+/**
+ * Retrieve and manage alert sources
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(AlertsSourcesService.class)
+@Scope("COMPOSITE")
+public class AlertsSourcesServiceImpl implements AlertsSourcesService {
+
+ ConfigType alertSources;
+
+ /**
+ * Constructor reads the configuration to provide
+ * the initial list of alert sources
+ */
+ public AlertsSourcesServiceImpl(){
+ System.err.println("AlertsSourcesServiceImpl()");
+ try {
+ // read the alerts config from an XML file
+ InputStream is = this.getClass().getClassLoader().getResourceAsStream("sources.xml");
+
+ if (is == null) {
+ throw new Exception("Can;t find sources.xml");
+ } else {
+ HelperContext helperContext = HelperProvider.getDefaultContext();
+ TypesFactory.INSTANCE.register(helperContext);
+ XMLDocument xmlDoc = helperContext.getXMLHelper().load(is);
+ alertSources = (ConfigType)xmlDoc.getRootObject();
+ }
+ } catch (Exception ex) {
+ System.err.println("Exception " + ex.toString());
+ }
+ }
+
+ /**
+ * Return all of the configured alert sources.
+ *
+ * @return the list of alert sources
+ */
+ public ConfigType getAlertSources (String id)
+ {
+ System.err.println("getAlertSources(" + id + ")");
+
+ // convert alert sources to POJOs so that
+ // the JSONRPC binding will work
+ ConfigTypeNonSDOImpl sources = new ConfigTypeNonSDOImpl();
+
+ for (Object source : alertSources.getSource()) {
+ SourceTypeNonSDOImpl newSource = new SourceTypeNonSDOImpl();
+ newSource.setAddress(((SourceTypeImpl)source).getAddress());
+ newSource.setFeedAddress(((SourceTypeImpl)source).getFeedAddress());
+ newSource.setId(((SourceTypeImpl)source).getId());
+ newSource.setLastChecked(((SourceTypeImpl)source).getLastChecked());
+ newSource.setName(((SourceTypeImpl)source).getName());
+ newSource.setFeedType(((SourceTypeImpl)source).getFeedType());
+ sources.getSource().add(newSource);
+ }
+
+ return sources;
+ }
+
+ /**
+ * Return a single alert source.
+ * @param id the alert source id number
+ * @return the alert source
+ */
+ public SourceType getAlertSource (String id)
+ {
+ System.err.println("getAlertSource(" + id + ")");
+ SourceType alertSource = null;
+
+ for (Object source : alertSources.getSource()) {
+ if ( ((SourceType)source).getId().equals(id)) {
+ alertSource = (SourceType)source;
+ }
+ }
+ return alertSource;
+ }
+
+ /**
+ * Update an alert source.
+ *
+ * @param updatedSource the alert source to update
+ */
+ public void updateAlertSource (SourceType updatedSource)
+ {
+ System.err.println("updateAlertSource()");
+
+ Object originalSource = null;
+
+ for (Object source : alertSources.getSource()) {
+ if ( ((SourceType)source).getId().equals(updatedSource.getId())) {
+ originalSource = source;
+ break;
+ }
+ }
+
+ if (originalSource != null){
+ alertSources.getSource().add(updatedSource);
+ alertSources.getSource().remove(originalSource);
+ }
+ }
+
+ /**
+ * Add an alert source.
+ *
+ * @param newSource the alert source to add
+ */
+ public String addAlertSource (SourceType newSource)
+ {
+ System.err.println("addAlertSource()");
+ // set the date to now less 2 hours so we
+ // get some alerts straight away
+ DateFormat dateFormatter = DateFormat.getDateTimeInstance();
+ Date now = new Date();
+ now.setHours(now.getHours()-2);
+ String nowString = dateFormatter.format(now);
+ newSource.setLastChecked(nowString);
+ alertSources.getSource().add(newSource);
+ return "Done";
+ }
+
+ /**
+ * Remove an alert source.
+ *
+ * @param oldSource the alert source to remove
+ */
+ public void removeAlertSource (String id)
+ {
+ System.err.println("removeAlertSource()");
+
+ Object originalSource = null;
+
+ for (Object source : alertSources.getSource()) {
+ if ( ((SourceType)source).getId().equals(id)) {
+ originalSource = source;
+ break;
+ }
+ }
+
+ if (originalSource != null) {
+ alertSources.getSource().remove(originalSource);
+ }
+
+ }
+
+}
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsTypeNonSDOImpl.java b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsTypeNonSDOImpl.java
new file mode 100644
index 0000000000..2962defb25
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsTypeNonSDOImpl.java
@@ -0,0 +1,74 @@
+/*
+ * 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.tuscany.sca.demos.aggregator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.demos.aggregator.types.AlertsType;
+
+/**
+ *
+ * An implementation of the model object 'Alerts Type'.
+ *
+ *
+ * The following features are implemented:
+ *
+ * - {@link org.apache.tuscany.sca.samples.aggregator.types.impl.AlertsTypeImpl#getAlert Alert}
+ *
+ *
+ *
+ * @generated
+ */
+public class AlertsTypeNonSDOImpl implements AlertsType
+{
+ private static final long serialVersionUID = -3784576466148158776L;
+
+/**
+ * The cached value of the '{@link #getAlert() Alert}' containment reference list.
+ *
+ *
+ * @see #getAlert()
+ * @generated
+ * @ordered
+ */
+
+ protected List alert = new ArrayList();
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public AlertsTypeNonSDOImpl()
+ {
+ super();
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public List getAlert()
+ {
+ return alert;
+ }
+
+} //AlertsTypeImpl
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/ConfigTypeNonSDOImpl.java b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/ConfigTypeNonSDOImpl.java
new file mode 100644
index 0000000000..75544294ce
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/ConfigTypeNonSDOImpl.java
@@ -0,0 +1,55 @@
+/*
+ * 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.tuscany.sca.demos.aggregator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.demos.aggregator.types.ConfigType;
+
+
+public class ConfigTypeNonSDOImpl implements ConfigType
+{
+ private static final long serialVersionUID = 2522843951360675364L;
+
+ protected List source = new ArrayList();
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public ConfigTypeNonSDOImpl()
+ {
+ super();
+ }
+
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public List getSource()
+ {
+ return source;
+ }
+
+
+} //ConfigTypeImpl
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerService.java b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerService.java
new file mode 100644
index 0000000000..2a5775e9a9
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerService.java
@@ -0,0 +1,30 @@
+/*
+ * 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.tuscany.sca.demos.aggregator;
+
+import org.apache.tuscany.sca.demos.aggregator.types.AlertsType;
+
+/**
+ * The interface for the rss checker service
+ */
+public interface RSSCheckerService {
+
+ public AlertsType getNewAlerts(String rssaddress, String lastchecktimestamp);
+
+}
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerServiceImpl.java b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerServiceImpl.java
new file mode 100644
index 0000000000..549abbf602
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerServiceImpl.java
@@ -0,0 +1,91 @@
+/*
+ * 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.tuscany.sca.demos.aggregator;
+
+import java.net.URL;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.tuscany.sca.demos.aggregator.types.AlertType;
+import org.apache.tuscany.sca.demos.aggregator.types.AlertsType;
+import org.apache.tuscany.sca.demos.aggregator.types.TypesFactory;
+
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.io.SyndFeedInput;
+import com.sun.syndication.io.XmlReader;
+
+/**
+ * The interface for the rss checker service
+ */
+public class RSSCheckerServiceImpl implements RSSCheckerService {
+
+ public AlertsType getNewAlerts(String rssaddress, String lastchecktimestamp){
+ // Create the list of alerts to return
+ TypesFactory factory = TypesFactory.INSTANCE;
+ AlertsType returnAlerts = factory.createAlertsType();
+ List returnAlertList = returnAlerts.getAlert();
+
+ try {
+ // lastchecktimestamp comes from sources.xml configuration.
+ // That origin requires ISO 8601 date input (yyyy-MM-dd hh:mm:ss).
+ DateFormat configDateFormatter = new SimpleDateFormat( "yyyy-MM-dd hh:mm:ss");
+ Date timestamp = configDateFormatter.parse(lastchecktimestamp);
+ // Turn feed dates into something we can process.
+ DateFormat feedDateFormatter = DateFormat.getDateTimeInstance();
+
+ // get the feed data from the supplied address
+ SyndFeedInput input = new SyndFeedInput();
+ SyndFeed feed = input.build(new XmlReader(new URL(rssaddress)));
+ //System.out.println(feed);
+
+ // check all the items to see if we have seen them before
+ List entries = feed.getEntries();
+ for(Object entry: entries){
+ SyndEntry syndEntry = (SyndEntry)entry;
+
+ // System.err.println( "Entry pubdate=" + syndEntry.getPublishedDate() );
+ if (syndEntry.getPublishedDate().after(timestamp)){
+ AlertType newAlert = factory.createAlertType();
+
+ newAlert.setTitle(syndEntry.getTitle());
+ // newAlert.setSummary("");
+ newAlert.setSummary("");
+ newAlert.setAddress(syndEntry.getLink());
+ newAlert.setDate(feedDateFormatter.format(syndEntry.getPublishedDate()));
+ newAlert.setId(rssaddress);
+ newAlert.setUnread(true);
+
+ returnAlertList.add(newAlert);
+ }
+ }
+
+ } catch(Exception ex) {
+ ex.printStackTrace( System.err );
+ System.err.println("Exception " + ex.toString());
+ }
+
+ return returnAlerts;
+ }
+
+}
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/SourceTypeNonSDOImpl.java b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/SourceTypeNonSDOImpl.java
new file mode 100644
index 0000000000..10575bf0dc
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/SourceTypeNonSDOImpl.java
@@ -0,0 +1,536 @@
+/*
+ * 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.tuscany.sca.demos.aggregator;
+
+import org.apache.tuscany.sca.demos.aggregator.types.SourceType;
+
+import commonj.sdo.Sequence;
+
+
+public class SourceTypeNonSDOImpl implements SourceType
+{
+ private static final long serialVersionUID = -4986294578888767793L;
+
+ public final static int NAME = 0;
+
+ public final static int ADDRESS = 1;
+
+ public final static int LAST_CHECKED = 2;
+
+ public final static int FEED_ADDRESS = 3;
+
+ public final static int POP_SERVER = 4;
+
+ public final static int POP_USERNAME = 5;
+
+ public final static int POP_PASSWORD = 6;
+
+ public final static int ANY = -1;
+
+ public final static int ID = 7;
+
+ public final static int TYPE = 8;
+
+ public final static int SDO_PROPERTY_COUNT = 9;
+
+ public final static int EXTENDED_PROPERTY_COUNT = -1;
+
+
+ /**
+ * The internal feature id for the 'Name' attribute.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_NAME = 0;
+
+ /**
+ * The internal feature id for the 'Address' attribute.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_ADDRESS = 1;
+
+ /**
+ * The internal feature id for the 'Last Checked' attribute.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_LAST_CHECKED = 2;
+
+ /**
+ * The internal feature id for the 'Feed Address' attribute.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_FEED_ADDRESS = 3;
+
+ /**
+ * The internal feature id for the 'Pop Server' attribute.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_POP_SERVER = 4;
+
+ /**
+ * The internal feature id for the 'Pop Username' attribute.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_POP_USERNAME = 5;
+
+ /**
+ * The internal feature id for the 'Pop Password' attribute.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_POP_PASSWORD = 6;
+
+ /**
+ * The internal feature id for the 'Any' attribute list.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_ANY = 7;
+
+ /**
+ * The internal feature id for the 'Id' attribute.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_ID = 8;
+
+ /**
+ * The internal feature id for the 'Type' attribute.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_TYPE = 9;
+
+ /**
+ * The number of properties for this type.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_PROPERTY_COUNT = 10;
+
+
+
+
+ /**
+ * The default value of the '{@link #getName() Name}' attribute.
+ *
+ *
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected static final String NAME_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getName() Name}' attribute.
+ *
+ *
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected String name = NAME_DEFAULT_;
+
+ /**
+ * The default value of the '{@link #getAddress() Address}' attribute.
+ *
+ *
+ * @see #getAddress()
+ * @generated
+ * @ordered
+ */
+ protected static final String ADDRESS_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getAddress() Address}' attribute.
+ *
+ *
+ * @see #getAddress()
+ * @generated
+ * @ordered
+ */
+ protected String address = ADDRESS_DEFAULT_;
+
+ /**
+ * The default value of the '{@link #getLastChecked() Last Checked}' attribute.
+ *
+ *
+ * @see #getLastChecked()
+ * @generated
+ * @ordered
+ */
+ protected static final String LAST_CHECKED_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getLastChecked() Last Checked}' attribute.
+ *
+ *
+ * @see #getLastChecked()
+ * @generated
+ * @ordered
+ */
+ protected String lastChecked = LAST_CHECKED_DEFAULT_;
+
+ /**
+ * The default value of the '{@link #getFeedAddress() Feed Address}' attribute.
+ *
+ *
+ * @see #getFeedAddress()
+ * @generated
+ * @ordered
+ */
+ protected static final String FEED_ADDRESS_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getFeedAddress() Feed Address}' attribute.
+ *
+ *
+ * @see #getFeedAddress()
+ * @generated
+ * @ordered
+ */
+ protected String feedAddress = FEED_ADDRESS_DEFAULT_;
+
+ /**
+ * The default value of the '{@link #getPopServer() Pop Server}' attribute.
+ *
+ *
+ * @see #getPopServer()
+ * @generated
+ * @ordered
+ */
+ protected static final String POP_SERVER_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getPopServer() Pop Server}' attribute.
+ *
+ *
+ * @see #getPopServer()
+ * @generated
+ * @ordered
+ */
+ protected String popServer = POP_SERVER_DEFAULT_;
+
+ /**
+ * The default value of the '{@link #getPopUsername() Pop Username}' attribute.
+ *
+ *
+ * @see #getPopUsername()
+ * @generated
+ * @ordered
+ */
+ protected static final String POP_USERNAME_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getPopUsername() Pop Username}' attribute.
+ *
+ *
+ * @see #getPopUsername()
+ * @generated
+ * @ordered
+ */
+ protected String popUsername = POP_USERNAME_DEFAULT_;
+
+ /**
+ * The default value of the '{@link #getPopPassword() Pop Password}' attribute.
+ *
+ *
+ * @see #getPopPassword()
+ * @generated
+ * @ordered
+ */
+ protected static final String POP_PASSWORD_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getPopPassword() Pop Password}' attribute.
+ *
+ *
+ * @see #getPopPassword()
+ * @generated
+ * @ordered
+ */
+ protected String popPassword = POP_PASSWORD_DEFAULT_;
+
+ /**
+ * The cached value of the '{@link #getAny() Any}' attribute list.
+ *
+ *
+ * @see #getAny()
+ * @generated
+ * @ordered
+ */
+
+ protected Sequence any = null;
+
+ /**
+ * The default value of the '{@link #getId() Id}' attribute.
+ *
+ *
+ * @see #getId()
+ * @generated
+ * @ordered
+ */
+ protected static final String ID_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getId() Id}' attribute.
+ *
+ *
+ * @see #getId()
+ * @generated
+ * @ordered
+ */
+ protected String id = ID_DEFAULT_;
+
+ /**
+ * The default value of the '{@link #getFeedType() Feed Type}' attribute.
+ *
+ *
+ * @see #getFeedType()
+ * @generated
+ * @ordered
+ */
+ protected static final String FEED_TYPE_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getFeedType() Feed Type}' attribute.
+ *
+ *
+ * @see #getFeedType()
+ * @generated
+ * @ordered
+ */
+ protected String feedType = FEED_TYPE_DEFAULT_;
+
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public SourceTypeNonSDOImpl()
+ {
+ super();
+ }
+
+
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getName()
+ {
+ return name;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setName(String newName)
+ {
+ name = newName;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getAddress()
+ {
+ return address;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setAddress(String newAddress)
+ {
+ address = newAddress;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getLastChecked()
+ {
+ return lastChecked;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setLastChecked(String newLastChecked)
+ {
+ lastChecked = newLastChecked;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getFeedAddress()
+ {
+ return feedAddress;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setFeedAddress(String newFeedAddress)
+ {
+ feedAddress = newFeedAddress;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getPopServer()
+ {
+ return popServer;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setPopServer(String newPopServer)
+ {
+ popServer = newPopServer;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getPopUsername()
+ {
+ return popUsername;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setPopUsername(String newPopUsername)
+ {
+ popUsername = newPopUsername;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getPopPassword()
+ {
+ return popPassword;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setPopPassword(String newPopPassword)
+ {
+ popPassword = newPopPassword;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getId()
+ {
+ return id;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setId(String newId)
+ {
+ id = newId;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getFeedType()
+ {
+ return feedType;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setFeedType(String newType)
+ {
+ feedType = newType;
+ }
+
+ public Sequence getAny(){
+ return null;
+ }
+
+} //SourceTypeImpl
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/Alerts.wsdl b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/Alerts.wsdl
new file mode 100644
index 0000000000..8b376240c8
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/Alerts.wsdl
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/Alerts.xsd b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/Alerts.xsd
new file mode 100644
index 0000000000..f0ec561ad8
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/Alerts.xsd
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/AlertsSources.wsdl b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/AlertsSources.wsdl
new file mode 100644
index 0000000000..d5642a32d1
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/AlertsSources.wsdl
@@ -0,0 +1,124 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/alerts-client.composite b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/alerts-client.composite
new file mode 100644
index 0000000000..49f44f9da8
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/alerts-client.composite
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/alerts.composite b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/alerts.composite
new file mode 100644
index 0000000000..c359b275be
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/alerts.composite
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/sources.xml b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/sources.xml
new file mode 100644
index 0000000000..e45250eddb
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/resources/sources.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+ BBC News
+ http://news.bbc.co.uk/
+ 2008-06-20 12:00:00
+ http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml
+
+
+ Engadget
+ http://www.engadget.com
+ 2008-06-20 12:00:00
+ http://www.engadget.com/rss.xml
+
+
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/AlertAggregator.html b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/AlertAggregator.html
new file mode 100644
index 0000000000..8b472fd0fa
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/AlertAggregator.html
@@ -0,0 +1,330 @@
+
+
+
+Apache Tuscany Alert Aggregator Sample
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Apache Tuscany Alert Aggregator Demo
+
+Alert Sources:
+
+Refreshing...
+
+
+Refreshing...
+Back to top
+
+
+
+
+
+
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..0bc67c4c98
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml
new file mode 100644
index 0000000000..0e7125fe66
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+ org.apache.tuscany.sca
+ demo-alert-aggregator-webapp
+ 1.4-SNAPSHOT
+ war
+
+
+
+
+
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/web.xml b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..a81165e1b4
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+ Apache Tuscany Alert Aggregator Demo
+
+
+ tuscany
+ org.apache.tuscany.sca.host.webapp.TuscanyServletFilter
+
+
+
+ tuscany
+ /*
+
+
+
+ AlertAggregator.html
+
+
+
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/pop.png b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/pop.png
new file mode 100644
index 0000000000..1cf1df24a7
Binary files /dev/null and b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/pop.png differ
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/rss.png b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/rss.png
new file mode 100644
index 0000000000..b3c949d224
Binary files /dev/null and b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/rss.png differ
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/service.smd b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/service.smd
new file mode 100644
index 0000000000..3c6b6c9b12
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/service.smd
@@ -0,0 +1 @@
+{"SMDVersion":".1","objectName":"AlertsService","serviceType":"JSON-RPC","serviceURL":"http://localhost:8085/sample-feed-aggregator/services/AlertsServiceJSONRPC","methods":[{"name":"getAllNewAlerts","parameters":[{"name":"param0","type":"STRING"}]}]}
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/sources.smd b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/sources.smd
new file mode 100644
index 0000000000..b5f1824363
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/sources.smd
@@ -0,0 +1 @@
+{"SMDVersion":".1","objectName":"AlertsSourcesService","serviceType":"JSON-RPC","serviceURL":"http://localhost:8081/sample-feed-aggregator/services/AlertsSourcesServiceJSONRPC","methods":[{"name":"getAlertSources","parameters":[{"name":"param0","type":"STRING"}]},{"name":"getAlertSource","parameters":[{"name":"param0","type":"STRING"}]},{"name":"updateAlertSource","parameters":[{"name":"param0","type":"STRING"}]},{"name":"addAlertSource","parameters":[{"name":"param0","type":"STRING"}]},{"name":"removeAlertSource","parameters":[{"name":"param0","type":"STRING"}]}]}
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/style.css b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/style.css
new file mode 100644
index 0000000000..f5bbf23379
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/main/webapp/style.css
@@ -0,0 +1,176 @@
+/*
+ * 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.
+ */
+
+p,table,li,h1,h2,h3
+{
+font-family: verdana, arial, 'sans serif';
+}
+
+p, h1, h2, h3, table, li, hr
+{
+margin-left: 10pt;
+}
+
+table
+{
+border-color: black;
+border-collapse: separate;
+border-spacing: 0px 1px;
+
+margin-right: 10pt;
+margin-left: 10pt;
+width: 800px;
+}
+
+.sourceDetailsTable
+{
+width: 600px;
+}
+
+tr, td
+{
+margin-left: 0pt;
+margin-right: 0pt;
+padding-left: 10pt;
+font-size: 90%;
+}
+
+p,li,th
+{
+font-size: 90%;
+margin-left: 10pt;
+}
+
+pre
+{
+margin-left: 10pt;
+}
+
+body
+{
+#ffffff;
+}
+
+h1,h2,h3,hr
+{
+color: firebrick;
+}
+
+a:link {COLOR: firebrick;}
+a:visited {COLOR: firebrick;}
+a:active {COLOR: navy;}
+
+.link
+{
+COLOR: firebrick;
+text-decoration: underline;
+}
+
+.clickable
+{
+cursor: pointer
+}
+
+.unread_title
+{
+font-weight: bold;
+}
+
+.read_title
+{
+font-weight: normal;
+}
+
+.summary
+{
+color: DimGrey;
+}
+
+.hidden
+{
+display: none;
+}
+
+.source_name
+{
+width: 600px;
+}
+
+.alert_text
+{
+width: 600px;
+}
+
+.alert_data
+{
+margin-left: 10px;
+width: 800px;
+height: 800px;
+}
+
+.source_0
+{
+background-color: LightGreen;
+}
+
+.source_1
+{
+background-color: LightSkyBlue;
+}
+
+.source_2
+{
+background-color: Khaki;
+}
+
+.source_3
+{
+background-color: LightPink;
+}
+
+.source_4
+{
+background-color: Orange;
+}
+
+.source_5
+{
+background-color: LightCoral;
+}
+
+.source_6
+{
+background-color: Orchid;
+}
+
+.source_7
+{
+background-color: Peru;
+}
+
+.source_8
+{
+background-color: SpringGreen;
+}
+
+.source_9
+{
+background-color: LightGrey;
+}
+
diff --git a/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/test/java/org/apache/tuscany/sca/demos/aggregator/AlertsIntegrationTest.java b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/test/java/org/apache/tuscany/sca/demos/aggregator/AlertsIntegrationTest.java
new file mode 100644
index 0000000000..f0cb9ecfcb
--- /dev/null
+++ b/branches/sca-trunk-20080910/demos/alert-aggregator-webapp/src/test/java/org/apache/tuscany/sca/demos/aggregator/AlertsIntegrationTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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.tuscany.sca.demos.aggregator;
+
+import java.io.ByteArrayInputStream;
+
+import junit.framework.Assert;
+
+import org.json.JSONObject;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.meterware.httpunit.PostMethodWebRequest;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+
+/**
+ */
+public class AlertsIntegrationTest {
+ //private static SCADomain scaDomain;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ //scaDomain = SCADomain.newInstance("alerts.composite");
+ }
+
+ /**
+ * Runs after each test method
+ */
+ @AfterClass
+ public static void tearDown() {
+ //scaDomain.close();
+ }
+
+/* Use this if you want to test locally without deploying to a web container
+ public void testWait() throws Exception {
+ System.out.println("Feed aggregator server started (press enter to shutdown)");
+ System.in.read();
+ System.out.println("Feed aggregator server stopped");
+ }
+*/
+
+ @Test
+ public void testGetAllNewAlerts() throws Exception {
+ JSONObject jsonRequest = new JSONObject("{\"params\":[\"sometext\"],\"method\":\"getAllNewAlerts\",\"id\":2}");
+ JSONObject jsonResp = callService ("http://localhost:8085/demo-alert-aggregator-webapp/AlertsServiceJSONRPC",
+ jsonRequest);
+ Assert.assertNotNull(jsonResp);
+ }
+
+ @Test
+ public void testAddAlertSources() throws Exception {
+ JSONObject jsonRequest = new JSONObject("{\"params\":[{\"name\":\"news\",\"id\":\"2\",\"address\":\"www.news.com\",\"feedAddress\":\"http://news.com.com/2547-1_3-0-20.xml\",\"feedType\":\"rss\",\"lastChecked\":\"lastChecked\",\"javaClass\":\"org.apache.tuscany.sca.demos.aggregator.types.impl.SourceTypeImpl\"}],\"method\":\"addAlertSource\",\"id\":2}");
+ JSONObject jsonResp = callService ("http://localhost:8085/demo-alert-aggregator-webapp/AlertsSourcesServiceJSONRPC",
+ jsonRequest);
+ Assert.assertNotNull(jsonResp);
+ }
+
+ @Test
+ public void testGetAlertSources() throws Exception {
+ JSONObject jsonRequest = new JSONObject("{\"params\":[\"sometext\"],\"method\":\"getAlertSources\",\"id\":2}");
+ JSONObject jsonResp = callService ("http://localhost:8085/demo-alert-aggregator-webapp/AlertsSourcesServiceJSONRPC",
+ jsonRequest);
+ Assert.assertEquals("BBC News", jsonResp.getJSONObject("result").getJSONObject("source").optJSONArray("list").getJSONObject(0).getString("name"));
+ }
+
+ public JSONObject callService(String url, JSONObject jsonRequest) throws Exception {
+ System.out.println("Request = " + jsonRequest.toString());
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest( url,
+ new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")),"application/json");
+ WebResponse response = wc.getResource(request);
+ System.out.println("Response= " + response.getText());
+ Assert.assertEquals(200, response.getResponseCode());
+ return new JSONObject(response.getText());
+ }
+}
--
cgit v1.2.3