Skip to content

Commit

Permalink
Issue #LR-122 chore: Replaced learner with userorg (#1201)
Browse files Browse the repository at this point in the history
  • Loading branch information
AmiableAnil authored Jun 22, 2023
1 parent 5808a96 commit 66e420d
Show file tree
Hide file tree
Showing 18 changed files with 219 additions and 217 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ jobs:
steps:
- checkout
- restore_cache:
key: lms-dependency-cache-{{ checksum "pom.xml" }}
key: userorg-dependency-cache-{{ checksum "pom.xml" }}
- run: mvn clean install
- run: cd controller && mvn play2:dist
- save_cache:
key: lms-dependency-cache-{{ checksum "pom.xml" }}
key: userorg-dependency-cache-{{ checksum "pom.xml" }}
paths: ~/.m2
- run:
name: Analyze on SonarCloud
command: mvn verify -DskipTests sonar:sonar -Dsonar.projectKey=project-sunbird_sunbird-lms-service -Dsonar.organization=project-sunbird -Dsonar.host.url=https://sonarcloud.io -Dsonar.coverage.exclusions=**/cassandra-utils/**,**/es-utils/**,**/models/**,**/model/**,**/bean/**,**/dto/**,**/bulkupload/**,**/error/**,**/exception/**,**/util/search/** -Dsonar.coverage.jacoco.xmlReportPaths=/home/circleci/project/reports/target/jacoco/jacoco.xml
command: mvn verify -DskipTests sonar:sonar -Dsonar.projectKey=Sunbird-Lern_userorg-service -Dsonar.organization=sunbird-lern -Dsonar.host.url=https://sonarcloud.io -Dsonar.coverage.exclusions=**/cassandra-utils/**,**/es-utils/**,**/models/**,**/model/**,**/bean/**,**/dto/**,**/bulkupload/**,**/error/**,**/exception/**,**/util/search/** -Dsonar.coverage.jacoco.xmlReportPaths=/home/circleci/project/reports/target/jacoco/jacoco.xml

workflows:
version: 2.1
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ RUN apk update \
&& apk add unzip \
&& apk add curl \
&& adduser -u 1001 -h /home/sunbird/ -D sunbird \
&& mkdir -p /home/sunbird/learner
&& mkdir -p /home/sunbird
#ENV sunbird_learnerstate_actor_host 52.172.24.203
#ENV sunbird_learnerstate_actor_port 8088
RUN chown -R sunbird:sunbird /home/sunbird
USER sunbird
COPY ./controller/target/learning-service-1.0-SNAPSHOT-dist.zip /home/sunbird/learner/
RUN unzip /home/sunbird/learner/learning-service-1.0-SNAPSHOT-dist.zip -d /home/sunbird/learner/
WORKDIR /home/sunbird/learner/
CMD java -XX:+PrintFlagsFinal $JAVA_OPTIONS -Dplay.server.http.idleTimeout=180s -Dlog4j2.formatMsgNoLookups=true -cp '/home/sunbird/learner/learning-service-1.0-SNAPSHOT/lib/*' play.core.server.ProdServerStart /home/sunbird/learner/learning-service-1.0-SNAPSHOT
COPY ./controller/target/userorg-service-1.0-SNAPSHOT-dist.zip /home/sunbird/
RUN unzip /home/sunbird/userorg-service-1.0-SNAPSHOT-dist.zip -d /home/sunbird/
WORKDIR /home/sunbird/
CMD java -XX:+PrintFlagsFinal $JAVA_OPTIONS -Dplay.server.http.idleTimeout=180s -Dlog4j2.formatMsgNoLookups=true -cp '/home/sunbird/userorg-service-1.0-SNAPSHOT/lib/*' play.core.server.ProdServerStart /home/sunbird/userorg-service-1.0-SNAPSHOT

8 changes: 4 additions & 4 deletions Dockerfile.Build
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ FROM openjdk:8-jdk-alpine
MAINTAINER "Manojv" "[email protected]"
WORKDIR /opt
RUN apk update \
&& mkdir -p /opt/learner \
&& mkdir -p /opt/userorg \
&& apk add wget \
&& wget http://www-eu.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz \
&& tar -xvzf apache-maven-3.3.9-bin.tar.gz
ENV M2_HOME /opt/apache-maven-3.3.9
ENV PATH ${M2_HOME}/bin:${PATH}
COPY learner /opt/learner/
WORKDIR /opt/learner/services
COPY userorg /opt/userorg/
WORKDIR /opt/userorg/services
RUN mvn clean install -DskipTests
WORKDIR /opt/learner/services/learning-service
WORKDIR /opt/userorg/services/userorg-service
CMD ["mvn", "play2:dist"]
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -eo pipefail

build_tag=$1
name=learner_service
name=userorg-service
node=$2
org=$3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class HealthController extends BaseController {
*
* @return CompletionStage<Result>
*/
public CompletionStage<Result> getHealth(Http.Request httpRequest) {
public CompletionStage<Result> health(Http.Request httpRequest) {
Request reqObj = new Request();
try {
handleSigTerm();
Expand All @@ -72,7 +72,7 @@ public CompletionStage<Result> getHealth(Http.Request httpRequest) {
*
* @return CompletionStage<Result>
*/
public CompletionStage<Result> getLearnerServiceHealth(String val, Http.Request httpRequest) {
public CompletionStage<Result> serviceHealth(String val, Http.Request httpRequest) {
Map<String, Object> finalResponseMap = new HashMap<>();
List<Map<String, Object>> responseList = new ArrayList<>();
Request reqObj = new Request();
Expand All @@ -99,11 +99,11 @@ public CompletionStage<Result> getLearnerServiceHealth(String val, Http.Request
handleSigTerm();
responseList.add(ProjectUtil.createCheckResponse(JsonKey.LEARNER_SERVICE, false, null));
finalResponseMap.put(JsonKey.CHECKS, responseList);
finalResponseMap.put(JsonKey.NAME, "Learner service health");
finalResponseMap.put(JsonKey.NAME, "UserOrg service health");
finalResponseMap.put(JsonKey.Healthy, true);
Response response = new Response();
response.getResult().put(JsonKey.RESPONSE, finalResponseMap);
response.setId("learner.service.health.api");
response.setId("api.userorg.service.health");
response.setVer(getApiVersion(httpRequest.path()));
response.setTs(Common.getFromRequest(httpRequest, Attrs.X_REQUEST_ID));
return CompletableFuture.completedFuture(ok(play.libs.Json.toJson(response)));
Expand Down
8 changes: 5 additions & 3 deletions controller/conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ POST /v1/user/create @controllers.usermanagement.User
POST /v2/user/create @controllers.usermanagement.UserController.createUser(request: play.mvc.Http.Request)
POST /v3/user/create @controllers.usermanagement.UserController.createUser(request: play.mvc.Http.Request)
POST /v1/ssouser/create @controllers.usermanagement.UserController.createSSOUser(request: play.mvc.Http.Request)

# Managed-User creation, this is not for regular user creation.
POST /v4/user/create @controllers.usermanagement.UserController.createUserV4(request: play.mvc.Http.Request)
POST /v1/manageduser/create @controllers.usermanagement.UserController.createManagedUser(request: play.mvc.Http.Request)
POST /v2/manageduser/create @controllers.usermanagement.UserController.createManagedUser(request: play.mvc.Http.Request)

# SSU user creation
POST /v1/user/signup @controllers.usermanagement.UserController.createUserV3(request: play.mvc.Http.Request)
POST /v2/user/signup @controllers.usermanagement.UserController.createSSUUser(request: play.mvc.Http.Request)
Expand Down Expand Up @@ -45,7 +47,7 @@ POST /v1/user/block @controllers.usermanagement.User
POST /v1/user/unblock @controllers.usermanagement.UserStatusController.unblockUser(request: play.mvc.Http.Request)

GET /v1/role/read @controllers.usermanagement.UserRoleController.getRoles(request: play.mvc.Http.Request)
GET /v1/user/role/read/:uid @controllers.usermanagement.UserRoleController.getUserRolesById(uid:String, request: play.mvc.Http.Request)
GET /v1/user/role/read/:uid @controllers.usermanagement.UserRoleController.getUserRolesById(uid:String, request: play.mvc.Http.Request)
POST /v1/user/assign/role @controllers.usermanagement.UserRoleController.assignRoles(request: play.mvc.Http.Request)
POST /private/user/v1/assign/role @controllers.usermanagement.UserRoleController.assignRoles(request: play.mvc.Http.Request)
POST /v2/user/assign/role @controllers.usermanagement.UserRoleController.assignRolesV2(request: play.mvc.Http.Request)
Expand Down Expand Up @@ -109,8 +111,8 @@ PATCH /v1/org/assign/key @controllers.organisationmanagem
PATCH /v1/org/update/encryptionkey @controllers.organisationmanagement.OrgController.addKey(request: play.mvc.Http.Request)

#Health check
GET /health @controllers.healthmanager.HealthController.getHealth(request: play.mvc.Http.Request)
GET /:service/health @controllers.healthmanager.HealthController.getLearnerServiceHealth(service:String, request: play.mvc.Http.Request)
GET /health @controllers.healthmanager.HealthController.health(request: play.mvc.Http.Request)
GET /:service/health @controllers.healthmanager.HealthController.serviceHealth(service:String, request: play.mvc.Http.Request)

#Notes API
POST /v1/note/create @controllers.notesmanagement.NotesController.createNote(request: play.mvc.Http.Request)
Expand Down
4 changes: 2 additions & 2 deletions controller/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.sunbird</groupId>
<artifactId>lms-service</artifactId>
<artifactId>userorg-service</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -249,7 +249,7 @@
</dependency>
</dependencies>
<build>
<finalName>learning-service-${version}</finalName>
<finalName>userorg-service-${version}</finalName>
<sourceDirectory>${basedir}/app</sourceDirectory>
<testSourceDirectory>${basedir}/test</testSourceDirectory>
<resources>
Expand Down
2 changes: 1 addition & 1 deletion controller/test/controllers/sync/SyncControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void testsync() {
Map<String, Object> requestMap = new HashMap<>();
Map<String, Object> innerMap = new HashMap<>();
innerMap.put(JsonKey.OBJECT_TYPE, JsonKey.ORGANISATION);
innerMap.put(JsonKey.OPERATION_FOR, "learner");
innerMap.put(JsonKey.OPERATION_FOR, "userorg");
requestMap.put(JsonKey.REQUEST, innerMap);
String data = mapToJson(requestMap);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static String verifyUserToken(String token, Map<String, Object> requestCo
try {
Map<String, Object> payload = validateToken(token, requestContext);
logger.debug(
"learner access token validateToken() :"
"userorg access token validateToken() :"
+ payload.toString()
+ ", request context data : "
+ requestContext);
Expand Down Expand Up @@ -135,7 +135,7 @@ public static String verifySourceUserToken(
try {
Map<String, Object> payload = validateToken(token, requestContext);
logger.debug(
"learner source access token validateToken() :"
"userorg source access token validateToken() :"
+ payload.toString()
+ ", request context data : "
+ requestContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public final class JsonKey {
public static final String LANGUAGE = "language";
public static final String LAST_LOGIN_TIME = "lastLoginTime";
public static final String LAST_NAME = "lastName";
public static final String LEARNER_SERVICE = "Learner service";
public static final String LEARNER_SERVICE = "UserOrg service";
public static final String LEVEL = "level";
public static final String LIMIT = "limit";
public static final String LIST = "List";
Expand Down
Loading

0 comments on commit 66e420d

Please sign in to comment.