Permalink
Browse files

Added linkedin connect

  • Loading branch information...
1 parent e472b34 commit ed8e913b9961b6cd3610f90591e888050a1e4492 shravanmahankali committed Apr 25, 2011
@@ -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";
+ }
+
+}
@@ -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";
+ }
+
+}
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ed8e913

Please sign in to comment.