Skip to content

Commit

Permalink
Refactoring OAuthServiceHandler to OAuthService
Browse files Browse the repository at this point in the history
OPEN - issue SEAMSOCIAL-9: Refactor Api and ClassName to Avoid Handler
suffix 
https://issues.jboss.org/browse/SEAMSOCIAL-9
  • Loading branch information
antoinesd committed May 3, 2011
1 parent 832fa88 commit f9cdd64
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 54 deletions.
Expand Up @@ -18,15 +18,15 @@
package org.jboss.seam.social.facebook;

import org.jboss.seam.social.oauth.HasStatus;
import org.jboss.seam.social.oauth.OAuthServiceHandler;
import org.jboss.seam.social.oauth.OAuthService;

/**
*
* A specialization of {@link OAuthServiceHandler} to add Facebook specific methods
* A specialization of {@link OAuthService} to add Facebook specific methods
*
* @author Antoine Sabot-Durand
*
*/
public interface FacebookHandler extends OAuthServiceHandler, HasStatus {
public interface FacebookHandler extends OAuthService, HasStatus {

}
Expand Up @@ -17,14 +17,14 @@
package org.jboss.seam.social.linkedin;

import org.jboss.seam.social.oauth.HasStatus;
import org.jboss.seam.social.oauth.OAuthServiceHandler;
import org.jboss.seam.social.oauth.OAuthService;

/**
* A specialization of {@link OAuthServiceHandler} to add LinkedIn specific methods
* A specialization of {@link OAuthService} to add LinkedIn specific methods
*
* @author Antoine Sabot-Durand
*
*/
public interface LinkedInHandler extends OAuthServiceHandler, HasStatus {
public interface LinkedInHandler extends OAuthService, HasStatus {

}
Expand Up @@ -24,7 +24,7 @@
* @author Antoine Sabot-Durand
*
*/
public interface OAuthServiceHandler {
public interface OAuthService {

/**
*
Expand Down
Expand Up @@ -17,11 +17,11 @@
package org.jboss.seam.social.oauth;

/**
* Interface for model containing settings needed to access to an OAuth 1.0a service It's used by {@link OAuthServiceHandler} to
* Interface for model containing settings needed to access to an OAuth 1.0a service It's used by {@link OAuthService} to
* setup connection to OAuth Service
*
* @author Antoine Sabot-Durand
* @see OAuthServiceHandler
* @see OAuthService
*/
public interface OAuthServiceSettings {

Expand Down
Expand Up @@ -17,7 +17,7 @@
package org.jboss.seam.social.oauth;

/**
* Enum containing the verb used in REST request. Used mainly in {@link OAuthServiceHandler#OAuthServiceHandler
* Enum containing the verb used in REST request. Used mainly in {@link OAuthService#OAuthServiceHandler
* #sendSignedRequest(RestVerb, String, java.util.Map)} and other sendSignedRequest method. to set REST verb to add to request
*
* @author Antoine Sabot-Durand
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/org/jboss/seam/social/oauth/Setted.java
Expand Up @@ -30,7 +30,7 @@
import javax.inject.Qualifier;

/**
* A CDI Qualifier annotation to qualify and set OAuthServiceHandler directly in the code It can be used like this :
* A CDI Qualifier annotation to qualify and set OAuthService directly in the code It can be used like this :
*
* <pre>
* &#064;Inject
Expand Down
Expand Up @@ -17,15 +17,15 @@
package org.jboss.seam.social.twitter;

import org.jboss.seam.social.oauth.HasStatus;
import org.jboss.seam.social.oauth.OAuthServiceHandler;
import org.jboss.seam.social.oauth.OAuthService;

/**
* A specialization of {@link OAuthServiceHandler} to add Twitter specific methods
* A specialization of {@link OAuthService} to add Twitter specific methods
*
* @author Antoine Sabot-Durand
*
*/

public interface TwitterHandler extends OAuthServiceHandler, HasStatus {
public interface TwitterHandler extends OAuthService, HasStatus {

}
Expand Up @@ -30,7 +30,7 @@
import javax.inject.Inject;
import javax.inject.Named;

import org.jboss.seam.social.oauth.OAuthServiceHandler;
import org.jboss.seam.social.oauth.OAuthService;
import org.jboss.seam.social.oauth.OAuthToken;
import org.jboss.seam.social.oauth.UserProfile;

Expand All @@ -51,49 +51,49 @@ public class SocialClient implements Serializable {

@Inject
@Any
private Instance<OAuthServiceHandler> serviceHandlerInstances;
private Instance<OAuthService> serviceHandlerInstances;

private OAuthServiceHandler currentServiceHdl;
private OAuthService currentServiceHdl;
private String status;

private List<OAuthServiceHandler> serviceHandlers;
private List<OAuthService> serviceHandlers;

private Map<String, OAuthServiceHandler> serviceHandlersMap;
private Map<String, OAuthService> serviceHandlersMap;

public List<OAuthServiceHandler> getServiceHandlers() {
public List<OAuthService> getServiceHandlers() {
return serviceHandlers;
}

@PostConstruct
public void init() {

serviceHandlers = Lists.newArrayList(serviceHandlerInstances);
serviceHandlersMap = Maps.uniqueIndex(serviceHandlerInstances, new Function<OAuthServiceHandler, String>() {
serviceHandlersMap = Maps.uniqueIndex(serviceHandlerInstances, new Function<OAuthService, String>() {

@Override
public String apply(OAuthServiceHandler arg0) {
public String apply(OAuthService arg0) {

return arg0.getType();
}
});

}

public List<OAuthServiceHandler> getConnectedServices() {
return Lists.newArrayList(Iterables.filter(serviceHandlers, new Predicate<OAuthServiceHandler>() {
public List<OAuthService> getConnectedServices() {
return Lists.newArrayList(Iterables.filter(serviceHandlers, new Predicate<OAuthService>() {

@Override
public boolean apply(OAuthServiceHandler arg0) {
public boolean apply(OAuthService arg0) {
return arg0.isConnected();
}
}));
}

public List<OAuthServiceHandler> getUnconnectedServices() {
return Lists.newArrayList(Iterables.filter(serviceHandlers, new Predicate<OAuthServiceHandler>() {
public List<OAuthService> getUnconnectedServices() {
return Lists.newArrayList(Iterables.filter(serviceHandlers, new Predicate<OAuthService>() {

@Override
public boolean apply(OAuthServiceHandler arg0) {
public boolean apply(OAuthService arg0) {
return !arg0.isConnected();
}
}));
Expand Down Expand Up @@ -143,11 +143,11 @@ public UserProfile getUser() {
return res;
}

public OAuthServiceHandler getCurrentServiceHdl() {
public OAuthService getCurrentServiceHdl() {
return currentServiceHdl;
}

public void setCurrentServiceHdl(OAuthServiceHandler currentServiceHdl) {
public void setCurrentServiceHdl(OAuthService currentServiceHdl) {
this.currentServiceHdl = currentServiceHdl;
}

Expand All @@ -159,7 +159,7 @@ public void setCurrentServiceName(String cursrvHdlStr) {
this.currentServiceHdl = serviceHandlersMap.get(cursrvHdlStr);
}

public void gotoAuthorizationURL(OAuthServiceHandler service) throws IOException {
public void gotoAuthorizationURL(OAuthService service) throws IOException {
setCurrentServiceHdl(service);
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
externalContext.redirect(getAuthorizationURL());
Expand Down
Expand Up @@ -14,7 +14,7 @@
import javax.faces.convert.FacesConverter;
import javax.inject.Inject;

import org.jboss.seam.social.oauth.OAuthServiceHandler;
import org.jboss.seam.social.oauth.OAuthService;

import com.google.common.base.Function;
import com.google.common.collect.Collections2;
Expand All @@ -24,21 +24,21 @@
* @author antoine
*
*/
@FacesConverter(value = "socialConverter", forClass = OAuthServiceHandler.class)
@FacesConverter(value = "socialConverter", forClass = OAuthService.class)
public class SocialServiceConverter implements Converter {

@Inject
@Any
private Instance<OAuthServiceHandler> serviceHandlerInstances;
private Instance<OAuthService> serviceHandlerInstances;

private Map<String, OAuthServiceHandler> services;
private Map<String, OAuthService> services;

private Map<String, OAuthServiceHandler> getServices() {
private Map<String, OAuthService> getServices() {
if (services == null) {
services = Maps.uniqueIndex(serviceHandlerInstances, new Function<OAuthServiceHandler, String>() {
services = Maps.uniqueIndex(serviceHandlerInstances, new Function<OAuthService, String>() {

@Override
public String apply(OAuthServiceHandler arg0) {
public String apply(OAuthService arg0) {

return arg0.getType();
}
Expand All @@ -56,7 +56,7 @@ public String apply(OAuthServiceHandler arg0) {
@Override
public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
Object res = getServices().get(arg2);
return ((OAuthServiceHandler) res);
return ((OAuthService) res);
}

/*
Expand All @@ -67,7 +67,7 @@ public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
*/
@Override
public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
String res = ((OAuthServiceHandler) arg2).getType();
String res = ((OAuthService) arg2).getType();
return res;
}

Expand Down
Expand Up @@ -63,7 +63,7 @@ public void setSettings(@Facebook OAuthServiceSettings settings) {
/*
* (non-Javadoc)
*
* @see org.jboss.seam.social.oauth.OAuthServiceHandler#getServiceLogo()
* @see org.jboss.seam.social.oauth.OAuthService#getServiceLogo()
*/
@Override
public String getServiceLogo() {
Expand All @@ -73,7 +73,7 @@ public String getServiceLogo() {
/*
* (non-Javadoc)
*
* @see org.jboss.seam.social.oauth.OAuthServiceHandler#getUser()
* @see org.jboss.seam.social.oauth.OAuthService#getUser()
*/
@Override
public UserProfile getUser() {
Expand All @@ -87,7 +87,7 @@ public UserProfile getUser() {
/*
* (non-Javadoc)
*
* @see org.jboss.seam.social.oauth.OAuthServiceHandler#getType()
* @see org.jboss.seam.social.oauth.OAuthService#getType()
*/
@Override
public String getType() {
Expand Down
Expand Up @@ -91,7 +91,7 @@ protected Class<? extends Api> getApiClass() {
/*
* (non-Javadoc)
*
* @see org.jboss.seam.social.oauth.OAuthServiceHandler#getServiceLogo()
* @see org.jboss.seam.social.oauth.OAuthService#getServiceLogo()
*/
@Override
public String getServiceLogo() {
Expand All @@ -101,7 +101,7 @@ public String getServiceLogo() {
/*
* (non-Javadoc)
*
* @see org.jboss.seam.social.oauth.OAuthServiceHandler#getUserProfile()
* @see org.jboss.seam.social.oauth.OAuthService#getUserProfile()
*/
@Override
public UserProfile getUser() {
Expand All @@ -125,7 +125,7 @@ protected Profile getLinkedInProfile() {
/*
* (non-Javadoc)
*
* @see org.jboss.seam.social.oauth.OAuthServiceHandler#getType()
* @see org.jboss.seam.social.oauth.OAuthService#getType()
*/
@Override
public String getType() {
Expand Down
Expand Up @@ -26,22 +26,22 @@
import org.scribe.model.OAuthRequest;
import org.scribe.model.Verb;
import org.scribe.model.Verifier;
import org.scribe.oauth.OAuthService;


/**
* @author Antoine Sabot-Durand
*
*/

public abstract class OAuthServiceHandlerScribe implements OAuthServiceHandler, Serializable {
public abstract class OAuthServiceHandlerScribe implements OAuthService, Serializable {

/**
*
*/
private static final long serialVersionUID = -8423894021913341674L;
private static final String VERIFIER_PARAM_NAME = "oauth_verifier";

private OAuthService service;
private org.scribe.oauth.OAuthService service;

protected OAuthTokenScribe requestToken;
protected OAuthTokenScribe accessToken;
Expand All @@ -64,7 +64,7 @@ public void setStatus(String status) {
this.status = status;
}

protected OAuthService getService() {
protected org.scribe.oauth.OAuthService getService() {
if (service == null)
initService();
return service;
Expand Down
Expand Up @@ -23,7 +23,7 @@
*/
public abstract class SettedHandlerProducer {

protected <T extends OAuthServiceHandler> T setService(InjectionPoint ip, T hdl) {
protected <T extends OAuthService> T setService(InjectionPoint ip, T hdl) {
if (ip == null || ip.getAnnotated() == null || hdl == null)
return null;
Setted setted = ip.getAnnotated().getAnnotation(Setted.class);
Expand Down
Expand Up @@ -82,7 +82,7 @@ protected Class<? extends Api> getApiClass() {
/*
* (non-Javadoc)
*
* @see org.jboss.seam.social.oauth.OAuthServiceHandler#getServiceLogo()
* @see org.jboss.seam.social.oauth.OAuthService#getServiceLogo()
*/
@Override
public String getServiceLogo() {
Expand All @@ -92,7 +92,7 @@ public String getServiceLogo() {
/*
* (non-Javadoc)
*
* @see org.jboss.seam.social.oauth.OAuthServiceHandler#getUserProfile()
* @see org.jboss.seam.social.oauth.OAuthService#getUserProfile()
*/
@Override
public UserProfile getUser() {
Expand All @@ -106,7 +106,7 @@ public UserProfile getUser() {
/*
* (non-Javadoc)
*
* @see org.jboss.seam.social.oauth.OAuthServiceHandler#getType()
* @see org.jboss.seam.social.oauth.OAuthService#getType()
*/
@Override
public String getType() {
Expand Down

0 comments on commit f9cdd64

Please sign in to comment.