├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── src ├── main │ ├── java │ │ └── com │ │ │ └── sphere │ │ │ └── compentencytool │ │ │ ├── common │ │ │ └── utils │ │ │ │ ├── package-info.java │ │ │ │ ├── propertiesCache.java │ │ │ │ └── AppProperties.java │ │ │ ├── repository │ │ │ ├── impl │ │ │ │ └── package-info.java │ │ │ ├── RolesRepository.java │ │ │ ├── UserRepository.java │ │ │ ├── DesignationsRepository.java │ │ │ ├── RoleDesignationMapRepository.java │ │ │ └── passbookRepository.java │ │ │ ├── model │ │ │ ├── GetPassbookBase.java │ │ │ ├── GetPassbook.java │ │ │ ├── Request.java │ │ │ ├── Passbook.java │ │ │ ├── RoleDesignationMap.java │ │ │ ├── User.java │ │ │ ├── Roles.java │ │ │ └── Designations.java │ │ │ ├── constants │ │ │ └── Constants.java │ │ │ ├── kafka │ │ │ └── consumer │ │ │ │ └── api │ │ │ │ ├── SearchObject.java │ │ │ │ ├── kafkaConsumer.java │ │ │ │ ├── test.java │ │ │ │ └── Api_services.java │ │ │ ├── CompentencyToolApplication.java │ │ │ ├── exception │ │ │ ├── ResourceNotFoundException.java │ │ │ ├── ErrorDetails.java │ │ │ └── GlobalExceptionHandler.java │ │ │ ├── external │ │ │ └── service │ │ │ │ ├── ExternalService.java │ │ │ │ └── impl │ │ │ │ └── ExternalServiceImpl.java │ │ │ ├── externalservice │ │ │ └── controller │ │ │ │ └── ServiceController.java │ │ │ └── controller │ │ │ └── Controller.java │ └── resources │ │ ├── logback.xml │ │ └── application.properties └── test │ └── java │ └── com │ └── sphere │ └── compentencytool │ └── CompentencyToolApplicationTests.java ├── Dockerfile.build ├── .gitignore ├── README.md ├── Dockerfile ├── Jenkinsfile ├── pom.xml ├── mvnw.cmd └── mvnw /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sphere/compentency-tool/main/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/common/utils/package-info.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.common.utils; -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/repository/impl/package-info.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.repository.impl; -------------------------------------------------------------------------------- /Dockerfile.build: -------------------------------------------------------------------------------- 1 | FROM openjdk:8 2 | 3 | RUN apt update && apt install maven -y 4 | 5 | COPY . /opt 6 | WORKDIR /opt 7 | RUN mvn clean install -DskipTests=true 8 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar 3 | -------------------------------------------------------------------------------- /src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/test/java/com/sphere/compentencytool/CompentencyToolApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class CompentencyToolApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/model/GetPassbookBase.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.model; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import javax.persistence.Column; 7 | import java.util.List; 8 | 9 | @Getter 10 | @Setter 11 | public class GetPassbookBase { 12 | 13 | 14 | private List userId ; 15 | private String typeName; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/constants/Constants.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.constants; 2 | 3 | import com.sphere.compentencytool.common.utils.AppProperties; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Service; 6 | 7 | @Service 8 | public class Constants { 9 | @Autowired 10 | AppProperties props; 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/repository/RolesRepository.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.repository; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import com.sphere.compentencytool.model.Roles; 7 | 8 | @Repository 9 | public interface RolesRepository extends JpaRepository { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/common/utils/propertiesCache.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.common.utils; 2 | 3 | 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | 7 | public class propertiesCache { 8 | public String getProperty(String key) { 9 | String value = System.getenv(key); 10 | // if (StringUtils.isNotBlank(value)); 11 | return value; 12 | } 13 | } -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/kafka/consumer/api/SearchObject.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.kafka.consumer.api; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import java.util.Map; 7 | 8 | @Getter 9 | @Setter 10 | public class SearchObject { 11 | 12 | private Map filter; 13 | private Map search; 14 | private Boolean keywordSearch; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.repository; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import com.sphere.compentencytool.model.User; 7 | 8 | @Repository 9 | public interface UserRepository extends JpaRepository{ 10 | 11 | // public String Save_user(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/repository/DesignationsRepository.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.repository; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import com.sphere.compentencytool.model.Designations; 7 | 8 | 9 | @Repository 10 | public interface DesignationsRepository extends JpaRepository{ 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/CompentencyToolApplication.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class CompentencyToolApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(CompentencyToolApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/repository/RoleDesignationMapRepository.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.repository; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import com.sphere.compentencytool.model.RoleDesignationMap; 7 | 8 | @Repository 9 | public interface RoleDesignationMapRepository extends JpaRepository { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/exception/ResourceNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.web.bind.annotation.ResponseStatus; 5 | 6 | @ResponseStatus(value=HttpStatus.NOT_FOUND) 7 | public class ResourceNotFoundException extends Exception { 8 | 9 | /** 10 | * 11 | */ 12 | private static final long serialVersionUID = 1L; 13 | public ResourceNotFoundException(String message) { 14 | super(message); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/model/GetPassbook.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.model; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import org.hibernate.annotations.Type; 6 | 7 | import javax.persistence.Column; 8 | 9 | @Getter 10 | @Setter 11 | public class GetPassbook implements Cloneable { 12 | 13 | @Type(type = "json") 14 | private GetPassbookBase request; 15 | 16 | public GetPassbook clone() throws CloneNotSupportedException { 17 | return (GetPassbook) super.clone(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # compentency-tool 2 | 3 | 1.Create User: 4 | POST localhost:8080/api/user 5 | request body = { 6 | "name":"Ankit", 7 | "email":"Ankit@tarento.com", 8 | "phone_num":"9677896757" 9 | } 10 | 11 | 2.GetAllUser: 12 | GET localhost:8080/api/user 13 | 14 | 3.UpdateUser 15 | PUT localhost:8080/api/user/1 16 | requestbody = { 17 | "id": 1, 18 | "name": "samynathan", 19 | "email": "samynathan@gmail.com", 20 | "phone_num": 321 21 | } 22 | 23 | 4.Delete User 24 | DELETE localhost:8080/api/user/1 25 | 26 | 27 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8 2 | 3 | RUN apt-get update \ 4 | && apt-get install -y \ 5 | curl \ 6 | libxrender1 \ 7 | libjpeg62-turbo \ 8 | fontconfig \ 9 | libxtst6 \ 10 | xfonts-75dpi \ 11 | xfonts-base \ 12 | xz-utils 13 | 14 | COPY compentency-tool-0.0.1-SNAPSHOT.jar /opt/ 15 | #HEALTHCHECK --interval=30s --timeout=30s CMD curl --fail http://localhost:7001/actuator/health || exit 1 16 | CMD ["java", "-XX:+PrintFlagsFinal", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCGroupMemoryLimitForHeap", "-jar", "/opt/compentency-tool-0.0.1-SNAPSHOT.jar"] 17 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/external/service/ExternalService.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.external.service; 2 | 3 | 4 | import java.util.Map; 5 | 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.util.MultiValueMap; 8 | 9 | public interface ExternalService { 10 | 11 | public ResponseEntity read_user(Map headers,String UserID); 12 | public ResponseEntity read_content(String ContentID); 13 | public ResponseEntity Verify_token(Map headers); 14 | public ResponseEntity Generate_token(MultiValueMap map); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/model/Request.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.model; 2 | import lombok.Getter; 3 | import lombok.Setter; 4 | import org.hibernate.annotations.Type; 5 | 6 | import javax.persistence.Column; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | @Getter 11 | @Setter 12 | public class Request { 13 | 14 | @Column(name = "userId") 15 | private String userId ; 16 | @Column(name = "typeName") 17 | private String typeName; 18 | 19 | @Type(type = "json") 20 | @Column(name = "competencyDetails", columnDefinition = "json") 21 | private List> competencyDetails; 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/exception/ErrorDetails.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.exception; 2 | 3 | import java.util.Date; 4 | 5 | public class ErrorDetails { 6 | private Date timestamp; 7 | private String message; 8 | private String details; 9 | 10 | public ErrorDetails(Date timestamp, String message, String details) { 11 | super(); 12 | this.timestamp = timestamp; 13 | this.message = message; 14 | this.details = details; 15 | } 16 | 17 | public Date getTimestamp() { 18 | return timestamp; 19 | } 20 | 21 | public String getMessage() { 22 | return message; 23 | } 24 | 25 | public String getDetails() { 26 | return details; 27 | } 28 | } -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/repository/passbookRepository.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.repository; 2 | 3 | 4 | import com.sphere.compentencytool.model.Passbook; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.jpa.repository.Query; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | @Repository 12 | public interface passbookRepository extends JpaRepository { 13 | 14 | @Query(value = "SELECT * FROM passbook where request->>'typeName' = ?1 ",nativeQuery = true) 15 | public List searchByTypeName(String typeName); 16 | 17 | @Query(value = "SELECT * FROM passbook where request->>'userId' IN (?1) and request->>'typeName' = ?2 ",nativeQuery = true) 18 | public List searchByTypeNameUserId(String typeName,List user_ids); 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/model/Passbook.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.model; 2 | 3 | import com.vladmihalcea.hibernate.type.json.JsonType; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | import org.hibernate.annotations.DynamicUpdate; 7 | import org.hibernate.annotations.Type; 8 | import org.hibernate.annotations.TypeDef; 9 | import org.hibernate.annotations.TypeDefs; 10 | 11 | import javax.persistence.*; 12 | @Getter 13 | @Setter 14 | @Entity() 15 | @Table(name="passbook",schema="public") 16 | @DynamicUpdate 17 | @TypeDefs({ @TypeDef(name = "json", typeClass = JsonType.class) }) 18 | public class Passbook implements Cloneable { 19 | @Id 20 | @GeneratedValue(strategy= GenerationType.IDENTITY) 21 | private long id; 22 | @Type(type = "json") 23 | @Column(name = "request", columnDefinition = "json") 24 | private Request request; 25 | 26 | public Passbook clone() throws CloneNotSupportedException { 27 | return (Passbook) super.clone(); 28 | } 29 | 30 | 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/exception/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.exception; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.http.HttpStatus; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.web.bind.annotation.ControllerAdvice; 8 | import org.springframework.web.bind.annotation.ExceptionHandler; 9 | import org.springframework.web.context.request.WebRequest; 10 | import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; 11 | 12 | @ControllerAdvice 13 | public class GlobalExceptionHandler extends ResponseEntityExceptionHandler { 14 | @ExceptionHandler(ResourceNotFoundException.class) 15 | public ResponseEntity resourceNotFoundException(ResourceNotFoundException ex, WebRequest request) { 16 | ErrorDetails errorDetails = new ErrorDetails(new Date(), ex.getMessage(), request.getDescription(false)); 17 | return new ResponseEntity<>(errorDetails, HttpStatus.NOT_FOUND); 18 | } 19 | 20 | @ExceptionHandler(Exception.class) 21 | public ResponseEntity globleExcpetionHandler(Exception ex, WebRequest request) { 22 | ErrorDetails errorDetails = new ErrorDetails(new Date(), ex.getMessage(), request.getDescription(false)); 23 | return new ResponseEntity<>(errorDetails, HttpStatus.INTERNAL_SERVER_ERROR); 24 | } 25 | } -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/model/RoleDesignationMap.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.model; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | 10 | @Entity 11 | @Table(name="roledesignationmap",schema="public") 12 | public class RoleDesignationMap { 13 | 14 | @Id 15 | @GeneratedValue(strategy=GenerationType.IDENTITY) 16 | private long id; 17 | 18 | @Column(name="role_id") 19 | private String role_id; 20 | 21 | @Column(name="designation_id") 22 | private String designation_id; 23 | 24 | public RoleDesignationMap() { 25 | super(); 26 | } 27 | 28 | public RoleDesignationMap(long id, String role_id, String designation_id) { 29 | super(); 30 | this.id = id; 31 | this.role_id = role_id; 32 | this.designation_id = designation_id; 33 | } 34 | 35 | public long getId() { 36 | return id; 37 | } 38 | 39 | public void setId(long id) { 40 | this.id = id; 41 | } 42 | 43 | public String getRole_id() { 44 | return role_id; 45 | } 46 | 47 | public void setRole_id(String role_id) { 48 | this.role_id = role_id; 49 | } 50 | 51 | public String getDesignation_id() { 52 | return designation_id; 53 | } 54 | 55 | public void setDesignation_id(String designation_id) { 56 | this.designation_id = designation_id; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/model/User.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.model; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | 10 | @Entity 11 | @Table(name="user",schema="public") 12 | public class User { 13 | 14 | @Id 15 | @GeneratedValue(strategy=GenerationType.IDENTITY) 16 | private long id; 17 | 18 | @Column(name="name") 19 | private String name; 20 | 21 | @Column(name="email") 22 | private String email; 23 | 24 | @Column(name="phone_num") 25 | private String phone_num; 26 | 27 | 28 | public User() { 29 | super(); 30 | } 31 | public User(String name, String email, String phone_num) { 32 | super(); 33 | this.name = name; 34 | this.email = email; 35 | this.phone_num = phone_num; 36 | } 37 | 38 | public long getId() { 39 | return id; 40 | } 41 | public void setId(long id) { 42 | this.id = id; 43 | } 44 | public String getName() { 45 | return name; 46 | } 47 | public void setName(String name) { 48 | this.name = name; 49 | } 50 | public String getEmail() { 51 | return email; 52 | } 53 | public void setEmail(String email) { 54 | this.email = email; 55 | } 56 | public String getPhone_num() { 57 | return phone_num; 58 | } 59 | public void setPhone_num(String phone_num) { 60 | this.phone_num = phone_num; 61 | } 62 | 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url= jdbc:postgresql://localhost:5432/compentency 2 | spring.datasource.username= postgres 3 | spring.datasource.password= postgres 4 | 5 | spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation= true 6 | spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.PostgreSQLDialect 7 | 8 | # Hibernate ddl auto (create, create-drop, validate, update) 9 | spring.jpa.hibernate.ddl-auto= update 10 | 11 | 12 | user.read.api = https://aastrika-stage.tarento.com/api/user/v2/read/ 13 | content.read.api = https://aastrika-stage.tarento.com/api/content/v1/read/ 14 | generate.token = https://aastrika-stage.tarento.com/auth/realms/sunbird/protocol/openid-connect/token 15 | verify.token = https://aastrika-stage.tarento.com/auth/realms/sunbird/protocol/openid-connect/userinfo 16 | 17 | kafka.bootstrapServers = 10.1.2.138:9092 18 | kafka.topic = dev.issue.certificate.request 19 | kafka.groupID = dev-activity-aggregate-updater-group 20 | 21 | get.hierarchy=https://sphere.aastrika.org/api/private/content/v3/hierarchy/ 22 | Api.key=bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJYUkZWVDBidDlBNGdsWm5uSUF5d1BJYWFzdjRReGFHWSJ9.APB-Ma_1l_R5l0xRddDhhlYkxBxxwZzcQofyhoif2bE 23 | get.entityById = http://localhost:8083/getEntityById/ 24 | passbook.update.url = https://aastrika-stage.tarento.com/api/user/v1/passbook 25 | 26 | 27 | 28 | 29 | #logging.level.org.springframework=OFF 30 | #logging.level.root=OFF 31 | #logging.level.org.springframework.web=ERROR -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | @Library('deploy-conf') _ 2 | node() { 3 | try { 4 | String ANSI_GREEN = "\u001B[32m" 5 | String ANSI_NORMAL = "\u001B[0m" 6 | String ANSI_BOLD = "\u001B[1m" 7 | String ANSI_RED = "\u001B[31m" 8 | String ANSI_YELLOW = "\u001B[33m" 9 | 10 | ansiColor('xterm') { 11 | stage('Checkout') { 12 | if (!env.hub_org) { 13 | println(ANSI_BOLD + ANSI_RED + "Uh Oh! Please set a Jenkins environment variable named hub_org with value as registery/sunbidrded" + ANSI_NORMAL) 14 | error 'Please resolve the errors and rerun..' 15 | } else 16 | println(ANSI_BOLD + ANSI_GREEN + "Found environment variable named hub_org with value as: " + hub_org + ANSI_NORMAL) 17 | } 18 | cleanWs() 19 | checkout scm 20 | commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() 21 | build_tag = sh(script: "echo " + params.github_release_tag.split('/')[-1] + "_" + commit_hash + "_" + env.BUILD_NUMBER, returnStdout: true).trim() 22 | echo "build_tag: " + build_tag 23 | 24 | stage('docker-pre-build') { 25 | sh ''' 26 | docker build -f ./Dockerfile.build -t $docker_pre_build . 27 | docker run --name $docker_pre_build $docker_pre_build:latest && docker cp $docker_pre_build:/opt/target/compentency-tool-0.0.1-SNAPSHOT.jar . 28 | sleep 30 29 | docker rm -f $docker_pre_build 30 | docker rmi -f $docker_pre_build 31 | ''' 32 | } 33 | stage('Build') { 34 | env.NODE_ENV = "build" 35 | print "Environment will be : ${env.NODE_ENV}" 36 | sh('chmod 777 build.sh') 37 | sh("bash -x build.sh ${build_tag} ${env.NODE_NAME} ${docker_server}") 38 | } 39 | stage('ArchiveArtifacts') { 40 | archiveArtifacts "metadata.json" 41 | currentBuild.description = "${build_tag}" 42 | } 43 | 44 | } 45 | 46 | } 47 | catch (err) { 48 | currentBuild.result = "FAILURE" 49 | throw err 50 | } 51 | finally { 52 | email_notify() 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/externalservice/controller/ServiceController.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.externalservice.controller; 2 | 3 | import java.util.Map; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.http.MediaType; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.util.LinkedMultiValueMap; 9 | import org.springframework.util.MultiValueMap; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.RequestHeader; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.RestController; 16 | 17 | import com.sphere.compentencytool.external.service.ExternalService; 18 | 19 | @RestController 20 | @RequestMapping("/compentencytool/v1") 21 | public class ServiceController { 22 | 23 | @Autowired 24 | ExternalService externalService; 25 | @GetMapping("/user/read/{user_Id}") 26 | public ResponseEntity UserRead(@RequestHeader Map headers,@PathVariable (value = "user_Id") String UserID){ 27 | return externalService.read_user(headers,UserID); 28 | } 29 | 30 | @GetMapping("/content/read/{Content_Id}") 31 | public ResponseEntity ContentRead(@PathVariable(value = "Content_Id") String ContentID){ 32 | return externalService.read_content(ContentID); 33 | } 34 | 35 | @PostMapping(value = "/generate-token",consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) 36 | public ResponseEntity GenerateToken(String username,String password,String client_id,String grant_type){ 37 | System.out.println("generate token : "+username+password+client_id+grant_type); 38 | 39 | MultiValueMap map = new LinkedMultiValueMap<>(); 40 | map.add("username",username); 41 | map.add("password",password); 42 | map.add("client_id",client_id); 43 | map.add("grant_type",grant_type); 44 | return externalService.Generate_token(map); 45 | 46 | } 47 | 48 | @GetMapping("/verify-token") 49 | public ResponseEntity VerifyToken(@RequestHeader Map headers){ 50 | System.out.println(headers); 51 | return externalService.Verify_token(headers); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/model/Roles.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.model; 2 | 3 | import java.sql.Timestamp; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.Table; 11 | 12 | 13 | 14 | @Entity 15 | @Table(name="Roles",schema="public") 16 | public class Roles { 17 | 18 | @Id 19 | @GeneratedValue(strategy=GenerationType.IDENTITY) 20 | private long id; 21 | 22 | @Column(name="role_id") 23 | private String role_id; 24 | 25 | @Column(name="role_name") 26 | private String role_name; 27 | 28 | @Column(name="role_description") 29 | private String role_description; 30 | 31 | @Column(name="status") 32 | private long status; 33 | 34 | @Column(name="createdon") 35 | private Timestamp createdon; 36 | 37 | @Column(name="createdby") 38 | private String createdby; 39 | 40 | public Roles() { 41 | super(); 42 | } 43 | 44 | public Roles(long id, String role_id, String role_name, String role_description, long status, Timestamp createdon, 45 | String createdby) { 46 | super(); 47 | this.id = id; 48 | this.role_id = role_id; 49 | this.role_name = role_name; 50 | this.role_description = role_description; 51 | this.status = status; 52 | this.createdon = createdon; 53 | this.createdby = createdby; 54 | } 55 | 56 | 57 | public long getId() { 58 | return id; 59 | } 60 | public void setId(long id) { 61 | this.id = id; 62 | } 63 | public String getRole_id() { 64 | return role_id; 65 | } 66 | public void setRole_id(String role_id) { 67 | this.role_id = role_id; 68 | } 69 | public String getRole_name() { 70 | return role_name; 71 | } 72 | public void setRole_name(String role_name) { 73 | this.role_name = role_name; 74 | } 75 | public String getRole_description() { 76 | return role_description; 77 | } 78 | public void setRole_description(String role_description) { 79 | this.role_description = role_description; 80 | } 81 | public long getStatus() { 82 | return status; 83 | } 84 | public void setStatus(long status) { 85 | this.status = status; 86 | } 87 | public Timestamp getCreatedon() { 88 | return createdon; 89 | } 90 | public void setCreatedon(Timestamp createdon) { 91 | this.createdon = createdon; 92 | } 93 | public String getCreatedby() { 94 | return createdby; 95 | } 96 | public void setCreatedby(String createdby) { 97 | this.createdby = createdby; 98 | } 99 | 100 | 101 | 102 | 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/model/Designations.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.model; 2 | 3 | import java.sql.Timestamp; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.Table; 11 | 12 | @Entity 13 | @Table(name="Designations",schema="public") 14 | public class Designations { 15 | 16 | @Id 17 | @GeneratedValue(strategy=GenerationType.IDENTITY) 18 | private long id; 19 | 20 | @Column(name="designation_id") 21 | private String designation_id; 22 | 23 | @Column(name="designation_name") 24 | private String designation_name; 25 | 26 | @Column(name="designation_description") 27 | private String designation_description; 28 | 29 | @Column(name="status") 30 | private long status; 31 | 32 | @Column(name="createdon") 33 | private Timestamp createdon; 34 | 35 | @Column(name="createdby") 36 | private String createdby; 37 | 38 | public Designations() { 39 | super(); 40 | } 41 | 42 | public Designations(long id, String designation_id, String designation_name, String designation_description, 43 | long status, Timestamp createdon, String createdby) { 44 | super(); 45 | this.id = id; 46 | this.designation_id = designation_id; 47 | this.designation_name = designation_name; 48 | this.designation_description = designation_description; 49 | this.status = status; 50 | this.createdon = createdon; 51 | this.createdby = createdby; 52 | } 53 | 54 | 55 | public long getId() { 56 | return id; 57 | } 58 | public void setId(long id) { 59 | this.id = id; 60 | } 61 | public String getDesignation_id() { 62 | return designation_id; 63 | } 64 | public void setDesignation_id(String designation_id) { 65 | this.designation_id = designation_id; 66 | } 67 | public String getDesignation_name() { 68 | return designation_name; 69 | } 70 | public void setDesignation_name(String designation_name) { 71 | this.designation_name = designation_name; 72 | } 73 | public String getDesignation_description() { 74 | return designation_description; 75 | } 76 | public void setDesignation_description(String designation_description) { 77 | this.designation_description = designation_description; 78 | } 79 | public long getStatus() { 80 | return status; 81 | } 82 | public void setStatus(long status) { 83 | this.status = status; 84 | } 85 | public Timestamp getCreatedon() { 86 | return createdon; 87 | } 88 | public void setCreatedon(Timestamp createdon) { 89 | this.createdon = createdon; 90 | } 91 | public String getCreatedby() { 92 | return createdby; 93 | } 94 | public void setCreatedby(String createdby) { 95 | this.createdby = createdby; 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.7.4 9 | 10 | 11 | com.sphere.compentency.app 12 | compentency-tool 13 | 0.0.1-SNAPSHOT 14 | compentency-tool 15 | compentency-tool project for Spring Boot 16 | 17 | 1.8 18 | 19 | 20 | 21 | 22 | org.apache.kafka 23 | kafka-clients 24 | 2.4.0 25 | 26 | 27 | org.projectlombok 28 | lombok 29 | 1.18.24 30 | provided 31 | 32 | 33 | 34 | com.vladmihalcea 35 | hibernate-types-55 36 | 2.12.1 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter-data-jpa 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-starter-web 46 | 47 | 48 | 49 | 50 | org.json 51 | json 52 | 20180813 53 | 54 | 55 | 56 | org.apache.commons 57 | commons-lang3 58 | 3.12.0 59 | 60 | 61 | 62 | org.apache.httpcomponents 63 | httpclient 64 | 4.4.1 65 | 66 | 67 | org.postgresql 68 | postgresql 69 | runtime 70 | 71 | 72 | org.springframework.boot 73 | spring-boot-starter-test 74 | test 75 | 76 | 77 | 78 | 79 | 80 | 81 | org.springframework.boot 82 | spring-boot-maven-plugin 83 | 84 | com.sphere.compentencytool.kafka.consumer.api.kafkaConsumer 85 | 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/common/utils/AppProperties.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.common.utils; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class AppProperties { 8 | @Value("${kafka.topic}") 9 | private String kafkaTopic; 10 | 11 | @Value("${kafka.groupID}") 12 | private String kafkaGroupID; 13 | 14 | @Value("${get.hierarchy}") 15 | private String getHierarchyApi; 16 | 17 | @Value("${Api.key}") 18 | private String Apikey; 19 | 20 | @Value("${get.entityById}") 21 | private String getEntityById; 22 | @Value("${passbook.update.url}") 23 | private String passbookUpdateUrl; 24 | 25 | @Value("${kafka.bootstrapServers}") 26 | private String kafkaBootstrapServers; 27 | 28 | public String getKafkaBootstrapServers() { 29 | return kafkaBootstrapServers; 30 | } 31 | 32 | public void setKafkaBootstrapServers(String kafkaBootstrapServers) { 33 | this.kafkaBootstrapServers = kafkaBootstrapServers; 34 | } 35 | 36 | public String getKafkaTopic() { 37 | return kafkaTopic; 38 | } 39 | 40 | public void setKafkaTopic(String kafkaTopic) { 41 | this.kafkaTopic = kafkaTopic; 42 | } 43 | 44 | public String getKafkaGroupID() { 45 | return kafkaGroupID; 46 | } 47 | 48 | public void setKafkaGroupID() { 49 | this.kafkaGroupID = kafkaGroupID; 50 | } 51 | 52 | public String getGetHierarchyApi() { 53 | return getHierarchyApi; 54 | } 55 | 56 | public void setGetHierarchyApi(String getHierarchyApi) { 57 | this.getHierarchyApi = getHierarchyApi; 58 | } 59 | 60 | public String getApikey() { 61 | return Apikey; 62 | } 63 | 64 | public void setApikey(String apikey) { 65 | Apikey = apikey; 66 | } 67 | 68 | public String getGetEntityById() { 69 | return getEntityById; 70 | } 71 | 72 | public void setGetEntityById(String getEntityById) { 73 | this.getEntityById = getEntityById; 74 | } 75 | 76 | public String getPassbookUpdateUrl() { 77 | return passbookUpdateUrl; 78 | } 79 | 80 | public void setPassbookUpdateUrl(String passbookUpdateUrl) { 81 | this.passbookUpdateUrl = passbookUpdateUrl; 82 | } 83 | 84 | @Value("${user.read.api}") 85 | private String UserReadApi; 86 | 87 | @Value("${content.read.api}") 88 | private String ContentReadAapi; 89 | 90 | @Value("${generate.token}") 91 | private String GenerateToken; 92 | 93 | public String getGenerateToken() { 94 | return GenerateToken; 95 | } 96 | 97 | public void setGenerateToken(String generateToken) { 98 | GenerateToken = generateToken; 99 | } 100 | 101 | public String getVerifyToken() { 102 | return VerifyToken; 103 | } 104 | 105 | public void setVerifyToken(String verifyToken) { 106 | VerifyToken = verifyToken; 107 | } 108 | 109 | @Value("${verify.token}") 110 | private String VerifyToken; 111 | 112 | public String getUserReadApi() { 113 | return UserReadApi; 114 | } 115 | 116 | public void setUserReadApi(String userReadApi) { 117 | UserReadApi = userReadApi; 118 | } 119 | 120 | public String getContentReadAapi() { 121 | return ContentReadAapi; 122 | } 123 | 124 | public void setContentReadAapi(String contentReadAapi) { 125 | ContentReadAapi = contentReadAapi; 126 | } 127 | 128 | 129 | } 130 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/kafka/consumer/api/kafkaConsumer.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.kafka.consumer.api; 2 | 3 | import com.sphere.compentencytool.common.utils.AppProperties; 4 | import com.sphere.compentencytool.common.utils.propertiesCache; 5 | import org.apache.kafka.clients.consumer.ConsumerConfig; 6 | import org.apache.kafka.clients.consumer.ConsumerRecord; 7 | import org.apache.kafka.clients.consumer.ConsumerRecords; 8 | import org.apache.kafka.clients.consumer.KafkaConsumer; 9 | import org.apache.kafka.common.serialization.StringDeserializer; 10 | import org.json.JSONArray; 11 | import org.json.JSONObject; 12 | 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.boot.SpringApplication; 17 | import org.springframework.boot.autoconfigure.SpringBootApplication; 18 | import org.springframework.context.ConfigurableApplicationContext; 19 | 20 | import java.time.Duration; 21 | import java.util.Arrays; 22 | import java.util.Properties; 23 | import java.util.ResourceBundle; 24 | 25 | @SpringBootApplication 26 | public class kafkaConsumer { 27 | 28 | 29 | public static void main(String[] args) { 30 | SpringApplication.run(kafkaConsumer.class, args); 31 | 32 | propertiesCache env=new propertiesCache(); 33 | 34 | Api_services api_services= new Api_services(); 35 | Logger logger= LoggerFactory.getLogger(kafkaConsumer.class.getName()); 36 | 37 | String bootstrapServers=env.getProperty("kafka.bootstrapServers"); 38 | String grp_id=env.getProperty("kafka.groupID"); 39 | String topic= env.getProperty("kafka.topic");; 40 | System.out.println("topic --- > "+topic); 41 | System.out.println("bootstrapServers --- > "+bootstrapServers); 42 | System.out.println("grp_id --- > "+grp_id); 43 | 44 | //Creating consumer properties 45 | Properties properties=new Properties(); 46 | properties.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG,bootstrapServers); 47 | properties.setProperty(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName()); 48 | properties.setProperty(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,StringDeserializer.class.getName()); 49 | properties.setProperty(ConsumerConfig.GROUP_ID_CONFIG,grp_id); 50 | properties.setProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG,"latest"); 51 | //creating consumer 52 | KafkaConsumer consumer= new KafkaConsumer(properties); 53 | //Subscribing 54 | consumer.subscribe(Arrays.asList(topic)); 55 | System.out.println("kafka consumer subscribe & running"); 56 | //polling 57 | while(true){ 58 | ConsumerRecords records=consumer.poll(Duration.ofMillis(100)); 59 | for(ConsumerRecord record: records) { 60 | // logger.info("Key: " + record.key() + ", Value:" + record.value()); 61 | String msg = record.value(); 62 | if (msg.length() != 0 & msg != null && !msg.isEmpty() && !msg.trim().isEmpty()) { 63 | JSONObject json = new JSONObject(record.value()); 64 | JSONObject edata = json.getJSONObject("edata"); 65 | JSONArray userId = (JSONArray) edata.get("userIds"); 66 | String courseId = (String) edata.get("courseId"); 67 | System.out.println(edata.get("userIds")); 68 | System.out.println(edata.get("courseId")); 69 | api_services.get_hierarchy(courseId,userId); 70 | } else { 71 | System.out.println("null check condition : "+record.value()); 72 | // logger.info("Partition:" + record.partition()+",Offset:"+record.offset()); 73 | } 74 | 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/external/service/impl/ExternalServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.external.service.impl; 2 | 3 | import java.util.Arrays; 4 | import java.util.Map; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.http.HttpEntity; 8 | import org.springframework.http.HttpHeaders; 9 | import org.springframework.http.HttpMethod; 10 | import org.springframework.http.MediaType; 11 | import org.springframework.http.ResponseEntity; 12 | import org.springframework.stereotype.Service; 13 | import org.springframework.util.MultiValueMap; 14 | import org.springframework.web.client.RestTemplate; 15 | 16 | import com.sphere.compentencytool.common.utils.AppProperties; 17 | import com.sphere.compentencytool.external.service.ExternalService; 18 | 19 | @Service 20 | public class ExternalServiceImpl implements ExternalService { 21 | 22 | RestTemplate restTemplate = new RestTemplate(); 23 | 24 | @Autowired 25 | AppProperties props; 26 | 27 | @Override 28 | public ResponseEntity read_user(Map headers,String UserID) { 29 | // TODO Auto-generated method stub 30 | System.out.println(headers.get("authorization")); 31 | System.out.println(headers.get("x-authenticated-user-token")); 32 | System.out.println(UserID); 33 | 34 | HttpHeaders header=new HttpHeaders(); 35 | header.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); 36 | // header.add("Authorization", "bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJYUkZWVDBidDlBNGdsWm5uSUF5d1BJYWFzdjRReGFHWSJ9.APB-Ma_1l_R5l0xRddDhhlYkxBxxwZzcQofyhoif2bE" ); 37 | // header.add("x-authenticated-user-token","eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJkelFFNjdiRmxRN0V2eUF3Tktndmk1X2ZQR0dsVUVKOGEyMnFlZ1R0TFU0In0.eyJqdGkiOiJkN2RhNzJjZC0wZDI0LTRlYzItOGYxYi1iODk2MjAwM2VmNDIiLCJleHAiOjE2NjY4NDg0NjgsIm5iZiI6MCwiaWF0IjoxNjY2NzYyMDY4LCJpc3MiOiJodHRwczovL2Fhc3RyaWthLXN0YWdlLnRhcmVudG8uY29tL2F1dGgvcmVhbG1zL3N1bmJpcmQiLCJhdWQiOiJhY2NvdW50Iiwic3ViIjoiZjo5MDdiNWM2NC0xZDc5LTQ0ZGItYjNiNS1lYzEyOWQ1N2Y0MjE6NjY3OGU4YWMtN2U3Ni00YWYzLTgzNTQtYzA5NzBkZDc4NDE5IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoicG9ydGFsIiwiYXV0aF90aW1lIjowLCJzZXNzaW9uX3N0YXRlIjoiYTA0NGQ3MGMtODdlOC00ZGYxLWJjMTctNjZhZjQzYzFiZDNmIiwiYWNyIjoiMSIsImFsbG93ZWQtb3JpZ2lucyI6WyJodHRwczovL2FkbWluLWFhc3RyaWthLXN0YWdlLnRhcmVudG8uY29tIiwiaHR0cHM6Ly9hYXN0cmlrYS1zdGFnZS50YXJlbnRvLmNvbS8qIiwiaHR0cHM6L2NicC1hYXN0cmlrYS1zdGFnZS50YXJlbnRvLmNvbSIsImh0dHBzOi8vb3JnLWFhc3RyaWthLXN0YWdlLnRhcmVudG8uY29tIiwiaHR0cDovL2xvY2FsaG9zdDozMDAwIl0sInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJvZmZsaW5lX2FjY2VzcyIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiYWNjb3VudCI6eyJyb2xlcyI6WyJtYW5hZ2UtYWNjb3VudCIsIm1hbmFnZS1hY2NvdW50LWxpbmtzIiwidmlldy1wcm9maWxlIl19fSwic2NvcGUiOiIiLCJuYW1lIjoiQW5raXRhIEthdXNoaWsiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJhbmtpdGFrYXVzaGlrX3M5dTMiLCJnaXZlbl9uYW1lIjoiQW5raXRhIiwiZmFtaWx5X25hbWUiOiJLYXVzaGlrIiwiZW1haWwiOiJzcCoqKioqKioqKioqKioqKkB5b3BtYWlsLmNvbSJ9.qyI1VcSoA-YsUA4Gq2FvpO1O1AghyL4izbybMOdqPr0W8mqVM_pX_2_JzLxGJE7FyavSEDOrtMhvjpppmk70u48Uvt1nvW7jthPE_lpI9sIKwuQGx8byokG86ok9Pk0XXoDeG3vFw8BzlHJ8NSYAynXzxrCoCuis7yEUUoxGIqlJfDbdRiQrSvtlWywwtgsWdIA3UQx2UqslooNKMHL0UhWr-lArplzGtKupuLNHcmVFVvDKFUMMWw9YE6X9wFraBeYt-hPkqM70fREafucs_umruiVtimvgklCMotM6UfPWXWvTAUeFLtXc6GFFphkmnU7kXEWFDGeApWsfs1rwvQ" ); 38 | header.add("Authorization",headers.get("authorization")); 39 | header.add("x-authenticated-user-token",headers.get("x-authenticated-user-token")); 40 | HttpEntity entity=new HttpEntity("parameters",header); 41 | 42 | String url=props.getUserReadApi()+UserID; 43 | System.out.println(url); 44 | 45 | ResponseEntity response=restTemplate.exchange(url,HttpMethod.GET,entity,String.class); 46 | 47 | return response; 48 | } 49 | 50 | @Override 51 | public ResponseEntity read_content(String contentID) { 52 | // TODO Auto-generated method stub 53 | System.out.println("impl : "+contentID); 54 | HttpHeaders header=new HttpHeaders(); 55 | header.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); 56 | 57 | // header.add("Cookie",headers.get("cookie") ); 58 | HttpEntity entity=new HttpEntity("parameters",header); 59 | System.out.println(props.getContentReadAapi()+contentID); 60 | 61 | ResponseEntity response=restTemplate.exchange(props.getContentReadAapi()+contentID,HttpMethod.GET,entity,String.class); 62 | 63 | return response; 64 | 65 | } 66 | 67 | @Override 68 | public ResponseEntity Generate_token(MultiValueMap map) { 69 | // TODO Auto-generated method stub 70 | HttpHeaders headers = new HttpHeaders(); 71 | headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); 72 | HttpEntity> body_request = new HttpEntity<>(map, headers); 73 | 74 | ResponseEntity response=restTemplate.exchange(props.getGenerateToken(),HttpMethod.POST,body_request,String.class); 75 | 76 | return response; 77 | } 78 | 79 | @Override 80 | public ResponseEntity Verify_token(Map headers) { 81 | // TODO Auto-generated method stub 82 | HttpHeaders header=new HttpHeaders(); 83 | header.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); 84 | header.add("Authorization",headers.get("authorization") ); 85 | HttpEntity entity=new HttpEntity("parameters",header); 86 | System.out.println(props.getVerifyToken()); 87 | System.out.println(headers.get("authorization") ); 88 | ResponseEntity response=restTemplate.exchange(props.getVerifyToken(),HttpMethod.GET,entity,String.class); 89 | 90 | return response; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/controller/Controller.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.controller; 2 | 3 | import java.util.List; 4 | 5 | import com.sphere.compentencytool.model.GetPassbook; 6 | import com.sphere.compentencytool.model.Passbook; 7 | import com.sphere.compentencytool.repository.passbookRepository; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.http.HttpStatus; 10 | import org.springframework.http.ResponseEntity; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import com.sphere.compentencytool.exception.ResourceNotFoundException; 14 | import com.sphere.compentencytool.model.Designations; 15 | import com.sphere.compentencytool.model.Roles; 16 | import com.sphere.compentencytool.repository.DesignationsRepository; 17 | import com.sphere.compentencytool.repository.RolesRepository; 18 | 19 | 20 | @RestController 21 | @RequestMapping("/compentencytool/v1") 22 | public class Controller { 23 | 24 | @Autowired 25 | DesignationsRepository designationsRepository; 26 | @Autowired 27 | RolesRepository rolesRepository; 28 | @Autowired 29 | passbookRepository PassbookRepository; 30 | 31 | 32 | // DESIGNATION API's 33 | 34 | // 1. Insert designations 35 | @PostMapping(value = "/designations", produces = "application/json") 36 | public Designations Add_Designations(@RequestBody Designations designations) { 37 | return this.designationsRepository.save(designations); 38 | } 39 | 40 | // 2. Get All designations 41 | @GetMapping("/designations") 42 | public List getAllDesignations(){ 43 | return this.designationsRepository.findAll(); 44 | } 45 | // 3. Get designations by id 46 | @GetMapping("/designations/{id}") 47 | public ResponseEntity getDesignationsById(@PathVariable(value = "id") Long designationsId) 48 | throws ResourceNotFoundException { 49 | Designations designations = designationsRepository.findById(designationsId) 50 | .orElseThrow(() -> new ResourceNotFoundException("designations not found for this id :: " + designationsId)); 51 | return ResponseEntity.ok().body(designations); 52 | } 53 | 54 | 55 | // 4. Update designations by id 56 | @PutMapping("/designations/{id}") 57 | public ResponseEntity UpdateDesignations(@PathVariable(value = "id") Long designation_id, 58 | @RequestBody Designations designationDetails) throws ResourceNotFoundException { 59 | Designations _design = designationsRepository.findById(designation_id) 60 | .orElseThrow(() -> new ResourceNotFoundException("designations not found for this id :: " + designation_id)); 61 | 62 | _design.setDesignation_id(designationDetails.getDesignation_id()); 63 | _design.setDesignation_name(designationDetails.getDesignation_name()); 64 | _design.setDesignation_description(designationDetails.getDesignation_description()); 65 | _design.setStatus(designationDetails.getStatus()); 66 | _design.setCreatedon(designationDetails.getCreatedon()); 67 | _design.setCreatedby(designationDetails.getCreatedby()); 68 | final Designations updated_designationDetails = designationsRepository.save(_design); 69 | return ResponseEntity.ok(updated_designationDetails); 70 | } 71 | 72 | // 5. delete designations by id 73 | @DeleteMapping("/designations/{id}") 74 | public ResponseEntity DeleteDesignations(@PathVariable("id") long id) { 75 | try { 76 | designationsRepository.deleteById(id); 77 | return new ResponseEntity<>(HttpStatus.NO_CONTENT); 78 | } catch (Exception e) { 79 | return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); 80 | } 81 | } 82 | 83 | 84 | //ROLE API's 85 | 86 | 87 | // 1. Insert roles 88 | @PostMapping(value = "/roles", produces = "application/json") 89 | public Roles Add_roles(@RequestBody Roles roles) { 90 | return this.rolesRepository.save(roles); 91 | } 92 | 93 | // 2. Get All roles 94 | @GetMapping("/roles") 95 | public List getAllRoles(){ 96 | return this.rolesRepository.findAll(); 97 | } 98 | 99 | // 3. Get roles by id 100 | @GetMapping("/roles/{id}") 101 | public ResponseEntity getrolesById(@PathVariable(value = "id") Long roleId) 102 | throws ResourceNotFoundException { 103 | Roles roles = rolesRepository.findById(roleId) 104 | .orElseThrow(() -> new ResourceNotFoundException("Roles not found for this id :: " + roleId)); 105 | return ResponseEntity.ok().body(roles); 106 | } 107 | 108 | 109 | // 4. Update roles by id 110 | @PutMapping("/roles/{id}") 111 | public ResponseEntity UpdateRoles(@PathVariable(value = "id") Long role_id, 112 | @RequestBody Roles roleDetails) throws ResourceNotFoundException { 113 | Roles _roles = rolesRepository.findById(role_id) 114 | .orElseThrow(() -> new ResourceNotFoundException("Roles not found for this id :: " + role_id)); 115 | 116 | _roles.setRole_id(roleDetails.getRole_id()); 117 | _roles.setRole_name(roleDetails.getRole_name()); 118 | _roles.setRole_description(roleDetails.getRole_description()); 119 | _roles.setStatus(roleDetails.getStatus()); 120 | _roles.setCreatedon(roleDetails.getCreatedon()); 121 | _roles.setCreatedby(roleDetails.getCreatedby()); 122 | final Roles updated_rolesDetails = rolesRepository.save(_roles); 123 | return ResponseEntity.ok(updated_rolesDetails); 124 | } 125 | 126 | // 5. delete role by id 127 | @DeleteMapping("/roles/{id}") 128 | public ResponseEntity DeleteRole(@PathVariable("id") long id) { 129 | try { 130 | rolesRepository.deleteById(id); 131 | return new ResponseEntity<>(HttpStatus.NO_CONTENT); 132 | } catch (Exception e) { 133 | return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); 134 | } 135 | } 136 | 137 | 138 | 139 | // ROLE-DESIGNATION-MAPPING API's 140 | 141 | // 1. Insert passbook 142 | @PatchMapping(value = "/passbook", produces = "application/json") 143 | public Passbook Add_Passbook(@RequestBody Passbook passbook) { 144 | System.out.println(passbook); 145 | return this.PassbookRepository.save(passbook); 146 | } 147 | @PostMapping("/passbook") 148 | public List GetPassbook(@RequestBody GetPassbook getpassbook){ 149 | String TypeName=getpassbook.getRequest().getTypeName(); 150 | List userId=getpassbook.getRequest().getUserId(); 151 | System.out.println("Userid = "+userId); 152 | List result = null; 153 | if (TypeName != null & userId != null) { 154 | System.out.println(userId); 155 | System.out.println(TypeName); 156 | result= this.PassbookRepository.searchByTypeNameUserId(TypeName,userId); 157 | } 158 | else if (TypeName != null & userId == null) { 159 | result= this.PassbookRepository.searchByTypeName(TypeName); 160 | } 161 | 162 | 163 | return result; 164 | } 165 | 166 | 167 | @GetMapping("/designations/test") 168 | public String Test(){ 169 | 170 | return "Api working "; 171 | } 172 | 173 | 174 | } 175 | 176 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/kafka/consumer/api/test.java: -------------------------------------------------------------------------------- 1 | //package com.sphere.compentencytool.kafka.consumer.api; 2 | // 3 | //import com.fasterxml.jackson.core.JsonProcessingException; 4 | //import com.fasterxml.jackson.databind.ObjectMapper; 5 | //import org.apache.http.client.HttpClient; 6 | //import org.apache.http.impl.client.HttpClientBuilder; 7 | //import org.json.JSONArray; 8 | //import org.json.JSONObject; 9 | //import org.springframework.http.*; 10 | //import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; 11 | //import org.springframework.web.client.RestTemplate; 12 | // 13 | //import java.io.IOException; 14 | //import java.util.Arrays; 15 | //import java.util.HashMap; 16 | //import java.util.Map; 17 | //import java.util.ResourceBundle; 18 | // 19 | //class test { 20 | // 21 | // public static void main(String[] args) throws IOException { 22 | // 23 | //// ObjectMapper mapper = new ObjectMapper(); 24 | //// JSONObject mainobj =new JSONObject(); 25 | //// JSONObject main1 =new JSONObject(); 26 | //// main1.put( "userId", "0eb7e0aa-481a-4f00-a8be-f5173202507ccc"); 27 | //// main1.put( "typeName", "competency"); 28 | //// 29 | //// JSONArray competencyDetails= new JSONArray(); 30 | //// JSONObject competencyDetails_main_obj =new JSONObject(); 31 | //// competencyDetails_main_obj.put("competencyId", "50"); 32 | //// 33 | //// JSONObject additionalParams = new JSONObject(); 34 | //// additionalParams.put("competencyName", "Procurement and Distribution of HCM"); 35 | //// competencyDetails_main_obj.put("additionalParams",additionalParams); 36 | //// 37 | //// JSONObject acquiredDetails = new JSONObject(); 38 | //// 39 | //// acquiredDetails.put("acquiredChannel", "Course"); 40 | //// acquiredDetails.put("competencyLevelId", "11"); 41 | //// acquiredDetails.put("secondaryPassbookId", "competencyLevelId1"); 42 | //// JSONObject acquiredDetails_additionalParams = new JSONObject(); 43 | //// acquiredDetails_additionalParams.put("courseId", "do_1134170689871134721450"); 44 | //// acquiredDetails_additionalParams.put("courseName", "Normal Labour & Birth and AMTSL"); 45 | //// 46 | //// acquiredDetails.put("additionalParams",acquiredDetails_additionalParams); 47 | //// competencyDetails_main_obj.put("acquiredDetails",acquiredDetails); 48 | //// competencyDetails.put(competencyDetails_main_obj); 49 | //// main1.put("competencyDetails",competencyDetails); 50 | //// 51 | //// 52 | //// 53 | //// mainobj.put("request",main1); 54 | //// Passbook_update("0eb7e0aa-481a-4f00-a8be-f5173202507ccc",mainobj); 55 | // 56 | // 57 | // 58 | //// System.out.println(mainobj.toString(4)); 59 | // 60 | // 61 | // 62 | //// // convert map to JSON string 63 | //// String json = mapper.writeValueAsString(mainobj); 64 | //// 65 | //// System.out.println(json); // compact-print 66 | //// 67 | //// json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(mainobj); 68 | //// 69 | //// System.out.println(json); // pretty-print 70 | // 71 | // JSONObject getentityid = get_entityById("45"); 72 | // System.out.println(getentityid); 73 | // 74 | // 75 | // 76 | // 77 | // } 78 | // 79 | // private static void Passbook_update(String userId, JSONObject request) throws JsonProcessingException { 80 | // 81 | // RestTemplate restTemplate = new RestTemplate(); 82 | // HttpClient httpClient = HttpClientBuilder.create().build(); 83 | // HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient); 84 | // restTemplate.setRequestFactory(requestFactory); 85 | // 86 | // String request_body = request.toString(); 87 | // String url = "https://sphere.aastrika.org/api/user/v1/passbook"; 88 | // String Api_key = "bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJTNHNNVFdjZUZqYkxUWGxiczkzUzk4dmFtODBhdkRPUiJ9.nPOCY0-bVX28iNcxxnYbGpihY3ZzfNwx0-SFCnJwjas"; 89 | // HttpHeaders header = new HttpHeaders(); 90 | // header.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); 91 | // header.add("Authorization", Api_key); 92 | // header.add("x-authenticated-userid",userId ); 93 | // Map mapping = new ObjectMapper().readValue(request_body, HashMap.class); 94 | // 95 | // System.out.println("mapping : "+mapping); 96 | // 97 | // HttpEntity> entity = new HttpEntity<>(mapping, header); 98 | // ResponseEntity passbookResponse = restTemplate.exchange(url , HttpMethod.PATCH, entity, String.class); 99 | // System.out.println(passbookResponse); 100 | // String responseStr = passbookResponse.getBody(); 101 | // int begin = responseStr.indexOf("{"); 102 | // int end = responseStr.lastIndexOf("}") + 1; 103 | // responseStr = responseStr.substring(begin, end); 104 | // System.out.println(responseStr); 105 | // JSONObject passbook_payload = new JSONObject(responseStr); 106 | // System.out.println(passbook_payload.toString(4)); 107 | // 108 | // } 109 | // 110 | // private static JSONObject get_entityById(String competency_id) throws JsonProcessingException { 111 | // ResourceBundle props = ResourceBundle.getBundle("application"); 112 | // RestTemplate restTemplate = new RestTemplate(); 113 | // String url = props.getString("get.entityById") + competency_id; 114 | // System.out.println("get_entityById fun "); 115 | // String token = props.getString("token.key"); 116 | // HttpHeaders header = new HttpHeaders(); 117 | // header.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); 118 | //// header.add("x-authenticated-user-token", token); 119 | // 120 | // String req = "{\"filter\":{\"isDetail\":true}}"; 121 | // Map mapping = new ObjectMapper().readValue(req, HashMap.class); 122 | // 123 | // HttpEntity> entity = new HttpEntity<>(mapping, header); 124 | // ResponseEntity entityResponse = restTemplate.exchange(url, HttpMethod.POST, entity, String.class); 125 | // 126 | // System.out.println(entityResponse.getStatusCode()); 127 | // 128 | // HttpStatus statusCode = entityResponse.getStatusCode(); 129 | // System.out.println(statusCode); 130 | // 131 | // String responseStr = entityResponse.getBody(); 132 | // int begin = responseStr.indexOf("{"); 133 | // int end = responseStr.lastIndexOf("}") + 1; 134 | // responseStr = responseStr.substring(begin, end); 135 | // System.out.println(responseStr); 136 | // JSONObject passbook_payload = new JSONObject(responseStr); 137 | // System.out.println(passbook_payload.get("responseCode")); 138 | // 139 | // JSONObject passbook_result = passbook_payload.getJSONObject("result"); 140 | // return (JSONObject) passbook_result.get("response"); 141 | // 142 | // } } -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* 50 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 124 | 125 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% ^ 162 | %JVM_CONFIG_MAVEN_PROPS% ^ 163 | %MAVEN_OPTS% ^ 164 | %MAVEN_DEBUG_OPTS% ^ 165 | -classpath %WRAPPER_JAR% ^ 166 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ 167 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 168 | if ERRORLEVEL 1 goto error 169 | goto end 170 | 171 | :error 172 | set ERROR_CODE=1 173 | 174 | :end 175 | @endlocal & set ERROR_CODE=%ERROR_CODE% 176 | 177 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost 178 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 179 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" 180 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" 181 | :skipRcPost 182 | 183 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 184 | if "%MAVEN_BATCH_PAUSE%"=="on" pause 185 | 186 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% 187 | 188 | cmd /C exit /B %ERROR_CODE% 189 | -------------------------------------------------------------------------------- /src/main/java/com/sphere/compentencytool/kafka/consumer/api/Api_services.java: -------------------------------------------------------------------------------- 1 | package com.sphere.compentencytool.kafka.consumer.api; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import com.sphere.compentencytool.common.utils.propertiesCache; 6 | import org.apache.http.client.HttpClient; 7 | import org.apache.http.impl.client.HttpClientBuilder; 8 | import org.json.JSONArray; 9 | import org.json.JSONObject; 10 | import org.springframework.http.*; 11 | import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; 12 | import org.springframework.web.client.RestTemplate; 13 | 14 | import java.util.Arrays; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | import java.util.ResourceBundle; 18 | 19 | 20 | public class Api_services { 21 | RestTemplate restTemplate = new RestTemplate(); 22 | 23 | // ResourceBundle props = ResourceBundle.getBundle("application"); 24 | propertiesCache env=new propertiesCache(); 25 | public Object get_hierarchy(String courseId, JSONArray UserId) { 26 | // String url = "https://sphere.aastrika.org/api/private/content/v3/hierarchy/"+courseId+"?hierarchyType=detail"; 27 | String url = env.getProperty("get.hierarchy")+ courseId + "?hierarchyType=detail"; 28 | System.out.println(url); 29 | String Api_key = env.getProperty("Api.key"); 30 | System.out.println(Api_key); 31 | HttpHeaders header = new HttpHeaders(); 32 | header.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); 33 | header.add("Authorization", Api_key); 34 | ResponseEntity response = null; 35 | try { 36 | HttpEntity entity = new HttpEntity("parameters", header); 37 | response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class); 38 | String responseStr = response.getBody(); 39 | int begin = responseStr.indexOf("{"); 40 | int end = responseStr.lastIndexOf("}") + 1; 41 | responseStr = responseStr.substring(begin, end); 42 | 43 | System.out.println("=========******** hierachy API Called return response ************============="); 44 | System.out.println(responseStr); 45 | Object course_data = getCourseInfo_parse(responseStr, UserId); 46 | } catch (Exception e) { 47 | System.out.println(e.fillInStackTrace()); 48 | } 49 | 50 | return response; 51 | 52 | } 53 | 54 | private Object getCourseInfo_parse(String response, JSONArray userId) throws JsonProcessingException { 55 | 56 | JSONObject Competency_object = new JSONObject(response); 57 | JSONObject result_object = Competency_object.getJSONObject("result"); 58 | JSONObject content_data = (JSONObject) result_object.get("content"); 59 | // Course info 60 | String Course_name = (String) content_data.get("name"); 61 | String course_Id = (String) content_data.get("identifier"); 62 | // parse competencies_v1 string json 63 | System.out.println(content_data.get("competencies_v1")); 64 | String competencyData = (String) content_data.get("competencies_v1"); 65 | JSONArray competencyData1 = new JSONArray(competencyData); 66 | 67 | for (int id = 0; id < userId.length(); id++) { 68 | System.out.println(userId.get(id)); 69 | String Userid = (String) userId.get(id); 70 | 71 | for (int i = 0; i < competencyData1.length(); i++) { 72 | System.out.println("competency loop inside "); 73 | JSONObject compentency_parse = (JSONObject) competencyData1.get(i); 74 | 75 | // competencies_v1 Info 76 | String cmp_id = compentency_parse.get("competencyId").toString(); 77 | String competencyName = (String) compentency_parse.get("competencyName"); 78 | String competency_level = String.valueOf(compentency_parse.get("level")) ; 79 | System.out.println("cmp_id = " + cmp_id + "competencyName = " + competencyName + "competency_level =" + competency_level); 80 | 81 | // Call Get_entityById (CompetenceId) Api Service 82 | JSONObject get_entity_response = get_entityById(cmp_id); 83 | System.out.println("get_entity_response :" + get_entity_response); 84 | 85 | 86 | System.out.println(get_entity_response.get("name")); 87 | String entity_name = (String) get_entity_response.get("name"); 88 | Integer levelId = (Integer) get_entity_response.get("levelId"); 89 | 90 | // Prepare passbook data 91 | 92 | JSONObject mainobj = new JSONObject(); 93 | JSONObject main1 = new JSONObject(); 94 | main1.put("userId", Userid); 95 | main1.put("typeName", "competency"); 96 | 97 | JSONArray competencyDetails = new JSONArray(); 98 | JSONObject competencyDetails_main_obj = new JSONObject(); 99 | competencyDetails_main_obj.put("competencyId", cmp_id); 100 | 101 | JSONObject additionalParams = new JSONObject(); 102 | additionalParams.put("competencyName", competencyName); 103 | // additionalParams.put("competencyType", (Collection) null); 104 | // additionalParams.put("competencyArea", (Collection) null); 105 | competencyDetails_main_obj.put("additionalParams", additionalParams); 106 | 107 | JSONObject acquiredDetails = new JSONObject(); 108 | 109 | acquiredDetails.put("acquiredChannel", "course"); 110 | acquiredDetails.put("competencyLevelId", competency_level); 111 | // acquiredDetails.put("secondaryPassbookId", (Collection) null); 112 | JSONObject acquiredDetails_additionalParams = new JSONObject(); 113 | acquiredDetails_additionalParams.put("courseId", course_Id); 114 | acquiredDetails_additionalParams.put("courseName", Course_name); 115 | 116 | acquiredDetails.put("additionalParams", acquiredDetails_additionalParams); 117 | competencyDetails_main_obj.put("acquiredDetails", acquiredDetails); 118 | competencyDetails.put(competencyDetails_main_obj); 119 | main1.put("competencyDetails", competencyDetails); 120 | 121 | mainobj.put("request", main1); 122 | System.out.println(mainobj.toString(4)); 123 | Passbook_update(Userid, mainobj); 124 | } 125 | } 126 | return null; 127 | } 128 | 129 | private void Passbook_update(String userId, JSONObject request) throws JsonProcessingException { 130 | 131 | RestTemplate restTemplate = new RestTemplate(); 132 | HttpClient httpClient = HttpClientBuilder.create().build(); 133 | HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient); 134 | restTemplate.setRequestFactory(requestFactory); 135 | 136 | String request_body = request.toString(); 137 | String url = env.getProperty("passbook.update.url"); 138 | String Api_key =env.getProperty("Api.key"); 139 | HttpHeaders header = new HttpHeaders(); 140 | header.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); 141 | header.add("Authorization", Api_key); 142 | header.add("x-authenticated-userid", userId); 143 | Map mapping = new ObjectMapper().readValue(request_body, HashMap.class); 144 | 145 | System.out.println("mapping : " + mapping); 146 | 147 | HttpEntity> entity = new HttpEntity<>(mapping, header); 148 | ResponseEntity passbookResponse = restTemplate.exchange(url, HttpMethod.PATCH, entity, String.class); 149 | System.out.println(passbookResponse); 150 | String responseStr = passbookResponse.getBody(); 151 | int begin = responseStr.indexOf("{"); 152 | int end = responseStr.lastIndexOf("}") + 1; 153 | responseStr = responseStr.substring(begin, end); 154 | System.out.println(responseStr); 155 | JSONObject passbook_payload = new JSONObject(responseStr); 156 | System.out.println(passbook_payload.toString(4)); 157 | 158 | } 159 | 160 | private JSONObject get_entityById(String competency_id) throws JsonProcessingException { 161 | String url = env.getProperty("get.entityById") + competency_id; 162 | System.out.println("get_entityById fun "); 163 | HttpHeaders header = new HttpHeaders(); 164 | header.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); 165 | // header.add("x-authenticated-user-token", token); 166 | 167 | String req = "{\"filter\":{\"isDetail\":true}}"; 168 | Map mapping = new ObjectMapper().readValue(req, HashMap.class); 169 | 170 | HttpEntity> entity = new HttpEntity<>(mapping, header); 171 | ResponseEntity entityResponse = restTemplate.exchange(url, HttpMethod.POST, entity, String.class); 172 | // System.out.println(entityResponse); 173 | String responseStr = entityResponse.getBody(); 174 | int begin = responseStr.indexOf("{"); 175 | int end = responseStr.lastIndexOf("}") + 1; 176 | responseStr = responseStr.substring(begin, end); 177 | // System.out.println(responseStr); 178 | JSONObject passbook_payload = new JSONObject(responseStr); 179 | JSONObject passbook_result = passbook_payload.getJSONObject("result"); 180 | return (JSONObject) passbook_result.get("response"); 181 | 182 | } 183 | 184 | // private void GetPassbook(JSONArray userId) throws JsonProcessingException { 185 | // 186 | // String url = "https://sphere.aastrika.org/api/user/v1/passbook"; 187 | // String Api_key = "bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJTNHNNVFdjZUZqYkxUWGxiczkzUzk4dmFtODBhdkRPUiJ9.nPOCY0-bVX28iNcxxnYbGpihY3ZzfNwx0-SFCnJwjas"; 188 | // for (int i=0; i mapping = new ObjectMapper().readValue(req, HashMap.class); 197 | // 198 | // System.out.println(mapping); 199 | // 200 | // HttpEntity> entity = new HttpEntity<>(mapping, header); 201 | // ResponseEntity entityResponse = restTemplate.exchange(url , HttpMethod.POST, entity, String.class); 202 | // System.out.println(entityResponse); 203 | // String responseStr = entityResponse.getBody(); 204 | // int begin = responseStr.indexOf("{"); 205 | // int end = responseStr.lastIndexOf("}") + 1; 206 | // responseStr = responseStr.substring(begin, end); 207 | // System.out.println(responseStr); 208 | // JSONObject passbook_payload = new JSONObject(responseStr); 209 | // JSONObject passbook_result=passbook_payload.getJSONObject("result"); 210 | // System.out.println(passbook_result); 211 | // 212 | // } 213 | 214 | 215 | } 216 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /usr/local/etc/mavenrc ] ; then 40 | . /usr/local/etc/mavenrc 41 | fi 42 | 43 | if [ -f /etc/mavenrc ] ; then 44 | . /etc/mavenrc 45 | fi 46 | 47 | if [ -f "$HOME/.mavenrc" ] ; then 48 | . "$HOME/.mavenrc" 49 | fi 50 | 51 | fi 52 | 53 | # OS specific support. $var _must_ be set to either true or false. 54 | cygwin=false; 55 | darwin=false; 56 | mingw=false 57 | case "`uname`" in 58 | CYGWIN*) cygwin=true ;; 59 | MINGW*) mingw=true;; 60 | Darwin*) darwin=true 61 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 62 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 63 | if [ -z "$JAVA_HOME" ]; then 64 | if [ -x "/usr/libexec/java_home" ]; then 65 | export JAVA_HOME="`/usr/libexec/java_home`" 66 | else 67 | export JAVA_HOME="/Library/Java/Home" 68 | fi 69 | fi 70 | ;; 71 | esac 72 | 73 | if [ -z "$JAVA_HOME" ] ; then 74 | if [ -r /etc/gentoo-release ] ; then 75 | JAVA_HOME=`java-config --jre-home` 76 | fi 77 | fi 78 | 79 | if [ -z "$M2_HOME" ] ; then 80 | ## resolve links - $0 may be a link to maven's home 81 | PRG="$0" 82 | 83 | # need this for relative symlinks 84 | while [ -h "$PRG" ] ; do 85 | ls=`ls -ld "$PRG"` 86 | link=`expr "$ls" : '.*-> \(.*\)$'` 87 | if expr "$link" : '/.*' > /dev/null; then 88 | PRG="$link" 89 | else 90 | PRG="`dirname "$PRG"`/$link" 91 | fi 92 | done 93 | 94 | saveddir=`pwd` 95 | 96 | M2_HOME=`dirname "$PRG"`/.. 97 | 98 | # make it fully qualified 99 | M2_HOME=`cd "$M2_HOME" && pwd` 100 | 101 | cd "$saveddir" 102 | # echo Using m2 at $M2_HOME 103 | fi 104 | 105 | # For Cygwin, ensure paths are in UNIX format before anything is touched 106 | if $cygwin ; then 107 | [ -n "$M2_HOME" ] && 108 | M2_HOME=`cygpath --unix "$M2_HOME"` 109 | [ -n "$JAVA_HOME" ] && 110 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 111 | [ -n "$CLASSPATH" ] && 112 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 113 | fi 114 | 115 | # For Mingw, ensure paths are in UNIX format before anything is touched 116 | if $mingw ; then 117 | [ -n "$M2_HOME" ] && 118 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 119 | [ -n "$JAVA_HOME" ] && 120 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 121 | fi 122 | 123 | if [ -z "$JAVA_HOME" ]; then 124 | javaExecutable="`which javac`" 125 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 126 | # readlink(1) is not available as standard on Solaris 10. 127 | readLink=`which readlink` 128 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 129 | if $darwin ; then 130 | javaHome="`dirname \"$javaExecutable\"`" 131 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 132 | else 133 | javaExecutable="`readlink -f \"$javaExecutable\"`" 134 | fi 135 | javaHome="`dirname \"$javaExecutable\"`" 136 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 137 | JAVA_HOME="$javaHome" 138 | export JAVA_HOME 139 | fi 140 | fi 141 | fi 142 | 143 | if [ -z "$JAVACMD" ] ; then 144 | if [ -n "$JAVA_HOME" ] ; then 145 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 146 | # IBM's JDK on AIX uses strange locations for the executables 147 | JAVACMD="$JAVA_HOME/jre/sh/java" 148 | else 149 | JAVACMD="$JAVA_HOME/bin/java" 150 | fi 151 | else 152 | JAVACMD="`\\unset -f command; \\command -v java`" 153 | fi 154 | fi 155 | 156 | if [ ! -x "$JAVACMD" ] ; then 157 | echo "Error: JAVA_HOME is not defined correctly." >&2 158 | echo " We cannot execute $JAVACMD" >&2 159 | exit 1 160 | fi 161 | 162 | if [ -z "$JAVA_HOME" ] ; then 163 | echo "Warning: JAVA_HOME environment variable is not set." 164 | fi 165 | 166 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 167 | 168 | # traverses directory structure from process work directory to filesystem root 169 | # first directory with .mvn subdirectory is considered project base directory 170 | find_maven_basedir() { 171 | 172 | if [ -z "$1" ] 173 | then 174 | echo "Path not specified to find_maven_basedir" 175 | return 1 176 | fi 177 | 178 | basedir="$1" 179 | wdir="$1" 180 | while [ "$wdir" != '/' ] ; do 181 | if [ -d "$wdir"/.mvn ] ; then 182 | basedir=$wdir 183 | break 184 | fi 185 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 186 | if [ -d "${wdir}" ]; then 187 | wdir=`cd "$wdir/.."; pwd` 188 | fi 189 | # end of workaround 190 | done 191 | echo "${basedir}" 192 | } 193 | 194 | # concatenates all lines of a file 195 | concat_lines() { 196 | if [ -f "$1" ]; then 197 | echo "$(tr -s '\n' ' ' < "$1")" 198 | fi 199 | } 200 | 201 | BASE_DIR=`find_maven_basedir "$(pwd)"` 202 | if [ -z "$BASE_DIR" ]; then 203 | exit 1; 204 | fi 205 | 206 | ########################################################################################## 207 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 208 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 209 | ########################################################################################## 210 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Found .mvn/wrapper/maven-wrapper.jar" 213 | fi 214 | else 215 | if [ "$MVNW_VERBOSE" = true ]; then 216 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 217 | fi 218 | if [ -n "$MVNW_REPOURL" ]; then 219 | jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 220 | else 221 | jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" 222 | fi 223 | while IFS="=" read key value; do 224 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 225 | esac 226 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 227 | if [ "$MVNW_VERBOSE" = true ]; then 228 | echo "Downloading from: $jarUrl" 229 | fi 230 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 231 | if $cygwin; then 232 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 233 | fi 234 | 235 | if command -v wget > /dev/null; then 236 | if [ "$MVNW_VERBOSE" = true ]; then 237 | echo "Found wget ... using wget" 238 | fi 239 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 240 | wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" 241 | else 242 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" 243 | fi 244 | elif command -v curl > /dev/null; then 245 | if [ "$MVNW_VERBOSE" = true ]; then 246 | echo "Found curl ... using curl" 247 | fi 248 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 249 | curl -o "$wrapperJarPath" "$jarUrl" -f 250 | else 251 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 252 | fi 253 | 254 | else 255 | if [ "$MVNW_VERBOSE" = true ]; then 256 | echo "Falling back to using Java to download" 257 | fi 258 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 259 | # For Cygwin, switch paths to Windows format before running javac 260 | if $cygwin; then 261 | javaClass=`cygpath --path --windows "$javaClass"` 262 | fi 263 | if [ -e "$javaClass" ]; then 264 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 265 | if [ "$MVNW_VERBOSE" = true ]; then 266 | echo " - Compiling MavenWrapperDownloader.java ..." 267 | fi 268 | # Compiling the Java class 269 | ("$JAVA_HOME/bin/javac" "$javaClass") 270 | fi 271 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 272 | # Running the downloader 273 | if [ "$MVNW_VERBOSE" = true ]; then 274 | echo " - Running MavenWrapperDownloader.java ..." 275 | fi 276 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 277 | fi 278 | fi 279 | fi 280 | fi 281 | ########################################################################################## 282 | # End of extension 283 | ########################################################################################## 284 | 285 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 286 | if [ "$MVNW_VERBOSE" = true ]; then 287 | echo $MAVEN_PROJECTBASEDIR 288 | fi 289 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 290 | 291 | # For Cygwin, switch paths to Windows format before running java 292 | if $cygwin; then 293 | [ -n "$M2_HOME" ] && 294 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 295 | [ -n "$JAVA_HOME" ] && 296 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 297 | [ -n "$CLASSPATH" ] && 298 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 299 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 300 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 301 | fi 302 | 303 | # Provide a "standardized" way to retrieve the CLI args that will 304 | # work with both Windows and non-Windows executions. 305 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 306 | export MAVEN_CMD_LINE_ARGS 307 | 308 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 309 | 310 | exec "$JAVACMD" \ 311 | $MAVEN_OPTS \ 312 | $MAVEN_DEBUG_OPTS \ 313 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 314 | "-Dmaven.home=${M2_HOME}" \ 315 | "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 316 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 317 | --------------------------------------------------------------------------------