diff options
author | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
---|---|---|
committer | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
commit | bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch) | |
tree | 38a92061c0793434c4be189f1d70c3458b6bc41d /branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main |
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main')
26 files changed, 2709 insertions, 0 deletions
diff --git a/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertTypeNonSDOImpl.java b/branches/sca-java-1.2/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-java-1.2/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() <em>Title</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getTitle() + * @generated + * @ordered + */ + protected static final String TITLE_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getTitle() <em>Title</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getTitle() + * @generated + * @ordered + */ + protected String title = TITLE_DEFAULT_; + + /** + * The default value of the '{@link #getSummary() <em>Summary</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getSummary() + * @generated + * @ordered + */ + protected static final String SUMMARY_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getSummary() <em>Summary</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getSummary() + * @generated + * @ordered + */ + protected String summary = SUMMARY_DEFAULT_; + + /** + * The default value of the '{@link #getAddress() <em>Address</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAddress() + * @generated + * @ordered + */ + protected static final String ADDRESS_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getAddress() <em>Address</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAddress() + * @generated + * @ordered + */ + protected String address = ADDRESS_DEFAULT_; + + /** + * The default value of the '{@link #getDate() <em>Date</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getDate() + * @generated + * @ordered + */ + protected static final String DATE_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getDate() <em>Date</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getDate() + * @generated + * @ordered + */ + protected String date = DATE_DEFAULT_; + + /** + * The default value of the '{@link #getSourceId() <em>Source Id</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getSourceId() + * @generated + * @ordered + */ + protected static final String SOURCE_ID_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getSourceId() <em>Source Id</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getSourceId() + * @generated + * @ordered + */ + protected String sourceId = SOURCE_ID_DEFAULT_; + + /** + * The default value of the '{@link #isUnread() <em>Unread</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isUnread() + * @generated + * @ordered + */ + protected static final boolean UNREAD_DEFAULT_ = false; + + /** + * The cached value of the '{@link #isUnread() <em>Unread</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isUnread() + * @generated + * @ordered + */ + protected boolean unread = UNREAD_DEFAULT_; + + /** + * The default value of the '{@link #getId() <em>Id</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getId() + * @generated + * @ordered + */ + protected static final String ID_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getId() <em>Id</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getId() + * @generated + * @ordered + */ + protected String id = ID_DEFAULT_; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public AlertTypeNonSDOImpl() + { + super(); + } + + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getTitle() + { + return title; + } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setTitle(String newTitle) + { + title = newTitle; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getSummary() + { + return summary; + } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setSummary(String newSummary) + { + summary = newSummary; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getAddress() + { + return address; + } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setAddress(String newAddress) + { + address = newAddress; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getDate() + { + return date; + } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setDate(String newDate) + { + date = newDate; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getSourceId() + { + return sourceId; + } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setSourceId(String newSourceId) + { + sourceId = newSourceId; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isUnread() + { + return unread; + } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setUnread(boolean newUnread) + { + unread = newUnread; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getId() + { + return id; + } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setId(String newId) + { + id = newId; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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-java-1.2/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsFeedServiceImpl.java b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsFeedServiceImpl.java new file mode 100644 index 0000000000..b062504311 --- /dev/null +++ b/branches/sca-java-1.2/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://incubator.apache.org/tuscany"); + + // 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-java-1.2/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsService.java b/branches/sca-java-1.2/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-java-1.2/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-java-1.2/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsServiceImpl.java b/branches/sca-java-1.2/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-java-1.2/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-java-1.2/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesService.java b/branches/sca-java-1.2/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-java-1.2/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-java-1.2/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesServiceImpl.java b/branches/sca-java-1.2/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-java-1.2/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-java-1.2/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsTypeNonSDOImpl.java b/branches/sca-java-1.2/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-java-1.2/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; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Alerts Type</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sca.samples.aggregator.types.impl.AlertsTypeImpl#getAlert <em>Alert</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class AlertsTypeNonSDOImpl implements AlertsType +{ + private static final long serialVersionUID = -3784576466148158776L; + +/** + * The cached value of the '{@link #getAlert() <em>Alert</em>}' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAlert() + * @generated + * @ordered + */ + + protected List alert = new ArrayList(); + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public AlertsTypeNonSDOImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public List getAlert() + { + return alert; + } + +} //AlertsTypeImpl diff --git a/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/ConfigTypeNonSDOImpl.java b/branches/sca-java-1.2/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-java-1.2/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(); + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ConfigTypeNonSDOImpl() + { + super(); + } + + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public List getSource() + { + return source; + } + + +} //ConfigTypeImpl diff --git a/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerService.java b/branches/sca-java-1.2/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-java-1.2/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-java-1.2/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerServiceImpl.java b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerServiceImpl.java new file mode 100644 index 0000000000..9b73a27625 --- /dev/null +++ b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerServiceImpl.java @@ -0,0 +1,85 @@ +/* + * 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.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 { + // Turn the date into something we can process. + DateFormat dateFormatter = DateFormat.getDateTimeInstance(); + Date timestamp = dateFormatter.parse(lastchecktimestamp); + + // 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; + + if (syndEntry.getPublishedDate().after(timestamp)){ + AlertType newAlert = factory.createAlertType(); + + newAlert.setTitle(syndEntry.getTitle()); + // newAlert.setSummary("<![CDATA[" + + // syndEntry.getDescription().getValue() + + // "]]>"); + newAlert.setSummary(""); + newAlert.setAddress(syndEntry.getLink()); + newAlert.setDate(dateFormatter.format(syndEntry.getPublishedDate())); + newAlert.setId(rssaddress); + newAlert.setUnread(true); + + returnAlertList.add(newAlert); + } + } + + } catch(Exception ex) { + System.err.println("Exception " + ex.toString()); + } + + return returnAlerts; + } + +} diff --git a/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/SourceTypeNonSDOImpl.java b/branches/sca-java-1.2/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-java-1.2/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 '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public final static int INTERNAL_NAME = 0; + + /** + * The internal feature id for the '<em><b>Address</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public final static int INTERNAL_ADDRESS = 1; + + /** + * The internal feature id for the '<em><b>Last Checked</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public final static int INTERNAL_LAST_CHECKED = 2; + + /** + * The internal feature id for the '<em><b>Feed Address</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public final static int INTERNAL_FEED_ADDRESS = 3; + + /** + * The internal feature id for the '<em><b>Pop Server</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public final static int INTERNAL_POP_SERVER = 4; + + /** + * The internal feature id for the '<em><b>Pop Username</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public final static int INTERNAL_POP_USERNAME = 5; + + /** + * The internal feature id for the '<em><b>Pop Password</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public final static int INTERNAL_POP_PASSWORD = 6; + + /** + * The internal feature id for the '<em><b>Any</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public final static int INTERNAL_ANY = 7; + + /** + * The internal feature id for the '<em><b>Id</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public final static int INTERNAL_ID = 8; + + /** + * The internal feature id for the '<em><b>Type</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public final static int INTERNAL_TYPE = 9; + + /** + * The number of properties for this type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY_COUNT = 10; + + + + + /** + * The default value of the '{@link #getName() <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getName() <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_DEFAULT_; + + /** + * The default value of the '{@link #getAddress() <em>Address</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAddress() + * @generated + * @ordered + */ + protected static final String ADDRESS_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getAddress() <em>Address</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAddress() + * @generated + * @ordered + */ + protected String address = ADDRESS_DEFAULT_; + + /** + * The default value of the '{@link #getLastChecked() <em>Last Checked</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getLastChecked() + * @generated + * @ordered + */ + protected static final String LAST_CHECKED_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getLastChecked() <em>Last Checked</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getLastChecked() + * @generated + * @ordered + */ + protected String lastChecked = LAST_CHECKED_DEFAULT_; + + /** + * The default value of the '{@link #getFeedAddress() <em>Feed Address</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getFeedAddress() + * @generated + * @ordered + */ + protected static final String FEED_ADDRESS_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getFeedAddress() <em>Feed Address</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getFeedAddress() + * @generated + * @ordered + */ + protected String feedAddress = FEED_ADDRESS_DEFAULT_; + + /** + * The default value of the '{@link #getPopServer() <em>Pop Server</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getPopServer() + * @generated + * @ordered + */ + protected static final String POP_SERVER_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getPopServer() <em>Pop Server</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getPopServer() + * @generated + * @ordered + */ + protected String popServer = POP_SERVER_DEFAULT_; + + /** + * The default value of the '{@link #getPopUsername() <em>Pop Username</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getPopUsername() + * @generated + * @ordered + */ + protected static final String POP_USERNAME_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getPopUsername() <em>Pop Username</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getPopUsername() + * @generated + * @ordered + */ + protected String popUsername = POP_USERNAME_DEFAULT_; + + /** + * The default value of the '{@link #getPopPassword() <em>Pop Password</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getPopPassword() + * @generated + * @ordered + */ + protected static final String POP_PASSWORD_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getPopPassword() <em>Pop Password</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getPopPassword() + * @generated + * @ordered + */ + protected String popPassword = POP_PASSWORD_DEFAULT_; + + /** + * The cached value of the '{@link #getAny() <em>Any</em>}' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAny() + * @generated + * @ordered + */ + + protected Sequence any = null; + + /** + * The default value of the '{@link #getId() <em>Id</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getId() + * @generated + * @ordered + */ + protected static final String ID_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getId() <em>Id</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getId() + * @generated + * @ordered + */ + protected String id = ID_DEFAULT_; + + /** + * The default value of the '{@link #getFeedType() <em>Feed Type</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getFeedType() + * @generated + * @ordered + */ + protected static final String FEED_TYPE_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getFeedType() <em>Feed Type</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getFeedType() + * @generated + * @ordered + */ + protected String feedType = FEED_TYPE_DEFAULT_; + + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public SourceTypeNonSDOImpl() + { + super(); + } + + + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getName() + { + return name; + } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setName(String newName) + { + name = newName; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getAddress() + { + return address; + } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setAddress(String newAddress) + { + address = newAddress; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getLastChecked() + { + return lastChecked; + } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setLastChecked(String newLastChecked) + { + lastChecked = newLastChecked; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getFeedAddress() + { + return feedAddress; + } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setFeedAddress(String newFeedAddress) + { + feedAddress = newFeedAddress; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getPopServer() + { + return popServer; + } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setPopServer(String newPopServer) + { + popServer = newPopServer; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getPopUsername() + { + return popUsername; + } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setPopUsername(String newPopUsername) + { + popUsername = newPopUsername; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getPopPassword() + { + return popPassword; + } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setPopPassword(String newPopPassword) + { + popPassword = newPopPassword; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getId() + { + return id; + } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setId(String newId) + { + id = newId; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getFeedType() + { + return feedType; + } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setFeedType(String newType) + { + feedType = newType; + } + + public Sequence getAny(){ + return null; + } + +} //SourceTypeImpl diff --git a/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/resources/Alerts.wsdl b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/resources/Alerts.wsdl new file mode 100644 index 0000000000..79b025bc73 --- /dev/null +++ b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/resources/Alerts.wsdl @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<wsdl:definitions targetNamespace="http://tuscany.apache.org/sca/demos/aggregator/service" + xmlns:tns="http://tuscany.apache.org/sca/demos/aggregator/service" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + name="Alerter"> + + <wsdl:types> + <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://tuscany.apache.org/sca/demos/aggregator/service" + xmlns:alerter="http://tuscany.apache.org/sca/demos/aggregator/types" + elementFormDefault="qualified"> + + <xsd:import namespace="http://tuscany.apache.org/sca/demos/aggregator/types" + schemaLocation="Alerts.xsd" /> + + <element name="getAllNewAlerts"> + <xsd:complexType> + <sequence> + <element name="parm" type="string" /> + </sequence> + </xsd:complexType> + </element> + + <element name="getAllNewAlertsResponse"> + <complexType> + <sequence> + <element name="parm" type="alerter:AlertsType" /> + </sequence> + </complexType> + </element> + + </xsd:schema> + </wsdl:types> + + <wsdl:message name="GetAllNewAlertsRequest"> + <wsdl:part element="tns:getAllNewAlerts" name="parameters" /> + </wsdl:message> + <wsdl:message name="GetAllNewAlertsResponse"> + <wsdl:part element="tns:getAllNewAlertsResponse" name="parameters" /> + </wsdl:message> + + <wsdl:portType name="AlertsPortType"> + <wsdl:operation name="getAllNewAlerts"> + <wsdl:input message="tns:GetAllNewAlertsRequest" name="GetAllNewAlertsRequestMsg" /> + <wsdl:output message="tns:GetAllNewAlertsResponse" name="GetAllNewAlertsResponseMsg" /> + </wsdl:operation> + </wsdl:portType> + + <wsdl:binding name="AlertsBinding" type="tns:AlertsPortType"> + <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> + <wsdl:operation name="getAllNewAlerts"> + <wsdlsoap:operation soapAction="" /> + <wsdl:input name="GetAllNewAlertsRequestMsg"> + <wsdlsoap:body use="literal" /> + </wsdl:input> + <wsdl:output name="GetAllNewAlertsResponseMsg"> + <wsdlsoap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + + <wsdl:service name="AlertsService"> + <wsdl:port name="AlertsPort" binding="tns:AlertsBinding"> + <wsdlsoap:address location="http://localhost:8080/services/AlertsServiceWebServiceBinding" /> + </wsdl:port> + </wsdl:service> + +</wsdl:definitions> diff --git a/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/resources/Alerts.xsd b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/resources/Alerts.xsd new file mode 100644 index 0000000000..f0ec561ad8 --- /dev/null +++ b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/resources/Alerts.xsd @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<schema targetNamespace="http://tuscany.apache.org/sca/demos/aggregator/types" + xmlns="http://www.w3.org/2001/XMLSchema" + xmlns:ns="http://tuscany.apache.org/sca/demos/aggregator/types"> + <element name="Alerts" type="ns:AlertsType"/> + + <complexType name="AlertType"> + <sequence> + <element name="Title" type="string"/> + <element name="Summary" type="string"/> + <element name="Address" type="anyURI" maxOccurs="1" minOccurs="1"/> + <element name="Date" type="string" maxOccurs="1" minOccurs="1"/> + </sequence> + <attribute name="SourceId" type="string" use="optional"/> + <attribute name="Unread" type="boolean" use="optional"/> + <attribute name="Id" type="string" use="optional"/> + </complexType> + + <complexType name="AlertsType"> + <sequence> + <element name="Alert" type="ns:AlertType" maxOccurs="unbounded" minOccurs="0" /> + </sequence> + </complexType> + + <complexType name="SourceType"> + <sequence> + <element name="Name" type="string" maxOccurs="1" minOccurs="1"/> + <element name="Address" type="anyURI" maxOccurs="1" minOccurs="1"/> + <element name="LastChecked" type="string" maxOccurs="1" minOccurs="0"/> + <element name="FeedAddress" type="string" maxOccurs="1" minOccurs="0"/> + <element name="PopServer" type="string" maxOccurs="1" minOccurs="0"/> + <element name="PopUsername" type="string" maxOccurs="1" minOccurs="0"/> + <element name="PopPassword" type="string" maxOccurs="1" minOccurs="0"/> + <any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="Id" type="string" use="optional"/> + <attribute name="FeedType" use="required"> + <simpleType> + <restriction base="string"> + <enumeration value="rss"/> + <enumeration value="pop"/> + <enumeration value="nntp"/> + </restriction> + </simpleType> + </attribute> + </complexType> + + <complexType name="ConfigType"> + <sequence> + <element name="Source" type="ns:SourceType" maxOccurs="unbounded" minOccurs="0"/> + </sequence> + </complexType> + + <complexType name="SingleSourceType"> + <sequence> + <element name="Source" type="ns:SourceType"/> + </sequence> + </complexType> + + <element name="Config" type="ns:ConfigType"/> + <element name="Source" type="ns:SourceType"/> +</schema>
\ No newline at end of file diff --git a/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/resources/AlertsSources.wsdl b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/resources/AlertsSources.wsdl new file mode 100644 index 0000000000..987481bd14 --- /dev/null +++ b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/resources/AlertsSources.wsdl @@ -0,0 +1,124 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<wsdl:definitions targetNamespace="http://tuscany.apache.org/sca/demos/aggregator/sources" + xmlns:tns="http://tuscany.apache.org/sca/demos/aggregator/sources" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + name="Alerter"> + + <wsdl:types> + <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://tuscany.apache.org/sca/demos/aggregator/sources" + xmlns:alerter="http://tuscany.apache.org/sca/demos/aggregator/types" + elementFormDefault="qualified"> + + <xsd:import namespace="http://tuscany.apache.org/sca/demos/aggregator/types" + schemaLocation="Alerts.xsd" /> + + <element name="getAlertSources"> + <xsd:complexType> + <sequence> + <element name="parm" type="string" /> + </sequence> + </xsd:complexType> + </element> + + <element name="getAlertSourcesResponse"> + <complexType> + <sequence> + <element name="parm" type="alerter:ConfigType" /> + </sequence> + </complexType> + </element> + + <element name="addAlertSource"> + <xsd:complexType> + <sequence> + <element name="parm" type="alerter:SourceType"/> + </sequence> + </xsd:complexType> + </element> + + <element name="addAlertSourceResponse"> + <complexType> + <sequence> + <element name="parm" type="string" /> + </sequence> + </complexType> + </element> + + </xsd:schema> + </wsdl:types> + + <wsdl:message name="GetAlertSourcesRequest"> + <wsdl:part element="tns:getAlertSources" name="parameters" /> + </wsdl:message> + <wsdl:message name="GetAlertSourcesResponse"> + <wsdl:part element="tns:getAlertSourcesResponse" name="parameters" /> + </wsdl:message> + + <wsdl:message name="AddAlertSourceRequest"> + <wsdl:part element="tns:addAlertSource" name="parameters" /> + </wsdl:message> + <wsdl:message name="AddAlertSourceResponse"> + <wsdl:part element="tns:addAlertSourceResponse" name="parameters" /> + </wsdl:message> + + <wsdl:portType name="AlertsSourcesPortType"> + <wsdl:operation name="getAlertSources"> + <wsdl:input message="tns:GetAlertSourcesRequest" name="GetAlertSourcesRequestMsg" /> + <wsdl:output message="tns:GetAlertSourcesResponse" name="GetAlertSourcesResponseMsg" /> + </wsdl:operation> + <wsdl:operation name="addAlertSource"> + <wsdl:input message="tns:AddAlertSourceRequest" name="AddAlertSourceRequestMsg" /> + <wsdl:output message="tns:AddAlertSourceResponse" name="AddAlertSourceResponseMsg" /> + </wsdl:operation> + </wsdl:portType> + + <wsdl:binding name="AlertsSourcesBinding" type="tns:AlertsSourcesPortType"> + <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> + <wsdl:operation name="getAlertSources"> + <wsdlsoap:operation soapAction="" /> + <wsdl:input name="GetAlertSourcesRequestMsg"> + <wsdlsoap:body use="literal" /> + </wsdl:input> + <wsdl:output name="GetAlertSourcesResponseMsg"> + <wsdlsoap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="addAlertSource"> + <wsdlsoap:operation soapAction="" /> + <wsdl:input name="AddAlertSourceRequestMsg"> + <wsdlsoap:body use="literal" /> + </wsdl:input> + <wsdl:output name="AddAlertSourceResponseMsg"> + <wsdlsoap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + + <wsdl:service name="AlertsSourcesService"> + <wsdl:port name="AlertsSourcesPort" binding="tns:AlertsSourcesBinding"> + <wsdlsoap:address location="http://localhost:8080/services/AlertsSourcesServiceWebServiceBinding" /> + </wsdl:port> + </wsdl:service> + +</wsdl:definitions> diff --git a/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/resources/alerts-client.composite b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/resources/alerts-client.composite new file mode 100644 index 0000000000..49f44f9da8 --- /dev/null +++ b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/resources/alerts-client.composite @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ xmlns:dbsdo="http://tuscany.apache.org/xmlns/sca/databinding/sdo/1.0" targetNamespace="http://sample"
+ name="FeedAggregatorClient">
+
+ <!-- SDO factory classes -->
+ <!-- dbsdo:import.sdo factory="org.apache.tuscany.sca.demos.aggregator.service.ServiceFactory"/ -->
+ <!-- dbsdo:import.sdo factory="org.apache.tuscany.sca.demos.aggregator.types.TypesFactory"/ -->
+
+ <component name="AlertsFeedServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.demos.aggregator.AlertsFeedServiceImpl" />
+ <reference name="alerts" target="AlertsServiceComponent" />
+ </component>
+
+ <component name="AlertsServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.demos.aggregator.AlertsServiceImpl" />
+ <reference name="rssChecker" target="RSSCheckerComponent" />
+ <reference name="alertsSources" target="AlertsSourcesServiceComponent" />
+ </component>
+
+ <component name="AlertsSourcesServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.demos.aggregator.AlertsSourcesServiceImpl" />
+ </component>
+
+ <!-- The RSS reader -->
+ <component name="RSSCheckerComponent">
+ <implementation.java class="org.apache.tuscany.sca.demos.aggregator.RSSCheckerServiceImpl" />
+ </component>
+
+</composite>
diff --git a/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/resources/alerts.composite b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/resources/alerts.composite new file mode 100644 index 0000000000..c359b275be --- /dev/null +++ b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/resources/alerts.composite @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ xmlns:dbsdo="http://tuscany.apache.org/xmlns/sca/databinding/sdo/1.0"
+ targetNamespace="http://sample"
+ name="FeedAggregator">
+
+ <!-- SDO factory classes -->
+ <!-- dbsdo:import.sdo factory="org.apache.tuscany.sca.demos.aggregator.service.ServiceFactory"/ -->
+ <!-- dbsdo:import.sdo factory="org.apache.tuscany.sca.demos.aggregator.types.TypesFactory"/ -->
+
+ <!-- The alerts rss service -->
+ <service name="AlertsFeedServiceRSS" promote="AlertsFeedServiceComponent/Collection">
+ <tuscany:binding.rss />
+ </service>
+
+ <!-- The alerts atom service -->
+ <service name="AlertsFeedServiceAtom" promote="AlertsFeedServiceComponent/Collection">
+ <tuscany:binding.atom />
+ </service>
+
+ <component name="AlertsFeedServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.demos.aggregator.AlertsFeedServiceImpl" />
+ <reference name="alerts" target="AlertsServiceComponent"/>
+ </component>
+
+ <!-- The alerts web service -->
+ <service name="AlertsService" promote="AlertsServiceComponent">
+ <interface.wsdl interface="http://tuscany.apache.org/sca/demos/aggregator/service#wsdl.interface(AlertsPortType)"/>
+ <binding.ws wsdlElement="http://tuscany.apache.org/sca/demos/aggregator/service#wsdl.port(AlertsService/AlertsPort)"/>
+ </service>
+
+ <!-- The alerts jsonrpc service -->
+ <service name="AlertsServiceJSONRPC" promote="AlertsServiceComponent/AlertsService">
+ <interface.java interface="org.apache.tuscany.sca.demos.aggregator.AlertsService" />
+ <tuscany:binding.jsonrpc />
+ </service>
+
+ <component name="AlertsServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.demos.aggregator.AlertsServiceImpl" />
+ <reference name="rssChecker" target="RSSCheckerComponent"/>
+ <reference name="alertsSources" target="AlertsSourcesServiceComponent"/>
+ </component>
+
+ <!-- The alerts sources web service -->
+ <service name="AlertsSourcesService" promote="AlertsSourcesServiceComponent">
+ <interface.wsdl interface="http://tuscany.apache.org/sca/demos/aggregator/sources#wsdl.interface(AlertsSourcesPortType)"/>
+ <binding.ws wsdlElement="http://tuscany.apache.org/sca/demos/aggregator/sources#wsdl.port(AlertsSourcesService/AlertsSourcesPort)"/>
+ </service>
+
+ <!-- The alerts jsonrpc service -->
+ <service name="AlertsSourcesServiceJSONRPC" promote="AlertsSourcesServiceComponent/AlertsSourcesService">
+ <interface.java interface="org.apache.tuscany.sca.demos.aggregator.AlertsSourcesService" />
+ <tuscany:binding.jsonrpc />
+ </service>
+
+ <component name="AlertsSourcesServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.demos.aggregator.AlertsSourcesServiceImpl" />
+ </component>
+
+ <!-- The RSS reader -->
+ <component name="RSSCheckerComponent">
+ <implementation.java class="org.apache.tuscany.sca.demos.aggregator.RSSCheckerServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/resources/sources.xml b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/resources/sources.xml new file mode 100644 index 0000000000..2168c10c9c --- /dev/null +++ b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/resources/sources.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<ns0:Config xmlns:ns0="http://tuscany.apache.org/sca/demos/aggregator/types"> +<ns0:Source Id="0" FeedType="rss"> + <ns0:Name>BBC News</ns0:Name> + <ns0:Address>http://news.bbc.co.uk/</ns0:Address> + <ns0:LastChecked>10-Jun-2007 16:34:03</ns0:LastChecked> + <ns0:FeedAddress>http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml</ns0:FeedAddress> +</ns0:Source> +<ns0:Source Id="1" FeedType="rss"> + <ns0:Name>Engadget</ns0:Name> + <ns0:Address>http://www.engadget.com</ns0:Address> + <ns0:LastChecked>10-Jun-2007 16:34:03</ns0:LastChecked> + <ns0:FeedAddress>http://www.engadget.com/rss.xml</ns0:FeedAddress> +</ns0:Source> +</ns0:Config> diff --git a/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/AlertAggregator.html b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/AlertAggregator.html new file mode 100644 index 0000000000..8b472fd0fa --- /dev/null +++ b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/AlertAggregator.html @@ -0,0 +1,330 @@ +<html> +<!-- + * 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. + --> +<head> +<title>Apache Tuscany Alert Aggregator Sample</TITLE> + +<script type="text/javascript"> + //var djConfig = {isDebug: true,debugContainerId: "dojoDebug" }; + //djConfig.debugAtAllCosts = true; + </script> + +<script type="text/javascript" src="dojo/dojo/dojo.js"> + </script> +<script type="text/javascript" src="dojo/dijit/dijit.js"> + </script> + +<script type="text/javascript"> + dojo.require("dijit.form.Button"); + dojo.require("dojo.rpc.JsonService"); + </script> + +<link rel="stylesheet" type="text/css" href="style.css" /> +</head> + +<body onload="getAlertSources()"> + +<script type="text/javascript"> + + // The proxy for the alert and alertsources services running in Tuscany + var alertsService = new dojo.rpc.JsonService("AlertsServiceJSONRPC?smd"); + var alertSourcesService = new dojo.rpc.JsonService("AlertsSourcesServiceJSONRPC?smd"); + + // If you want to put an HTTP sniffer in the way to look at the JSONROPC packets you'll + // need to edit the target address of the service in the smd. The only way to do this easily + // is to read an smd from disc rather than generate one. There are two smds provided for this + //var alertsService = new dojo.rpc.JsonService("service.smd"); + //var alertSourcesService = new dojo.rpc.JsonService("sources.smd"); + + // The global list of alerts sources + var alertSourceList = null; + + // The global list of alerts + var alertList = null; + + // the constructor for entries on the alert source list + function alertSourceType(name,id,address,feedAddress,feedType,popUsername,popPassword,popServer,lastChecked,javaClass) { + this.name = name; + this.id = id; + this.address = address; + this.feedAddress = feedAddress; + this.feedType = feedType; + this.lastChecked = lastChecked; + this.javaClass = "org.apache.tuscany.sca.demos.aggregator.types.impl.SourceTypeImpl"; + + } + + function errorCallback(result, error, id) { + var resultsNode = document.getElementById("errors"); + // There seems to be a problem somewhere as I should be able to get the error + // details but all I can actually get is the Id from the error message + // resultsNode.innerHTML = "there was an error! message id = " + " error code = " + result.error.code + " error message = " + result.error.msg ; + resultsNode.innerHTML = "An error was returned by the server. Message id = " + result.id; + } + + // Generate the alert sources table + function getAlertSources() + { + response = alertSourcesService.getAlertSources("Dojo"); + response.addCallbacks(getAlertSourcesCallback, errorCallback); + + getAlerts(); + } + + function getAlertSourcesCallback(result) { + var resultsNode = document.getElementById("alertSourcesTable"); + if ( result.error != null ) { + resultsNode.innerHTML = result.error; + } else { + // stash away the source list for when we come to edit it + alertSourceList = result.source.list; + + // put out the html + var text = "" + var nextSourceId = 0 + for (var i in result.source.list){ + var source = result.source.list[i]; + + text = text + "<table>"; + text = text + "<TR CLASS='source_" + source.id + "' >"; + text = text + " <TD CLASS='source_name clickable' ONCLICK=\"displayAlert('" + source.address + "')\">"; + text = text + " <IMG SRC='rss.png'/> " + source.name; + text = text + " </TD>"; + text = text + " <TD CLASS='clickable link' ONCLICK=\"showEditSource('" + source.id + "')\">Edit</TD>"; + text = text + " <TD CLASS='clickable link' ONCLICK=\"deleteSource('" + source.id + "')\">Delete</TD>"; + text = text + "</TR>"; + text = text + "<TR ID='edit_source_" + source.id + "' CLASS='hidden source_" + source.id + "'>"; + text = text + " <TD COLSPAN='3'>"; + text = text + " <TABLE CLASS='sourceDetailsTable'>"; + text = text + " <TR>"; + text = text + " <TD>Source name:</TD>"; + text = text + " <TD>"; + text = text + " <INPUT ID='source_" + source.id + "_name' TYPE='TEXT' SIZE='50' VALUE='" + source.name + "'/>"; + text = text + " </TD>"; + text = text + " </TR>"; + text = text + " <TR>"; + text = text + " <TD>Source address:</TD>" + text = text + " <TD>"; + text = text + " <INPUT ID='source_" + source.id + "_address' TYPE='TEXT' SIZE='50' VALUE='" + source.address + "'/>"; + text = text + " </TD>"; + text = text + " </TR>"; + text = text + " <TR>"; + text = text + " <TD>"; + text = text + " <INPUT ID='source_" + source.id + "_type' TYPE='HIDDEN' VALUE='" + source.id + "'/>"; + text = text + " <INPUT TYPE='BUTTON' VALUE='Update' ONCLICK=\"updateSource('" + source.id + "')\"/>"; + text = text + " <INPUT TYPE='BUTTON' VALUE='Cancel' ONCLICK=\"hideEditSource('" + source.id + "')\"/>"; + text = text + " </TD>"; + text = text + " </TR>"; + text = text + " </TABLE>"; + text = text + " </TD>"; + text = text + "</TR>"; + + nextSourceId = eval(source.id); + } + + nextSourceId = nextSourceId + 1; + + text = text + "<TR CLASS='source_" + nextSourceId + "'>"; + text = text + " <TD COLSPAN='4' CLASS='clickable link' ONCLICK=\"showAddNewSource('" + nextSourceId + "')\">Add new Alert Source</TD>"; + text = text + "</TR>"; + text = text + "<TR ID='add_source_" + nextSourceId + "' CLASS='hidden source_" + nextSourceId + "'>"; + text = text + " <TD COLSPAN='4'>"; + text = text + " <TABLE CLASS='sourceDetailsTable'>"; + text = text + " <TR>"; + text = text + " <TD>Source name:</TD>"; + text = text + " <TD>"; + text = text + " <INPUT ID='source_" + nextSourceId + "_name' TYPE='TEXT' SIZE='50'>"; + text = text + " </TD>"; + text = text + " </TR>"; + text = text + " <TR>"; + text = text + " <TD>Source address:</TD>"; + text = text + " <TD>"; + text = text + " <INPUT ID='source_" + nextSourceId + "_address' TYPE='TEXT' SIZE='50'>"; + text = text + " </TD>"; + text = text + " </TR>"; + text = text + " <TR>"; + text = text + " <TD>Source type:</TD>"; + text = text + " <TD>"; + text = text + " <SELECT ID='source_" + nextSourceId + "_type' ONCHANGE=\"showSourceType('" + nextSourceId + "')\">"; + text = text + " <OPTION value='rss' selected='selected'>RSS/Atom feed</OPTION>"; + text = text + " </SELECT>"; + text = text + " </TD>"; + text = text + " </TR>"; + text = text + " <TR ID='add_rss_source'>"; + text = text + " <TD COLSPAN='2'>"; + text = text + " <TABLE CLASS='sourceDetailsTable'>"; + text = text + " <TR>"; + text = text + " <TD>Feed address:</TD>"; + text = text + " <TD>"; + text = text + " <INPUT ID='source_" + nextSourceId + "_feedAddress' TYPE='TEXT' SIZE='50'/>"; + text = text + " </TD>"; + text = text + " </TR>"; + text = text + " </TABLE>"; + text = text + " </TD>"; + text = text + " </TR>"; + text = text + " <TR>"; + text = text + " <TD>"; + text = text + " <INPUT TYPE='BUTTON' VALUE='Add' ONCLICK=\"addSource('" + nextSourceId + "')\">"; + text = text + " <INPUT TYPE='BUTTON' VALUE='Cancel' ONCLICK=\"hideAddNewSource('" + nextSourceId + "')\">"; + text = text + " </TD>"; + text = text + " </TR>"; + text = text + " </TABLE>"; + text = text + " </TD>"; + text = text + "</TR>"; + text = text + "</table>"; + + resultsNode.innerHTML = text; + } + } + + function showEditSource(sourceid) + { + document.getElementById("edit_source_"+sourceid).className = "source_"+sourceid; + } + + function hideEditSource(sourceid) + { + document.getElementById("edit_source_"+sourceid).className = "hidden source_"+sourceid; + } + + function updateSource(sourceid) + { + hideEditSource(sourceid); + var source = getSource(sourceId); + alertSourcesService.updateAlertSource(source); + getAlertSources(); + } + + function deleteSource(sourceid) + { + alertSourcesService.removeAlertSource(sourceid); + getAlertSources(); + } + + function showAddNewSource(sourceid) + { + document.getElementById("add_source_"+sourceid).className = "source_"+sourceid; + } + + function hideAddNewSource(sourceid) + { + document.getElementById("add_source_"+sourceid).className = "hidden source_"+sourceid; + } + + function addSource(sourceid) + { + hideAddNewSource(sourceid); + var source = getSource(sourceid); + alertSourcesService.addAlertSource(source); + + // wait a little before getting the list back from the server + setTimeout("getAlertSources()",1250); + } + + function getSource(sourceid) + { + var source = alertSourceList[sourceid]; + + if ( source == null ){ + source = new alertSourceType("name","id","address","feedAddress","feedType","popUsername","popPassword","popServer","lastChecked","javaClass"); + alertSourceList[sourceid] = source; + } + + source.name = document.getElementById("source_"+sourceid+"_name").value; + source.id = sourceid; + source.address = document.getElementById("source_"+sourceid+"_address").value; + var typeElem = document.getElementById("source_"+sourceid+"_type"); + source.feedType = typeElem.options[typeElem.selectedIndex].value; + + if(source.feedType=="rss") + { + source.feedAddress = document.getElementById("source_"+sourceid+"_feedAddress").value; + + } + else if(source.feedType=="pop") + { + source.popServer = document.getElementById("source_"+sourceid+"_popServer").value; + source.popUsername = document.getElementById("source_"+sourceid+"_popUsername").value; + source.popPassword = document.getElementById("source_"+sourceid+"_popPassword").value; + } + return source; + } + + // Generate the alerts table + function getAlerts() + { + response = alertsService.getAllNewAlerts("Dojo"); + response.addCallbacks(getAlertsCallback, errorCallback); + } + + function getAlertsCallback(result) { + var resultsNode = document.getElementById("alertsTable"); + if ( result.error != null ) { + resultsNode.innerHTML = result.error; + } else { + alertList = result.alert.list; + var text = "" + for (var i in result.alert.list){ + var alert = result.alert.list[i]; + + text = text + "<table>"; + text = text + "<TR class='source_" + alert.sourceId + " clickable' onclick=\"displayAlert('" + alert.address + "')\">"; + text = text + " <TD class='alert_text'>"; + text = text + " <SPAN id='" + alert.id + "' class='unread_title'>" + alert.title + "</SPAN>"; + text = text + " <SPAN class='summary'> - " + alert.summary.substring(0, 80) + "...</SPAN>"; + text = text + " </TD>"; + text = text + " <TD>"; + text = text + alert.date; + text = text + " </TD>" + text = text + "</TR>" + text = text + "</table>"; + } + + resultsNode.innerHTML = text; + } + } + + + + function displayAlert(url) + { + document.getElementById("alertData").innerHTML="<IFRAME CLASS='alert_data' SRC='"+url+"'/>"; + window.location="#data"; + return; + } + + + + </script> + +<h1 id="top">Apache Tuscany Alert Aggregator Demo</h1> +<div id="errors"></div> +<p>Alert Sources<span id="refreshSources"></span>:</p> +<!--input type="button" value="getSources" onclick="getAlertSources()"/--> +<div id="alertSourcesTable">Refreshing...</div> +<p /><input type="button" value="Refresh" onclick="getAlerts()" /> +<p /> +<div id="alertsTable">Refreshing...</div> +<p><a id="data" HREF="#top">Back to top</a></p> +<div id="alertData"></div> +<p /> +<div id="dojoDebug"></div> + +</body> +</html> diff --git a/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..0bc67c4c98 --- /dev/null +++ b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +* 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. +--> + +<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0" +targetNamespace="http://sample" + xmlns:sample="http://sample"> + <deployable composite="sample:FeedAggregator"/> +</contribution> + diff --git a/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml new file mode 100644 index 0000000000..2588187a7a --- /dev/null +++ b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-2.0" + xmlns:d="http://geronimo.apache.org/xml/ns/deployment-1.2"> + <d:environment> + <d:moduleId> + <d:groupId>org.apache.tuscany.sca</d:groupId> + <d:artifactId>demo-alert-aggregator-webapp</d:artifactId> + <d:version>1.2-incubating-SNAPSHOT</d:version> + <d:type>war</d:type> + </d:moduleId> + <!-- TUSCANY-1986 --> + <d:inverse-classloading /> + </d:environment> +</web-app> diff --git a/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/web.xml b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..a81165e1b4 --- /dev/null +++ b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + * 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. +--> + +<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web +Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> +<web-app> + + <display-name>Apache Tuscany Alert Aggregator Demo</display-name> + + <filter> + <filter-name>tuscany</filter-name> + <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class> + </filter> + + <filter-mapping> + <filter-name>tuscany</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + + <welcome-file-list id="WelcomeFileList"> + <welcome-file>AlertAggregator.html</welcome-file> + </welcome-file-list> + +</web-app> diff --git a/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/pop.png b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/pop.png Binary files differnew file mode 100644 index 0000000000..1cf1df24a7 --- /dev/null +++ b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/pop.png diff --git a/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/rss.png b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/rss.png Binary files differnew file mode 100644 index 0000000000..b3c949d224 --- /dev/null +++ b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/rss.png diff --git a/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/service.smd b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/service.smd new file mode 100644 index 0000000000..bc77e39bf9 --- /dev/null +++ b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/service.smd @@ -0,0 +1 @@ +{"SMDVersion":".1","objectName":"AlertsService","serviceType":"JSON-RPC","serviceURL":"http://localhost:8080/sample-feed-aggregator/services/AlertsServiceJSONRPC","methods":[{"name":"getAllNewAlerts","parameters":[{"name":"param0","type":"STRING"}]}]} diff --git a/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/sources.smd b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/sources.smd new file mode 100644 index 0000000000..b5f1824363 --- /dev/null +++ b/branches/sca-java-1.2/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-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/style.css b/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/webapp/style.css new file mode 100644 index 0000000000..f5bbf23379 --- /dev/null +++ b/branches/sca-java-1.2/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; +} + |