diff options
12 files changed, 144 insertions, 177 deletions
diff --git a/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/Collection.java b/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/Collection.java index 5400e0b90f..8bff8631a6 100644 --- a/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/Collection.java +++ b/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/Collection.java @@ -25,6 +25,8 @@ import org.osoa.sca.annotations.Remotable; /** * Provides access to a collection of resources using Gdata. + * + * @version $Rev$ $Date$ */ @Remotable public interface Collection { diff --git a/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/MediaCollection.java b/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/MediaCollection.java index 31e16e5f56..699e9f0172 100644 --- a/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/MediaCollection.java +++ b/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/collection/MediaCollection.java @@ -20,13 +20,14 @@ package org.apache.tuscany.sca.binding.gdata.collection; import java.io.InputStream; -import org.osoa.sca.annotations.Remotable; // import - // org.apache.abdera.model.Entry; +import org.osoa.sca.annotations.Remotable; import com.google.gdata.data.Entry; /** * Provides access to a collection of resources using Atom. + * + * @version $Rev$ $Date$ */ @Remotable public interface MediaCollection extends Collection { diff --git a/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingInvoker.java b/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingInvoker.java index 859318a306..9575b2ebd0 100644 --- a/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingInvoker.java +++ b/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingInvoker.java @@ -18,19 +18,15 @@ */ package org.apache.tuscany.sca.binding.gdata.provider; -import static org.apache.tuscany.sca.binding.gdata.provider.GdataBindingUtil.entry; import static org.apache.tuscany.sca.binding.gdata.provider.GdataBindingUtil.feedEntry; import java.io.IOException; import java.net.URL; -import java.util.ArrayList; -import java.util.List; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.methods.DeleteMethod; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.PutMethod; -import org.apache.tuscany.sca.binding.gdata.collection.NotFoundException; import org.apache.tuscany.sca.data.collection.Entry; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.DataExchangeSemantics; @@ -46,6 +42,8 @@ import com.google.gdata.util.ServiceException; /** * Invoker for the GData binding. + * + * @version $Rev$ $Date$ */ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { @@ -71,6 +69,11 @@ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { } + + public boolean allowsPassByReference() { + return true; + } + public Message invoke(Message msg) { // Shouldn't get here, as the only supported methods are // defined in the ResourceCollection interface, and implemented @@ -83,6 +86,7 @@ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { * Get operation invoker */ public static class GetInvoker extends GdataBindingInvoker { + public GetInvoker(Operation operation, String uri, GoogleService googleService, @@ -145,23 +149,19 @@ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { // Expect an GData entry - System.out.println("[Debug Info]GdataBindingInvoker.PostInvoker --- supportsFeedEntries: " + provider - .supportsFeedEntries()); + System.out.println("[Debug Info]GdataBindingInvoker.PostInvoker --- supportsFeedEntries: " + provider.supportsFeedEntries()); feedEntry = (com.google.gdata.data.Entry)args[0]; - System.out.println("[Debug Info]GdataBindingInvoker.PostInvoker --- feedEntry title: " + feedEntry - .getTitle().getPlainText()); + System.out.println("[Debug Info]GdataBindingInvoker.PostInvoker --- feedEntry title: " + feedEntry.getTitle().getPlainText()); } else { // Expect a key and data item Entry<Object, Object> entry = new Entry<Object, Object>(args[0], args[1]); // FIXME: this needs to be examinated more.... - feedEntry = - feedEntry(entry, provider.getItemClassType(), provider.getItemXMLType(), provider.getMediator()); + feedEntry = feedEntry(entry, provider.getItemClassType(), provider.getItemXMLType(), provider.getMediator()); } - try { com.google.gdata.data.Entry createdEntry = googleService.insert(new URL(uri), feedEntry); @@ -212,13 +212,6 @@ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { id = (String)args[0]; Entry<Object, Object> entry = new Entry<Object, Object>(id, args[1]); - // FIXME: The following statement needs to be modified - // accordingly - /* - * feedEntry = feedEntry(entry, provider.getItemClassType(), - * provider.getItemXMLType(), provider.getMediator(), - * abderaFactory); - */ } // Send an HTTP PUT <Localhost> @@ -425,10 +418,4 @@ class GdataBindingInvoker implements Invoker, DataExchangeSemantics { return super.invoke(msg); } } - - public boolean allowsPassByReference() { - // TODO Auto-generated method stub - return true; - } - } diff --git a/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingListenerServlet.java b/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingListenerServlet.java index c09c1f7788..a615b2067e 100644 --- a/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingListenerServlet.java +++ b/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingListenerServlet.java @@ -61,6 +61,8 @@ import com.google.gdata.util.ServiceException; /** * A resource collection binding listener, implemented as a Servlet and * registered in a Servlet host provided by the SCA hosting runtime. + * + * @version $Rev$ $Date$ */ class GdataBindingListenerServlet extends HttpServlet { private static final Logger logger = Logger.getLogger(GdataBindingListenerServlet.class.getName()); diff --git a/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingProviderFactory.java b/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingProviderFactory.java index fa99f4cb1b..9be7ba6392 100644 --- a/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingProviderFactory.java +++ b/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingProviderFactory.java @@ -40,6 +40,8 @@ import com.google.gdata.util.AuthenticationException; /** * Implementation of a Binding provider factory for the Atom binding. + * + * @version $Rev$ $Date$ */ public class GdataBindingProviderFactory implements BindingProviderFactory<GdataBinding> { @@ -63,7 +65,6 @@ public class GdataBindingProviderFactory implements BindingProviderFactory<Gdata try { return new GdataReferenceBindingProvider(component, reference, binding, mediator); } catch (AuthenticationException e) { - // TODO Auto-generated catch block e.printStackTrace(); return null; //Google authentication error! : This exception needs to be handled into a better way } diff --git a/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingUtil.java b/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingUtil.java index 86fc8fd43f..3d476df764 100644 --- a/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingUtil.java +++ b/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataBindingUtil.java @@ -33,6 +33,7 @@ import com.google.gdata.data.TextContent; /** * Utility methods used in this package. * + * @version $Rev$ $Date$ */ class GdataBindingUtil { diff --git a/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java b/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java index ba082e72b6..7656754bca 100644 --- a/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java +++ b/java/sca/modules/binding-gdata-runtime/src/main/java/org/apache/tuscany/sca/binding/gdata/provider/GdataReferenceBindingProvider.java @@ -83,7 +83,6 @@ class GdataReferenceBindingProvider implements ReferenceBindingProvider { String authorization = "admin" + ":" + "admin"; authorizationHeader = "Basic " + new String(Base64.encodeBase64(authorization.getBytes())); - // Prepare gdata header String serviceType = binding.getServiceType(); String usernane = binding.getUsername(); @@ -97,8 +96,6 @@ class GdataReferenceBindingProvider implements ReferenceBindingProvider { if(binding.getUsername().equals("admin") == false && binding.getPassword().equals("admin")==false){ googleService.setUserCredentials(binding.getUsername(),binding.getPassword()); } - - // Create an HTTP client HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); @@ -111,9 +108,6 @@ class GdataReferenceBindingProvider implements ReferenceBindingProvider { String operationName = operation.getName(); - // //System.out.println("GdataReferenceBindingProvider.createInvoker---operationName:" - // + operationName); - if (operationName.equals("get")) { // Determine the collection item type @@ -131,9 +125,9 @@ class GdataReferenceBindingProvider implements ReferenceBindingProvider { String entryURI = this.binding.getURI(); if(entryURI.contains("picasaweb.google.com/data/feed/api/")){ entryURI = entryURI.replace("picasaweb.google.com/data/feed/api/", "picasaweb.google.com/data/entry/api/"); - binding.setURI(entryURI); } - return new GdataBindingInvoker.GetInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, this); + + return new GdataBindingInvoker.GetInvoker(operation, entryURI, googleService, httpClient, authorizationHeader, this); } else if (operationName.equals("post")) { @@ -144,62 +138,48 @@ class GdataReferenceBindingProvider implements ReferenceBindingProvider { String entryURI = this.binding.getURI(); if(entryURI.contains("picasaweb.google.com/data/feed/api/")){ entryURI = entryURI.replace("picasaweb.google.com/data/feed/api/", "picasaweb.google.com/data/entry/api/"); - binding.setURI(entryURI); } - return new GdataBindingInvoker.PutInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, - this); + + return new GdataBindingInvoker.PutInvoker(operation, entryURI, googleService, httpClient, authorizationHeader, this); + } else if (operationName.equals("delete")) { - - - String entryURI = this.binding.getURI(); + + String entryURI = this.binding.getURI(); if(entryURI.contains("picasaweb.google.com/data/feed/api/")){ entryURI = entryURI.replace("picasaweb.google.com/data/feed/api/", "picasaweb.google.com/data/entry/api/"); - binding.setURI(entryURI); } - return new GdataBindingInvoker.DeleteInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, - this); + return new GdataBindingInvoker.DeleteInvoker(operation, entryURI, googleService, httpClient, authorizationHeader, this); + } else if (operationName.equals("getFeed") || operationName.equals("getAll")) { - // //System.out.println("GdataReferenceBindingProvider - // CreateInvoker: getFeed or getAll"); - - return new GdataBindingInvoker.GetAllInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, - this); + return new GdataBindingInvoker.GetAllInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, this); } else if (operationName.equals("postMedia")) { - return new GdataBindingInvoker.PostMediaInvoker(operation, binding.getURI(), googleService, httpClient, - authorizationHeader, this); + + return new GdataBindingInvoker.PostMediaInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, this); + } else if (operationName.equals("putMedia")) { - return new GdataBindingInvoker.PutMediaInvoker(operation, binding.getURI(), googleService, httpClient, - authorizationHeader, this); + + return new GdataBindingInvoker.PutMediaInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, this); + } else if (operationName.equals("query")) { - return new GdataBindingInvoker.QueryInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, - this); + + return new GdataBindingInvoker.QueryInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, this); } return new GdataBindingInvoker(operation, binding.getURI(), googleService, httpClient, authorizationHeader, this); } - - public InterfaceContract getBindingInterfaceContract() { return reference.getInterfaceContract(); } - - public void start() { - // Configure the HTTP client credentials Credentials credentials = new UsernamePasswordCredentials("admin", "admin"); httpClient.getParams().setAuthenticationPreemptive(true); URI uri = URI.create(binding.getURI()); httpClient.getState().setCredentials(new AuthScope(uri.getHost(), uri.getPort()), credentials); - - // Find the get operation on the reference interface - if (true) { - return; - } } public void stop() { diff --git a/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBinding.java b/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBinding.java index ab2acef234..a3a0b834cd 100644 --- a/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBinding.java +++ b/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBinding.java @@ -40,10 +40,39 @@ public interface GdataBinding extends Binding { */ void setTitle(String title); + /** + * Returns the username to be used when authenticating with GData Services + * @return + */ String getUsername(); + + /** + * Sets the username to be used when authenticating with GData Services + * @param username + */ + void setUsername(String username); + + /** + * Returns the password to be used when authenticating with GData Services + * @return + */ String getPassword(); - String getServiceType(); - void setUsername(String username); + + /** + * Sets the password to be used when authenticating with GData Services + * @param password + */ void setPassword(String password); + + /** + * Returns the type os service being used + * @return + */ + String getServiceType(); + + /** + * Sets the type of service being used + * @param serviceType + */ void setServiceType(String serviceType); } diff --git a/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBindingFactory.java b/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBindingFactory.java index 847bb6956b..5cfc688dcb 100644 --- a/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBindingFactory.java +++ b/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/GdataBindingFactory.java @@ -22,6 +22,7 @@ package org.apache.tuscany.sca.binding.gdata; /** * Factory for the GData binding * + * @version $Rev$ $Date$ */ public interface GdataBindingFactory { diff --git a/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingFactoryImpl.java b/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingFactoryImpl.java index 656776c358..87f3597248 100644 --- a/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingFactoryImpl.java +++ b/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingFactoryImpl.java @@ -25,6 +25,7 @@ import org.apache.tuscany.sca.binding.gdata.GdataBindingFactory; /** * Factory for the GData binding model. * + * @version $Rev$ $Date$ */ public class GdataBindingFactoryImpl implements GdataBindingFactory { diff --git a/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingImpl.java b/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingImpl.java index c389bacdc9..b4b0a5f449 100644 --- a/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingImpl.java +++ b/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingImpl.java @@ -22,10 +22,6 @@ package org.apache.tuscany.sca.binding.gdata.impl; import java.util.ArrayList; import java.util.List; -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.OptimizableBinding; import org.apache.tuscany.sca.binding.gdata.GdataBinding; import org.apache.tuscany.sca.policy.Intent; import org.apache.tuscany.sca.policy.IntentAttachPointType; @@ -35,6 +31,7 @@ import org.apache.tuscany.sca.policy.PolicySetAttachPoint; /** * Implementation of the GData binding model. * + * @version $Rev$ $Date$ */ class GdataBindingImpl implements GdataBinding, PolicySetAttachPoint { @@ -44,15 +41,12 @@ class GdataBindingImpl implements GdataBinding, PolicySetAttachPoint { private String username; private String password; private String serviceType; + private List<Intent> requiredIntents = new ArrayList<Intent>(); private List<PolicySet> policySets = new ArrayList<PolicySet>(); private IntentAttachPointType intentAttachPointType; private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>(); - public List<PolicySet> getApplicablePolicySets() { - return applicablePolicySets; - } - public String getName() { return name; } @@ -61,6 +55,10 @@ class GdataBindingImpl implements GdataBinding, PolicySetAttachPoint { return uri; } + public String getTitle() { + return title; + } + public String getUsername(){ return username; } @@ -80,6 +78,10 @@ class GdataBindingImpl implements GdataBinding, PolicySetAttachPoint { public void setURI(String uri) { this.uri = uri; } + + public void setTitle(String title) { + this.title = title; + } public void setUsername(String username) { this.username = username; @@ -93,15 +95,6 @@ class GdataBindingImpl implements GdataBinding, PolicySetAttachPoint { this.serviceType = serviceType; } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - public boolean isUnresolved() { // The binding is always resolved return false; @@ -111,6 +104,12 @@ class GdataBindingImpl implements GdataBinding, PolicySetAttachPoint { // The binding is always resolved } + //Policy related getters/setters + + public List<PolicySet> getApplicablePolicySets() { + return applicablePolicySets; + } + public List<PolicySet> getPolicySets() { return policySets; } diff --git a/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingProcessor.java b/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingProcessor.java index 1cd0f72a93..01551e3e82 100644 --- a/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingProcessor.java +++ b/java/sca/modules/binding-gdata/src/main/java/org/apache/tuscany/sca/binding/gdata/impl/GdataBindingProcessor.java @@ -18,32 +18,24 @@ */ package org.apache.tuscany.sca.binding.gdata.impl; -import java.util.ArrayList; -import java.util.List; - import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; -//import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor; +import org.apache.tuscany.sca.binding.gdata.GdataBinding; +import org.apache.tuscany.sca.binding.gdata.GdataBindingFactory; import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; import org.apache.tuscany.sca.contribution.service.ContributionReadException; import org.apache.tuscany.sca.contribution.service.ContributionResolveException; import org.apache.tuscany.sca.contribution.service.ContributionWriteException; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.apache.tuscany.sca.policy.IntentAttachPointType; -import org.apache.tuscany.sca.policy.impl.IntentAttachPointTypeFactoryImpl; - -import org.apache.tuscany.sca.binding.gdata.GdataBinding; -import org.apache.tuscany.sca.binding.gdata.GdataBindingFactory; /** * A processor for <binding.gdata> elements. + * + * @version $Rev$ $Date$ */ public class GdataBindingProcessor implements StAXArtifactProcessor<GdataBinding> { @@ -51,12 +43,9 @@ public class GdataBindingProcessor implements StAXArtifactProcessor<GdataBinding private final GdataBindingFactory factory; - //private PolicyAttachPointProcessor policyProcessor; - public GdataBindingProcessor(ModelFactoryExtensionPoint modelFactories) { this.factory = modelFactories.getFactory(GdataBindingFactory.class); System.out.println("[Debug Info]GdataBindingProcessor reached"); - //this.policyProcessor = new PolicyAttachPointProcessor(policyFactory); } public QName getArtifactType() { @@ -68,91 +57,65 @@ public class GdataBindingProcessor implements StAXArtifactProcessor<GdataBinding } public GdataBinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - GdataBinding gdataBinding = factory.createGdataBinding(); - IntentAttachPointType bindingType = new IntentAttachPointTypeFactoryImpl().createBindingType(); - bindingType.setName(getArtifactType()); - bindingType.setUnresolved(true); - ((PolicySetAttachPoint)gdataBinding).setType(bindingType); - - String name = reader.getAttributeValue(null, "name"); - if (name != null) { - gdataBinding.setName(name); - } - - String uri = reader.getAttributeValue(null, "uri"); - if (uri != null) { - gdataBinding.setURI(uri); - } - - String serviceType = reader.getAttributeValue(null, "serviceType"); - if (serviceType != null) { - gdataBinding.setServiceType(serviceType); - } - - String username = reader.getAttributeValue(null, "username"); - if (username != null) { - gdataBinding.setUsername(username); - } - - String password = reader.getAttributeValue(null, "password"); - if (password != null) { - gdataBinding.setPassword(password); - } - - //policyProcessor.readPolicies(echoBinding, reader); - - return gdataBinding; + GdataBinding gdataBinding = factory.createGdataBinding(); + + String name = reader.getAttributeValue(null, "name"); + if (name != null) { + gdataBinding.setName(name); + } + + String uri = reader.getAttributeValue(null, "uri"); + if (uri != null) { + gdataBinding.setURI(uri); + } + + String serviceType = reader.getAttributeValue(null, "serviceType"); + if (serviceType != null) { + gdataBinding.setServiceType(serviceType); + } + + String username = reader.getAttributeValue(null, "username"); + if (username != null) { + gdataBinding.setUsername(username); + } + + String password = reader.getAttributeValue(null, "password"); + if (password != null) { + gdataBinding.setPassword(password); + } + + + return gdataBinding; } public void write(GdataBinding gdataBinding, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException { + writer.writeStartElement(BINDING_GDATA.getNamespaceURI(), BINDING_GDATA.getLocalPart()); + + if (gdataBinding.getName() != null) { + writer.writeAttribute("name", gdataBinding.getName()); + } - //policyProcessor.writePolicyPrefixes(gdataBinding, writer); - writer.writeStartElement(BINDING_GDATA.getNamespaceURI(), BINDING_GDATA.getLocalPart()); - //policyProcessor.writePolicyAttributes(gdataBinding, writer); - - if (gdataBinding.getName() != null) { - writer.writeAttribute("name", gdataBinding.getName()); - } - - if (gdataBinding.getURI() != null) { - writer.writeAttribute("uri", gdataBinding.getURI()); - } - - if (gdataBinding.getServiceType() != null) { - writer.writeAttribute("serviceType", gdataBinding.getServiceType()); - } - - if (gdataBinding.getUsername() != null) { - writer.writeAttribute("username", gdataBinding.getUsername()); - } - - if (gdataBinding.getPassword() != null) { - writer.writeAttribute("password", gdataBinding.getPassword()); - } - - writer.writeEndElement(); + if (gdataBinding.getURI() != null) { + writer.writeAttribute("uri", gdataBinding.getURI()); + } + + if (gdataBinding.getServiceType() != null) { + writer.writeAttribute("serviceType", gdataBinding.getServiceType()); + } + + if (gdataBinding.getUsername() != null) { + writer.writeAttribute("username", gdataBinding.getUsername()); + } + + if (gdataBinding.getPassword() != null) { + writer.writeAttribute("password", gdataBinding.getPassword()); + } + + writer.writeEndElement(); } - //FIXME: Resolve the attached policySet, might not needed (the echo binding implementation example) public void resolve(GdataBinding gdataBinding, ModelResolver resolver) throws ContributionResolveException { - PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)gdataBinding; - List<Intent> requiredIntents = new ArrayList<Intent>(); - Intent resolvedIntent = null; - for ( Intent intent : policySetAttachPoint.getRequiredIntents() ) { - resolvedIntent = resolver.resolveModel(Intent.class, intent); - requiredIntents.add(resolvedIntent); - } - policySetAttachPoint.getRequiredIntents().clear(); - policySetAttachPoint.getRequiredIntents().addAll(requiredIntents); - - List<PolicySet> resolvedPolicySets = new ArrayList<PolicySet>(); - PolicySet resolvedPolicySet = null; - for ( PolicySet policySet : policySetAttachPoint.getPolicySets() ) { - resolvedPolicySet = resolver.resolveModel(PolicySet.class, policySet); - resolvedPolicySets.add(resolvedPolicySet); - } - policySetAttachPoint.getPolicySets().clear(); - policySetAttachPoint.getPolicySets().addAll(resolvedPolicySets); + } } |