Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added Linkedin Connect and fixed few compilation errors #1

Open
wants to merge 2 commits into from

2 participants

@shravanmahankali

Hi There,

Added linkedin connect and replaced following no more available classes causing compilation failures:
-> "org.springframework.social.connect.signin.web.ProviderUserSignInController" class with "org.springframework.social.connect.signin.web.ProviderSignInController",
-> "org.springframework.social.connect.signin.web.ProviderUserSignInUtils" class with "org.springframework.social.connect.signin.web.ProviderSignInUtils".

NOTE: Please add the SpringSource "linkedin.consumerKey" and "linkedin.consumerSecret" in the following file src\main\webapp\WEB-INF\spring\properties.xml to make linkedin connect working.

PS: Here I have briefed my work - http://shravanmahankali.wordpress.com/2011/04/21/spring-social-and-linkedin/ (this draft is based on my work on spring-social 1.0.0.M2 version, which is not committed due to various differences.)

Let me know if need any information.

Thank You,
Shravan

shravanmahan... added some commits
shravanmahankali Added linkedin connect and replaced following no more available class…
…es causing compilation failures:

"org.springframework.social.connect.signin.web.ProviderUserSignInController" class with "org.springframework.social.connect.signin.web.ProviderSignInController",
"org.springframework.social.connect.signin.web.ProviderUserSignInUtils" class with "org.springframework.social.connect.signin.web.ProviderSignInUtils"
e472b34
shravanmahankali Added linkedin connect ed8e913
@shravanmahankali shravanmahankali commented on the diff
...ramework/social/showcase/signup/SignupController.java
@@ -54,7 +54,7 @@ public class SignupController {
}
boolean accountCreated = createAccount(form, formBinding);
if (accountCreated) {
- ProviderUserSignInUtils.handlePostSignUp(request);

ProviderUserSignInUtils is being replaced by ProviderSignInUtils

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@shravanmahankali shravanmahankali commented on the diff
...main/webapp/WEB-INF/spring/appServlet/controllers.xml
@@ -20,7 +20,7 @@
</property>
</bean>
- <bean class="org.springframework.social.connect.signin.web.ProviderUserSignInController">
+ <bean class="org.springframework.social.connect.signin.web.ProviderSignInController">

ProviderUserSignInController is being replaced by ProviderSignInController

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@shravanmahankali

would anyone review this change and merge to main source?

@kdonald

Have you merged with the latest changes in master? Some of the changes I'm seeing have already been applied. Need to make sure your changes can be applied on top of the latest. See Github help & http://blog.springsource.com/2010/12/21/social-coding-in-spring-projects/ for some guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 25, 2011
  1. Added linkedin connect and replaced following no more available class…

    shravanmahankali authored
    …es causing compilation failures:
    
    "org.springframework.social.connect.signin.web.ProviderUserSignInController" class with "org.springframework.social.connect.signin.web.ProviderSignInController",
    "org.springframework.social.connect.signin.web.ProviderUserSignInUtils" class with "org.springframework.social.connect.signin.web.ProviderSignInUtils"
  2. Added linkedin connect

    shravanmahankali authored
This page is out of date. Refresh to see the latest.
Showing with 258 additions and 4 deletions.
  1. +1 −0  spring-social-showcase/README
  2. +6 −0 spring-social-showcase/pom.xml
  3. +2 −0  spring-social-showcase/src/main/java/org/springframework/social/showcase/ConnectedToHandlerInterceptor.java
  4. +8 −0 spring-social-showcase/src/main/java/org/springframework/social/showcase/config/ServiceApisConfig.java
  5. +27 −0 ...cial-showcase/src/main/java/org/springframework/social/showcase/linkedin/LinkedInConnectionsController.java
  6. +51 −0 ...g-social-showcase/src/main/java/org/springframework/social/showcase/linkedin/LinkedInProfileController.java
  7. +2 −2 spring-social-showcase/src/main/java/org/springframework/social/showcase/signup/SignupController.java
  8. +8 −0 spring-social-showcase/src/main/webapp/WEB-INF/layouts/menu.jsp
  9. +1 −1  spring-social-showcase/src/main/webapp/WEB-INF/spring/appServlet/controllers.xml
  10. +4 −0 spring-social-showcase/src/main/webapp/WEB-INF/spring/connect.xml
  11. +2 −0  spring-social-showcase/src/main/webapp/WEB-INF/spring/properties.xml
  12. +17 −0 spring-social-showcase/src/main/webapp/WEB-INF/views/connect/linkedinConnect.jsp
  13. +19 −0 spring-social-showcase/src/main/webapp/WEB-INF/views/connect/linkedinConnected.jsp
  14. +8 −0 spring-social-showcase/src/main/webapp/WEB-INF/views/connect/tiles.xml
  15. +17 −0 spring-social-showcase/src/main/webapp/WEB-INF/views/linkedin/connections.jsp
  16. +40 −0 spring-social-showcase/src/main/webapp/WEB-INF/views/linkedin/linkedin.jsp
  17. +24 −0 spring-social-showcase/src/main/webapp/WEB-INF/views/linkedin/profile.jsp
  18. +14 −0 spring-social-showcase/src/main/webapp/WEB-INF/views/linkedin/tiles.xml
  19. +7 −1 spring-social-showcase/src/main/webapp/resources/page.css
  20. BIN  spring-social-showcase/src/main/webapp/resources/social/linkedin/connect_with_linkedin-logo-150x150.jpg
View
1  spring-social-showcase/README
@@ -1,6 +1,7 @@
This sample app demonstrates many of the capabilities of the Spring Social project, including:
- Connect to Facebook
- Connect to Twitter
+- Connect to LinkedIn
- Sign in using Facebook
- Sign in using Twitter
View
6 spring-social-showcase/pom.xml
@@ -59,6 +59,11 @@
<artifactId>spring-social-twitter</artifactId>
<version>${org.springframework.social-version}</version>
</dependency>
+ <dependency>
+ <groupId>org.springframework.social</groupId>
+ <artifactId>spring-social-linkedin</artifactId>
+ <version>${org.springframework.social-version}</version>
+ </dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-web</artifactId>
@@ -265,5 +270,6 @@
<version>1.0-beta-1</version>
</plugin>
</plugins>
+ <finalName>spring-social-showcase</finalName>
</build>
</project>
View
2  ...case/src/main/java/org/springframework/social/showcase/ConnectedToHandlerInterceptor.java
@@ -6,6 +6,7 @@
import org.springframework.social.connect.ServiceProviderConnectionRepository;
import org.springframework.social.facebook.api.FacebookApi;
+import org.springframework.social.linkedin.api.LinkedInApi;
import org.springframework.social.twitter.api.TwitterApi;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
@@ -19,6 +20,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
if (request.getUserPrincipal() != null) {
request.setAttribute("connectedToTwitter", connectionRepository.findPrimaryConnectionToServiceApi(TwitterApi.class) != null);
request.setAttribute("connectedToFacebook", connectionRepository.findPrimaryConnectionToServiceApi(FacebookApi.class) != null);
+ request.setAttribute("connectedToLinkedIn", connectionRepository.findPrimaryConnectionToServiceApi(LinkedInApi.class) != null);
}
return true;
}
View
8 ...-showcase/src/main/java/org/springframework/social/showcase/config/ServiceApisConfig.java
@@ -9,6 +9,7 @@
import org.springframework.social.connect.ServiceProviderConnection;
import org.springframework.social.connect.ServiceProviderConnectionRepository;
import org.springframework.social.facebook.api.FacebookApi;
+import org.springframework.social.linkedin.api.LinkedInApi;
import org.springframework.social.tripit.api.TripItApi;
import org.springframework.social.twitter.api.TwitterApi;
@@ -38,5 +39,12 @@ public TwitterApi twitterApi() {
ServiceProviderConnection<TwitterApi> connection = connectionRepository.findPrimaryConnectionToServiceApi(TwitterApi.class);
return connection != null ? connection.getServiceApi() : null;
}
+
+ @Bean
+ @Scope(value="request", proxyMode=ScopedProxyMode.INTERFACES)
+ public LinkedInApi linkedInApi() {
+ ServiceProviderConnection<LinkedInApi> connection = connectionRepository.findPrimaryConnectionToServiceApi(LinkedInApi.class);
+ return connection != null ? connection.getServiceApi() : null;
+ }
}
View
27 ...main/java/org/springframework/social/showcase/linkedin/LinkedInConnectionsController.java
@@ -0,0 +1,27 @@
+package org.springframework.social.showcase.linkedin;
+
+import javax.inject.Inject;
+
+import org.springframework.social.linkedin.api.LinkedInApi;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+@Controller
+public class LinkedInConnectionsController {
+
+ private final LinkedInApi linkedInApi;
+
+ @Inject
+ public LinkedInConnectionsController(LinkedInApi linkedInApi) {
+ this.linkedInApi = linkedInApi;
+ }
+
+ @RequestMapping(value="/linkedin/connections", method=RequestMethod.GET)
+ public String showFeed(Model model) {
+ model.addAttribute("connections", linkedInApi.getConnections());
+ return "linkedin/connections";
+ }
+
+}
View
51 ...src/main/java/org/springframework/social/showcase/linkedin/LinkedInProfileController.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2011 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.social.showcase.linkedin;
+
+import javax.inject.Inject;
+
+import org.springframework.social.connect.ServiceProviderConnection;
+import org.springframework.social.connect.ServiceProviderConnectionRepository;
+import org.springframework.social.linkedin.api.LinkedInApi;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+@Controller
+public class LinkedInProfileController {
+
+ private final ServiceProviderConnectionRepository connectionRepository;
+
+ private final LinkedInApi linkedInApi;
+
+ @Inject
+ public LinkedInProfileController(ServiceProviderConnectionRepository connectionRepository, LinkedInApi linkedInApi) {
+ this.connectionRepository = connectionRepository;
+ this.linkedInApi = linkedInApi;
+ }
+
+ @RequestMapping(value="/linkedin", method=RequestMethod.GET)
+ public String home(Model model) {
+ ServiceProviderConnection<LinkedInApi> connection = connectionRepository.findPrimaryConnectionToServiceApi(LinkedInApi.class);
+ if (connection == null) {
+ return "redirect:/connect/linkedin";
+ }
+ model.addAttribute("profile", linkedInApi.getUserProfile());
+ return "linkedin/profile";
+ }
+
+}
View
4 ...l-showcase/src/main/java/org/springframework/social/showcase/signup/SignupController.java
@@ -18,7 +18,7 @@
import javax.inject.Inject;
import javax.validation.Valid;
-import org.springframework.social.connect.signin.web.ProviderUserSignInUtils;
+import org.springframework.social.connect.signin.web.ProviderSignInUtils;
import org.springframework.social.showcase.account.Account;
import org.springframework.social.showcase.account.AccountRepository;
import org.springframework.social.showcase.account.UsernameAlreadyInUseException;
@@ -54,7 +54,7 @@ public String signup(@Valid SignupForm form, BindingResult formBinding, WebReque
}
boolean accountCreated = createAccount(form, formBinding);
if (accountCreated) {
- ProviderUserSignInUtils.handlePostSignUp(request);

ProviderUserSignInUtils is being replaced by ProviderSignInUtils

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ ProviderSignInUtils.handlePostSignUp(request);
return "redirect:/";
}
return null;
View
8 spring-social-showcase/src/main/webapp/WEB-INF/layouts/menu.jsp
@@ -24,3 +24,11 @@
</c:if>
<h4><a href="<c:url value="/tripit"/>">TripIt</a></h4>
+
+<h4><a href="<c:url value="/linkedin"/>">LinkedIn</a></h4>
+<c:if test="${connectedToLinkedIn}">
+<ul class="menu">
+ <li><a href="<c:url value="/linkedin"/>">User Profile</a></li>
+ <li><a href="<c:url value="/linkedin/connections"/>">Connections</a></li>
+</ul>
+</c:if>
View
2  spring-social-showcase/src/main/webapp/WEB-INF/spring/appServlet/controllers.xml
@@ -20,7 +20,7 @@
</property>
</bean>
- <bean class="org.springframework.social.connect.signin.web.ProviderUserSignInController">
+ <bean class="org.springframework.social.connect.signin.web.ProviderSignInController">

ProviderUserSignInController is being replaced by ProviderSignInController

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
<constructor-arg value="${application.url}" />
</bean>
View
4 spring-social-showcase/src/main/webapp/WEB-INF/spring/connect.xml
@@ -26,6 +26,10 @@
<constructor-arg value="${tripit.consumerKey}" />
<constructor-arg value="${tripit.consumerSecret}" />
</bean>
+ <bean class="org.springframework.social.linkedin.connect.LinkedInServiceProviderConnectionFactory">
+ <constructor-arg value="${linkedin.consumerKey}" />
+ <constructor-arg value="${linkedin.consumerSecret}" />
+ </bean>
</list>
</property>
</bean>
View
2  spring-social-showcase/src/main/webapp/WEB-INF/spring/properties.xml
@@ -16,6 +16,8 @@
<prop key="twitter.consumerSecret">Kb8hS0luftwCJX3qVoyiLUMfZDtK1EozFoUkjNLUMx4</prop>
<prop key="tripit.consumerKey">ee68437fbf8f42315a1b1ebe5a2a3009bd3f5cf9</prop>
<prop key="tripit.consumerSecret">6b3cf4d183cc02076d068eea91080ca0bf666336</prop>
+ <prop key="linkedin.consumerKey"></prop>
+ <prop key="linkedin.consumerSecret"></prop>
</util:properties>
</beans>
View
17 spring-social-showcase/src/main/webapp/WEB-INF/views/connect/linkedinConnect.jsp
@@ -0,0 +1,17 @@
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
+<%@ taglib uri="http://www.springframework.org/tags" prefix="s" %>
+<%@ taglib uri="http://www.springframework.org/tags/form" prefix="sf" %>
+<%@ page session="false" %>
+
+<h3>Connect to LinkedIn</h3>
+
+<form action="<c:url value="/connect/linkedin" />" method="POST">
+ <div class="formInfo">
+ <p>
+ You haven't created any connections with LinkedIn yet. Click the button to connect Spring Social Showcase with your LinkedIn account.
+ (You'll be redirected to LinkedIn where you'll be asked to authorize the connection.)
+ </p>
+ </div>
+ <p><button type="submit"><img src="<c:url value="/resources/social/linkedin/connect_with_linkedin-logo-150x150.jpg" />" width="40px"/></button></p>
+</form>
View
19 spring-social-showcase/src/main/webapp/WEB-INF/views/connect/linkedinConnected.jsp
@@ -0,0 +1,19 @@
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://www.springframework.org/tags" prefix="s" %>
+<%@ page session="false" %>
+
+<h3>Connected to LinkedIn</h3>
+
+<form id="disconnect" method="post">
+ <div class="formInfo">
+ <p>
+ Spring Social Showcase is connected to your LinkedIn account.
+ Click the button if you wish to disconnect.
+ </p>
+ </div>
+
+ <button type="submit">Disconnect</button>
+ <input type="hidden" name="_method" value="delete" />
+</form>
+
+<p><a href="<c:url value="/linkedin" />">View your LinkedIn profile</a></p>
View
8 spring-social-showcase/src/main/webapp/WEB-INF/views/connect/tiles.xml
@@ -26,5 +26,13 @@
<definition name="connect/tripitConnected" extends="page">
<put-attribute name="content" value="/WEB-INF/views/connect/tripitConnected.jsp" />
</definition>
+
+ <definition name="connect/linkedinConnect" extends="page">
+ <put-attribute name="content" value="/WEB-INF/views/connect/linkedinConnect.jsp" />
+ </definition>
+
+ <definition name="connect/linkedinConnected" extends="page">
+ <put-attribute name="content" value="/WEB-INF/views/connect/linkedinConnected.jsp" />
+ </definition>
</tiles-definitions>
View
17 spring-social-showcase/src/main/webapp/WEB-INF/views/linkedin/connections.jsp
@@ -0,0 +1,17 @@
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
+<%@ taglib uri="http://www.springframework.org/tags/form" prefix="sf" %>
+<%@ page session="false" %>
+
+<h3>Your LinkedIn Connections</h3>
+
+<ul class="friends">
+<c:forEach items="${connections}" var="connection" varStatus="status">
+ <c:choose>
+ <c:when test="${status.count%2 == 0}"><c:set var="altrow" value="evenrow"/></c:when>
+ <c:otherwise><c:set var="altrow" value="oddrow"/></c:otherwise>
+ </c:choose>
+ <li class="${altrow}"><a href="${connection.standardProfileUrl}" target="_blank"><c:out value="${connection.firstName}"/>&nbsp;
+ <c:out value="${connection.lastName}"/></a>&nbsp;<sub><c:out value="${connection.headline}"/></sub>&nbsp;@&nbsp;<c:out value="${connection.industry}"/></li>
+</c:forEach>
+</ul>
View
40 spring-social-showcase/src/main/webapp/WEB-INF/views/linkedin/linkedin.jsp
@@ -0,0 +1,40 @@
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
+<%@ taglib uri="http://www.springframework.org/tags" prefix="s" %>
+<%@ taglib uri="http://www.springframework.org/tags/form" prefix="sf" %>
+<%@ page session="false" %>
+<html>
+<head>
+ <title>Spring Social Showcase: LinkedIn</title>
+ <style type="text/css">
+ .evenrow {background-color:white;}
+ .oddrow {background-color:lightgrey;}
+ </style>
+</head>
+<body>
+ <h1>Spring Social Showcase: LinkedIn</h1>
+ <p>Hello, <c:out value="${linkedInApi.userProfile.firstName}"/> &nbsp; <c:out value="${linkedInApi.userProfile.lastName}"/>! (<a href="<c:url value="/connect/linkedin"/>">Disconnect from Facebook</a>)</p>
+ <p>Your LinkedIn profile:</p>
+ <dl>
+ <dt>LinkedIn ID:</dt>
+ <dd><a href="${linkedInApi.profileUrl}" target="_blank"><c:out value="${linkedInApi.userProfile.id}"/></a></dd>
+ <dt>Industry:</dt>
+ <dd><c:out value="${linkedInApi.userProfile.industry}"/></dd>
+ <dt>Headline:</dt>
+ <dd><c:out value="${linkedInApi.userProfile.headline}"/></dd>
+ <dt id="friendsIds">Connections:</dt>
+ <dd><ol>
+ <c:forEach items="${linkedInApi.connections}" var="connection" varStatus="status">
+ <c:choose>
+ <c:when test="${status.count%2 == 0}"><c:set var="altrow" value="evenrow"/></c:when>
+ <c:otherwise><c:set var="altrow" value="oddrow"/></c:otherwise>
+ </c:choose>
+ <li class="${altrow}"><a href="${connection.standardProfileUrl}" target="_blank"><c:out value="${connection.firstName}"/>&nbsp;
+ <c:out value="${connection.lastName}"/></a>&nbsp;<sub><c:out value="${connection.headline}"/></sub>&nbsp;@&nbsp;<c:out value="${connection.industry}"/></li>
+ </c:forEach>
+ </ol></dd>
+ </dl>
+
+ <p><a href="<s:url value="/" />">Return to home page</a></p>
+</body>
+</html>
View
24 spring-social-showcase/src/main/webapp/WEB-INF/views/linkedin/profile.jsp
@@ -0,0 +1,24 @@
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
+<%@ taglib uri="http://www.springframework.org/tags/form" prefix="sf" %>
+<%@ page session="false" %>
+
+<h3>Your LinkedIn Profile</h3>
+<p>Hello, <c:out value="${profile.firstName}"/>!</p>
+<img src="<c:out value="${profile.profilePictureUrl}"/>" alt="Seems your profile image is not accessible" title=""/>
+<dl>
+ <dt>LinkedIn ID:</dt>
+ <dd><a href="${profile.standardProfileUrl}" target="_blank"><c:out value="${profile.id}"/></a></dd>
+ <dt>Name:</dt>
+ <dd><c:out value="${profile.firstName}"/>&nbsp;<c:out value="${profile.lastName}"/></dd>
+ <dt>Industry:</dt>
+ <dd><c:out value="${profile.industry}"/></dd>
+ <dt>Headline:</dt>
+ <dd><c:out value="${profile.headline}"/></dd>
+</dl>
+
+<c:url value="/connect/linkedin" var="disconnectUrl"/>
+<form id="disconnect" action="${disconnectUrl}" method="post">
+ <button type="submit">Disconnect from LinkedIn</button>
+ <input type="hidden" name="_method" value="delete" />
+</form>
View
14 spring-social-showcase/src/main/webapp/WEB-INF/views/linkedin/tiles.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN" "http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
+
+<tiles-definitions>
+
+ <definition name="linkedin/profile" extends="page">
+ <put-attribute name="content" value="/WEB-INF/views/linkedin/profile.jsp" />
+ </definition>
+
+ <definition name="linkedin/connections" extends="page">
+ <put-attribute name="content" value="/WEB-INF/views/linkedin/connections.jsp" />
+ </definition>
+
+</tiles-definitions>
View
8 spring-social-showcase/src/main/webapp/resources/page.css
@@ -99,4 +99,10 @@ ul.choices li {
ul.choices li:first-child {
padding-left: 0px;
border-left: none;
-}
+}
+
+.evenrow {background-color:white;}
+
+.oddrow {background-color:lightgrey;}
+
+img {color:red; font-size:small; font-style:italic;}
View
BIN  ...showcase/src/main/webapp/resources/social/linkedin/connect_with_linkedin-logo-150x150.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Something went wrong with that request. Please try again.