Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
apollo
Commits
bf722d5c
Commit
bf722d5c
authored
Jun 27, 2016
by
Jason Song
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
return users assigned and adjust rest template timeout
parent
78912008
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
7 deletions
+24
-7
RestTemplateFactory.java
...rip/framework/apollo/common/auth/RestTemplateFactory.java
+9
-5
CtripUserService.java
.../ctrip/framework/apollo/portal/auth/CtripUserService.java
+10
-1
RolePermissionService.java
...ramework/apollo/portal/service/RolePermissionService.java
+5
-1
No files found.
apollo-common/src/main/java/com/ctrip/framework/apollo/common/auth/RestTemplateFactory.java
View file @
bf722d5c
package
com
.
ctrip
.
framework
.
apollo
.
common
.
auth
;
import
java.io.UnsupportedEncodingException
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
com.google.common.io.BaseEncoding
;
import
org.apache.http.Header
;
import
org.apache.http.auth.AuthScope
;
...
...
@@ -19,7 +17,9 @@ import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.RestTemplate
;
import
com.google.common.io.BaseEncoding
;
import
java.io.UnsupportedEncodingException
;
import
java.util.ArrayList
;
import
java.util.Collection
;
@Component
public
class
RestTemplateFactory
implements
FactoryBean
<
RestTemplate
>,
InitializingBean
{
...
...
@@ -54,7 +54,11 @@ public class RestTemplateFactory implements FactoryBean<RestTemplate>, Initializ
.
setDefaultHeaders
(
defaultHeaders
).
build
();
restTemplate
=
new
RestTemplate
(
httpMessageConverters
.
getConverters
());
restTemplate
.
setRequestFactory
(
new
HttpComponentsClientHttpRequestFactory
(
httpClient
));
HttpComponentsClientHttpRequestFactory
requestFactory
=
new
HttpComponentsClientHttpRequestFactory
(
httpClient
);
requestFactory
.
setConnectTimeout
(
3000
);
requestFactory
.
setReadTimeout
(
10000
);
restTemplate
.
setRequestFactory
(
requestFactory
);
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/auth/CtripUserService.java
View file @
bf722d5c
...
...
@@ -12,6 +12,8 @@ import org.springframework.core.ParameterizedTypeReference;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.client.ClientHttpRequestFactory
;
import
org.springframework.http.client.SimpleClientHttpRequestFactory
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.client.RestTemplate
;
...
...
@@ -31,13 +33,20 @@ public class CtripUserService implements UserService {
public
CtripUserService
(
ServerConfigService
serverConfigService
)
{
this
.
serverConfigService
=
serverConfigService
;
this
.
restTemplate
=
new
RestTemplate
();
this
.
restTemplate
=
new
RestTemplate
(
clientHttpRequestFactory
()
);
this
.
searchUserMatchFields
=
Lists
.
newArrayList
(
"empcode"
,
"empaccount"
,
"displayname"
,
"c_name"
,
"pinyin"
);
this
.
responseType
=
new
ParameterizedTypeReference
<
Map
<
String
,
List
<
UserServiceResponse
>>>()
{
};
}
private
ClientHttpRequestFactory
clientHttpRequestFactory
()
{
SimpleClientHttpRequestFactory
factory
=
new
SimpleClientHttpRequestFactory
();
factory
.
setReadTimeout
(
3000
);
factory
.
setConnectTimeout
(
5000
);
return
factory
;
}
@Override
public
List
<
UserInfo
>
searchUsers
(
String
keyword
,
int
offset
,
int
limit
)
{
UserServiceRequest
request
=
assembleSearchUserRequest
(
keyword
,
offset
,
limit
);
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/RolePermissionService.java
View file @
bf722d5c
...
...
@@ -87,9 +87,12 @@ public class RolePermissionService implements InitializingBean {
/**
* Assign role to users
*
* @return the users assigned roles
*/
@Transactional
public
void
assignRoleToUsers
(
String
roleName
,
Set
<
String
>
userIds
,
String
operatorUserId
)
{
public
Set
<
String
>
assignRoleToUsers
(
String
roleName
,
Set
<
String
>
userIds
,
String
operatorUserId
)
{
Role
role
=
findRoleByRoleName
(
roleName
);
Preconditions
.
checkState
(
role
!=
null
,
"Role %s doesn't exist!"
,
roleName
);
...
...
@@ -110,6 +113,7 @@ public class RolePermissionService implements InitializingBean {
});
userRoleRepository
.
save
(
toCreate
);
return
toAssignUserIds
;
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment