This repository has been archived by the owner on Apr 5, 2022. It is now read-only.
Added Linkedin Connect and fixed few compilation errors #1
Open
shravanmahankali
wants to merge
2
commits into
spring-attic:master
Choose a base branch
from
shravanmahankali:master
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...main/java/org/springframework/social/showcase/linkedin/LinkedInConnectionsController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
...src/main/java/org/springframework/social/showcase/linkedin/LinkedInProfileController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
</property> | ||
</bean> | ||
|
||
<bean class="org.springframework.social.connect.signin.web.ProviderUserSignInController"> | ||
<bean class="org.springframework.social.connect.signin.web.ProviderSignInController"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ProviderUserSignInController is being replaced by ProviderSignInController |
||
<constructor-arg value="${application.url}" /> | ||
</bean> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
spring-social-showcase/src/main/webapp/WEB-INF/views/connect/linkedinConnect.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
19 changes: 19 additions & 0 deletions
19
spring-social-showcase/src/main/webapp/WEB-INF/views/connect/linkedinConnected.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
spring-social-showcase/src/main/webapp/WEB-INF/views/linkedin/connections.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}"/> | ||
<c:out value="${connection.lastName}"/></a> <sub><c:out value="${connection.headline}"/></sub> @ <c:out value="${connection.industry}"/></li> | ||
</c:forEach> | ||
</ul> |
40 changes: 40 additions & 0 deletions
40
spring-social-showcase/src/main/webapp/WEB-INF/views/linkedin/linkedin.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}"/> <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}"/> | ||
<c:out value="${connection.lastName}"/></a> <sub><c:out value="${connection.headline}"/></sub> @ <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> |
24 changes: 24 additions & 0 deletions
24
spring-social-showcase/src/main/webapp/WEB-INF/views/linkedin/profile.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}"/> <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> |
14 changes: 14 additions & 0 deletions
14
spring-social-showcase/src/main/webapp/WEB-INF/views/linkedin/tiles.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+4.95 KB
...rc/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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ProviderUserSignInUtils is being replaced by ProviderSignInUtils