Skip to content

Commit

Permalink
Merge commit '5345b259181cdc2c84361cc7854b4754957eed46'
Browse files Browse the repository at this point in the history
Conflicts:
	src/main/webapp/assets/modules/common/history.fac.js
  • Loading branch information
phuonghuynh committed Jan 9, 2015
2 parents 1ce018f + 5345b25 commit 581009b
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import javax.annotation.Resource;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;

import static com.techlooper.entity.AccessGrant.AccessGrantBuilder.accessGrant;
import static com.techlooper.entity.UserEntity.UserEntityBuilder.userEntity;
Expand All @@ -29,60 +30,65 @@
*/
public abstract class AbstractSocialService implements SocialService {

@Resource
protected UserService userService;
@Resource
protected UserService userService;

@Resource
protected Mapper dozerBeanMapper;
@Resource
protected Mapper dozerBeanMapper;

@Resource
protected TextEncryptor textEncryptor;
@Resource
protected TextEncryptor textEncryptor;

protected SocialConfig socialConfig;
protected SocialConfig socialConfig;

public AbstractSocialService(JsonConfigRepository jsonConfigRepository, SocialProvider socialProvider) {
socialConfig = jsonConfigRepository.getSocialConfig().stream()
.filter(config -> socialProvider == config.getProvider()).findFirst().get();
}
public AbstractSocialService(JsonConfigRepository jsonConfigRepository, SocialProvider socialProvider) {
socialConfig = jsonConfigRepository.getSocialConfig().stream()
.filter(config -> socialProvider == config.getProvider()).findFirst().get();
}

public com.techlooper.entity.AccessGrant getAccessGrant(String accessCode) {
AccessGrant access = getOAuth2ConnectionFactory().getOAuthOperations().exchangeForAccess(accessCode, socialConfig.getRedirectUri(), null);
return dozerBeanMapper.map(access, com.techlooper.entity.AccessGrant.class);
}

public com.techlooper.entity.AccessGrant getAccessGrant(String accessCode) {
AccessGrant access = getOAuth2ConnectionFactory().getOAuthOperations().exchangeForAccess(accessCode, socialConfig.getRedirectUri(), null);
return dozerBeanMapper.map(access, com.techlooper.entity.AccessGrant.class);
}
public com.techlooper.entity.AccessGrant getAccessGrant(String accessToken, String accessSecret) {
OAuth1Operations oAuthOperations = getOAuth1ConnectionFactory().getOAuthOperations();
if (Optional.ofNullable(accessToken).isPresent()) {
OAuthToken token = oAuthOperations.exchangeForAccessToken(
new AuthorizedRequestToken(new OAuthToken(accessToken, null), accessSecret), null);
return dozerBeanMapper.map(token, com.techlooper.entity.AccessGrant.class);
}
OAuthToken token = oAuthOperations.fetchRequestToken(socialConfig.getRedirectUri(), null);
String authorizeUrl = oAuthOperations.buildAuthorizeUrl(token.getValue(), OAuth1Parameters.NONE);
return accessGrant().withAuthorizeUrl(authorizeUrl).build();
}

public com.techlooper.entity.AccessGrant getAccessGrant(String accessToken, String accessSecret) {
OAuth1Operations oAuthOperations = getOAuth1ConnectionFactory().getOAuthOperations();
if (Optional.ofNullable(accessToken).isPresent()) {
OAuthToken token = oAuthOperations.exchangeForAccessToken(
new AuthorizedRequestToken(new OAuthToken(accessToken, null), accessSecret), null);
return dozerBeanMapper.map(token, com.techlooper.entity.AccessGrant.class);
protected AccessGrant getAccessGrant(com.techlooper.entity.AccessGrant accessGrant) {
return new AccessGrant(accessGrant.getAccessToken(), accessGrant.getScope(), accessGrant.getRefreshToken(), accessGrant.getExpireTime());
}
OAuthToken token = oAuthOperations.fetchRequestToken(socialConfig.getRedirectUri(), null);
String authorizeUrl = oAuthOperations.buildAuthorizeUrl(token.getValue(), OAuth1Parameters.NONE);
return accessGrant().withAuthorizeUrl(authorizeUrl).build();
}

protected AccessGrant getAccessGrant(com.techlooper.entity.AccessGrant accessGrant) {
return new AccessGrant(accessGrant.getAccessToken(), accessGrant.getScope(), accessGrant.getRefreshToken(), accessGrant.getExpireTime());
}
public OAuth2ConnectionFactory getOAuth2ConnectionFactory() {
throw new UnsupportedOperationException("Method is not supported");
}

public OAuth1ConnectionFactory getOAuth1ConnectionFactory() {
throw new UnsupportedOperationException("Method is not supported");
}

public OAuth2ConnectionFactory getOAuth2ConnectionFactory() {
throw new UnsupportedOperationException("Method is not supported");
}
public abstract UserProfile getProfile(com.techlooper.entity.AccessGrant accessGrant);

public OAuth1ConnectionFactory getOAuth1ConnectionFactory() {
throw new UnsupportedOperationException("Method is not supported");
}
public UserEntity saveFootprint(com.techlooper.entity.AccessGrant accessGrant, String key) {
UserEntity entity = userService.findUserEntityByKey(key);
if (!Optional.ofNullable(entity).isPresent()) {
throw new EntityNotFoundException("Can not find User by key: " + key);
}

public abstract UserProfile getProfile(com.techlooper.entity.AccessGrant accessGrant);
CompletableFuture.supplyAsync(() -> getProfile(accessGrant)).thenAccept((profile) -> {
userEntity(entity).withProfile(socialConfig.getProvider(), profile);
userService.save(entity);
});

public UserEntity saveFootprint(com.techlooper.entity.AccessGrant accessGrant, String key) {
UserEntity entity = userService.findUserEntityByKey(key);
if (!Optional.ofNullable(entity).isPresent()) {
throw new EntityNotFoundException("Can not find User by key: " + key);
userEntity(entity).withProfile(socialConfig.getProvider(), null);
return entity;
}
userEntity(entity).withProfile(socialConfig.getProvider(), getProfile(accessGrant));
userService.save(entity);
return entity;
}
}
1 change: 1 addition & 0 deletions src/main/webapp/assets/modules/chart/chart.con.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ angular.module('Chart').controller('chartController', function ($scope, jsonValu

connectionFactory.receiveTechnicalTerms();
navigationService.reSetingPositionLangIcon();
navigationService.keepNaviBar();
});
1 change: 0 additions & 1 deletion src/main/webapp/assets/modules/common/history.fac.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ angular.module("Common").factory("historyFactory", function (jsonValue, $locatio
$("body").css("background-color", "#201d1e");
}
instance.trackHistory();

utils.sendNotification(jsonValue.notifications.changeUrl/*, current.$$route.originalPath, next.$$route.originalPath*/);
});

Expand Down
3 changes: 2 additions & 1 deletion src/main/webapp/assets/modules/common/json.val.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ angular.module("Common").constant("jsonValue", {

storage: {
key: "key",
back2Me: "back2Me"
back2Me: "back2Me",
navigation: "navigation"
},

histograms: {
Expand Down
10 changes: 7 additions & 3 deletions src/main/webapp/assets/modules/navigation/navigation.ser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
angular.module("Navigation").factory("navigationService", function (utils, jsonValue, $rootScope, $http, $location, tourService, userService) {
angular.module("Navigation").factory("navigationService", function (localStorageService, utils, jsonValue, $rootScope, $http, $location, tourService, userService) {

var $$ = {
naviControl: function () {
//localStorageService.set(jsonValue.storage.navigation, 'close');
$('.manager-navi').find('.fa-bars').on('tap click', function () {
if ($(this).hasClass('active')) {
$('.main-navi-block').animate({
Expand All @@ -22,6 +23,7 @@ angular.module("Navigation").factory("navigationService", function (utils, jsonV
});

$(this).removeClass('active');
localStorageService.set(jsonValue.storage.navigation, 'close');
}
else {
var view = utils.getView();
Expand All @@ -41,6 +43,7 @@ angular.module("Navigation").factory("navigationService", function (utils, jsonV
'width': '100%'
}).css('display', 'block');
$(this).addClass('active');
localStorageService.set(jsonValue.storage.navigation, 'open');
}
});
},
Expand Down Expand Up @@ -156,15 +159,16 @@ angular.module("Navigation").factory("navigationService", function (utils, jsonV
$('.main-navi-block').css('background','url(images/line-h.png) #000 right top repeat-y');
},
keepNaviBar: function(){
utils.registerNotification(jsonValue.notifications.userInfo, function(userInfo) {
var status = localStorageService.get(jsonValue.storage.navigation);
if(status == 'open'){
$('.main-navi-block').css({
'width': '85px',
'position': 'fixed'
});
$('.navi-container').css({'width': '100%', 'display': 'block'});
$('.manager-navi').find('.fa-bars').addClass('active');
instance.addSpaceforNavi();
});
}
}
}

Expand Down

0 comments on commit 581009b

Please sign in to comment.