• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DuplicateConnectionException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.social.connect.DuplicateConnectionException的典型用法代码示例。如果您正苦于以下问题:Java DuplicateConnectionException类的具体用法?Java DuplicateConnectionException怎么用?Java DuplicateConnectionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DuplicateConnectionException类属于org.springframework.social.connect包,在下文中一共展示了DuplicateConnectionException类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createRemoteUser

import org.springframework.social.connect.DuplicateConnectionException; //导入依赖的package包/类
@Transactional(
    readOnly = false,
    propagation = Propagation.REQUIRED
)
public RemoteUser createRemoteUser(String userId, String providerId, String providerUserId, int rank, String displayName, String profileUrl, String imageUrl, String accessToken, String secret, String refreshToken, Long expireTime) {
    AbstractUserConnection remoteUser = this.createNewUserConnection(userId, providerId, providerUserId, rank, displayName, profileUrl, imageUrl, accessToken, secret, refreshToken, expireTime);

    try {
        RemoteUser e = this.get(userId, providerId, providerUserId);
        if(e != null) {
            throw new DuplicateConnectionException(new ConnectionKey(providerId, providerUserId));
        }
    } catch (EmptyResultDataAccessException var14) {
        ;
    }

    this.save(remoteUser);
    return remoteUser;
}
 
开发者ID:chocotan,项目名称:lolibox,代码行数:20,代码来源:AbstractUserConnectionJpaDao.java


示例2: addConnection

import org.springframework.social.connect.DuplicateConnectionException; //导入依赖的package包/类
@Override
@Transactional
public void addConnection(final Connection<?> connection) {

    final ConnectionData connectionData = connection.createData();
    final String providerId = connectionData.getProviderId();
    final String providerUserId = connectionData.getProviderUserId();

    final int rank = userConnectionRepository.findRank(user, providerId);

    final UserConnection userConnection = Functions.toUserConnection(textEncryptor, rank, user)
                                                   .apply(connectionData);

    if (userConnectionRepository.findOne(user, providerId, providerUserId) != null) {
        throw new DuplicateConnectionException(connection.getKey());
    }
    userConnectionRepository.save(userConnection);
}
 
开发者ID:martinlau,项目名称:unidle-old,代码行数:19,代码来源:ConnectionRepositoryImpl.java


示例3: testAddConnectionWithDuplicate

import org.springframework.social.connect.DuplicateConnectionException; //导入依赖的package包/类
@Test(expected = DuplicateConnectionException.class)
public void testAddConnectionWithDuplicate() throws Exception {
    final ConnectionData connectionData = new ConnectionData("twitter",
                                                             "provider user id 3",
                                                             "display name",
                                                             "profile url",
                                                             "image url",
                                                             "access token",
                                                             "secret",
                                                             "refresh token",
                                                             1234L);
    final Connection<?> connection = new ConnectionStub<>(connectionData);

    subject.addConnection(connection);
    subject.addConnection(connection);
}
 
开发者ID:martinlau,项目名称:unidle-old,代码行数:17,代码来源:ConnectionRepositoryImplTest.java


示例4: addConnection

import org.springframework.social.connect.DuplicateConnectionException; //导入依赖的package包/类
public void addConnection(Connection<?> connection) {
	try {
		ConnectionData data = connection.createData();
		SQLiteDatabase db = repositoryHelper.getWritableDatabase();

		// generate rank
		final String sql = "select coalesce(max(rank) + 1, 1) as rank from UserConnection where userId = ? and providerId = ?";
		final String[] selectionArgs = { userId, data.getProviderId() };
		Cursor c = db.rawQuery(sql, selectionArgs);
		c.moveToFirst();
		int rank = c.getInt(c.getColumnIndex("rank"));
		c.close();

		// insert connection
		ContentValues values = new ContentValues();
		values.put("userId", userId);
		values.put("providerId", data.getProviderId());
		values.put("providerUserId", data.getProviderUserId());
		values.put("rank", rank);
		values.put("displayName", data.getDisplayName());
		values.put("profileUrl", data.getProfileUrl());
		values.put("imageUrl", data.getImageUrl());
		values.put("accessToken", encrypt(data.getAccessToken()));
		values.put("secret", encrypt(data.getSecret()));
		values.put("refreshToken", encrypt(data.getRefreshToken()));
		values.put("expireTime", data.getExpireTime());
		db.insertOrThrow("UserConnection", null, values);
		db.close();
	} catch (SQLiteConstraintException e) {
		throw new DuplicateConnectionException(connection.getKey());
	}
}
 
开发者ID:bestarandyan,项目名称:ShoppingMall,代码行数:33,代码来源:SQLiteConnectionRepository.java


示例5: addConnection

import org.springframework.social.connect.DuplicateConnectionException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Transactional
public void addConnection(Connection<?> connection) {
	try {
		ConnectionData cd = connection.createData();
		// Get next rank, default to 1
		TypedQuery<Integer> nextRankQuery = entityManager.createQuery(QUERY_NEXT_RANK, Integer.class)
				                                         .setParameter("userId", userId)
				                                         .setParameter("providerId", cd.getProviderId());
		Integer nextRank = nextRankQuery.getSingleResult();
		// Build & persist new AppUserSocialConnection object
		AppUser appUser = entityManager.find(AppUser.class, userId);
		AppUserSocialConnection ausc = new AppUserSocialConnection();
		ausc.setKey(new AppUserSocialConnectionKey(appUser, cd.getProviderId(), cd.getProviderUserId()));
		ausc.setRank(nextRank.intValue());
		ausc.setDisplayName(cd.getDisplayName());
		ausc.setProfileUrl(cd.getProfileUrl());
		ausc.setImageUrl(cd.getImageUrl());
		ausc.setAccessToken(encrypt(cd.getAccessToken()));
		ausc.setSecret(encrypt(cd.getSecret()));
		ausc.setRefreshToken(encrypt(cd.getRefreshToken()));
		ausc.setExpireTime(cd.getExpireTime());
		entityManager.persist(ausc);
	} catch (EntityExistsException eee) {
		throw new DuplicateConnectionException(connection.getKey());
	}
}
 
开发者ID:davejoyce,项目名称:composite-dao,代码行数:30,代码来源:JpaConnectionRepository.java


示例6: addConnection

import org.springframework.social.connect.DuplicateConnectionException; //导入依赖的package包/类
public void addConnection(Connection<?> connection) {
    //check cardinality
    SocialAuthenticationService<?> socialAuthenticationService = 
            this.socialAuthenticationServiceLocator.getAuthenticationService(connection.getKey().getProviderId());
    if (socialAuthenticationService.getConnectionCardinality() == ConnectionCardinality.ONE_TO_ONE ||
            socialAuthenticationService.getConnectionCardinality() == ConnectionCardinality.ONE_TO_MANY){
        List<UserSocialConnection> storedConnections = 
                this.userSocialConnectionRepository.findByProviderIdAndProviderUserId(
                        connection.getKey().getProviderId(), connection.getKey().getProviderUserId());
        if (storedConnections.size() > 0){
            //not allow one providerId/providerUserId connect to multiple userId
            throw new DuplicateConnectionException(connection.getKey());
        }
    }
    
    UserSocialConnection userSocialConnection = this.userSocialConnectionRepository
            .findByUserIdAndProviderIdAndProviderUserId(userId, connection.getKey().getProviderId(), 
                    connection.getKey().getProviderUserId());
    if (userSocialConnection == null) {
        ConnectionData data = connection.createData();
        userSocialConnection = new UserSocialConnection(userId, data.getProviderId(), data.getProviderUserId(), 0,
                data.getDisplayName(), data.getProfileUrl(), data.getImageUrl(), encrypt(data.getAccessToken()),
                encrypt(data.getSecret()), encrypt(data.getRefreshToken()), data.getExpireTime());
        this.userSocialConnectionRepository.save(userSocialConnection);
    } else {
        throw new DuplicateConnectionException(connection.getKey());
    }
}
 
开发者ID:jiwhiz,项目名称:JiwhizBlogWeb,代码行数:29,代码来源:MongoConnectionRepositoryImpl.java



注:本文中的org.springframework.social.connect.DuplicateConnectionException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RedisFuture类代码示例发布时间:2022-05-23
下一篇:
Java ICondition类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap