Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
userManagement
Commits
47631820
Commit
47631820
authored
1 year ago
by
jay pratap singh
Browse files
Options
Download
Patches
Plain Diff
changed/fixed and tested- create, update,list,activate,deactivate endpoints.
parent
8b77ba10
main
UAT_quick_fix_keycloak
UPHRH_8164_ErrorHandling
dev
dev_stable
devops-patch
feature_update_fee
github/fork/jaypratapsingh1/test_changes
keycloak_logs
payment-webhook
rahu_error_message_fix
uat
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pom.xml
+9
-14
pom.xml
src/main/java/com/tarento/upsmf/userManagement/services/UserService.java
+24
-7
...om/tarento/upsmf/userManagement/services/UserService.java
with
33 additions
and
21 deletions
+33
-21
pom.xml
+
9
−
14
View file @
47631820
...
...
@@ -2,12 +2,6 @@
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
2.7.15-SNAPSHOT
</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>
com.tarento.upsmf
</groupId>
<artifactId>
userManagement
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
...
...
@@ -15,6 +9,8 @@
<description>
userManagement project for upsmf
</description>
<properties>
<java.version>
11
</java.version>
<maven.compiler.source>
11
</maven.compiler.source>
<maven.compiler.target>
11
</maven.compiler.target>
</properties>
<dependencies>
...
...
@@ -32,18 +28,17 @@
</dependency>
<dependency>
<groupId>
org.
springframework.boot
</groupId>
<artifactId>
spring-boot-starter-tes
t
</artifactId>
<
scope>
test
</scope
>
<groupId>
org.
apache.httpcomponents
</groupId>
<artifactId>
httpclien
t
</artifactId>
<
version>
4.5.13
</version
>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-web
</artifactId>
<version>
5.3.29
</version>
<scope>
provided
</scope>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
<version>
2.7.14
</version>
</dependency>
<dependency>
<groupId>
org.tuxdude.logback.extensions
</groupId>
<artifactId>
logback-colorizer
</artifactId>
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/userManagement/services/UserService.java
+
24
−
7
View file @
47631820
package
com.tarento.upsmf.userManagement.services
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.impl.client.HttpClientBuilder
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.*
;
import
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.RestTemplate
;
...
...
@@ -16,6 +18,9 @@ import java.net.URISyntaxException;
@Component
public
class
UserService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
UserService
.
class
);
@Autowired
private
Environment
env
;
...
...
@@ -24,6 +29,7 @@ public class UserService {
private
HttpHeaders
getHeader
(){
System
.
out
.
println
(
env
.
getProperty
(
"BaseURL"
));
logger
.
info
(
"Getting headers..."
);
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
headers
.
add
(
"Authorization"
,
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJSR3RkMkZzeG1EMnJER3I4dkJHZ0N6MVhyalhZUzBSSyJ9.kMLn6177rvY53i0RAN3SPD5m3ctwaLb32pMYQ65nBdA"
);
...
...
@@ -32,23 +38,32 @@ public class UserService {
}
public
ResponseEntity
<
JsonNode
>
createUser
(
final
JsonNode
body
)
throws
URISyntaxException
{
logger
.
info
(
"Creating user..."
);
URI
uri
=
new
URI
(
BASE_URL
+
"/user/v1/sso/create"
);
HttpHeaders
headers
=
getHeader
();
HttpEntity
<
JsonNode
>
httpEntity
=
new
HttpEntity
(
body
,
headers
);
ResponseEntity
<
JsonNode
>
result
=
restTemplate
.
postForEntity
(
uri
,
httpEntity
,
JsonNode
.
class
);
return
result
;
}
public
ResponseEntity
<
JsonNode
>
updateUser
(
final
JsonNode
body
)
throws
URISyntaxException
{
public
ResponseEntity
<
JsonNode
>
updateUser
(
final
JsonNode
body
)
throws
URISyntaxException
{
logger
.
info
(
"Updating user..."
);
RestTemplate
restTemplate
=
new
RestTemplate
();
// Create HttpClient with PATCH support
HttpClient
httpClient
=
HttpClientBuilder
.
create
().
build
();
HttpComponentsClientHttpRequestFactory
requestFactory
=
new
HttpComponentsClientHttpRequestFactory
(
httpClient
);
restTemplate
.
setRequestFactory
(
requestFactory
);
URI
uri
=
new
URI
(
BASE_URL
+
"/user/v1/update"
);
HttpHeaders
headers
=
getHeader
();
HttpEntity
httpEntity
=
new
HttpEntity
(
body
,
headers
);
ResponseEntity
<
JsonNode
>
result
=
restTemplate
.
postForEntity
(
uri
,
httpEntity
,
JsonNode
.
class
);
HttpEntity
<
JsonNode
>
httpEntity
=
new
HttpEntity
<>
(
body
,
headers
);
ResponseEntity
<
JsonNode
>
result
=
restTemplate
.
exchange
(
uri
,
HttpMethod
.
PATCH
,
httpEntity
,
JsonNode
.
class
);
return
result
;
}
public
ResponseEntity
<
JsonNode
>
listUser
(
final
JsonNode
body
)
throws
URISyntaxException
{
logger
.
info
(
"Listing users..."
);
RestTemplate
restTemplate
=
new
RestTemplate
();
URI
uri
=
new
URI
(
BASE_URL
+
"/user/v1/search"
);
HttpHeaders
headers
=
getHeader
();
...
...
@@ -58,6 +73,7 @@ public class UserService {
}
public
ResponseEntity
<
JsonNode
>
activateUser
(
final
JsonNode
body
)
throws
URISyntaxException
{
logger
.
info
(
"Activating user..."
);
RestTemplate
restTemplate
=
new
RestTemplate
();
URI
uri
=
new
URI
(
BASE_URL
+
"/user/v1/unblock"
);
HttpHeaders
headers
=
getHeader
();
...
...
@@ -67,6 +83,7 @@ public class UserService {
}
public
ResponseEntity
<
JsonNode
>
deactivateUser
(
final
JsonNode
body
)
throws
URISyntaxException
{
logger
.
info
(
"Deactivating user..."
);
RestTemplate
restTemplate
=
new
RestTemplate
();
URI
uri
=
new
URI
(
BASE_URL
+
"/user/v1/block"
);
HttpHeaders
headers
=
getHeader
();
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets