summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 23:14:18 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 23:14:18 +0000
commitfdd5b43d3c139cf2cbd1655d2efbfaf9032a5b5e (patch)
treebcd16e19fa4bbd45f956812be8b65f7a143b573f /branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org
parent3caf8614f25d6b1962e20331fdf423c863bc02f3 (diff)
Moving 1.x branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835145 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org')
-rw-r--r--branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/Collection.java58
-rw-r--r--branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/MediaCollection.java55
-rw-r--r--branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/NotFoundException.java45
-rw-r--r--branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingInvoker.java76
-rw-r--r--branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingListenerServlet.java397
-rw-r--r--branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingProviderFactory.java71
-rw-r--r--branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSReferenceBindingProvider.java65
-rw-r--r--branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSServiceBindingProvider.java85
8 files changed, 0 insertions, 852 deletions
diff --git a/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/Collection.java b/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/Collection.java
deleted file mode 100644
index ed86dc4848..0000000000
--- a/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/Collection.java
+++ /dev/null
@@ -1,58 +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 org.apache.tuscany.sca.binding.rss.collection;
-
-import org.osoa.sca.annotations.Remotable;
-
-import com.sun.syndication.feed.synd.SyndEntry;
-import com.sun.syndication.feed.synd.SyndFeed;
-
-
-/**
- * Provides access to a collection of resources using RSS.
- *
- * @version $Rev$ $Date$
- */
-@Remotable
-public interface Collection {
-
- /**
- * Get an RSS feed for a collection of resources.
- *
- * @return the RSS feed
- */
- SyndFeed getFeed();
-
- /**
- * Get an RSS feed for a collection of resources resulting from a query.
- *
- * @param queryString the query string
- * @return the RSS feed
- */
- SyndFeed query(String queryString);
-
- /**
- * Retrieves an RSS entry.
- *
- * @param id The entry ID
- * @return The requested entry
- * @throws NotFoundException No entry found with the given ID
- */
- SyndEntry get(String id) throws NotFoundException;
-}
diff --git a/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/MediaCollection.java b/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/MediaCollection.java
deleted file mode 100644
index 2213b50b53..0000000000
--- a/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/MediaCollection.java
+++ /dev/null
@@ -1,55 +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 org.apache.tuscany.sca.binding.rss.collection;
-
-import java.io.InputStream;
-
-import org.osoa.sca.annotations.Remotable;
-
-import com.sun.syndication.feed.atom.Entry;
-
-/**
- * Provides access to a collection of resources using Atom.
- *
- * @version $Rev$ $Date$
- */
-@Remotable
-public interface MediaCollection extends Collection {
-
- /**
- * Creates a new media entry
- *
- * @param title
- * @param slug
- * @param contentType
- * @param media
- */
- Entry postMedia(String title, String slug, String contentType, InputStream media);
-
- /**
- * Update a media entry.
- *
- * @param id
- * @param contentType
- * @param media
- * @return
- */
- void putMedia(String id, String contentType, InputStream media) throws NotFoundException;
-
-}
diff --git a/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/NotFoundException.java b/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/NotFoundException.java
deleted file mode 100644
index 0912878938..0000000000
--- a/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/collection/NotFoundException.java
+++ /dev/null
@@ -1,45 +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 org.apache.tuscany.sca.binding.rss.collection;
-
-/**
- * Indicates that a resource could not be found.
- *
- * @version $Rev$ $Date$
- */
-public class NotFoundException extends Exception {
- private static final long serialVersionUID = -5046027674128627383L;
-
- public NotFoundException() {
- }
-
- public NotFoundException(String message) {
- super(message);
- }
-
- public NotFoundException(Throwable cause) {
- super(cause);
- }
-
- public NotFoundException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
diff --git a/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingInvoker.java b/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingInvoker.java
deleted file mode 100644
index e3a177198c..0000000000
--- a/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingInvoker.java
+++ /dev/null
@@ -1,76 +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 org.apache.tuscany.sca.binding.rss.provider;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.logging.Logger;
-
-import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.invocation.Message;
-
-import com.sun.syndication.feed.synd.SyndFeed;
-import com.sun.syndication.io.FeedException;
-import com.sun.syndication.io.SyndFeedInput;
-import com.sun.syndication.io.XmlReader;
-
-/**
- * Invoker for the RSS binding.
- *
- * @version $Rev$ $Date$
- */
-class RSSBindingInvoker implements Invoker , DataExchangeSemantics {
- private static final Logger logger = Logger.getLogger(RSSBindingInvoker.class.getName());
-
- private String uri;
-
- RSSBindingInvoker(String uri, String feedType) {
- this.uri = uri;
- }
-
- public Message invoke(Message msg) {
- try {
- logger.fine("invoke " + uri);
-
- // Read an RSS feed into a Synd feed
- SyndFeedInput input = new SyndFeedInput();
- SyndFeed feed = input.build(new XmlReader(new URL(uri)));
-
- //FIXME Support conversion to data-api entries
-
- msg.setBody(feed);
-
- } catch (MalformedURLException e) {
- msg.setFaultBody(e);
- } catch (IllegalArgumentException e) {
- msg.setFaultBody(e);
- } catch (FeedException e) {
- msg.setFaultBody(e);
- } catch (IOException e) {
- msg.setFaultBody(e);
- }
- return msg;
- }
-
- public boolean allowsPassByReference() {
- return true;
- }
-}
diff --git a/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingListenerServlet.java b/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingListenerServlet.java
deleted file mode 100644
index 96493a5150..0000000000
--- a/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingListenerServlet.java
+++ /dev/null
@@ -1,397 +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 org.apache.tuscany.sca.binding.rss.provider;
-
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.logging.Logger;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.xml.namespace.QName;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.tuscany.sca.data.collection.Item;
-import org.apache.tuscany.sca.databinding.Mediator;
-import org.apache.tuscany.sca.interfacedef.DataType;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
-import org.apache.tuscany.sca.interfacedef.util.XMLType;
-import org.apache.tuscany.sca.invocation.InvocationChain;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.runtime.RuntimeWire;
-
-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.sun.syndication.feed.synd.SyndLink;
-import com.sun.syndication.feed.synd.SyndLinkImpl;
-import com.sun.syndication.io.FeedException;
-import com.sun.syndication.io.SyndFeedOutput;
-
-/**
- * An RSS binding listener, implemented as a Servlet and
- * registered in a Servlet host provided by the SCA hosting runtime.
- *
- * @version $Rev$ $Date$
- */
-class RSSBindingListenerServlet extends HttpServlet {
- private static final Logger logger = Logger.getLogger(RSSBindingListenerServlet.class.getName());
- private static final long serialVersionUID = 1L;
-
- private RuntimeWire wire;
- private Invoker getFeedInvoker;
- private Invoker getAllInvoker;
- private Invoker queryInvoker;
- private MessageFactory messageFactory;
- private Mediator mediator;
- private DataType<?> itemClassType;
- private DataType<?> itemXMLType;
- private boolean supportsFeedEntries;
-
- /**
- * Constructs a new binding listener.
- *
- * @param wire
- * @param messageFactory
- */
- RSSBindingListenerServlet(RuntimeWire wire, MessageFactory messageFactory, Mediator mediator) {
- this.wire = wire;
- this.messageFactory = messageFactory;
- this.mediator = mediator;
-
- // Get the invokers for the supported operations
- Operation getOperation = null;
- for (InvocationChain invocationChain : this.wire.getInvocationChains()) {
- invocationChain.setAllowsPassByReference(true);
- Operation operation = invocationChain.getTargetOperation();
- String operationName = operation.getName();
- if (operationName.equals("getFeed")) {
- getFeedInvoker = invocationChain.getHeadInvoker();
- } else if (operationName.equals("getAll")) {
- getAllInvoker = invocationChain.getHeadInvoker();
- } else if (operationName.equals("query")) {
- queryInvoker = invocationChain.getHeadInvoker();
- } else if (operationName.equals("get")) {
- getOperation = operation;
- }
- }
-
- // Determine the collection item type
- if (getOperation != null) {
- itemXMLType = new DataTypeImpl<Class<?>>(String.class.getName(), String.class, String.class);
- Class<?> itemClass = getOperation.getOutputType().getPhysical();
- if (itemClass == SyndEntry.class) {
- supportsFeedEntries = true;
- }
- DataType<XMLType> outputType = getOperation.getOutputType();
- QName qname = outputType.getLogical().getElementName();
- qname = new QName(qname.getNamespaceURI(), itemClass.getSimpleName());
- itemClassType = new DataTypeImpl<XMLType>("java:complexType", itemClass, new XMLType(qname, null));
- }
- }
-
- @Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-
- // No authentication required for a get request
-
- // Get the request path
- String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
-
- logger.fine("get " + request.getRequestURI());
-
- // Handle an RSS request
- if (path == null || path.length() == 0 || path.equals("/")) {
-
- // Return an RSS feed containing the entries in the collection
- SyndFeed feed = null;
- if (supportsFeedEntries) {
-
- // The service implementation supports feed entries, invoke its getFeed operation
- Message requestMessage = messageFactory.createMessage();
- Message responseMessage = getFeedInvoker.invoke(requestMessage);
- if (responseMessage.isFault()) {
- throw new ServletException((Throwable)responseMessage.getBody());
- }
- feed = (SyndFeed)responseMessage.getBody();
-
- } else {
-
- // The service implementation does not support feed entries, invoke its
- // getAll operation to get the data item collection. then create feed entries
- // from the data items
- Message requestMessage = messageFactory.createMessage();
- Message responseMessage;
- if (request.getQueryString() != null) {
- requestMessage.setBody(new Object[] {request.getQueryString()});
- responseMessage = queryInvoker.invoke(requestMessage);
- } else {
- responseMessage = getAllInvoker.invoke(requestMessage);
- }
- if (responseMessage.isFault()) {
- throw new ServletException((Throwable)responseMessage.getBody());
- }
- org.apache.tuscany.sca.data.collection.Entry<Object, Object>[] collection =
- (org.apache.tuscany.sca.data.collection.Entry<Object, Object>[])responseMessage.getBody();
- if (collection != null) {
- // Create the feed
- feed = new SyndFeedImpl();
- feed.setTitle("Feed");
- feed.setDescription("Feed description");
-
- for (org.apache.tuscany.sca.data.collection.Entry<Object, Object> entry: collection) {
- SyndEntry feedEntry = createFeedEntry(entry);
- feed.getEntries().add(feedEntry);
- }
- }
- }
-
- // Convert to an RSS feed
- if (feed != null) {
- response.setContentType("application/rss+xml; charset=utf-8");
- feed.setFeedType("rss_2.0");
- feed.setLink(path);
- SyndFeedOutput syndOutput = new SyndFeedOutput();
- try {
- syndOutput.output(feed, getWriter(response));
- } catch (FeedException e) {
- throw new ServletException(e);
- }
- } else {
- response.sendError(HttpServletResponse.SC_NOT_FOUND);
- }
- } else {
- response.sendError(HttpServletResponse.SC_NOT_FOUND);
- }
-
- }
-
- /**
- * Create an RSS entry from a data collection entry.
- * @param entry
- * @return
- */
- private SyndEntry createFeedEntry(org.apache.tuscany.sca.data.collection.Entry<Object, Object> entry) {
- Object key = entry.getKey();
- Object data = entry.getData();
- if (data instanceof Item) {
- Item item = (Item)data;
-
- SyndEntry feedEntry = new SyndEntryImpl();
- feedEntry.setUri(key.toString());
- feedEntry.setTitle(item.getTitle());
-
- String value = item.getContents();
- if (value != null) {
- SyndContent content = new SyndContentImpl();
- content.setType("text/xml");
- content.setValue(value);
- List<SyndContent> contents = new ArrayList<SyndContent>();
- contents.add(content);
- feedEntry.setContents(contents);
- }
-
- String href = item.getLink();
- if (href == null) {
- href = key.toString();
- }
- SyndLink link = new SyndLinkImpl();
- link.setRel("edit");
- link.setHref(href);
- feedEntry.getLinks().add(link);
- link = new SyndLinkImpl();
- link.setRel("alternate");
- link.setHref(href);
- feedEntry.getLinks().add(link);
- feedEntry.setLink(href);
-
- Date date = item.getDate();
- if (date == null) {
- date = new Date();
- }
- feedEntry.setPublishedDate(date);
- return feedEntry;
-
- } else if (data != null) {
- SyndEntry feedEntry = new SyndEntryImpl();
- feedEntry.setUri(key.toString());
- feedEntry.setTitle("item");
-
- // Convert the item to XML
- String value = mediator.mediate(data, itemClassType, itemXMLType, null).toString();
-
- SyndContent content = new SyndContentImpl();
- content.setType("text/xml");
- content.setValue(value);
- List<SyndContent> contents = new ArrayList<SyndContent>();
- contents.add(content);
- feedEntry.setContents(contents);
-
- SyndLink link = new SyndLinkImpl();
- link.setRel("edit");
- link.setHref(key.toString());
- feedEntry.getLinks().add(link);
- link = new SyndLinkImpl();
- link.setRel("alternate");
- link.setHref(key.toString());
- feedEntry.getLinks().add(link);
-
- feedEntry.setPublishedDate(new Date());
- return feedEntry;
- } else {
- return null;
- }
- }
-
- /**
- * Create a data collection entry from an RSS entry.
- * @param feedEntry
- * @return
- */
- private org.apache.tuscany.sca.data.collection.Entry<Object, Object> createEntry(SyndEntry feedEntry) {
- if (feedEntry != null) {
- if (itemClassType.getPhysical() == Item.class) {
- String key = feedEntry.getUri();
-
- Item item = new Item();
- item.setTitle(feedEntry.getTitle());
-
- List<?> contents = feedEntry.getContents();
- if (!contents.isEmpty()) {
- SyndContent content = (SyndContent)contents.get(0);
- String value = content.getValue();
- item.setContents(value);
- }
-
- for (Object l : feedEntry.getLinks()) {
- SyndLink link = (SyndLink)l;
- if (link.getRel() == null || "edit".equals(link.getRel())) {
- String href = link.getHref();
- if (href.startsWith("null/")) {
- href = href.substring(5);
- }
- item.setLink(href);
- break;
- }
- }
-
- item.setDate(feedEntry.getPublishedDate());
-
- return new org.apache.tuscany.sca.data.collection.Entry<Object, Object>(key, item);
-
- } else {
- String key = feedEntry.getUri();
-
- // Create the item from XML
- List<?> contents = feedEntry.getContents();
- if (contents.isEmpty()) {
- return null;
- }
- SyndContent content = (SyndContent)contents.get(0);
- String value = content.getValue();
- Object data = mediator.mediate(value, itemXMLType, itemClassType, null);
-
- return new org.apache.tuscany.sca.data.collection.Entry<Object, Object>(key, data);
- }
- } else {
- return null;
- }
- }
-
-
- private Writer getWriter(HttpServletResponse response) throws UnsupportedEncodingException, IOException {
- Writer writer = new OutputStreamWriter(response.getOutputStream(), "UTF-8");
- return writer;
- }
-
- /**
- * Process the authorization header
- *
- * @param request
- * @return
- * @throws ServletException
- */
- private String processAuthorizationHeader(HttpServletRequest request) throws ServletException {
- try {
- String authorization = request.getHeader("Authorization");
- if (authorization != null) {
- StringTokenizer tokens = new StringTokenizer(authorization);
- if (tokens.hasMoreTokens()) {
- String basic = tokens.nextToken();
- if (basic.equalsIgnoreCase("Basic")) {
- String credentials = tokens.nextToken();
- String userAndPassword = new String(Base64.decodeBase64(credentials.getBytes()));
- int colon = userAndPassword.indexOf(":");
- if (colon != -1) {
- String user = userAndPassword.substring(0, colon);
- String password = userAndPassword.substring(colon + 1);
-
- // Authenticate the User.
- if (authenticate(user, password)) {
- return user;
- }
- }
- }
- }
- }
- } catch (Exception e) {
- throw new ServletException(e);
- }
- return null;
- }
-
- /**
- * Authenticate a user.
- *
- * @param user
- * @param password
- * @return
- */
- private boolean authenticate(String user, String password) {
-
- // TODO Handle this using SCA security policies
- //FIXME Why are we using endsWith instead of equals here??
- return ("admin".endsWith(user) && "admin".equals(password));
- }
-
- /**
- * Reject an unauthorized request.
- *
- * @param response
- */
- private void unauthorized(HttpServletResponse response) throws IOException {
- response.setHeader("WWW-Authenticate", "BASIC realm=\"Tuscany\"");
- response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
- }
-}
diff --git a/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingProviderFactory.java b/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingProviderFactory.java
deleted file mode 100644
index d588f041db..0000000000
--- a/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSBindingProviderFactory.java
+++ /dev/null
@@ -1,71 +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 org.apache.tuscany.sca.binding.rss.provider;
-
-import org.apache.tuscany.sca.binding.rss.RSSBinding;
-import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.UtilityExtensionPoint;
-import org.apache.tuscany.sca.databinding.Mediator;
-import org.apache.tuscany.sca.host.http.ServletHost;
-import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint;
-import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.provider.BindingProviderFactory;
-import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
-import org.apache.tuscany.sca.provider.ServiceBindingProvider;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
-import org.apache.tuscany.sca.runtime.RuntimeComponentService;
-
-/**
- * Implementation of the RSS binding provider factory.
- *
- * @version $Rev$ $Date$
- */
-public class RSSBindingProviderFactory implements BindingProviderFactory<RSSBinding> {
-
- private MessageFactory messageFactory;
- private Mediator mediator;
- private ServletHost servletHost;
-
- public RSSBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
- ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class);
- this.servletHost = servletHosts.getServletHosts().get(0);
- ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
- this.messageFactory = modelFactories.getFactory(MessageFactory.class);
- this.mediator = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Mediator.class);
- }
-
- public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component,
- RuntimeComponentReference reference,
- RSSBinding binding) {
- return new RSSReferenceBindingProvider(component, reference, binding);
- }
-
- public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component,
- RuntimeComponentService service,
- RSSBinding binding) {
- return new RSSServiceBindingProvider(component, service, binding, servletHost, messageFactory, mediator);
- }
-
- public Class<RSSBinding> getModelType() {
- return RSSBinding.class;
- }
-}
diff --git a/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSReferenceBindingProvider.java b/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSReferenceBindingProvider.java
deleted file mode 100644
index 8a30e9d3fb..0000000000
--- a/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSReferenceBindingProvider.java
+++ /dev/null
@@ -1,65 +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 org.apache.tuscany.sca.binding.rss.provider;
-
-import org.apache.tuscany.sca.binding.rss.RSSBinding;
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
-
-/**
- * Implementation of the RSS binding provider.
- *
- * @version $Rev$ $Date$
- */
-class RSSReferenceBindingProvider implements ReferenceBindingProvider {
-
- private RuntimeComponentReference reference;
- private RSSBinding binding;
-
- RSSReferenceBindingProvider(RuntimeComponent component,
- RuntimeComponentReference reference,
- RSSBinding binding) {
- this.reference = reference;
- this.binding = binding;
- }
-
- public Invoker createInvoker(Operation operation) {
- return new RSSBindingInvoker(binding.getURI(), "rss_2.0");
- }
-
- public boolean supportsOneWayInvocation() {
- return false;
- }
-
- public InterfaceContract getBindingInterfaceContract() {
- return reference.getInterfaceContract();
- }
-
- public void start() {
- }
-
- public void stop() {
- }
-
-}
diff --git a/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSServiceBindingProvider.java b/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSServiceBindingProvider.java
deleted file mode 100644
index 4e5429ac83..0000000000
--- a/branches/sca-java-1.5.1/modules/binding-rss-rome/src/main/java/org/apache/tuscany/sca/binding/rss/provider/RSSServiceBindingProvider.java
+++ /dev/null
@@ -1,85 +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 org.apache.tuscany.sca.binding.rss.provider;
-
-import org.apache.tuscany.sca.binding.rss.RSSBinding;
-import org.apache.tuscany.sca.databinding.Mediator;
-import org.apache.tuscany.sca.host.http.ServletHost;
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.provider.ServiceBindingProvider;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.runtime.RuntimeComponentService;
-import org.apache.tuscany.sca.runtime.RuntimeWire;
-
-/**
- * Implementation of the RSS binding provider.
- *
- * @version $Rev$ $Date$
- */
-class RSSServiceBindingProvider implements ServiceBindingProvider {
-
- private RuntimeComponentService service;
- private RSSBinding binding;
- private ServletHost servletHost;
- private MessageFactory messageFactory;
- private String servletMapping;
- private Mediator mediator;
-
- RSSServiceBindingProvider(RuntimeComponent component,
- RuntimeComponentService service,
- RSSBinding binding,
- ServletHost servletHost,
- MessageFactory messageFactory,
- Mediator mediator) {
- this.service = service;
- this.binding = binding;
- this.servletHost = servletHost;
- this.messageFactory = messageFactory;
- this.mediator = mediator;
- }
-
- public InterfaceContract getBindingInterfaceContract() {
- return service.getInterfaceContract();
- }
-
- public boolean supportsOneWayInvocation() {
- return false;
- }
-
- public void start() {
- RuntimeComponentService componentService = (RuntimeComponentService)service;
- RuntimeWire wire = componentService.getRuntimeWire(binding);
-
- RSSBindingListenerServlet servlet =
- new RSSBindingListenerServlet(wire, messageFactory, mediator);
-
- servletMapping = binding.getURI();
- servletHost.addServletMapping(servletMapping, servlet);
-
- // Save the actual binding URI in the binding
- binding.setURI(servletHost.getURLMapping(binding.getURI()).toString());
- }
-
- public void stop() {
- servletHost.removeServletMapping(servletMapping);
- }
-
-}