Package net.sf.iqser.plugin.facebook.restfacebook

Examples of net.sf.iqser.plugin.facebook.restfacebook.IFacebookRESTClient


public class FacebookClientFactoryTest extends TestCase {

  public void test(){
    IFacebookClientFactory factory = new FacebookClientFactory();
    IFacebookRESTClient facebookApi = factory.createFacebookAPIClient("accessToken");
   
    assertNotNull(facebookApi);
  }
View Full Code Here


    }
  }
 
  private IFacebookRESTClient openFbConnection(String user, String password)
    throws IQserSecurityException {
    IFacebookRESTClient conn;
   
    String accessToken = getUserAccessToken().get(user);
   
    if (accessToken==null){
      throw new IQserSecurityException("Cannot find access token for user " + user + " password" + password);
View Full Code Here

   *
   * @see com.iqser.core.plugin.security.SecurityFilter#canRead(java.lang.String, java.lang.String, com.iqser.core.model.Content)
   */
  public boolean canRead(String user, String password, Content content)
      throws IQserSecurityException {
    IFacebookRESTClient fbClient = openFbConnection(user, password);
   
    String fbId = URLUtils.getFbId(content.getContentUrl());
    JsonObject fbObject = fbClient.getObjectByID(fbId);
   
    return ! fbObject.isNull("id");
  }
View Full Code Here

      existingContents = getExistingContents();
    } catch (IQserException e) {
      throw new IQserRuntimeException("Error in doHousekeeping() - getExistingContents()", e);
    }
       
    IFacebookRESTClient fbClient = facebookClientFactory.createFacebookAPIClient(accessToken);

    // an improvement to this would be to group contents by user and for
    // each user see if the facebook objects visible by him exists
    // https://graph.facebook.com/?ids=id1,id2,id3&fields=id&access_token=myaccessToken
    for (Content content : existingContents) {
View Full Code Here

      IFacebookContentBuilder builder = createBuilder(type, accessToken);
      builder.doSynchonization("me", lastSyncDate);
    }
   
    // get friends
    IFacebookRESTClient fbClient = facebookClientFactory.createFacebookAPIClient(accessToken);
    //List<User> friendList = fbClient.getUserFriends();
    List<User> friendList = fbClient.getFacebookConnectionByID("me/friends", User.class);
   
    // for each friend synch types:  User, Post, Events, Status, Notes
    for (User friend : friendList) {
      for (String type : friendDataTypes) {
        IFacebookContentBuilder builder = createBuilder(type, accessToken);
View Full Code Here

   * @param accessToken - the Facebook access token
   * @return a IFacebookContentBuilder
   */
  private IFacebookContentBuilder createBuilder(String type, String accessToken){
    IFacebookContentBuilder builder = ContentBuilderFactory.getContentBuilder(type);
    IFacebookRESTClient fbClient = facebookClientFactory.createFacebookAPIClient(accessToken);
    builder.setFbClient(fbClient);
    builder.setFbContentProvider(this);
   
    return builder;
  }
View Full Code Here

    content.setContentUrl(URLUtils.makeContentURL(fbItemId, "Post"));
   
    IFacebookClientFactory mockFactory = EasyMock.createMock(IFacebookClientFactory.class);   
    // set private property using reflexion
    setPrivateField(securityFilter, "factory", mockFactory);
    IFacebookRESTClient mockClient = EasyMock.createMock(IFacebookRESTClient.class);
                   
    String accessToken = securityFilter.getUserAccessToken().get(user);       
    EasyMock.expect(mockFactory.createFacebookAPIClient(accessToken)).andReturn(mockClient);
    JsonObject jsonObject = new JsonObject();
    jsonObject.put("id", fbItemId);
    EasyMock.expect(mockClient.getObjectByID(fbItemId)).andReturn(jsonObject);
   
    EasyMock.replay(mockFactory, mockClient);
   
    boolean isAllowed = securityFilter.canRead(user, password, content);
 
View Full Code Here

TOP

Related Classes of net.sf.iqser.plugin.facebook.restfacebook.IFacebookRESTClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.