diff options
Diffstat (limited to 'sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed')
9 files changed, 0 insertions, 625 deletions
diff --git a/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/build.xml b/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/build.xml deleted file mode 100644 index 2f0f6b12a5..0000000000 --- a/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/build.xml +++ /dev/null @@ -1,22 +0,0 @@ -<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-
-<project name="scatours-contribution-blog-feed" default="compile">
- <import file="../../antdefs.xml"/>
-</project>
diff --git a/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/pom.xml b/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/pom.xml deleted file mode 100644 index e3f37cc21d..0000000000 --- a/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ -<?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.
--->
-<project>
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>scatours</artifactId>
- <version>2.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent><version>2.0-SNAPSHOT</version>
- <artifactId>scatours-contribution-blog-feed</artifactId>
- <name>Apache Tuscany SCA Tours Blog Feed Contribution</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-node-impl</artifactId>
- <version>${tuscany.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-host-jetty</artifactId>
- <version>${tuscany.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-implementation-java-runtime</artifactId>
- <version>${tuscany.version}</version>
- <scope>runtime</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-binding-atom</artifactId>
- <version>${tuscany.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-binding-atom-runtime</artifactId>
- <version>${tuscany.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-binding-rss-runtime</artifactId>
- <version>${tuscany.version}</version>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.5</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <finalName>${artifactId}</finalName>
- </build>
-</project>
diff --git a/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/java/com/tuscanyscatours/blog/BlogPost.java b/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/java/com/tuscanyscatours/blog/BlogPost.java deleted file mode 100644 index f93fe59b9d..0000000000 --- a/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/java/com/tuscanyscatours/blog/BlogPost.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 com.tuscanyscatours.blog; - -import java.util.Date; - -/** - * Bean for blog posts. - */ -public class BlogPost { - - private final String author; - private final String title; - private final String content; - private final Date updated; - private final String link; - private final String related; - - public BlogPost(String author, String title, String content, Date updated, String link, String related) { - this.author = author; - this.title = title; - this.content = content; - this.updated = updated; - this.link = link; - this.related = related; - } - - public String getAuthor() { - return author; - } - - public String getTitle() { - return title; - } - - public String getContent() { - return content; - } - - public Date getUpdated() { - return updated; - } - - public String getLink() { - return link; - } - - public String getRelated() { - return related; - } -} diff --git a/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/java/com/tuscanyscatours/blog/feed/impl/AtomBlogFeedImpl.java b/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/java/com/tuscanyscatours/blog/feed/impl/AtomBlogFeedImpl.java deleted file mode 100644 index b7a392f927..0000000000 --- a/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/java/com/tuscanyscatours/blog/feed/impl/AtomBlogFeedImpl.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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 com.tuscanyscatours.blog.feed.impl; - -import java.util.List; - -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.NotFoundException; - -import com.tuscanyscatours.blog.BlogPost; - -/** - * An Atom feed that implements the org.apache.tuscany.sca.binding.atom.collection.Collection - * interface and uses the Atom APIs to construct the Atom feed. - */ -public class AtomBlogFeedImpl extends BaseBlogFeedImpl implements - org.apache.tuscany.sca.binding.atom.collection.Collection { - - /** - * Gets an Atom feed containing all the blog posts. - * - * @return An Atom feed containing all the blog posts. - */ - public Feed getFeed() { - // Create SCA Tours blog Atom feed - final Factory factory = Abdera.getNewFactory(); - final Feed feed = factory.newFeed(); - feed.setTitle(FEED_TITLE); - feed.setSubtitle(FEED_DESCRIPTION); - feed.addAuthor(FEED_AUTHOR); - - // Get all blog posts and convert to Atom entries - final List<BlogPost> blogEntries = getAllBlogPosts(); - for (BlogPost blogEntry : blogEntries) { - final Entry entry = factory.newEntry(); - entry.setId(nextBlogID()); - entry.addAuthor(blogEntry.getAuthor()); - entry.setTitle(blogEntry.getTitle()); - entry.setContentAsHtml(blogEntry.getContent()); - entry.setUpdated(blogEntry.getUpdated()); - entry.addLink(blogEntry.getLink()); - feed.addEntry(entry); - } - - return feed; - } - - /** - * Query the feed. - * - * @param query The query - * @return Always returns null as method not implemented - */ - public Feed query(String query) { - // Not implemented - return null; - } - - /** - * Posts a new entry to the blog. - * - * @param entry The new entry - * @return Always returns null as method not implemented - */ - public Entry post(Entry entry) { - // Not implemented - return null; - } - - /** - * Gets the specified entry from the blog. - * - * @param id ID of the entry to get - * @return Not used - * @throws NotFoundException Always thrown as method not implemented - */ - public Entry get(String id) throws NotFoundException { - // Not implemented - throw new NotFoundException("You are not allowed to update entries"); - } - - /** - * Updates the specified entry on the blog. - * - * @param id ID of the entry to update - * @param entry The new entry - * @throws NotFoundException Always thrown as method not implemented - */ - public void put(String id, Entry entry) throws NotFoundException { - // Not implemented - throw new NotFoundException("You are not allowed to update entries"); - } - - /** - * Deletes the specified entry from the blog. - * - * @param id ID of the entry to delete - * @throws NotFoundException Always thrown as method not implemented - */ - public void delete(String id) throws NotFoundException { - // Not implemented - throw new NotFoundException("You are not allowed to delete entries"); - } -} diff --git a/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/java/com/tuscanyscatours/blog/feed/impl/BaseBlogFeedImpl.java b/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/java/com/tuscanyscatours/blog/feed/impl/BaseBlogFeedImpl.java deleted file mode 100644 index f132d340ea..0000000000 --- a/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/java/com/tuscanyscatours/blog/feed/impl/BaseBlogFeedImpl.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 com.tuscanyscatours.blog.feed.impl; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; - -import com.tuscanyscatours.blog.BlogPost; - -/** - * Base class for all blog feeds that provides the common methods - * that are shared by all the blog feed implementations. - */ -public abstract class BaseBlogFeedImpl { - - /** - * Title of the blog.feed. - */ - protected static final String FEED_TITLE = "Tuscany SCA Tours Blog Feed"; - - /** - * Description of the blog feed. - */ - protected static final String FEED_DESCRIPTION = "Feed contianing the latest blog posts from Tuscany SCA Tours"; - - /** - * Author of the blog feed. - */ - protected static final String FEED_AUTHOR = "SCA Tours CEO"; - - /** - * Used to generate unique IDs for the blog entries. - */ - protected static final AtomicInteger ID_GEN = new AtomicInteger(); - - /** - * Generates the next blog entry ID. - * - * @return Next blog entry ID - */ - protected String nextBlogID() { - return Integer.toString(ID_GEN.incrementAndGet()); - } - - /** - * Retrieves a list of all blog posts. - * - * @return A list of all blog posts. - */ - public List<BlogPost> getAllBlogPosts() { - // Note: To keep things simple, we will just hard code a sample post. - // A proper implementation would load all blog posts from some resource - // such as files or a database. - List<BlogPost> blogEntries = new ArrayList<BlogPost>(); - - // Create a sample entry - final BlogPost samplePost = - new BlogPost( - FEED_AUTHOR, - "Apache Tuscany in Action book features SCA Tours", - "We are famous as SCA Tours has been featured in the Apache Tuscany in Action book published by Manning", - new Date(), "http://www.manning.com/laws/", null); - - // Add sample post to the list of posts - blogEntries.add(samplePost); - - return blogEntries; - } -} diff --git a/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/java/com/tuscanyscatours/blog/feed/impl/GenericBlogFeedImpl.java b/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/java/com/tuscanyscatours/blog/feed/impl/GenericBlogFeedImpl.java deleted file mode 100644 index c427b658a4..0000000000 --- a/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/java/com/tuscanyscatours/blog/feed/impl/GenericBlogFeedImpl.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 com.tuscanyscatours.blog.feed.impl; - -import java.util.List; - -import org.apache.tuscany.sca.data.collection.Entry; -import org.apache.tuscany.sca.data.collection.Item; - -import com.tuscanyscatours.blog.BlogPost; - -/** - * Implementation of the blog feed that uses the Tuscany Data API so - * that it is independent of any Feed APIs such as Atom and RSS. - */ -public class GenericBlogFeedImpl extends BaseBlogFeedImpl { - - /** - * Implementation of the getAll() method from the Tuscany API - * that will return all of the blog posts as generic Tuscany - * feed items. - * - * @return All blog entries - */ - public Entry<Object, Object>[] getAll() { - final List<BlogPost> posts = getAllBlogPosts(); - - final Entry<Object, Object>[] entries = new Entry[posts.size()]; - int i = 0; - for (BlogPost post : posts) { - entries[i++] = convertBlogPostToFeedItem(post); - } - - return entries; - } - - /** - * Converts a blog post to a Tuscany API feed item. - * - * @param post The blog post to convert - * @return The blog post as a Tuscany API feed item - */ - private Entry<Object, Object> convertBlogPostToFeedItem(BlogPost post) { - // Convert Blog entry into an Item - final Item item = - new Item(post.getTitle(), post.getContent(), post.getLink(), post.getRelated(), post.getUpdated()); - - // Add item to entry - final Entry<Object, Object> entry = new Entry<Object, Object>(nextBlogID(), item); - - return entry; - } -} diff --git a/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/java/com/tuscanyscatours/blog/feed/impl/RSSBlogFeedImpl.java b/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/java/com/tuscanyscatours/blog/feed/impl/RSSBlogFeedImpl.java deleted file mode 100644 index efccffef67..0000000000 --- a/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/java/com/tuscanyscatours/blog/feed/impl/RSSBlogFeedImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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 com.tuscanyscatours.blog.feed.impl; - -import java.util.List; - -import org.apache.tuscany.sca.binding.rss.collection.NotFoundException; - -import com.sun.syndication.feed.synd.SyndContent; -import com.sun.syndication.feed.synd.SyndContentImpl; -import com.sun.syndication.feed.synd.SyndEntry; -import com.sun.syndication.feed.synd.SyndEntryImpl; -import com.sun.syndication.feed.synd.SyndFeed; -import com.sun.syndication.feed.synd.SyndFeedImpl; -import com.tuscanyscatours.blog.BlogPost; - -/** - * An RSS feed that implements the org.apache.tuscany.sca.binding.rss.collection.Collection - * interface and uses the RSS APIs to construct the RSS feed. - */ -public class RSSBlogFeedImpl extends BaseBlogFeedImpl implements - org.apache.tuscany.sca.binding.rss.collection.Collection { - - /** - * Gets an RSS feed containing all the blog posts. - * - * @return An RSS feed containing all the blog posts. - */ - public SyndFeed getFeed() { - // Create SCA Tours blog RSS feed - SyndFeed feed = new SyndFeedImpl(); - feed.setTitle(FEED_TITLE); - feed.setDescription(FEED_DESCRIPTION); - feed.setAuthor(FEED_AUTHOR); - - // Get all blog posts and convert to RSS entries - final List<BlogPost> blogEntries = getAllBlogPosts(); - for (BlogPost blogEntry : blogEntries) { - SyndEntry entry = new SyndEntryImpl(); - entry.setUri(nextBlogID()); - entry.setAuthor(blogEntry.getAuthor()); - entry.setTitle(blogEntry.getTitle()); - - SyndContent content = new SyndContentImpl(); - content.setType("text"); - content.setValue(blogEntry.getContent()); - - entry.setPublishedDate(blogEntry.getUpdated()); - entry.setLink(blogEntry.getLink()); - - feed.getEntries().add(entry); - } - - return feed; - } - - /** - * Query the feed. - * - * @param query The query - * @return Always returns null as method not implemented - */ - public SyndFeed query(String query) { - // Not implemented - return null; - } - - public SyndEntry get(String id) throws NotFoundException { - // Not implemented - return null; - } - - public List<SyndEntry> getAll() throws NotFoundException { - // Not implemented - return null; - } -} diff --git a/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/resources/META-INF/sca-contribution.xml deleted file mode 100644 index 1259a688e3..0000000000 --- a/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/resources/META-INF/sca-contribution.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?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://docs.oasis-open.org/ns/opencsa/sca/200912">
-</contribution>
\ No newline at end of file diff --git a/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/resources/blog-feed.composite b/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/resources/blog-feed.composite deleted file mode 100644 index 8fb948dddc..0000000000 --- a/sca-java-2.x/trunk/tutorials/travelsample/contributions/blog-feed/src/main/resources/blog-feed.composite +++ /dev/null @@ -1,58 +0,0 @@ -<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
- xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
- targetNamespace="http://tuscanyscatours.com/"
- name="blogFeed">
-
- <!-- Example that shows using the Tuscany Data APIs to create a feed that -->
- <!-- is independent of the Feed API -->
- <service name="BlogAtom" promote="BlogFeed">
- <tuscany:binding.atom uri="http://localhost:8090/BlogAtom"/>
- </service>
-
- <service name="BlogRSS" promote="BlogFeed">
- <tuscany:binding.rss uri="http://localhost:8090/BlogRSS"/>
- </service>
-
- <component name="BlogFeed">
- <implementation.java class="com.tuscanyscatours.blog.feed.impl.GenericBlogFeedImpl"/>
- </component>
-
- <!-- Example that shows using the Atom Collections API to create a feed that -->
- <!-- uses the Atom APIs -->
- <service name="BlogAtomAPIs" promote="BlogAtom">
- <tuscany:binding.atom uri="http://localhost:8090/BlogAtomAPIs"/>
- </service>
-
- <component name="BlogAtom">
- <implementation.java class="com.tuscanyscatours.blog.feed.impl.AtomBlogFeedImpl"/>
- </component>
-
- <!-- Example that shows using the RSS Collections API to create a feed that -->
- <!-- uses the RSS APIs -->
- <service name="BlogRSSAPIs" promote="BlogRSS">
- <tuscany:binding.rss uri="http://localhost:8090/BlogRSSAPIs"/>
- </service>
-
- <component name="BlogRSS">
- <implementation.java class="com.tuscanyscatours.blog.feed.impl.RSSBlogFeedImpl"/>
- </component>
-</composite>
|