Permalink
Browse files

Initial commit

  • Loading branch information...
zemlyanoi committed Nov 6, 2017
0 parents commit 6aea8ab357a366e9bdaa5f84bf9cfd204e8b5b9c
Showing with 2,582 additions and 0 deletions.
  1. +35 −0 .gitignore
  2. +13 −0 Dockerfile
  3. +120 −0 Jenkinsfile
  4. +75 −0 Jenkinsfile-case-management-api-tests
  5. 0 LICENSE
  6. +64 −0 README.md
  7. +282 −0 build.gradle
  8. +91 −0 config/case-management-api.yml
  9. +44 −0 config/shiro.ini
  10. +37 −0 config/shiro_nosec.ini
  11. +32 −0 config/shiro_v2.ini
  12. BIN config/testKeyStore.jks
  13. +30 −0 docker/docker-compose.yml
  14. +12 −0 docker/env_template
  15. +17 −0 entrypoint.sh
  16. +3 −0 env.sample
  17. +6 −0 gradle.properties
  18. BIN gradle/wrapper/gradle-wrapper.jar
  19. +6 −0 gradle/wrapper/gradle-wrapper.properties
  20. +172 −0 gradlew
  21. +84 −0 gradlew.bat
  22. +2 −0 settings.gradle
  23. +69 −0 src/main/java/gov/ca/cwds/cm/BaseCmApiApplication.java
  24. +41 −0 src/main/java/gov/ca/cwds/cm/CmApiApplication.java
  25. +19 −0 src/main/java/gov/ca/cwds/cm/CmApiConfiguration.java
  26. +65 −0 src/main/java/gov/ca/cwds/cm/Constants.java
  27. +10 −0 src/main/java/gov/ca/cwds/cm/Identifiable.java
  28. +12 −0 src/main/java/gov/ca/cwds/cm/RequestResponse.java
  29. +21 −0 src/main/java/gov/ca/cwds/cm/auth/PerryUserIdentity.java
  30. +33 −0 src/main/java/gov/ca/cwds/cm/inject/AbstractInjectProvider.java
  31. +63 −0 src/main/java/gov/ca/cwds/cm/inject/ApplicationModule.java
  32. +59 −0 src/main/java/gov/ca/cwds/cm/inject/DataAccessModule.java
  33. +26 −0 src/main/java/gov/ca/cwds/cm/inject/FiltersModule.java
  34. +30 −0 src/main/java/gov/ca/cwds/cm/inject/InjectorHolder.java
  35. +20 −0 src/main/java/gov/ca/cwds/cm/inject/MappingModule.java
  36. +26 −0 src/main/java/gov/ca/cwds/cm/inject/ResourcesModule.java
  37. +32 −0 src/main/java/gov/ca/cwds/cm/inject/ServicesModule.java
  38. +1 −0 src/main/java/gov/ca/cwds/cm/package-info.java
  39. +32 −0 src/main/java/gov/ca/cwds/cm/service/CrudServiceAdapter.java
  40. +33 −0 src/main/java/gov/ca/cwds/cm/service/TypedCrudServiceAdapter.java
  41. +31 −0 src/main/java/gov/ca/cwds/cm/service/dto/BaseDTO.java
  42. +28 −0 src/main/java/gov/ca/cwds/cm/service/dto/CollectionDTO.java
  43. +67 −0 src/main/java/gov/ca/cwds/cm/service/dto/system/HealthCheckResultDTO.java
  44. +59 −0 src/main/java/gov/ca/cwds/cm/service/dto/system/SystemInformationDTO.java
  45. +1 −0 src/main/java/gov/ca/cwds/cm/service/package-info.java
  46. +57 −0 src/main/java/gov/ca/cwds/cm/web/rest/filters/RequestExecutionContext.java
  47. +77 −0 src/main/java/gov/ca/cwds/cm/web/rest/filters/RequestExecutionContextFilter.java
  48. +135 −0 src/main/java/gov/ca/cwds/cm/web/rest/filters/RequestExecutionContextImpl.java
  49. +35 −0 src/main/java/gov/ca/cwds/cm/web/rest/filters/RequestExecutionContextRegistry.java
  50. +279 −0 src/main/java/gov/ca/cwds/cm/web/rest/filters/RequestResponseLoggingFilter.java
  51. +1 −0 src/main/java/gov/ca/cwds/cm/web/rest/package-info.java
  52. +93 −0 src/main/java/gov/ca/cwds/cm/web/rest/system/SystemInformationResource.java
  53. +2 −0 src/main/resources/version.properties
@@ -0,0 +1,35 @@
*.iml
.gradle/
build/
.classpath
.project
.settings/
bin/
.idea
*.env
*.sw*
/build/
/.idea/
/.gradle/
# dependencies
*/node_modules
# testing
*/coverage
# production
*/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
out/
gradle/wrapper
@@ -0,0 +1,13 @@
FROM cwds/javajdk
RUN mkdir /opt/case-management-api
RUN mkdir /opt/case-management-api/logs
ADD config/*.yml /opt/case-management-api/
ADD config/shiro.ini /opt/case-management-api/config/shiro.ini
ADD config/shiro_nosec.ini /opt/case-management-api/config/shiro_nosec.ini
ADD config/testKeyStore.jks /opt/case-management-api/config/testKeyStore.jks
ADD build/libs/case-management-api-dist.jar /opt/case-management-api/case-management-api.jar
ADD build/entrypoint.sh /opt/case-management-api/
EXPOSE 8080
RUN chmod +x /opt/case-management-api/entrypoint.sh
WORKDIR /opt/case-management-api
CMD ["/opt/case-management-api/entrypoint.sh"]
@@ -0,0 +1,120 @@
def notifyBuild(String buildStatus, Exception e) {
buildStatus = buildStatus ?: 'SUCCESSFUL'
// Default values
def colorName = 'RED'
def colorCode = '#FF0000'
def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'"
def summary = """*${buildStatus}*: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':\nMore detail in console output at <${env.BUILD_URL}|${env.BUILD_URL}>"""
def details = """${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':\n
Check console output at ${env.BUILD_URL} """
// Override default values based on build status
if (buildStatus == 'STARTED') {
color = 'YELLOW'
colorCode = '#FFFF00'
} else if (buildStatus == 'SUCCESSFUL') {
color = 'GREEN'
colorCode = '#00FF00'
} else {
color = 'RED'
colorCode = '#FF0000'
details +="<p>Error message ${e.message}, stacktrace: ${e}</p>"
summary +="\nError message ${e.message}, stacktrace: ${e}"
}
// Send notifications
slackSend channel: "#case-management-api", baseUrl: 'https://hooks.slack.com/services/', tokenCredentialId: 'slackmessagetpt3', color: colorCode, message: summary
emailext(
subject: subject,
body: details,
attachLog: true,
recipientProviders: [[$class: 'DevelopersRecipientProvider']],
to: "Igor.Chornobay@osi.ca.gov, Alex.Kuznetsov@osi.ca.gov, Dmytro.Sorych@osi.ca.gov, denis.davydov@osi.ca.gov, oleksii.khilkevych@osi.ca.gov, mykhailo.zemlianyi@osi.ca.gov, Dmytro.Palczewski@osi.ca.gov"
)
}
node ('dora-slave'){
def serverArti = Artifactory.server 'CWDS_DEV'
def rtGradle = Artifactory.newGradleBuild()
properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '5')), disableConcurrentBuilds(), [$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false],
parameters([
string(defaultValue: 'latest', description: '', name: 'APP_VERSION'),
string(defaultValue: 'development', description: '', name: 'branch'),
booleanParam(defaultValue: false, description: '', name: 'RELEASE_DOCKER'),
booleanParam(defaultValue: true, description: '', name: 'USE_NEWRELIC'),
string(defaultValue: 'inventories/tpt2dev/hosts.yml', description: '', name: 'inventory')
]), pipelineTriggers([pollSCM('H/5 * * * *')])])
try {
stage('Preparation') {
git branch: '$branch', url: 'https://github.com/ca-cwds/case-management-api.git'
rtGradle.tool = "Gradle_35"
rtGradle.resolver repo:'repo', server: serverArti
rtGradle.useWrapper = true
}
stage('Build'){
def buildInfo = rtGradle.run buildFile: 'build.gradle', tasks: 'jar'
}
stage('Unit Tests') {
buildInfo = rtGradle.run buildFile: 'build.gradle', tasks: 'test jacocoTestReport', switches: '--stacktrace'
publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true, reportDir: 'build/reports/tests/test', reportFiles: 'index.html', reportName: 'JUnit Report', reportTitles: 'JUnit tests summary'])
}
stage('License Report') {
buildInfo = rtGradle.run buildFile: 'build.gradle', tasks: 'downloadLicenses'
publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true, reportDir: 'build/reports/license', reportFiles: 'license-dependency.html', reportName: 'License Report', reportTitles: 'License summary'])
}
stage('SonarQube analysis'){
withSonarQubeEnv('Core-SonarQube') {
buildInfo = rtGradle.run buildFile: 'build.gradle', switches: '--info', tasks: 'sonarqube'
}
}
stage ('Push to artifactory'){
rtGradle.deployer repo:'libs-snapshot', server: serverArti
//rtGradle.deployer repo:'libs-release', server: serverArti
rtGradle.deployer.deployArtifacts = true
//buildInfo = rtGradle.run buildFile: 'build.gradle', tasks: 'artifactoryPublish'
buildInfo = rtGradle.run buildFile: 'build.gradle', tasks: 'publish'
rtGradle.deployer.deployArtifacts = false
}
stage ('Build Docker'){
buildInfo = rtGradle.run buildFile: 'build.gradle', tasks: 'createDockerImage'
withDockerRegistry([credentialsId: '6ba8d05c-ca13-4818-8329-15d41a089ec0']) {
buildInfo = rtGradle.run buildFile: 'build.gradle', tasks: 'publishDocker -DReleaseDocker=$RELEASE_DOCKER -DBuildNumber=$BUILD_NUMBER'
}
}
stage('Clean Workspace') {
buildInfo = rtGradle.run buildFile: 'build.gradle', tasks: 'dropDockerImage'
archiveArtifacts artifacts: '**/case-management-api-*.jar,readme.txt', fingerprint: true
cleanWs()
}
stage('Deploy Application'){
checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '433ac100-b3c2-4519-b4d6-207c029a103b', url: 'git@github.com:ca-cwds/de-ansible.git']]]
sh 'ansible-playbook -e NEW_RELIC_AGENT=$USE_NEWRELIC -e API_VERSION=$APP_VERSION -i $inventory deploy-casemanagementapi.yml --vault-password-file ~/.ssh/vault.txt -vv'
cleanWs()
sleep (20)
}
stage('Smoke Tests') {
git branch: 'development', url: 'https://github.com/ca-cwds/case-management-api.git'
buildInfo = rtGradle.run buildFile: 'build.gradle', tasks: 'smokeTest --stacktrace'
publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true, reportDir: 'build/reports/tests/smokeTest', reportFiles: 'index.html', reportName: 'Smoke Tests Report', reportTitles: 'Smoke tests summary'])
}
stage('Integration Tests') {
git branch: 'development', url: 'https://github.com/ca-cwds/case-management-api.git'
buildInfo = rtGradle.run buildFile: 'build.gradle', tasks: 'integrationTest --stacktrace'
publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true, reportDir: 'build/reports/tests/integrationTest', reportFiles: 'index.html', reportName: 'Integration Tests Report', reportTitles: 'Integration tests summary'])
cleanWs()
}
} catch (Exception e) {
errorcode = e
currentBuild.result = "FAIL"
notifyBuild(currentBuild.result,errorcode)
throw e;
}finally {
publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true, reportDir: 'build/reports/tests/smokeTest', reportFiles: 'index.html', reportName: 'Smoke Tests Reports', reportTitles: 'Smoke tests summary'])
publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true, reportDir: 'build/reports/tests/integrationTest', reportFiles: 'index.html', reportName: 'Integration Tests Reports', reportTitles: 'Integration tests summary'])
publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true, reportDir: 'build/reports/tests/test', reportFiles: 'index.html', reportName: 'JUnitReports', reportTitles: 'JUnit tests summary'])
cleanWs()
}
}
@@ -0,0 +1,75 @@
def notifyBuild(String buildStatus, Exception e) {
buildStatus = buildStatus ?: 'SUCCESSFUL'
// Default values
def colorName = 'RED'
def colorCode = '#FF0000'
def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'"
def summary = """*${buildStatus}*: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':\nMore detail in console output at <${env.BUILD_URL}|${env.BUILD_URL}>"""
def details = """${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':\n
Check console output at ${env.BUILD_URL} """
// Override default values based on build status
if (buildStatus == 'STARTED') {
color = 'YELLOW'
colorCode = '#FFFF00'
} else if (buildStatus == 'SUCCESSFUL') {
color = 'GREEN'
colorCode = '#00FF00'
} else {
color = 'RED'
colorCode = '#FF0000'
details +="<p>Error message ${e.message}, stacktrace: ${e}</p>"
summary +="\nError message ${e.message}, stacktrace: ${e}"
}
// Send notifications
slackSend channel: "#forms-api", baseUrl: 'https://hooks.slack.com/services/', tokenCredentialId: 'slackmessagetpt2', color: colorCode, message: summary
emailext(
subject: subject,
body: details,
attachLog: true,
recipientProviders: [[$class: 'DevelopersRecipientProvider']],
to: "Alex.Kuznetsov@osi.ca.gov, leonid.marushevskiy@osi.gov.ca"
)
}
node ('preint') {
def serverArti = Artifactory.newServer url: 'https://jcenter.bintray.com'
def rtGradle = Artifactory.newGradleBuild()
properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '5')),
[$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false],
parameters([
string(defaultValue: 'development', description: '', name: 'branch'),
string(defaultValue: 'https://forms-api.preint.cwds.io/', description: '', name: 'APP_URL')]),pipelineTriggers([])])
def errorcode = null;
def buildInfo = '';
try {
stage('Preparation') {
cleanWs()
git branch: '$branch', credentialsId: '433ac100-b3c2-4519-b4d6-207c029a103b', url: 'git@github.com:ca-cwds/forms-api.git'
rtGradle.tool = "Gradle_3.5.1"
rtGradle.resolver server: serverArti
rtGradle.useWrapper = true
}
stage('Run tests'){
writeFile file: "gradle.properties", text: "forms-api.url=${APP_URL}"
buildInfo = rtGradle.run buildFile: 'build.gradle', tasks: 'integrationTest'
}
} catch (Exception e) {
errorcode = e
currentBuild.result = "FAIL"
notifyBuild(currentBuild.result,errorcode)
throw e;
}finally {
publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true, reportDir: 'build/reports/tests/integrationTest', reportFiles: 'index.html', reportName: 'Integration Test Report', reportTitles: ''])
cleanWs()
}
}
No changes.
@@ -0,0 +1,64 @@
# CWDS CASE MANAGEMENT API
The CWDS API provides Forms Generation RESTful services for the CWDS CALS Digital Service.
## Wiki
The development team is actively using the [Github Wiki](https://github.com/ca-cwds/case-management-api/wiki).
## Documentation
The development team uses [Swagger](http://swagger.io/) for documenting the API.
NOTE : At this time there is not a publicy available link to the documentation, a link will be provided as soon as one is available.
## Configuration
### Application Configuration Parameters
- APP_VERSION -- Version of application
### SSL Configuration Parameters
- KEY_STORE_FILE -- Path to keystore file
- KEY_STORE_PASSWORD -- Keystore password
### Data Stores Configuration Parameters
The CWDS API currently utilizes four persistent stores:
In order for the CASE MANAGEMENT API successfully connect to the databases the following environment variables are required to be set:
#### DB2 - CMS database
- DB_CMS_USER -- the CMS database username
- DB_CMS_PASSWORD -- the CMS database password
- DB_CMS_DB2_HOST -- the CMS DB2 host (IP - address)
- DB_CMS_DB2_PORT -- the CMS DB2 port number
- DB_CMS_DB_NAME -- the CMS database name
- DB_CMS_JDBC_URL -- the CMS database URL in Java Database Connectivity format
- DB_CMS_SCHEMA -- the CMS database schema the tables belong to.
- DB_CMS_CP_INITIAL_SIZE -- the CMS connections pool iniitial size (default: 2)
- DB_CMS_CP_MIN_SIZE -- the CMS connections pool minimum size (default: 2)
- DB_CMS_CP_MAX_SIZE -- the CMS connections pool maximum size (default: 8)
#### Swagger Configuration Parameters**
- LOGIN_URL -- Login URL
- LOGOUT_URL -- Logout URL
- SHOW_SWAGGER -- Show swagger (true | false) default - true
- SWAGGER_JSON_URL -- default - http://localhost:8080/swagger.json
- SWAGGER_CALLBACK_URL -- default - http://localhost:8080/swagger
#### Shiro Configuration Parameters
- SHIRO_CONFIG_PATH -- path to Shiro configuration file
The Docker env-file option provides a convenient method to supply these variables. These instructions assume an env file called .env located in the current directory. The repository contains a sample env file called env.sample.
Further configuration options are available in the file config/case-management-api.yml.
## Testing
### Integration testing
To run Integration tests set property api.url to point to environment host. Use gradle integrationTest task. In this case token will be generated for default test user, so it's possible to test environment with Perry running in dev mode.
### Smoke Testing
Smoke test suite is part of integration tests. Set api.url, use gradle smokeTestSuite task. Smoke test endpoint is not protected by Perry.
Oops, something went wrong.

0 comments on commit 6aea8ab

Please sign in to comment.