just getting it her

master
nathan wagner 3 years ago
commit ffc1246564

6
.gitattributes vendored

@ -0,0 +1,6 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

21
.gitignore vendored

@ -0,0 +1,21 @@
*.iml
*.ipr
*.ids
*.iws
.idea/
.project
.metadata
local.properties
.classpath
.settings/
.loadpath
target/
.gradle
build/
*.log*
/classes/

277
Jenkinsfile vendored

@ -0,0 +1,277 @@
/*
* spring-music-cf service pipeline, file lives inside of app repository.
*
* See https://jenkins.io/doc/book/pipeline/syntax/ for details on the file format.
*/
// Branch to build
def gitBranch
// Build version of parcel-shipping-service
def deployVersion
// Whether the build will be deployed to production
def officialBuild
def deployToDev
def deployToTest
def deployToAze
// Pipeline should run build stage
def doBuild
pipeline {
// Choose the Jenkins VM configuration (definitions are in vault)
agent {
node {
label 'pipes-docker-agent'
}
}
// A pipeline consists of a series of stages
stages {
stage('Ingest Build Options') {
steps {
echo 'Parsing options passed in through Jenkins'
echo ''
echo "Unparsed content: ${params}"
script {
// Use version passed in through Jenkins if possible; otherwise, get new version
deployVersion = params.ARTIFACT_VERSION
if (!deployVersion) {
deployVersion = sh(returnStdout: true, script: "./version.sh").trim()
}
echo "deployVersion: '${deployVersion}'"
}
script {
gitBranch = params.GIT_BRANCH
echo "gitBranch: '${gitBranch}'"
}
script{
officialBuild = (params.OFFICIAL_BUILD as boolean)
deployToDev = (params.deploy_to_dev as boolean)
deployToTest = (params.deploy_to_test as boolean)
deployToAze = (params.deploy_to_aze as boolean)
echo "officialBuild: '${officialBuild}'"
}
script {
doBuild = (params.ARTIFACT_VERSION == '')
echo "doBuild: ${doBuild}"
}
// validate the combination of flags passed
script {
if (doBuild) {
echo "Building version '${deployVersion}'"
}
if (!doBuild) {
echo "Deploying previous build ${deployVersion}"
}
}
}
}
/* stage('Checkout Config Repository') {
when { expression { doBuild } }
steps {
echo 'Checkout Config Repository'
dir("./../parcel-shipping-service-config") {
git branch: "master",
credentialsId: 'github_credential',
url: 'https://github.gapinc.com/parcel-shipping/parcel-shipping-service-config.git'
}
}
}*/
stage('Build Artifacts') {
when { expression { doBuild } }
steps {
echo 'Build, deploy to Artifactory'
/* withCredentials(bindings: [
sshUserPrivateKey(credentialsId: 'pss-prod-rsakey', keyFileVariable: 'PSS_PROD_KEY', passphraseVariable: 'PSS_PROD_PASSPHRASE', usernameVariable: 'PSS_PROD_USERNAME'),
sshUserPrivateKey(credentialsId: 'pss-dev-rsakey', keyFileVariable: 'PSS_DEV_KEY', passphraseVariable: 'PSS_DEV_PASSPHRASE', usernameVariable: 'PSS_DEV_USERNAME')
]){
sh "./cpfile.sh $PSS_DEV_KEY 'src/main/resources/pssdev.rsa'"
sh "./cpfile.sh $PSS_PROD_KEY 'src/main/resources/pssprod.rsa'"
}
withCredentials(bindings: [ string(credentialsId: 'pss-oci-sso-wallet-dev', variable: 'PSS_OCI_SSO_WALLET_DEV'),
string(credentialsId: 'pss-oci-sso-p12-dev', variable: 'PSS_OCI_SSO_P12_DEV'),
string(credentialsId: 'pss-oci-sso-wallet-test', variable: 'PSS_OCI_SSO_WALLET_TEST'),
string(credentialsId: 'pss-oci-sso-p12-test', variable: 'PSS_OCI_SSO_P12_TEST')]) {
sh "mkdir -p src/main/resources/wallet"
sh "./oci_wallet_cpfile.sh $PSS_OCI_SSO_WALLET_DEV 'src/main/resources/wallet' 'dev' 'dev/cwallet.sso'"
sh "./oci_wallet_cpfile.sh $PSS_OCI_SSO_P12_DEV 'src/main/resources/wallet' 'dev' 'dev/ewallet.p12'"
sh "./oci_wallet_cpfile.sh $PSS_OCI_SSO_WALLET_TEST 'src/main/resources/wallet' 'test' 'test/cwallet.sso'"
sh "./oci_wallet_cpfile.sh $PSS_OCI_SSO_P12_TEST 'src/main/resources/wallet' 'test' 'test/ewallet.p12'"
}
withCredentials(bindings: [ string(credentialsId: 'pss-confluent-client-keystore-dev-jks', variable: 'PSS_CONFLUENT_CLIENT_KEYSTORE_DEV_JKS'),
string(credentialsId: 'pss-confluent-client-keystore-stage-jks', variable: 'PSS_CONFLUENT_CLIENT_KEYSTORE_STAGE_JKS'),
string(credentialsId: 'pss-confluent-client-keystore-prod-jks', variable: 'PSS_CONFLUENT_CLIENT_KEYSTORE_PROD_JKS'),
string(credentialsId: 'pss-confluent-client-truststore-jks', variable: 'PSS_CONFLUENT_CLIENT_TRUSTSTORE_JKS')]) {
sh "./oci_wallet_cpfile.sh $PSS_CONFLUENT_CLIENT_KEYSTORE_DEV_JKS 'src/main/resources' 'clientSSL' 'clientSSL/confluent.client.keystore.dev.jks'"
sh "./oci_wallet_cpfile.sh $PSS_CONFLUENT_CLIENT_KEYSTORE_STAGE_JKS 'src/main/resources' 'clientSSL' 'clientSSL/confluent.client.keystore.stage.jks'"
sh "./oci_wallet_cpfile.sh $PSS_CONFLUENT_CLIENT_KEYSTORE_PROD_JKS 'src/main/resources' 'clientSSL' 'clientSSL/confluent.client.keystore.prod.jks'"
sh "./oci_wallet_cpfile.sh $PSS_CONFLUENT_CLIENT_TRUSTSTORE_JKS 'src/main/resources' 'clientSSL' 'clientSSL/confluent.client.truststore.jks'"
}*/
withCredentials([usernamePassword(usernameVariable: 'GITHUB_USERNAME', passwordVariable: 'GITHUB_PASSWORD', credentialsId: 'github_credential'),
usernamePassword(usernameVariable: 'ARTIFACTORY_USERNAME', passwordVariable: 'ARTIFACTORY_PASSWORD', credentialsId: 'pt-classroom-artifactory-token')]) {
sh "./gradlew clean build uploadBootArchives"
}
//sh "./gradlew clean build uploadArchives"
//sh "./gradlew clean build"
}
}
stage('Deploy to DEV') {
when { expression { deployToDev } }
steps {
echo 'Deploy from Artifactory to DEV'
build job: 'spring_music_cf_service_deploy_to_dev', parameters: [[$class: 'StringParameterValue', name: 'ARTIFACT_VERSION', value: "${deployVersion}"]]
}
}
stage('Deploy to TEST') {
when { expression { deployToTest } }
steps {
echo 'Deploy from Artifactory to TEST'
build job: 'spring_music_cf_service_deploy_to_test', parameters: [[$class: 'StringParameterValue', name: 'ARTIFACT_VERSION', value: "${deployVersion}"]]
}
}
stage('Deploy to E2E2') {
when { expression { officialBuild } }
steps {
echo 'Deploy from Artifactory to E2E2'
build job: 'spring_music_cf_service_deploy_to_e2e2', parameters: [[$class: 'StringParameterValue', name: 'ARTIFACT_VERSION', value: "${deployVersion}"]]
}
}
stage('Deploy to AZE DEV') {
when { expression { deployToAze} }
steps {
echo 'Deploy from Artifactory to AZE DEV'
build job: 'spring_music_cf_service_deploy_to_azedev', parameters: [[$class: 'StringParameterValue', name: 'ARTIFACT_VERSION', value: "${deployVersion}"]]
}
}
stage('Deploy to AZE TEST') {
when { expression { deployToTest && deployToAze } }
steps {
echo 'Deploy from Artifactory to AZE TEST'
build job: 'spring_music_cf_service_deploy_to_azetest', parameters: [[$class: 'StringParameterValue', name: 'ARTIFACT_VERSION', value: "${deployVersion}"]]
}
}
stage('Deploy to AZE E2E2') {
when { expression { officialBuild && deployToAze} }
steps {
echo 'Deploy from Artifactory to AZE E2E2'
build job: 'parcel_shipping_service_deploy_to_azee2e2', parameters: [[$class: 'StringParameterValue', name: 'ARTIFACT_VERSION', value: "${deployVersion}"]]
}
}
// stage('Deploy to PROD') {
// when { expression { officialBuild } }
// steps {
// echo 'Deploy from Artifactory to PROD'
// build job: 'parcel_shipping_service_deploy_to_prod', parameters: [[$class: 'StringParameterValue', name: 'ARTIFACT_VERSION', value: "${deployVersion}"]]
// }
// }
}
post {
success {
notifyTeam(deployVersion, 'SUCCESS')
}
failure {
notifyTeam(deployVersion, 'FAILURE')
}
}
}
def notifyTeam(deployVersion, status) {
// don't send an email just for refreshing parameters, unless it fails
if (params.refreshParameters && (status == 'SUCCESS')) {
return
}
def recipients = 'nathan_wagner@gap.com'
def presendScript
if (status == 'SUCCESS') {
presendScript = ''
} else {
// failed builds are marked important
presendScript = """
msg.addHeader("X-Priority", "1 (Highest)");
msg.addHeader("Importance", "High");
"""
}
def buildStart = new java.text.SimpleDateFormat("h:mm a z 'on' MMMM d").format(new Date(currentBuild.startTimeInMillis))
def durationSeconds = (currentBuild.duration / 1000) as Long
def buildDuration = [
'hour': (durationSeconds / 3600) as Long,
'minute': (((durationSeconds / 60) as Long) % 60),
'second': durationSeconds % 60,
].findAll { it.value > 0 }.collect { "${it.value} ${it.key}${it.value == 1 ? '' : 's'}" }.join(', ')
def changeSet
if (currentBuild.changeSets.every { it.emptySet }) {
changeSet = '<tr><td colspan="2"><code>No changes since last build.</code></td></tr>'
} else {
changeSet = currentBuild.changeSets.collect {
it.items.collect { "<tr><td>${it.author.fullName}</td><td>${it.msg}</td></tr>" }
}.flatten().join('\n')
}
def touchedFiles = currentBuild.changeSets.collect {
it.items.collect { it.affectedPaths.collect { "<li><code>${it}</code></li>" } }
}.flatten().sort().unique(false).join('\n') ?: '<li>No files changed since last build.</li>'
def emailBody = [
"<h2>${currentBuild.fullDisplayName}</h2>",
"<p>${currentBuild.buildCauses[0].shortDescription} at ${buildStart}.</p>",
"<p>The build took ${buildDuration}.</p>",
"<p>View the build <a href='${currentBuild.absoluteUrl}'>in Jenkins</a>.</p>",
"<p>To redeploy the same artifacts, use deployVersion: <code>${deployVersion}</code></p>",
'<h3>Commits:</h3>',
'<style>tr:nth-child(3n) { background: #eee; }</style>',
'<table>',
'<thead style="background: #ddd;"><tr><th>Git Author</th><th>Commit Message</th></tr></thead>',
'<tbody>',
changeSet,
'</tbody>',
'</table>',
'<h3>Touched files:</h3>',
'<ul style="list-style-type: none;">',
touchedFiles,
'</ul>',
].join('\n')
emailext(
subject: "${status}: ${currentBuild.fullDisplayName}",
to: recipients,
body: emailBody,
mimeType: 'text/html',
presendScript: presendScript
)
}

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

@ -0,0 +1,133 @@
Spring Music
============
This is a sample application for using database services on [Cloud Foundry](http://cloudfoundry.org) with the [Spring Framework](http://spring.io) and [Spring Boot](http://projects.spring.io/spring-boot/).
This application has been built to store the same domain objects in one of a variety of different persistence technologies - relational, document, and key-value stores. This is not meant to represent a realistic use case for these technologies, since you would typically choose the one most applicable to the type of data you need to store, but it is useful for testing and experimenting with different types of services on Cloud Foundry.
The application use Spring Java configuration and [bean profiles](http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-profiles.html) to configure the application and the connection objects needed to use the persistence stores. It also uses the [Java CFEnv](https://github.com/pivotal-cf/java-cfenv/) library to inspect the environment when running on Cloud Foundry. See the [Cloud Foundry documentation](http://docs.cloudfoundry.org/buildpacks/java/spring-service-bindings.html) for details on configuring a Spring application for Cloud Foundry.
## Building
This project requires a Java version between 8 and 17 to compile.
To build a runnable Spring Boot jar file, run the following command:
~~~
$ ./gradlew clean assemble
~~~
## Running the application locally
One Spring bean profile should be activated to choose the database provider that the application should use. The profile is selected by setting the system property `spring.profiles.active` when starting the app.
The application can be started locally using the following command:
~~~
$ java -jar -Dspring.profiles.active=<profile> build/libs/spring-music.jar
~~~
where `<profile>` is one of the following values:
* `mysql`
* `postgres`
* `mongodb`
* `redis`
If no profile is provided, an in-memory relational database will be used. If any other profile is provided, the appropriate database server must be started separately. Spring Boot will auto-configure a connection to the database using it's auto-configuration defaults. The connection parameters can be configured by setting the appropriate [Spring Boot properties](http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html).
If more than one of these profiles is provided, the application will throw an exception and fail to start.
## Running the application on Cloud Foundry
When running on Cloud Foundry, the application will detect the type of database service bound to the application (if any). If a service of one of the supported types (MySQL, Postgres, Oracle, MongoDB, or Redis) is bound to the app, the appropriate Spring profile will be configured to use the database service. The connection strings and credentials needed to use the service will be extracted from the Cloud Foundry environment.
If no bound services are found containing any of these values in the name, an in-memory relational database will be used.
If more than one service containing any of these values is bound to the application, the application will throw an exception and fail to start.
After installing the 'cf' [command-line interface for Cloud Foundry](http://docs.cloudfoundry.org/cf-cli/), targeting a Cloud Foundry instance, and logging in, the application can be built and pushed using these commands:
~~~
$ cf push
~~~
The application will be pushed using settings in the provided `manifest.yml` file. The output from the command will show the URL that has been assigned to the application.
### Creating and binding services
Using the provided manifest, the application will be created without an external database (in the `in-memory` profile). You can create and bind database services to the application using the information below.
#### System-managed services
Depending on the Cloud Foundry service provider, persistence services might be offered and managed by the platform. These steps can be used to create and bind a service that is managed by the platform:
~~~
# view the services available
$ cf marketplace
# create a service instance
$ cf create-service <service> <service plan> <service name>
# bind the service instance to the application
$ cf bind-service <app name> <service name>
# restart the application so the new service is detected
$ cf restart
~~~
#### User-provided services
Cloud Foundry also allows service connection information and credentials to be provided by a user. In order for the application to detect and connect to a user-provided service, a single `uri` field should be given in the credentials using the form `<dbtype>://<username>:<password>@<hostname>:<port>/<databasename>`.
These steps use examples for username, password, host name, and database name that should be replaced with real values.
~~~
# create a user-provided Oracle database service instance
$ cf create-user-provided-service oracle-db -p '{"uri":"oracle://root:secret@dbserver.example.com:1521/mydatabase"}'
# create a user-provided MySQL database service instance
$ cf create-user-provided-service mysql-db -p '{"uri":"mysql://root:secret@dbserver.example.com:3306/mydatabase"}'
# bind a service instance to the application
$ cf bind-service <app name> <service name>
# restart the application so the new service is detected
$ cf restart
~~~
#### Changing bound services
To test the application with different services, you can simply stop the app, unbind a service, bind a different database service, and start the app:
~~~
$ cf unbind-service <app name> <service name>
$ cf bind-service <app name> <service name>
$ cf restart
~~~
#### Database drivers
Database drivers for MySQL, Postgres, Microsoft SQL Server, MongoDB, and Redis are included in the project.
To connect to an Oracle database, you will need to download the appropriate driver (e.g. from http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html). Then make a `libs` directory in the `spring-music` project, and move the driver, `ojdbc7.jar` or `ojdbc8.jar`, into the `libs` directory.
In `build.gradle`, uncomment the line `compile files('libs/ojdbc8.jar')` or `compile files('libs/ojdbc7.jar')` and run `./gradle assemble`.
## Alternate Java versions
By default, the application will be built and deployed using Java 8 compatibility.
If you want to use a more recent version of Java, you will need to update two things.
In `build.gradle`, change the `targetCompatibility` Java version:
~~~
java {
...
targetCompatibility = JavaVersion.VERSION_1_8
}
~~~
Set `targetCompatibility` to `JavaVersion.VERSION_11` for Java 11 or `JavaVersion.VERSION_17` for Java 17.
In `manifest.yml`, uncomment and change the Java buildpack JRE version:
~~~
# JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 11.+ } }'
~~~
Set the version to `11.+` for Java 11 or `17.+` for Java 17.

@ -0,0 +1,205 @@
[
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Nirvana",
"title": "Nevermind",
"releaseYear": "1991",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "The Beach Boys",
"title": "Pet Sounds",
"releaseYear": "1966",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Marvin Gaye",
"title": "What's Going On",
"releaseYear": "1971",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Jimi Hendrix Experience",
"title": "Are You Experienced?",
"releaseYear": "1967",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "U2",
"title": "The Joshua Tree",
"releaseYear": "1987",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "The Beatles",
"title": "Abbey Road",
"releaseYear": "1969",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Fleetwood Mac",
"title": "Rumours",
"releaseYear": "1977",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Elvis Presley",
"title": "Sun Sessions",
"releaseYear": "1976",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Michael Jackson",
"title": "Thriller",
"releaseYear": "1982",
"genre": "Pop"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "The Rolling Stones",
"title": "Exile on Main Street",
"releaseYear": "1972",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Bruce Springsteen",
"title": "Born to Run",
"releaseYear": "1975",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "The Clash",
"title": "London Calling",
"releaseYear": "1980",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "The Eagles",
"title": "Hotel California",
"releaseYear": "1976",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Led Zeppelin",
"title": "Led Zeppelin",
"releaseYear": "1969",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Led Zeppelin",
"title": "IV",
"releaseYear": "1971",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Police",
"title": "Synchronicity",
"releaseYear": "1983",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "U2",
"title": "Achtung Baby",
"releaseYear": "1991",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "The Rolling Stones",
"title": "Let it Bleed",
"releaseYear": "1969",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "The Beatles",
"title": "Rubber Soul",
"releaseYear": "1965",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "The Ramones",
"title": "The Ramones",
"releaseYear": "1976",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Queen",
"title": "A Night At The Opera",
"releaseYear": "1975",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Boston",
"title": "Don't Look Back",
"releaseYear": "1978",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "BB King",
"title": "Singin' The Blues",
"releaseYear": "1956",
"genre": "Blues"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Albert King",
"title": "Born Under A Bad Sign",
"releaseYear": "1967",
"genre": "Blues"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Muddy Waters",
"title": "Folk Singer",
"releaseYear": "1964",
"genre": "Blues"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "The Fabulous Thunderbirds",
"title": "Rock With Me",
"releaseYear": "1979",
"genre": "Blues"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Robert Johnson",
"title": "King of the Delta Blues",
"releaseYear": "1961",
"genre": "Blues"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Stevie Ray Vaughan",
"title": "Texas Flood",
"releaseYear": "1983",
"genre": "Blues"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Stevie Ray Vaughan",
"title": "Couldn't Stand The Weather",
"releaseYear": "1984",
"genre": "Blues"
}
]

@ -0,0 +1,52 @@
spring:
jpa:
generate-ddl: true
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: always
---
spring:
config:
activate:
on-profile: http2
server:
http2:
enabled: true
---
spring:
config:
activate:
on-profile: mysql
datasource:
url: "jdbc:mysql://localhost/music"
driver-class-name: com.mysql.jdbc.Driver
username:
password:
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL55Dialect
---
spring:
config:
activate:
on-profile: postgres
datasource:
url: "jdbc:postgresql://localhost/music"
driver-class-name: org.postgresql.Driver
username: postgres
password:
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.ProgressDialect

@ -0,0 +1,35 @@
#body {
padding-top: 10px;
}
.navbar {
background-color: white;
border: 0;
margin-bottom: 20px;
}
.navbar .container {
background-color: #008a00;
background-image: -moz-linear-gradient(top, #008a00, #006b00);
background-image: -ms-linear-gradient(top, #008a00, #006b00);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#008a00), to(#006b00));
background-image: -webkit-linear-gradient(top, #008a00, #006b00);
background-image: -o-linear-gradient(top, #008a00, #006b00);
background-image: linear-gradient(top, #008a00, #006b00);
}
.navbar .navbar-brand {
color: white;
}
.navbar .navbar-brand:hover {
color: white;
}
.btn {
background-color: white;
}
.icon-white {
color: white;
}

@ -0,0 +1,59 @@
/* From https://github.com/sixfootsixdesigns/Bootstrap-3-Grid-Columns-Clearing */
/* clear first in row in ie 8 or lower */
.multi-columns-row .first-in-row {
clear: left;
}
/* clear the first in row for any block that has the class "multi-columns-row" */
.multi-columns-row .col-xs-6:nth-child(2n + 3) { clear: left; }
.multi-columns-row .col-xs-4:nth-child(3n + 4) { clear: left; }
.multi-columns-row .col-xs-3:nth-child(4n + 5) { clear: left; }
.multi-columns-row .col-xs-2:nth-child(6n + 7) { clear: left; }
.multi-columns-row .col-xs-1:nth-child(12n + 13) { clear: left; }
@media (min-width: 768px) {
/* reset previous grid */
.multi-columns-row .col-xs-6:nth-child(2n + 3) { clear: none; }
.multi-columns-row .col-xs-4:nth-child(3n + 4) { clear: none; }
.multi-columns-row .col-xs-3:nth-child(4n + 5) { clear: none; }
.multi-columns-row .col-xs-2:nth-child(6n + 7) { clear: none; }
.multi-columns-row .col-xs-1:nth-child(12n + 13) { clear: none; }
/* clear first in row for small columns */
.multi-columns-row .col-sm-6:nth-child(2n + 3) { clear: left; }
.multi-columns-row .col-sm-4:nth-child(3n + 4) { clear: left; }
.multi-columns-row .col-sm-3:nth-child(4n + 5) { clear: left; }
.multi-columns-row .col-sm-2:nth-child(6n + 7) { clear: left; }
.multi-columns-row .col-sm-1:nth-child(12n + 13) { clear: left; }
}
@media (min-width: 992px) {
/* reset previous grid */
.multi-columns-row .col-sm-6:nth-child(2n + 3) { clear: none; }
.multi-columns-row .col-sm-4:nth-child(3n + 4) { clear: none; }
.multi-columns-row .col-sm-3:nth-child(4n + 5) { clear: none; }
.multi-columns-row .col-sm-2:nth-child(6n + 7) { clear: none; }
.multi-columns-row .col-sm-1:nth-child(12n + 13) { clear: none; }
/* clear first in row for medium columns */
.multi-columns-row .col-md-6:nth-child(2n + 3) { clear: left; }
.multi-columns-row .col-md-4:nth-child(3n + 4) { clear: left; }
.multi-columns-row .col-md-3:nth-child(4n + 5) { clear: left; }
.multi-columns-row .col-md-2:nth-child(6n + 7) { clear: left; }
.multi-columns-row .col-md-1:nth-child(12n + 13) { clear: left; }
}
@media (min-width: 1200px) {
/* reset previous grid */
.multi-columns-row .col-md-6:nth-child(2n + 3) { clear: none; }
.multi-columns-row .col-md-4:nth-child(3n + 4) { clear: none; }
.multi-columns-row .col-md-3:nth-child(4n + 5) { clear: none; }
.multi-columns-row .col-md-2:nth-child(6n + 7) { clear: none; }
.multi-columns-row .col-md-1:nth-child(12n + 13) { clear: none; }
/* clear first in row for large columns */
.multi-columns-row .col-lg-6:nth-child(2n + 3) { clear: left; }
.multi-columns-row .col-lg-4:nth-child(3n + 4) { clear: left; }
.multi-columns-row .col-lg-3:nth-child(4n + 5) { clear: left; }
.multi-columns-row .col-lg-2:nth-child(6n + 7) { clear: left; }
.multi-columns-row .col-lg-1:nth-child(12n + 13) { clear: left; }
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

@ -0,0 +1,47 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" class="en" ng-app="SpringMusic">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="Spring Music">
<meta name="title" content="Spring Music">
<link rel="shortcut icon" href="favicon.ico">
<title>Spring Music</title>
<link rel="stylesheet" type="text/css" href="webjars/bootstrap/3.1.1/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/app.css">
<link rel="stylesheet" type="text/css" href="css/multi-columns-row.css">
</head>
<body>
<div class="container">
<div class="row">
<div ng-include="'templates/header.html'"></div>
</div>
<div id="body" class="row">
<ng-view></ng-view>
</div>
<div class="row">
<div ng-include="'templates/footer.html'"></div>
</div>
</div>
<script type="text/javascript" src="webjars/jquery/2.1.0/jquery.min.js"></script>
<script type="text/javascript" src="webjars/angularjs/1.2.16/angular.js"></script>
<script type="text/javascript" src="webjars/angularjs/1.2.16/angular-resource.js"></script>
<script type="text/javascript" src="webjars/angularjs/1.2.16/angular-route.js"></script>
<script type="text/javascript" src="webjars/angular-ui/0.4.0/angular-ui.js"></script>
<script type="text/javascript" src="webjars/angular-ui-bootstrap/0.10.0/ui-bootstrap.js"></script>
<script type="text/javascript" src="webjars/angular-ui-bootstrap/0.10.0/ui-bootstrap-tpls.js"></script>
<script type="text/javascript" src="webjars/bootstrap/3.1.1/js/bootstrap.js"></script>
<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript" src="js/albums.js"></script>
<script type="text/javascript" src="js/errors.js"></script>
<script type="text/javascript" src="js/info.js"></script>
<script type="text/javascript" src="js/status.js"></script>
</body>
</html>

@ -0,0 +1,199 @@
angular.module('albums', ['ngResource', 'ui.bootstrap']).
factory('Albums', function ($resource) {
return $resource('albums');
}).
factory('Album', function ($resource) {
return $resource('albums/:id', {id: '@id'});
}).
factory("EditorStatus", function () {
var editorEnabled = {};
var enable = function (id, fieldName) {
editorEnabled = { 'id': id, 'fieldName': fieldName };
};
var disable = function () {
editorEnabled = {};
};
var isEnabled = function(id, fieldName) {
return (editorEnabled['id'] == id && editorEnabled['fieldName'] == fieldName);
};
return {
isEnabled: isEnabled,
enable: enable,
disable: disable
}
});
function AlbumsController($scope, $modal, Albums, Album, Status) {
function list() {
$scope.albums = Albums.query();
}
function clone (obj) {
return JSON.parse(JSON.stringify(obj));
}
function saveAlbum(album) {
Albums.save(album,
function () {
Status.success("Album saved");
list();
},
function (result) {
Status.error("Error saving album: " + result.status);
}
);
}
$scope.addAlbum = function () {
var addModal = $modal.open({
templateUrl: 'templates/albumForm.html',
controller: AlbumModalController,
resolve: {
album: function () {
return {};
},
action: function() {
return 'add';
}
}
});
addModal.result.then(function (album) {
saveAlbum(album);
});
};
$scope.updateAlbum = function (album) {
var updateModal = $modal.open({
templateUrl: 'templates/albumForm.html',
controller: AlbumModalController,
resolve: {
album: function() {
return clone(album);
},
action: function() {
return 'update';
}
}
});
updateModal.result.then(function (album) {
saveAlbum(album);
});
};
$scope.deleteAlbum = function (album) {
Album.delete({id: album.id},
function () {
Status.success("Album deleted");
list();
},
function (result) {
Status.error("Error deleting album: " + result.status);
}
);
};
$scope.setAlbumsView = function (viewName) {
$scope.albumsView = "templates/" + viewName + ".html";
};
$scope.init = function() {
list();
$scope.setAlbumsView("grid");
$scope.sortField = "name";
$scope.sortDescending = false;
};
}
function AlbumModalController($scope, $modalInstance, album, action) {
$scope.albumAction = action;
$scope.yearPattern = /^[1-2]\d{3}$/;
$scope.album = album;
$scope.ok = function () {
$modalInstance.close($scope.album);
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
};
function AlbumEditorController($scope, Albums, Status, EditorStatus) {
$scope.enableEditor = function (album, fieldName) {
$scope.newFieldValue = album[fieldName];
EditorStatus.enable(album.id, fieldName);
};
$scope.disableEditor = function () {
EditorStatus.disable();
};
$scope.isEditorEnabled = function (album, fieldName) {
return EditorStatus.isEnabled(album.id, fieldName);
};
$scope.save = function (album, fieldName) {
if ($scope.newFieldValue === "") {
return false;
}
album[fieldName] = $scope.newFieldValue;
Albums.save({}, album,
function () {
Status.success("Album saved");
list();
},
function (result) {
Status.error("Error saving album: " + result.status);
}
);
$scope.disableEditor();
};
$scope.disableEditor();
}
angular.module('albums').
directive('inPlaceEdit', function () {
return {
restrict: 'E',
transclude: true,
replace: true,
scope: {
ipeFieldName: '@fieldName',
ipeInputType: '@inputType',
ipeInputClass: '@inputClass',
ipePattern: '@pattern',
ipeModel: '=model'
},
template:
'<div>' +
'<span ng-hide="isEditorEnabled(ipeModel, ipeFieldName)" ng-click="enableEditor(ipeModel, ipeFieldName)">' +
'<span ng-transclude></span>' +
'</span>' +
'<span ng-show="isEditorEnabled(ipeModel, ipeFieldName)">' +
'<div class="input-append">' +
'<input type="{{ipeInputType}}" name="{{ipeFieldName}}" class="{{ipeInputClass}}" ' +
'ng-required ng-pattern="{{ipePattern}}" ng-model="newFieldValue" ' +
'ui-keyup="{enter: \'save(ipeModel, ipeFieldName)\', esc: \'disableEditor()\'}"/>' +
'<div class="btn-group btn-group-xs" role="toolbar">' +
'<button ng-click="save(ipeModel, ipeFieldName)" type="button" class="btn"><span class="glyphicon glyphicon-ok"></span></button>' +
'<button ng-click="disableEditor()" type="button" class="btn"><span class="glyphicon glyphicon-remove"></span></button>' +
'</div>' +
'</div>' +
'</span>' +
'</div>',
controller: 'AlbumEditorController'
};
});

@ -0,0 +1,14 @@
angular.module('SpringMusic', ['albums', 'errors', 'status', 'info', 'ngRoute', 'ui.directives']).
config(function ($locationProvider, $routeProvider) {
// $locationProvider.html5Mode(true);
$routeProvider.when('/errors', {
controller: 'ErrorsController',
templateUrl: 'templates/errors.html'
});
$routeProvider.otherwise({
controller: 'AlbumsController',
templateUrl: 'templates/albums.html'
});
}
);

@ -0,0 +1,37 @@
angular.module('errors', ['ngResource']).
factory('Errors', function ($resource) {
return $resource('errors', {}, {
kill: { url: 'errors/kill' },
throw: { url: 'errors/throw' }
});
});
function ErrorsController($scope, Errors, Status) {
$scope.kill = function() {
Errors.kill({},
function () {
Status.error("The application should have been killed, but returned successfully instead.");
},
function (result) {
if (result.status === 502)
Status.error("An error occurred as expected, the application backend was killed: " + result.status);
else
Status.error("An unexpected error occurred: " + result.status);
}
);
};
$scope.throwException = function() {
Errors.throw({},
function () {
Status.error("An exception should have been thrown, but was not.");
},
function (result) {
if (result.status === 500)
Status.error("An error occurred as expected: " + result.status);
else
Status.error("An unexpected error occurred: " + result.status);
}
);
};
}

@ -0,0 +1,8 @@
angular.module('info', ['ngResource']).
factory('Info', function ($resource) {
return $resource('appinfo');
});
function InfoController($scope, Info) {
$scope.info = Info.get();
}

@ -0,0 +1,38 @@
angular.module('status', []).
factory("Status", function () {
var status = null;
var success = function (message) {
this.status = { isError: false, message: message };
};
var error = function (message) {
this.status = { isError: true, message: message };
};
var clear = function () {
this.status = null;
};
return {
status: status,
success: success,
error: error,
clear: clear
}
});
function StatusController($scope, Status) {
$scope.$watch(
function () {
return Status.status;
},
function (status) {
$scope.status = status;
},
true);
$scope.clearStatus = function () {
Status.clear();
};
}

@ -0,0 +1,32 @@
<div class="modal-header">
<h3 ng-show="albumAction === 'add'">Add an album</h3>
<h3 ng-show="albumAction === 'update'">Edit an album</h3>
</div>
<div class="modal-body">
<form name="albumForm" role="form">
<div class="form-group has-feedback" ng-class="{'has-warning': albumForm.title.$invalid, 'has-success': albumForm.title.$valid}">
<label for="title">Album Title</label>
<input type="text" class="form-control input-large" id="title" name="title" required ng-model="album.title">
<span class="glyphicon form-control-feedback" ng-class="{'glyphicon-warning-sign': albumForm.title.$invalid, 'glyphicon-ok': albumForm.title.$valid}"></span>
</div>
<div class="form-group has-feedback" ng-class="{'has-warning': albumForm.artist.$invalid, 'has-success': albumForm.artist.$valid}">
<label for="artist">Artist</label>
<input type="text" class="form-control input-large" id="artist" name="artist" required ng-model="album.artist">
<span class="glyphicon form-control-feedback" ng-class="{'glyphicon-warning-sign': albumForm.artist.$invalid, 'glyphicon-ok': albumForm.artist.$valid}"></span>
</div>
<div class="form-group has-feedback" ng-class="{'has-warning': albumForm.releaseYear.$invalid, 'has-success': albumForm.releaseYear.$valid}">
<label for="releaseYear">Release Year</label>
<input type="text" class="form-control input-small" id="releaseYear" name="releaseYear" required ng-model="album.releaseYear" ng-pattern=yearPattern>
<span class="glyphicon form-control-feedback" ng-class="{'glyphicon-warning-sign': albumForm.releaseYear.$invalid, 'glyphicon-ok': albumForm.releaseYear.$valid}"></span>
</div>
<div class="form-group has-feedback" ng-class="{'has-warning': albumForm.genre.$invalid, 'has-success': albumForm.genre.$valid}">
<label for="genre">Genre</label>
<input type="text" class="form-control input-medium" id=genre name="genre" required ng-model="album.genre">
<span class="glyphicon form-control-feedback" ng-class="{'glyphicon-warning-sign': albumForm.genre.$invalid, 'glyphicon-ok': albumForm.genre.$valid}"></span>
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-primary btn-md active" ng-disabled="albumForm.$invalid" ng-click="ok()" >OK</button>
<button class="btn btn-warning btn-md active" ng-click="cancel()">Cancel</button>
</div>

@ -0,0 +1,29 @@
<div id="albums" ng-init="init()">
<div class="page-header">
<h1>Albums</h1>
<div>
<span> [ view as: </span>
<a href="" ng-click="setAlbumsView('grid')"><span class="glyphicon glyphicon-th"></span></a>
<a href="" ng-click="setAlbumsView('list')"><span class="glyphicon glyphicon-th-list"></span></a>
<span> | sort by: </span>
<a href="" ng-click="sortField='title'">title</a>
<a href="" ng-click="sortField='artist'">artist</a>
<a href="" ng-click="sortField='releaseYear'">year</a>
<a href="" ng-click="sortField='genre'">genre</a>
<a href="" ng-click="sortDescending=!sortDescending">
<span class="glyphicon" ng-class="{'glyphicon-chevron-up' : !sortDescending, 'glyphicon-chevron-down' : sortDescending}"></span>
</a>
<span> | </span>
<a href="" ng-click="addAlbum()"><span class="glyphicon glyphicon-plus"></span>add an album</a>
<span> ] </span>
</div>
</div>
<div class="row">
<div ng-include src="'templates/status.html'"></div>
</div>
<div class="row multi-columns-row">
<div ng-include src="albumsView"></div>
</div>
</div>

@ -0,0 +1,22 @@
<div id="errors" class="col-xs-12" ng-controller="ErrorsController">
<div class="page-header">
<h1>Force Errors</h1>
</div>
<div class="row">
<div ng-include src="'templates/status.html'"></div>
</div>
<div class="row">
<form role="form">
<div class="form-group">
<h3>Kill this instance of the application</h3>
<a ng-click="kill()" class="btn btn-primary btn-lg active" role="button">Kill</a>
</div>
<div class="form-group">
<h3>Force an exception to be thrown from the application</h3>
<a ng-click="throwException()" class="btn btn-primary btn-lg active" role="button">Throw Exception</a>
</div>
</form>
</div>
</div>

@ -0,0 +1,3 @@
<div id="footer" class="row">
</div>

@ -0,0 +1,31 @@
<div class="col-xs-6 col-sm-3 col-md-3 col-lg-3" ng-repeat="album in albums | orderBy:sortField:sortDescending">
<div class="thumbnail">
<div class="caption">
<h4>
<in-place-edit field-name='title' input-type='text' input-class='input-medium' model=album>{{album.title}}</in-place-edit>
</h4>
<h4>
<in-place-edit field-name='artist' input-type='text' input-class='input-medium' model=album>{{album.artist}}</in-place-edit>
</h4>
<h5>
<in-place-edit field-name='releaseYear' input-type='text' input-class='input-small' model=album>{{album.releaseYear}}</in-place-edit>
</h5>
<h5>
<in-place-edit field-name='genre' input-type='text' input-class='input-small' model=album>{{album.genre}}</in-place-edit>
</h5>
<div class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-cog"></span>
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<li role="presentation"><a ng-click="updateAlbum(album)">edit</a></li>
<li role="presentation"><a ng-click="deleteAlbum(album)">delete</a></li>
</ul>
</div>
</div>
</div>
</div>

@ -0,0 +1,24 @@
<div id="header" ng-controller="InfoController" class="col-xs-12">
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">Spring Music <span class="glyphicon glyphicon-music"></span></a>
<ul class="navbar-nav">
<!--<li></li>-->
</ul>
</div>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-info-sign icon-white"></span>
</a>
<ul class="dropdown-menu">
<li><a><strong>Profiles:</strong> {{info.profiles.join()}}</a></li>
<li><a><strong>Services:</strong> {{info.services.join()}}</a></li>
</ul>
</li>
</ul>
</div>
</nav>
</div>

@ -0,0 +1,38 @@
<div class="col-xs-12">
<table class="table table-striped">
<thead>
<tr>
<th>Album Title</th>
<th>Artist</th>
<th>Year</th>
<th>Genre</th>
<th></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="album in albums | orderBy:sortField:sortDescending">
<td>
<in-place-edit field-name='title' input-type='text' input-class='input-large' model=album>{{album.title}}</in-place-edit>
</td>
<td>
<in-place-edit field-name='artist' input-type='artist' input-class='input-large' model=album>{{album.artist}}</in-place-edit>
</td>
<td>
<in-place-edit field-name='releaseYear' input-type='text' input-class='input-small' model=album>{{album.releaseYear}}</in-place-edit>
</td>
<td>
<in-place-edit field-name='genre' input-type='text' input-class='input-medium' model=album>{{album.genre}}</in-place-edit>
</td>
<td class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-cog"></span>
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<li role="presentation"><a ng-click="updateAlbum(album)">edit</a></li>
<li role="presentation"><a ng-click="deleteAlbum(album)">delete</a></li>
</ul>
</td>
</tr>
</tbody>
</table>
</div>

@ -0,0 +1,8 @@
<div class="col-xs-12" id="status" ng-controller="StatusController">
<div id="alert" ng-show="status">
<div class="alert" ng-class="{'alert-success': !status.isError, 'alert-danger': status.isError}">
<button type="button" class="close" ng-click="clearStatus()"><span class="glyphicon glyphicon-remove-circle"></span></button>
<p>{{status.message}}</p>
</div>
</div>
</div>

@ -0,0 +1,128 @@
buildscript {
ext {
springBootVersion = '2.5.5'
javaCfEnvVersion = '2.1.2.RELEASE'
}
repositories {
maven {
credentials {
username System.getenv("ARTIFACTORY_USERNAME") ?: "$artifactory_username"
password System.getenv("ARTIFACTORY_PASSWORD") ?: "$artifactory_password"
}
url 'https://gapinc.jfrog.io/gapinc/maven-repos'
}
ivy {
credentials {
username System.getenv("ARTIFACTORY_USERNAME") ?: "$artifactory_username"
password System.getenv("ARTIFACTORY_PASSWORD") ?: "$artifactory_password"
}
layout "maven"
url 'https://gapinc.jfrog.io/gapinc/maven-repos'
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
group = 'springmusic'
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
version = {
def stdout = new ByteArrayOutputStream()
exec {
executable 'sh'
args 'version.sh'
standardOutput = stdout
}
return stdout.toString().trim()
}()
repositories {
mavenCentral()
}
dependencies {
// Spring Boot
implementation "org.springframework.boot:spring-boot-starter-web"
implementation "org.springframework.boot:spring-boot-starter-actuator"
implementation "org.springframework.boot:spring-boot-starter-data-jpa"
implementation "org.springframework.boot:spring-boot-starter-data-mongodb"
implementation "org.springframework.boot:spring-boot-starter-data-redis"
implementation "org.springframework.boot:spring-boot-starter-validation"
// Java CfEnv
implementation "io.pivotal.cfenv:java-cfenv-boot:${javaCfEnvVersion}"
// JPA Persistence
runtimeOnly "org.apache.commons:commons-pool2:2.6.0"
runtimeOnly "com.h2database:h2"
runtimeOnly "mysql:mysql-connector-java"
runtimeOnly "org.postgresql:postgresql"
runtimeOnly "com.microsoft.sqlserver:mssql-jdbc"
// uncomment to use Lettuce instead of Jedis for Redis connections
// runtime "io.lettuce:lettuce-core"
// Webjars
implementation "org.webjars:bootstrap:3.1.1"
implementation "org.webjars:angularjs:1.2.16"
implementation "org.webjars:angular-ui:0.4.0-2"
implementation "org.webjars:angular-ui-bootstrap:0.10.0-1"
implementation "org.webjars:jquery:2.1.0-2"
// Oracle - uncomment one of the following after placing driver in ./libs
// compile files('libs/ojdbc8.jar')
// compile files('libs/ojdbc7.jar')
// Testing
testImplementation "junit:junit"
testImplementation "org.springframework.boot:spring-boot-starter-test"
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
if (JavaVersion.current() != project.targetCompatibility) {
logger.warn("The build is using Java ${JavaVersion.current()} to build a Java ${project.targetCompatibility} compatible archive.")
logger.warn("See the project README for instructions on changing the target Java version.")
}
}
jar {
archiveBaseName = "spring-music"
}
uploadArchives {
repositories {
maven {
credentials {
username System.getenv('ARTIFACTORY_USERNAME')
password System.getenv('ARTIFACTORY_PASSWORD')
}
url 'https://gapinc.jfrog.io/gapinc/maven-repos'
}
}
}
uploadBootArchives {
repositories {
maven {
credentials {
username System.getenv('ARTIFACTORY_USERNAME')
password System.getenv('ARTIFACTORY_PASSWORD')
}
url "https://gapinc.jfrog.io/gapinc/maven-repos"
}
}
}

Binary file not shown.

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-6.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

185
gradlew vendored

@ -0,0 +1,185 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

89
gradlew.bat vendored

@ -0,0 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

@ -0,0 +1,10 @@
---
applications:
- name: spring-music-showoff
memory: 1G
random-route: true
path: build/libs/spring-music-1.0.jar
env:
JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '{enabled: false}'
SPRING_PROFILES_ACTIVE: http2
# JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 11.+ } }'

@ -0,0 +1 @@
rootProject.name = 'spring-music-cf'

@ -0,0 +1,277 @@
/*
* spring-music-cf service pipeline, file lives inside of app repository.
*
* See https://jenkins.io/doc/book/pipeline/syntax/ for details on the file format.
*/
// Branch to build
def gitBranch
// Build version of parcel-shipping-service
def deployVersion
// Whether the build will be deployed to production
def officialBuild
def deployToDev
def deployToTest
def deployToAze
// Pipeline should run build stage
def doBuild
pipeline {
// Choose the Jenkins VM configuration (definitions are in vault)
agent {
node {
label 'pipes-docker-agent'
}
}
// A pipeline consists of a series of stages
stages {
stage('Ingest Build Options') {
steps {
echo 'Parsing options passed in through Jenkins'
echo ''
echo "Unparsed content: ${params}"
script {
// Use version passed in through Jenkins if possible; otherwise, get new version
deployVersion = params.ARTIFACT_VERSION
if (!deployVersion) {
deployVersion = sh(returnStdout: true, script: "./version.sh").trim()
}
echo "deployVersion: '${deployVersion}'"
}
script {
gitBranch = params.GIT_BRANCH
echo "gitBranch: '${gitBranch}'"
}
script{
officialBuild = (params.OFFICIAL_BUILD as boolean)
deployToDev = (params.deploy_to_dev as boolean)
deployToTest = (params.deploy_to_test as boolean)
deployToAze = (params.deploy_to_aze as boolean)
echo "officialBuild: '${officialBuild}'"
}
script {
doBuild = (params.ARTIFACT_VERSION == '')
echo "doBuild: ${doBuild}"
}
// validate the combination of flags passed
script {
if (doBuild) {
echo "Building version '${deployVersion}'"
}
if (!doBuild) {
echo "Deploying previous build ${deployVersion}"
}
}
}
}
/* stage('Checkout Config Repository') {
when { expression { doBuild } }
steps {
echo 'Checkout Config Repository'
dir("./../parcel-shipping-service-config") {
git branch: "master",
credentialsId: 'github_credential',
url: 'https://github.gapinc.com/parcel-shipping/parcel-shipping-service-config.git'
}
}
}*/
stage('Build Artifacts') {
when { expression { doBuild } }
steps {
echo 'Build, deploy to Artifactory'
/* withCredentials(bindings: [
sshUserPrivateKey(credentialsId: 'pss-prod-rsakey', keyFileVariable: 'PSS_PROD_KEY', passphraseVariable: 'PSS_PROD_PASSPHRASE', usernameVariable: 'PSS_PROD_USERNAME'),
sshUserPrivateKey(credentialsId: 'pss-dev-rsakey', keyFileVariable: 'PSS_DEV_KEY', passphraseVariable: 'PSS_DEV_PASSPHRASE', usernameVariable: 'PSS_DEV_USERNAME')
]){
sh "./cpfile.sh $PSS_DEV_KEY 'src/main/resources/pssdev.rsa'"
sh "./cpfile.sh $PSS_PROD_KEY 'src/main/resources/pssprod.rsa'"
}
withCredentials(bindings: [ string(credentialsId: 'pss-oci-sso-wallet-dev', variable: 'PSS_OCI_SSO_WALLET_DEV'),
string(credentialsId: 'pss-oci-sso-p12-dev', variable: 'PSS_OCI_SSO_P12_DEV'),
string(credentialsId: 'pss-oci-sso-wallet-test', variable: 'PSS_OCI_SSO_WALLET_TEST'),
string(credentialsId: 'pss-oci-sso-p12-test', variable: 'PSS_OCI_SSO_P12_TEST')]) {
sh "mkdir -p src/main/resources/wallet"
sh "./oci_wallet_cpfile.sh $PSS_OCI_SSO_WALLET_DEV 'src/main/resources/wallet' 'dev' 'dev/cwallet.sso'"
sh "./oci_wallet_cpfile.sh $PSS_OCI_SSO_P12_DEV 'src/main/resources/wallet' 'dev' 'dev/ewallet.p12'"
sh "./oci_wallet_cpfile.sh $PSS_OCI_SSO_WALLET_TEST 'src/main/resources/wallet' 'test' 'test/cwallet.sso'"
sh "./oci_wallet_cpfile.sh $PSS_OCI_SSO_P12_TEST 'src/main/resources/wallet' 'test' 'test/ewallet.p12'"
}
withCredentials(bindings: [ string(credentialsId: 'pss-confluent-client-keystore-dev-jks', variable: 'PSS_CONFLUENT_CLIENT_KEYSTORE_DEV_JKS'),
string(credentialsId: 'pss-confluent-client-keystore-stage-jks', variable: 'PSS_CONFLUENT_CLIENT_KEYSTORE_STAGE_JKS'),
string(credentialsId: 'pss-confluent-client-keystore-prod-jks', variable: 'PSS_CONFLUENT_CLIENT_KEYSTORE_PROD_JKS'),
string(credentialsId: 'pss-confluent-client-truststore-jks', variable: 'PSS_CONFLUENT_CLIENT_TRUSTSTORE_JKS')]) {
sh "./oci_wallet_cpfile.sh $PSS_CONFLUENT_CLIENT_KEYSTORE_DEV_JKS 'src/main/resources' 'clientSSL' 'clientSSL/confluent.client.keystore.dev.jks'"
sh "./oci_wallet_cpfile.sh $PSS_CONFLUENT_CLIENT_KEYSTORE_STAGE_JKS 'src/main/resources' 'clientSSL' 'clientSSL/confluent.client.keystore.stage.jks'"
sh "./oci_wallet_cpfile.sh $PSS_CONFLUENT_CLIENT_KEYSTORE_PROD_JKS 'src/main/resources' 'clientSSL' 'clientSSL/confluent.client.keystore.prod.jks'"
sh "./oci_wallet_cpfile.sh $PSS_CONFLUENT_CLIENT_TRUSTSTORE_JKS 'src/main/resources' 'clientSSL' 'clientSSL/confluent.client.truststore.jks'"
}*/
withCredentials([usernamePassword(usernameVariable: 'GITHUB_USERNAME', passwordVariable: 'GITHUB_PASSWORD', credentialsId: 'github_credential'),
usernamePassword(usernameVariable: 'ARTIFACTORY_USERNAME', passwordVariable: 'ARTIFACTORY_PASSWORD', credentialsId: 'pt-classroom-artifactory-token')]) {
sh "./gradlew clean build uploadBootArchives"
}
//sh "./gradlew clean build uploadArchives"
//sh "./gradlew clean build"
}
}
stage('Deploy to DEV') {
when { expression { deployToDev } }
steps {
echo 'Deploy from Artifactory to DEV'
build job: 'spring_music_cf_service_deploy_to_dev', parameters: [[$class: 'StringParameterValue', name: 'ARTIFACT_VERSION', value: "${deployVersion}"]]
}
}
stage('Deploy to TEST') {
when { expression { deployToTest } }
steps {
echo 'Deploy from Artifactory to TEST'
build job: 'spring_music_cf_service_deploy_to_test', parameters: [[$class: 'StringParameterValue', name: 'ARTIFACT_VERSION', value: "${deployVersion}"]]
}
}
stage('Deploy to E2E2') {
when { expression { officialBuild } }
steps {
echo 'Deploy from Artifactory to E2E2'
build job: 'spring_music_cf_service_deploy_to_e2e2', parameters: [[$class: 'StringParameterValue', name: 'ARTIFACT_VERSION', value: "${deployVersion}"]]
}
}
stage('Deploy to AZE DEV') {
when { expression { deployToAze} }
steps {
echo 'Deploy from Artifactory to AZE DEV'
build job: 'spring_music_cf_service_deploy_to_azedev', parameters: [[$class: 'StringParameterValue', name: 'ARTIFACT_VERSION', value: "${deployVersion}"]]
}
}
stage('Deploy to AZE TEST') {
when { expression { deployToTest && deployToAze } }
steps {
echo 'Deploy from Artifactory to AZE TEST'
build job: 'spring_music_cf_service_deploy_to_azetest', parameters: [[$class: 'StringParameterValue', name: 'ARTIFACT_VERSION', value: "${deployVersion}"]]
}
}
stage('Deploy to AZE E2E2') {
when { expression { officialBuild && deployToAze} }
steps {
echo 'Deploy from Artifactory to AZE E2E2'
build job: 'parcel_shipping_service_deploy_to_azee2e2', parameters: [[$class: 'StringParameterValue', name: 'ARTIFACT_VERSION', value: "${deployVersion}"]]
}
}
// stage('Deploy to PROD') {
// when { expression { officialBuild } }
// steps {
// echo 'Deploy from Artifactory to PROD'
// build job: 'parcel_shipping_service_deploy_to_prod', parameters: [[$class: 'StringParameterValue', name: 'ARTIFACT_VERSION', value: "${deployVersion}"]]
// }
// }
}
post {
success {
notifyTeam(deployVersion, 'SUCCESS')
}
failure {
notifyTeam(deployVersion, 'FAILURE')
}
}
}
def notifyTeam(deployVersion, status) {
// don't send an email just for refreshing parameters, unless it fails
if (params.refreshParameters && (status == 'SUCCESS')) {
return
}
def recipients = 'nathan_wagner@gap.com'
def presendScript
if (status == 'SUCCESS') {
presendScript = ''
} else {
// failed builds are marked important
presendScript = """
msg.addHeader("X-Priority", "1 (Highest)");
msg.addHeader("Importance", "High");
"""
}
def buildStart = new java.text.SimpleDateFormat("h:mm a z 'on' MMMM d").format(new Date(currentBuild.startTimeInMillis))
def durationSeconds = (currentBuild.duration / 1000) as Long
def buildDuration = [
'hour': (durationSeconds / 3600) as Long,
'minute': (((durationSeconds / 60) as Long) % 60),
'second': durationSeconds % 60,
].findAll { it.value > 0 }.collect { "${it.value} ${it.key}${it.value == 1 ? '' : 's'}" }.join(', ')
def changeSet
if (currentBuild.changeSets.every { it.emptySet }) {
changeSet = '<tr><td colspan="2"><code>No changes since last build.</code></td></tr>'
} else {
changeSet = currentBuild.changeSets.collect {
it.items.collect { "<tr><td>${it.author.fullName}</td><td>${it.msg}</td></tr>" }
}.flatten().join('\n')
}
def touchedFiles = currentBuild.changeSets.collect {
it.items.collect { it.affectedPaths.collect { "<li><code>${it}</code></li>" } }
}.flatten().sort().unique(false).join('\n') ?: '<li>No files changed since last build.</li>'
def emailBody = [
"<h2>${currentBuild.fullDisplayName}</h2>",
"<p>${currentBuild.buildCauses[0].shortDescription} at ${buildStart}.</p>",
"<p>The build took ${buildDuration}.</p>",
"<p>View the build <a href='${currentBuild.absoluteUrl}'>in Jenkins</a>.</p>",
"<p>To redeploy the same artifacts, use deployVersion: <code>${deployVersion}</code></p>",
'<h3>Commits:</h3>',
'<style>tr:nth-child(3n) { background: #eee; }</style>',
'<table>',
'<thead style="background: #ddd;"><tr><th>Git Author</th><th>Commit Message</th></tr></thead>',
'<tbody>',
changeSet,
'</tbody>',
'</table>',
'<h3>Touched files:</h3>',
'<ul style="list-style-type: none;">',
touchedFiles,
'</ul>',
].join('\n')
emailext(
subject: "${status}: ${currentBuild.fullDisplayName}",
to: recipients,
body: emailBody,
mimeType: 'text/html',
presendScript: presendScript
)
}

@ -0,0 +1,18 @@
package org.cloudfoundry.samples.music;
import org.cloudfoundry.samples.music.config.SpringApplicationContextInitializer;
import org.cloudfoundry.samples.music.repositories.AlbumRepositoryPopulator;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
new SpringApplicationBuilder(Application.class)
.initializers(new SpringApplicationContextInitializer())
.listeners(new AlbumRepositoryPopulator())
.application()
.run(args);
}
}

@ -0,0 +1,144 @@
package org.cloudfoundry.samples.music.config;
import io.pivotal.cfenv.core.CfEnv;
import io.pivotal.cfenv.core.CfService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.Profiles;
import org.springframework.core.env.PropertySource;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class SpringApplicationContextInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
private static final Log logger = LogFactory.getLog(SpringApplicationContextInitializer.class);
private static final Map<String, List<String>> profileNameToServiceTags = new HashMap<>();
static {
profileNameToServiceTags.put("mongodb", Collections.singletonList("mongodb"));
profileNameToServiceTags.put("postgres", Collections.singletonList("postgres"));
profileNameToServiceTags.put("mysql", Collections.singletonList("mysql"));
profileNameToServiceTags.put("redis", Collections.singletonList("redis"));
profileNameToServiceTags.put("oracle", Collections.singletonList("oracle"));
profileNameToServiceTags.put("sqlserver", Collections.singletonList("sqlserver"));
}
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
ConfigurableEnvironment appEnvironment = applicationContext.getEnvironment();
validateActiveProfiles(appEnvironment);
addCloudProfile(appEnvironment);
excludeAutoConfiguration(appEnvironment);
}
private void addCloudProfile(ConfigurableEnvironment appEnvironment) {
CfEnv cfEnv = new CfEnv();
List<String> profiles = new ArrayList<>();
List<CfService> services = cfEnv.findAllServices();
List<String> serviceNames = services.stream()
.map(CfService::getName)
.collect(Collectors.toList());
logger.info("Found services " + StringUtils.collectionToCommaDelimitedString(serviceNames));
for (CfService service : services) {
for (String profileKey : profileNameToServiceTags.keySet()) {
if (service.getTags().containsAll(profileNameToServiceTags.get(profileKey))) {
profiles.add(profileKey);
}
}
}
if (profiles.size() > 1) {
throw new IllegalStateException(
"Only one service of the following types may be bound to this application: " +
profileNameToServiceTags.values().toString() + ". " +
"These services are bound to the application: [" +
StringUtils.collectionToCommaDelimitedString(profiles) + "]");
}
if (profiles.size() > 0) {
logger.info("Setting service profile " + profiles.get(0));
appEnvironment.addActiveProfile(profiles.get(0));
}
}
private void validateActiveProfiles(ConfigurableEnvironment appEnvironment) {
Set<String> validLocalProfiles = profileNameToServiceTags.keySet();
List<String> serviceProfiles = Stream.of(appEnvironment.getActiveProfiles())
.filter(validLocalProfiles::contains)
.collect(Collectors.toList());
if (serviceProfiles.size() > 1) {
throw new IllegalStateException("Only one active Spring profile may be set among the following: " +
validLocalProfiles.toString() + ". " +
"These profiles are active: [" +
StringUtils.collectionToCommaDelimitedString(serviceProfiles) + "]");
}
}
private void excludeAutoConfiguration(ConfigurableEnvironment environment) {
List<String> exclude = new ArrayList<>();
if (environment.acceptsProfiles(Profiles.of("redis"))) {
excludeDataSourceAutoConfiguration(exclude);
excludeMongoAutoConfiguration(exclude);
} else if (environment.acceptsProfiles(Profiles.of("mongodb"))) {
excludeDataSourceAutoConfiguration(exclude);
excludeRedisAutoConfiguration(exclude);
} else {
excludeMongoAutoConfiguration(exclude);
excludeRedisAutoConfiguration(exclude);
}
Map<String, Object> properties = Collections.singletonMap("spring.autoconfigure.exclude",
StringUtils.collectionToCommaDelimitedString(exclude));
PropertySource<?> propertySource = new MapPropertySource("springMusicAutoConfig", properties);
environment.getPropertySources().addFirst(propertySource);
}
private void excludeDataSourceAutoConfiguration(List<String> exclude) {
exclude.add(DataSourceAutoConfiguration.class.getName());
}
private void excludeMongoAutoConfiguration(List<String> exclude) {
exclude.addAll(Arrays.asList(
MongoAutoConfiguration.class.getName(),
MongoDataAutoConfiguration.class.getName(),
MongoRepositoriesAutoConfiguration.class.getName()
));
}
private void excludeRedisAutoConfiguration(List<String> exclude) {
exclude.addAll(Arrays.asList(
RedisAutoConfiguration.class.getName(),
RedisRepositoriesAutoConfiguration.class.getName()
));
}
}

@ -0,0 +1,34 @@
package org.cloudfoundry.samples.music.config.data;
import org.cloudfoundry.samples.music.domain.Album;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
@Profile("redis")
public class RedisConfig {
@Bean
public RedisTemplate<String, Album> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<String, Album> template = new RedisTemplate<>();
template.setConnectionFactory(redisConnectionFactory);
RedisSerializer<String> stringSerializer = new StringRedisSerializer();
RedisSerializer<Album> albumSerializer = new Jackson2JsonRedisSerializer<>(Album.class);
template.setKeySerializer(stringSerializer);
template.setValueSerializer(albumSerializer);
template.setHashKeySerializer(stringSerializer);
template.setHashValueSerializer(albumSerializer);
return template;
}
}

@ -0,0 +1,90 @@
package org.cloudfoundry.samples.music.domain;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class Album {
@Id
@Column(length=40)
@GeneratedValue(generator="randomId")
@GenericGenerator(name="randomId", strategy="org.cloudfoundry.samples.music.domain.RandomIdGenerator")
private String id;
private String title;
private String artist;
private String releaseYear;
private String genre;
private int trackCount;
private String albumId;
public Album() {
}
public Album(String title, String artist, String releaseYear, String genre) {
this.title = title;
this.artist = artist;
this.releaseYear = releaseYear;
this.genre = genre;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getArtist() {
return artist;
}
public void setArtist(String artist) {
this.artist = artist;
}
public String getReleaseYear() {
return releaseYear;
}
public void setReleaseYear(String releaseYear) {
this.releaseYear = releaseYear;
}
public String getGenre() {
return genre;
}
public void setGenre(String genre) {
this.genre = genre;
}
public int getTrackCount() {
return trackCount;
}
public void setTrackCount(int trackCount) {
this.trackCount = trackCount;
}
public String getAlbumId() {
return albumId;
}
public void setAlbumId(String albumId) {
this.albumId = albumId;
}
}

@ -0,0 +1,27 @@
package org.cloudfoundry.samples.music.domain;
public class ApplicationInfo {
private String[] profiles;
private String[] services;
public ApplicationInfo(String[] profiles, String[] services) {
this.profiles = profiles;
this.services = services;
}
public String[] getProfiles() {
return profiles;
}
public void setProfiles(String[] profiles) {
this.profiles = profiles;
}
public String[] getServices() {
return services;
}
public void setServices(String[] services) {
this.services = services;
}
}

@ -0,0 +1,19 @@
package org.cloudfoundry.samples.music.domain;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.IdentifierGenerator;
import java.io.Serializable;
import java.util.UUID;
public class RandomIdGenerator implements IdentifierGenerator {
@Override
public Serializable generate(SharedSessionContractImplementor session, Object object) throws HibernateException {
return generateId();
}
public String generateId() {
return UUID.randomUUID().toString();
}
}

@ -0,0 +1,59 @@
package org.cloudfoundry.samples.music.repositories;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.cloudfoundry.samples.music.domain.Album;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.init.Jackson2ResourceReader;
import java.util.Collection;
public class AlbumRepositoryPopulator implements ApplicationListener<ApplicationReadyEvent> {
private final Jackson2ResourceReader resourceReader;
private final Resource sourceData;
public AlbumRepositoryPopulator() {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
resourceReader = new Jackson2ResourceReader(mapper);
sourceData = new ClassPathResource("albums.json");
}
@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
CrudRepository albumRepository =
BeanFactoryUtils.beanOfTypeIncludingAncestors(event.getApplicationContext(), CrudRepository.class);
if (albumRepository != null && albumRepository.count() == 0) {
populate(albumRepository);
}
}
@SuppressWarnings("unchecked")
private void populate(CrudRepository repository) {
Object entity = getEntityFromResource(sourceData);
if (entity instanceof Collection) {
for (Album album : (Collection<Album>) entity) {
if (album != null) {
repository.save(album);
}
}
} else {
repository.save(entity);
}
}
private Object getEntityFromResource(Resource resource) {
try {
return resourceReader.readFrom(resource, this.getClass().getClassLoader());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

@ -0,0 +1,11 @@
package org.cloudfoundry.samples.music.repositories.jpa;
import org.cloudfoundry.samples.music.domain.Album;
import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
@Profile({"!mongodb", "!redis"})
public interface JpaAlbumRepository extends JpaRepository<Album, String> {
}

@ -0,0 +1,11 @@
package org.cloudfoundry.samples.music.repositories.mongodb;
import org.cloudfoundry.samples.music.domain.Album;
import org.springframework.context.annotation.Profile;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;
@Repository
@Profile("mongodb")
public interface MongoAlbumRepository extends MongoRepository<Album, String> {
}

@ -0,0 +1,117 @@
package org.cloudfoundry.samples.music.repositories.redis;
import org.cloudfoundry.samples.music.domain.Album;
import org.cloudfoundry.samples.music.domain.RandomIdGenerator;
import org.springframework.context.annotation.Profile;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
@Repository
@Profile("redis")
public class RedisAlbumRepository implements CrudRepository<Album, String> {
public static final String ALBUMS_KEY = "albums";
private final RandomIdGenerator idGenerator;
private final HashOperations<String, String, Album> hashOps;
public RedisAlbumRepository(RedisTemplate<String, Album> redisTemplate) {
this.hashOps = redisTemplate.opsForHash();
this.idGenerator = new RandomIdGenerator();
}
@Override
public <S extends Album> S save(S album) {
if (album.getId() == null) {
album.setId(idGenerator.generateId());
}
hashOps.put(ALBUMS_KEY, album.getId(), album);
return album;
}
@Override
public <S extends Album> Iterable<S> saveAll(Iterable<S> albums) {
List<S> result = new ArrayList<>();
for (S entity : albums) {
save(entity);
result.add(entity);
}
return result;
}
@Override
public Optional<Album> findById(String id) {
return Optional.ofNullable(hashOps.get(ALBUMS_KEY, id));
}
@Override
public boolean existsById(String id) {
return hashOps.hasKey(ALBUMS_KEY, id);
}
@Override
public Iterable<Album> findAll() {
return hashOps.values(ALBUMS_KEY);
}
@Override
public Iterable<Album> findAllById(Iterable<String> ids) {
return hashOps.multiGet(ALBUMS_KEY, convertIterableToList(ids));
}
@Override
public long count() {
return hashOps.keys(ALBUMS_KEY).size();
}
@Override
public void deleteById(String id) {
hashOps.delete(ALBUMS_KEY, id);
}
@Override
public void delete(Album album) {
hashOps.delete(ALBUMS_KEY, album.getId());
}
@Override
public void deleteAll(Iterable<? extends Album> albums) {
for (Album album : albums) {
delete(album);
}
}
@Override
public void deleteAll() {
Set<String> ids = hashOps.keys(ALBUMS_KEY);
for (String id : ids) {
deleteById(id);
}
}
@Override
public void deleteAllById(Iterable<? extends String> ids) {
for (String id : ids) {
deleteById(id);
}
}
private <T> List<T> convertIterableToList(Iterable<T> iterable) {
List<T> list = new ArrayList<>();
for (T object : iterable) {
list.add(object);
}
return list;
}
}

@ -0,0 +1,51 @@
package org.cloudfoundry.samples.music.web;
import org.cloudfoundry.samples.music.domain.Album;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.CrudRepository;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@RestController
@RequestMapping(value = "/albums")
public class AlbumController {
private static final Logger logger = LoggerFactory.getLogger(AlbumController.class);
private CrudRepository<Album, String> repository;
@Autowired
public AlbumController(CrudRepository<Album, String> repository) {
this.repository = repository;
}
@RequestMapping(method = RequestMethod.GET)
public Iterable<Album> albums() {
return repository.findAll();
}
@RequestMapping(method = RequestMethod.PUT)
public Album add(@RequestBody @Valid Album album) {
logger.info("Adding album " + album.getId());
return repository.save(album);
}
@RequestMapping(method = RequestMethod.POST)
public Album update(@RequestBody @Valid Album album) {
logger.info("Updating album " + album.getId());
return repository.save(album);
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public Album getById(@PathVariable String id) {
logger.info("Getting album " + id);
return repository.findById(id).orElse(null);
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public void deleteById(@PathVariable String id) {
logger.info("Deleting album " + id);
repository.deleteById(id);
}
}

@ -0,0 +1,36 @@
package org.cloudfoundry.samples.music.web;
import java.util.List;
import java.util.ArrayList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/errors")
public class ErrorController {
private static final Logger logger = LoggerFactory.getLogger(ErrorController.class);
private List<int[]> junk = new ArrayList<>();
@RequestMapping(value = "/kill")
public void kill() {
logger.info("Forcing application exit");
System.exit(1);
}
@RequestMapping(value = "/fill-heap")
public void fillHeap() {
logger.info("Filling heap with junk, to initiate a crash");
while (true) {
junk.add(new int[9999999]);
}
}
@RequestMapping(value = "/throw")
public void throwException() {
logger.info("Forcing an exception to be thrown");
throw new NullPointerException("Forcing an exception to be thrown");
}
}

@ -0,0 +1,61 @@
package org.cloudfoundry.samples.music.web;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.cloudfoundry.samples.music.domain.ApplicationInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.pivotal.cfenv.core.CfEnv;
import io.pivotal.cfenv.core.CfService;
@RestController
public class InfoController {
private final CfEnv cfEnv;
// just a change to kick a build
private Environment springEnvironment;
@Autowired
public InfoController(Environment springEnvironment) {
this.springEnvironment = springEnvironment;
this.cfEnv = new CfEnv();
}
@RequestMapping(value = "/request")
public Map<String, String> requestInfo(HttpServletRequest req) {
HashMap<String, String> result = new HashMap<>();
result.put("session-id", req.getSession().getId());
result.put("protocol", req.getProtocol());
result.put("method", req.getMethod());
result.put("scheme", req.getScheme());
result.put("remote-addr", req.getRemoteAddr());
return result;
}
@RequestMapping(value = "/appinfo")
public ApplicationInfo info() {
return new ApplicationInfo(springEnvironment.getActiveProfiles(), getServiceNames());
}
@RequestMapping(value = "/service")
public List<CfService> showServiceInfo() {
return cfEnv.findAllServices();
}
private String[] getServiceNames() {
List<CfService> services = cfEnv.findAllServices();
List<String> names = new ArrayList<>();
for (CfService service : services) {
names.add(service.getName());
}
return names.toArray(new String[0]);
}
}

@ -0,0 +1,205 @@
[
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Nirvana",
"title": "Nevermind",
"releaseYear": "1991",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "The Beach Boys",
"title": "Pet Sounds",
"releaseYear": "1966",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Marvin Gaye",
"title": "What's Going On",
"releaseYear": "1971",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Jimi Hendrix Experience",
"title": "Are You Experienced?",
"releaseYear": "1967",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "U2",
"title": "The Joshua Tree",
"releaseYear": "1987",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "The Beatles",
"title": "Abbey Road",
"releaseYear": "1969",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Fleetwood Mac",
"title": "Rumours",
"releaseYear": "1977",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Elvis Presley",
"title": "Sun Sessions",
"releaseYear": "1976",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Michael Jackson",
"title": "Thriller",
"releaseYear": "1982",
"genre": "Pop"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "The Rolling Stones",
"title": "Exile on Main Street",
"releaseYear": "1972",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Bruce Springsteen",
"title": "Born to Run",
"releaseYear": "1975",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "The Clash",
"title": "London Calling",
"releaseYear": "1980",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "The Eagles",
"title": "Hotel California",
"releaseYear": "1976",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Led Zeppelin",
"title": "Led Zeppelin",
"releaseYear": "1969",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Led Zeppelin",
"title": "IV",
"releaseYear": "1971",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Police",
"title": "Synchronicity",
"releaseYear": "1983",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "U2",
"title": "Achtung Baby",
"releaseYear": "1991",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "The Rolling Stones",
"title": "Let it Bleed",
"releaseYear": "1969",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "The Beatles",
"title": "Rubber Soul",
"releaseYear": "1965",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "The Ramones",
"title": "The Ramones",
"releaseYear": "1976",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Queen",
"title": "A Night At The Opera",
"releaseYear": "1975",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Boston",
"title": "Don't Look Back",
"releaseYear": "1978",
"genre": "Rock"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "BB King",
"title": "Singin' The Blues",
"releaseYear": "1956",
"genre": "Blues"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Albert King",
"title": "Born Under A Bad Sign",
"releaseYear": "1967",
"genre": "Blues"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Muddy Waters",
"title": "Folk Singer",
"releaseYear": "1964",
"genre": "Blues"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "The Fabulous Thunderbirds",
"title": "Rock With Me",
"releaseYear": "1979",
"genre": "Blues"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Robert Johnson",
"title": "King of the Delta Blues",
"releaseYear": "1961",
"genre": "Blues"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Stevie Ray Vaughan",
"title": "Texas Flood",
"releaseYear": "1983",
"genre": "Blues"
},
{
"_class": "org.cloudfoundry.samples.music.domain.Album",
"artist": "Stevie Ray Vaughan",
"title": "Couldn't Stand The Weather",
"releaseYear": "1984",
"genre": "Blues"
}
]

@ -0,0 +1,52 @@
spring:
jpa:
generate-ddl: true
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: always
---
spring:
config:
activate:
on-profile: http2
server:
http2:
enabled: true
---
spring:
config:
activate:
on-profile: mysql
datasource:
url: "jdbc:mysql://localhost/music"
driver-class-name: com.mysql.jdbc.Driver
username:
password:
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL55Dialect
---
spring:
config:
activate:
on-profile: postgres
datasource:
url: "jdbc:postgresql://localhost/music"
driver-class-name: org.postgresql.Driver
username: postgres
password:
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.ProgressDialect

@ -0,0 +1,35 @@
#body {
padding-top: 10px;
}
.navbar {
background-color: white;
border: 0;
margin-bottom: 20px;
}
.navbar .container {
background-color: #008a00;
background-image: -moz-linear-gradient(top, #008a00, #006b00);
background-image: -ms-linear-gradient(top, #008a00, #006b00);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#008a00), to(#006b00));
background-image: -webkit-linear-gradient(top, #008a00, #006b00);
background-image: -o-linear-gradient(top, #008a00, #006b00);
background-image: linear-gradient(top, #008a00, #006b00);
}
.navbar .navbar-brand {
color: white;
}
.navbar .navbar-brand:hover {
color: white;
}
.btn {
background-color: white;
}
.icon-white {
color: white;
}

@ -0,0 +1,59 @@
/* From https://github.com/sixfootsixdesigns/Bootstrap-3-Grid-Columns-Clearing */
/* clear first in row in ie 8 or lower */
.multi-columns-row .first-in-row {
clear: left;
}
/* clear the first in row for any block that has the class "multi-columns-row" */
.multi-columns-row .col-xs-6:nth-child(2n + 3) { clear: left; }
.multi-columns-row .col-xs-4:nth-child(3n + 4) { clear: left; }
.multi-columns-row .col-xs-3:nth-child(4n + 5) { clear: left; }
.multi-columns-row .col-xs-2:nth-child(6n + 7) { clear: left; }
.multi-columns-row .col-xs-1:nth-child(12n + 13) { clear: left; }
@media (min-width: 768px) {
/* reset previous grid */
.multi-columns-row .col-xs-6:nth-child(2n + 3) { clear: none; }
.multi-columns-row .col-xs-4:nth-child(3n + 4) { clear: none; }
.multi-columns-row .col-xs-3:nth-child(4n + 5) { clear: none; }
.multi-columns-row .col-xs-2:nth-child(6n + 7) { clear: none; }
.multi-columns-row .col-xs-1:nth-child(12n + 13) { clear: none; }
/* clear first in row for small columns */
.multi-columns-row .col-sm-6:nth-child(2n + 3) { clear: left; }
.multi-columns-row .col-sm-4:nth-child(3n + 4) { clear: left; }
.multi-columns-row .col-sm-3:nth-child(4n + 5) { clear: left; }
.multi-columns-row .col-sm-2:nth-child(6n + 7) { clear: left; }
.multi-columns-row .col-sm-1:nth-child(12n + 13) { clear: left; }
}
@media (min-width: 992px) {
/* reset previous grid */
.multi-columns-row .col-sm-6:nth-child(2n + 3) { clear: none; }
.multi-columns-row .col-sm-4:nth-child(3n + 4) { clear: none; }
.multi-columns-row .col-sm-3:nth-child(4n + 5) { clear: none; }
.multi-columns-row .col-sm-2:nth-child(6n + 7) { clear: none; }
.multi-columns-row .col-sm-1:nth-child(12n + 13) { clear: none; }
/* clear first in row for medium columns */
.multi-columns-row .col-md-6:nth-child(2n + 3) { clear: left; }
.multi-columns-row .col-md-4:nth-child(3n + 4) { clear: left; }
.multi-columns-row .col-md-3:nth-child(4n + 5) { clear: left; }
.multi-columns-row .col-md-2:nth-child(6n + 7) { clear: left; }
.multi-columns-row .col-md-1:nth-child(12n + 13) { clear: left; }
}
@media (min-width: 1200px) {
/* reset previous grid */
.multi-columns-row .col-md-6:nth-child(2n + 3) { clear: none; }
.multi-columns-row .col-md-4:nth-child(3n + 4) { clear: none; }
.multi-columns-row .col-md-3:nth-child(4n + 5) { clear: none; }
.multi-columns-row .col-md-2:nth-child(6n + 7) { clear: none; }
.multi-columns-row .col-md-1:nth-child(12n + 13) { clear: none; }
/* clear first in row for large columns */
.multi-columns-row .col-lg-6:nth-child(2n + 3) { clear: left; }
.multi-columns-row .col-lg-4:nth-child(3n + 4) { clear: left; }
.multi-columns-row .col-lg-3:nth-child(4n + 5) { clear: left; }
.multi-columns-row .col-lg-2:nth-child(6n + 7) { clear: left; }
.multi-columns-row .col-lg-1:nth-child(12n + 13) { clear: left; }
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

@ -0,0 +1,47 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" class="en" ng-app="SpringMusic">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="Spring Music">
<meta name="title" content="Spring Music">
<link rel="shortcut icon" href="favicon.ico">
<title>Spring Music</title>
<link rel="stylesheet" type="text/css" href="webjars/bootstrap/3.1.1/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/app.css">
<link rel="stylesheet" type="text/css" href="css/multi-columns-row.css">
</head>
<body>
<div class="container">
<div class="row">
<div ng-include="'templates/header.html'"></div>
</div>
<div id="body" class="row">
<ng-view></ng-view>
</div>
<div class="row">
<div ng-include="'templates/footer.html'"></div>
</div>
</div>
<script type="text/javascript" src="webjars/jquery/2.1.0/jquery.min.js"></script>
<script type="text/javascript" src="webjars/angularjs/1.2.16/angular.js"></script>
<script type="text/javascript" src="webjars/angularjs/1.2.16/angular-resource.js"></script>
<script type="text/javascript" src="webjars/angularjs/1.2.16/angular-route.js"></script>
<script type="text/javascript" src="webjars/angular-ui/0.4.0/angular-ui.js"></script>
<script type="text/javascript" src="webjars/angular-ui-bootstrap/0.10.0/ui-bootstrap.js"></script>
<script type="text/javascript" src="webjars/angular-ui-bootstrap/0.10.0/ui-bootstrap-tpls.js"></script>
<script type="text/javascript" src="webjars/bootstrap/3.1.1/js/bootstrap.js"></script>
<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript" src="js/albums.js"></script>
<script type="text/javascript" src="js/errors.js"></script>
<script type="text/javascript" src="js/info.js"></script>
<script type="text/javascript" src="js/status.js"></script>
</body>
</html>

@ -0,0 +1,199 @@
angular.module('albums', ['ngResource', 'ui.bootstrap']).
factory('Albums', function ($resource) {
return $resource('albums');
}).
factory('Album', function ($resource) {
return $resource('albums/:id', {id: '@id'});
}).
factory("EditorStatus", function () {
var editorEnabled = {};
var enable = function (id, fieldName) {
editorEnabled = { 'id': id, 'fieldName': fieldName };
};
var disable = function () {
editorEnabled = {};
};
var isEnabled = function(id, fieldName) {
return (editorEnabled['id'] == id && editorEnabled['fieldName'] == fieldName);
};
return {
isEnabled: isEnabled,
enable: enable,
disable: disable
}
});
function AlbumsController($scope, $modal, Albums, Album, Status) {
function list() {
$scope.albums = Albums.query();
}
function clone (obj) {
return JSON.parse(JSON.stringify(obj));
}
function saveAlbum(album) {
Albums.save(album,
function () {
Status.success("Album saved");
list();
},
function (result) {
Status.error("Error saving album: " + result.status);
}
);
}
$scope.addAlbum = function () {
var addModal = $modal.open({
templateUrl: 'templates/albumForm.html',
controller: AlbumModalController,
resolve: {
album: function () {
return {};
},
action: function() {
return 'add';
}
}
});
addModal.result.then(function (album) {
saveAlbum(album);
});
};
$scope.updateAlbum = function (album) {
var updateModal = $modal.open({
templateUrl: 'templates/albumForm.html',
controller: AlbumModalController,
resolve: {
album: function() {
return clone(album);
},
action: function() {
return 'update';
}
}
});
updateModal.result.then(function (album) {
saveAlbum(album);
});
};
$scope.deleteAlbum = function (album) {
Album.delete({id: album.id},
function () {
Status.success("Album deleted");
list();
},
function (result) {
Status.error("Error deleting album: " + result.status);
}
);
};
$scope.setAlbumsView = function (viewName) {
$scope.albumsView = "templates/" + viewName + ".html";
};
$scope.init = function() {
list();
$scope.setAlbumsView("grid");
$scope.sortField = "name";
$scope.sortDescending = false;
};
}
function AlbumModalController($scope, $modalInstance, album, action) {
$scope.albumAction = action;
$scope.yearPattern = /^[1-2]\d{3}$/;
$scope.album = album;
$scope.ok = function () {
$modalInstance.close($scope.album);
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
};
function AlbumEditorController($scope, Albums, Status, EditorStatus) {
$scope.enableEditor = function (album, fieldName) {
$scope.newFieldValue = album[fieldName];
EditorStatus.enable(album.id, fieldName);
};
$scope.disableEditor = function () {
EditorStatus.disable();
};
$scope.isEditorEnabled = function (album, fieldName) {
return EditorStatus.isEnabled(album.id, fieldName);
};
$scope.save = function (album, fieldName) {
if ($scope.newFieldValue === "") {
return false;
}
album[fieldName] = $scope.newFieldValue;
Albums.save({}, album,
function () {
Status.success("Album saved");
list();
},
function (result) {
Status.error("Error saving album: " + result.status);
}
);
$scope.disableEditor();
};
$scope.disableEditor();
}
angular.module('albums').
directive('inPlaceEdit', function () {
return {
restrict: 'E',
transclude: true,
replace: true,
scope: {
ipeFieldName: '@fieldName',
ipeInputType: '@inputType',
ipeInputClass: '@inputClass',
ipePattern: '@pattern',
ipeModel: '=model'
},
template:
'<div>' +
'<span ng-hide="isEditorEnabled(ipeModel, ipeFieldName)" ng-click="enableEditor(ipeModel, ipeFieldName)">' +
'<span ng-transclude></span>' +
'</span>' +
'<span ng-show="isEditorEnabled(ipeModel, ipeFieldName)">' +
'<div class="input-append">' +
'<input type="{{ipeInputType}}" name="{{ipeFieldName}}" class="{{ipeInputClass}}" ' +
'ng-required ng-pattern="{{ipePattern}}" ng-model="newFieldValue" ' +
'ui-keyup="{enter: \'save(ipeModel, ipeFieldName)\', esc: \'disableEditor()\'}"/>' +
'<div class="btn-group btn-group-xs" role="toolbar">' +
'<button ng-click="save(ipeModel, ipeFieldName)" type="button" class="btn"><span class="glyphicon glyphicon-ok"></span></button>' +
'<button ng-click="disableEditor()" type="button" class="btn"><span class="glyphicon glyphicon-remove"></span></button>' +
'</div>' +
'</div>' +
'</span>' +
'</div>',
controller: 'AlbumEditorController'
};
});

@ -0,0 +1,14 @@
angular.module('SpringMusic', ['albums', 'errors', 'status', 'info', 'ngRoute', 'ui.directives']).
config(function ($locationProvider, $routeProvider) {
// $locationProvider.html5Mode(true);
$routeProvider.when('/errors', {
controller: 'ErrorsController',
templateUrl: 'templates/errors.html'
});
$routeProvider.otherwise({
controller: 'AlbumsController',
templateUrl: 'templates/albums.html'
});
}
);

@ -0,0 +1,37 @@
angular.module('errors', ['ngResource']).
factory('Errors', function ($resource) {
return $resource('errors', {}, {
kill: { url: 'errors/kill' },
throw: { url: 'errors/throw' }
});
});
function ErrorsController($scope, Errors, Status) {
$scope.kill = function() {
Errors.kill({},
function () {
Status.error("The application should have been killed, but returned successfully instead.");
},
function (result) {
if (result.status === 502)
Status.error("An error occurred as expected, the application backend was killed: " + result.status);
else
Status.error("An unexpected error occurred: " + result.status);
}
);
};
$scope.throwException = function() {
Errors.throw({},
function () {
Status.error("An exception should have been thrown, but was not.");
},
function (result) {
if (result.status === 500)
Status.error("An error occurred as expected: " + result.status);
else
Status.error("An unexpected error occurred: " + result.status);
}
);
};
}

@ -0,0 +1,8 @@
angular.module('info', ['ngResource']).
factory('Info', function ($resource) {
return $resource('appinfo');
});
function InfoController($scope, Info) {
$scope.info = Info.get();
}

@ -0,0 +1,38 @@
angular.module('status', []).
factory("Status", function () {
var status = null;
var success = function (message) {
this.status = { isError: false, message: message };
};
var error = function (message) {
this.status = { isError: true, message: message };
};
var clear = function () {
this.status = null;
};
return {
status: status,
success: success,
error: error,
clear: clear
}
});
function StatusController($scope, Status) {
$scope.$watch(
function () {
return Status.status;
},
function (status) {
$scope.status = status;
},
true);
$scope.clearStatus = function () {
Status.clear();
};
}

@ -0,0 +1,32 @@
<div class="modal-header">
<h3 ng-show="albumAction === 'add'">Add an album</h3>
<h3 ng-show="albumAction === 'update'">Edit an album</h3>
</div>
<div class="modal-body">
<form name="albumForm" role="form">
<div class="form-group has-feedback" ng-class="{'has-warning': albumForm.title.$invalid, 'has-success': albumForm.title.$valid}">
<label for="title">Album Title</label>
<input type="text" class="form-control input-large" id="title" name="title" required ng-model="album.title">
<span class="glyphicon form-control-feedback" ng-class="{'glyphicon-warning-sign': albumForm.title.$invalid, 'glyphicon-ok': albumForm.title.$valid}"></span>
</div>
<div class="form-group has-feedback" ng-class="{'has-warning': albumForm.artist.$invalid, 'has-success': albumForm.artist.$valid}">
<label for="artist">Artist</label>
<input type="text" class="form-control input-large" id="artist" name="artist" required ng-model="album.artist">
<span class="glyphicon form-control-feedback" ng-class="{'glyphicon-warning-sign': albumForm.artist.$invalid, 'glyphicon-ok': albumForm.artist.$valid}"></span>
</div>
<div class="form-group has-feedback" ng-class="{'has-warning': albumForm.releaseYear.$invalid, 'has-success': albumForm.releaseYear.$valid}">
<label for="releaseYear">Release Year</label>
<input type="text" class="form-control input-small" id="releaseYear" name="releaseYear" required ng-model="album.releaseYear" ng-pattern=yearPattern>
<span class="glyphicon form-control-feedback" ng-class="{'glyphicon-warning-sign': albumForm.releaseYear.$invalid, 'glyphicon-ok': albumForm.releaseYear.$valid}"></span>
</div>
<div class="form-group has-feedback" ng-class="{'has-warning': albumForm.genre.$invalid, 'has-success': albumForm.genre.$valid}">
<label for="genre">Genre</label>
<input type="text" class="form-control input-medium" id=genre name="genre" required ng-model="album.genre">
<span class="glyphicon form-control-feedback" ng-class="{'glyphicon-warning-sign': albumForm.genre.$invalid, 'glyphicon-ok': albumForm.genre.$valid}"></span>
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-primary btn-md active" ng-disabled="albumForm.$invalid" ng-click="ok()" >OK</button>
<button class="btn btn-warning btn-md active" ng-click="cancel()">Cancel</button>
</div>

@ -0,0 +1,29 @@
<div id="albums" ng-init="init()">
<div class="page-header">
<h1>Albums</h1>
<div>
<span> [ view as: </span>
<a href="" ng-click="setAlbumsView('grid')"><span class="glyphicon glyphicon-th"></span></a>
<a href="" ng-click="setAlbumsView('list')"><span class="glyphicon glyphicon-th-list"></span></a>
<span> | sort by: </span>
<a href="" ng-click="sortField='title'">title</a>
<a href="" ng-click="sortField='artist'">artist</a>
<a href="" ng-click="sortField='releaseYear'">year</a>
<a href="" ng-click="sortField='genre'">genre</a>
<a href="" ng-click="sortDescending=!sortDescending">
<span class="glyphicon" ng-class="{'glyphicon-chevron-up' : !sortDescending, 'glyphicon-chevron-down' : sortDescending}"></span>
</a>
<span> | </span>
<a href="" ng-click="addAlbum()"><span class="glyphicon glyphicon-plus"></span>add an album</a>
<span> ] </span>
</div>
</div>
<div class="row">
<div ng-include src="'templates/status.html'"></div>
</div>
<div class="row multi-columns-row">
<div ng-include src="albumsView"></div>
</div>
</div>

@ -0,0 +1,22 @@
<div id="errors" class="col-xs-12" ng-controller="ErrorsController">
<div class="page-header">
<h1>Force Errors</h1>
</div>
<div class="row">
<div ng-include src="'templates/status.html'"></div>
</div>
<div class="row">
<form role="form">
<div class="form-group">
<h3>Kill this instance of the application</h3>
<a ng-click="kill()" class="btn btn-primary btn-lg active" role="button">Kill</a>
</div>
<div class="form-group">
<h3>Force an exception to be thrown from the application</h3>
<a ng-click="throwException()" class="btn btn-primary btn-lg active" role="button">Throw Exception</a>
</div>
</form>
</div>
</div>

@ -0,0 +1,3 @@
<div id="footer" class="row">
</div>

@ -0,0 +1,31 @@
<div class="col-xs-6 col-sm-3 col-md-3 col-lg-3" ng-repeat="album in albums | orderBy:sortField:sortDescending">
<div class="thumbnail">
<div class="caption">
<h4>
<in-place-edit field-name='title' input-type='text' input-class='input-medium' model=album>{{album.title}}</in-place-edit>
</h4>
<h4>
<in-place-edit field-name='artist' input-type='text' input-class='input-medium' model=album>{{album.artist}}</in-place-edit>
</h4>
<h5>
<in-place-edit field-name='releaseYear' input-type='text' input-class='input-small' model=album>{{album.releaseYear}}</in-place-edit>
</h5>
<h5>
<in-place-edit field-name='genre' input-type='text' input-class='input-small' model=album>{{album.genre}}</in-place-edit>
</h5>
<div class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-cog"></span>
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<li role="presentation"><a ng-click="updateAlbum(album)">edit</a></li>
<li role="presentation"><a ng-click="deleteAlbum(album)">delete</a></li>
</ul>
</div>
</div>
</div>
</div>

@ -0,0 +1,24 @@
<div id="header" ng-controller="InfoController" class="col-xs-12">
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">Spring Music <span class="glyphicon glyphicon-music"></span></a>
<ul class="navbar-nav">
<!--<li></li>-->
</ul>
</div>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-info-sign icon-white"></span>
</a>
<ul class="dropdown-menu">
<li><a><strong>Profiles:</strong> {{info.profiles.join()}}</a></li>
<li><a><strong>Services:</strong> {{info.services.join()}}</a></li>
</ul>
</li>
</ul>
</div>
</nav>
</div>

@ -0,0 +1,38 @@
<div class="col-xs-12">
<table class="table table-striped">
<thead>
<tr>
<th>Album Title</th>
<th>Artist</th>
<th>Year</th>
<th>Genre</th>
<th></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="album in albums | orderBy:sortField:sortDescending">
<td>
<in-place-edit field-name='title' input-type='text' input-class='input-large' model=album>{{album.title}}</in-place-edit>
</td>
<td>
<in-place-edit field-name='artist' input-type='artist' input-class='input-large' model=album>{{album.artist}}</in-place-edit>
</td>
<td>
<in-place-edit field-name='releaseYear' input-type='text' input-class='input-small' model=album>{{album.releaseYear}}</in-place-edit>
</td>
<td>
<in-place-edit field-name='genre' input-type='text' input-class='input-medium' model=album>{{album.genre}}</in-place-edit>
</td>
<td class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-cog"></span>
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<li role="presentation"><a ng-click="updateAlbum(album)">edit</a></li>
<li role="presentation"><a ng-click="deleteAlbum(album)">delete</a></li>
</ul>
</td>
</tr>
</tbody>
</table>
</div>

@ -0,0 +1,8 @@
<div class="col-xs-12" id="status" ng-controller="StatusController">
<div id="alert" ng-show="status">
<div class="alert" ng-class="{'alert-success': !status.isError, 'alert-danger': status.isError}">
<button type="button" class="close" ng-click="clearStatus()"><span class="glyphicon glyphicon-remove-circle"></span></button>
<p>{{status.message}}</p>
</div>
</div>
</div>

@ -0,0 +1,17 @@
package org.cloudfoundry.samples.music;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest()
public class ApplicationTests {
@Test
public void contextLoads() {
}
}

@ -0,0 +1,15 @@
#!/bin/sh
PROJECT_VERSION="0.1.0"
if [ "${OFFICIAL_BUILD}" = true ]; then
PROJECT_VERSION="${PROJECT_VERSION}"
else
if [ -z "${BUILD_NUMBER}" ]; then
PROJECT_VERSION="${PROJECT_VERSION}-LOCAL"
else
PROJECT_VERSION="${PROJECT_VERSION}-${BUILD_NUMBER}"
fi
fi
echo $PROJECT_VERSION
Loading…
Cancel
Save