Results 1 to 9 of 9

Thread: MissingNamespaceException on openGraphOperations().publishActi on(..)

  1. #1

    Default MissingNamespaceException on openGraphOperations().publishActi on(..)

    When I try to publish an action through FacebookTemplate

    Code:
    this.facebook.openGraphOperations().publishAction("myaction", "myobject", this.getObjectUrl(myObject));
    I get the following exception:
    Code:
    org.springframework.social.facebook.api.MissingNamespaceException: An application namespace is required to publish OpenGraph actions.
    	at org.springframework.social.facebook.api.impl.OpenGraphTemplate.requireApplicationNamespace(OpenGraphTemplate.java:44)
    	at org.springframework.social.facebook.api.impl.OpenGraphTemplate.publishAction(OpenGraphTemplate.java:35)
    I don't know where should I configure the application namespace? I can't find it in Spring Social documentation.

    Thanks,
    Yuval

  2. #2
    Join Date
    Aug 2004
    Posts
    1,072

    Default

    Well, there is a new constructor for FacebookTemplate that takes a namespace as its second argument. If you construct FacebookTemplate yourself, you can set the namespace that way. The problem, however, is that if you're using the connection framework, it's the framework that instantiates FacebookTemplate and it doesn't know anything about the namespace...and thus it constructs a FacebookTemplate without a namespace.

    I don't have a solution for you at the moment, but I'm glad you told me about this as it brings to light a missing piece in the open graph support. I've created https://jira.springsource.org/browse/SOCIALFB-96 to track this. Please watch that issue to see how this gets resolved. Also, if you've got any ideas on how to solve it, I'm open to suggestions.
    Craig Walls
    Spring Social Project Lead

  3. #3

    Default

    Thanks Craig. I will follow this, although i'm pretty certain that I will have to find a way to resolve or workaround this quite soon.

    Regarding the namespace argument, does it have to be a constructor arg? Why can't there be a setApplicationNamespace(..)?

    As for the general issue, if I understand correctly the root of the problem is that there is no way to tell the connection framework how does the constructor look like, so it doesn't know what arguments to take? I'll have to think about this.. maybe using an "Object ... args" vararg that will be passed during instantiation to the constructor by reflection?

    But it might just not be necessary if making sure all constructor arguments can also be set by a setter.

    Yuval
    Last edited by YuvalRon; Sep 6th, 2012 at 10:35 PM.

  4. #4
    Join Date
    Aug 2004
    Posts
    1,072

    Default

    Yes, following it with a setter is one idea I tossed around (honestly, I only thought about it for a moment, because my workday ended just about the time I answered your first message...but I did think about it some). The problem with that is that I'd need to expose that setter on the Facebook interface and I'm not sure I want to do that. The reason I'd need to do that is because it's a Facebook object that is given out by the connection framework, not a FacebookTemplate. Sure, some casting could be done, but I'd want to avoid that.

    I've got a few other ideas that I'd like to explore first. Shouldn't be that hard...I just need to give it some focused thought.

    BTW, I just fixed the initialize() thing you reported. Thanks for pointing that out.
    Craig Walls
    Spring Social Project Lead

  5. #5

    Default

    Hi Craig,

    In the meantime, I've figured out some workaround for this by extending OAuth2ConnectionFactory and FacebookServiceProvider:

    Code:
    public class FacebookServiceProviderNS extends FacebookServiceProvider {
    
    	private String appNamespace;
    
    	public FacebookServiceProviderNS(String clientId, String clientSecret, String appNamespace) {
    		super(clientId, clientSecret);
    		this.setAppNamespace(appNamespace);
    	}
    
    	public String getAppNamespace() { 
    		return this.appNamespace;
    	}
    	
    	public void setAppNamespace(String appNamespace) { 
    		this.appNamespace = appNamespace;
    	}
    	
    	@Override
    	public Facebook getApi(String accessToken) {
    		return new FacebookTemplate(accessToken, this.getAppNamespace());
    	}
    	
    }
    Code:
    public class FacebookConnectionFactoryNS extends OAuth2ConnectionFactory<Facebook> {
    
    	public FacebookConnectionFactoryNS(String clientId, String clientSecret, String appNamespace) {
    		super("facebook", new FacebookServiceProviderNS(clientId, clientSecret, appNamespace), new FacebookAdapter());
    	}
    
    }
    When configuring the connection repository, I use
    Code:
    @Bean
    public ConnectionFactoryLocator connectionFactoryLocator() {
    	ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry();
    	...
    	registry.addConnectionFactory(new FacebookConnectionFactoryNS(clientId, clientSecret, appNamespace));
    	
    	return registry;
    }
    This is working, but if you think there might be any problem with the usage, please let me know.
    Perhaps this is also the direction of the solution which you are looking for?

    Yuval
    Last edited by YuvalRon; Sep 10th, 2012 at 10:01 AM.

  6. #6
    Join Date
    Aug 2004
    Posts
    1,072

    Default

    That should work...it's one option I'm considering for sure...and seems to be the most reasonable one really.
    Craig Walls
    Spring Social Project Lead

  7. #7
    Join Date
    Aug 2004
    Posts
    1,072

    Default

    FYI: This has been resolved. See https://github.com/SpringSource/spri...cebook/pull/53 and https://jira.springsource.org/browse/SOCIALFB-96 for details. Also look at the Spring Social Showcase example to see how it's used.

    Try it out and let me know if it works for you.

    This change was only applied to the work being done for Spring Social Facebook 1.1.0 as the Open Graph support doesn't exist in the 1.0.x branch (and thus the namespace was unnecessary).
    Craig Walls
    Spring Social Project Lead

  8. #8

    Default

    Thanks Craig, sorry for the long delay, I finally had the time to refactor back and use the new 1.1.0 snapshot - it looks like it's working well.

    Yuval

  9. #9
    Join Date
    Aug 2004
    Posts
    1,072

    Default

    That's good to hear! Thanks for giving the feedback.
    Craig Walls
    Spring Social Project Lead

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •