diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-10-24 03:43:49 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-10-24 03:43:49 +0000 |
commit | 12af73bcbdfa19ed75672143849e41cd5ddd04de (patch) | |
tree | ae8ed3c3dc5267e455c8a68f2309b00f75f0f5d6 /java/sca/modules/binding-gdata/src | |
parent | 13d2bfc1130208dc2723b4475744cdcfe09c0dba (diff) |
Cleaning up GData binding implementation and fixing issue with retrieving Picassa feed
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@707532 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/binding-gdata/src')
5 files changed, 105 insertions, 112 deletions
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); + } } |