The ESPM (Enterprise Sales & Procurement Model) application is a reference application which demonstrates how to build applications on SAP Cloud Platform (Cloud Foundry) with the Java runtime.
ESPM application has 2 underlying applications
- webshop: this application is a webshopping app, which does not have any authentication.
- retailer: this application is used by a retailer to manage stocks, approve/reject sales orders. We use authentication here.
For more details about the project, please refer to https://github.com/SAP/cloud-espm-v2
- Java8
- Maven
- CF CLI
- If you do not yet have a Cloud Foundry environment trial or enterprise account, signup for a Cloud Foundry environment trial account by following the documentation
- To deploy the MTAR we need the MTA CF CLI plugin, download the MTA CF CLI Plugin from here
- To build the multi target application, we need the Cloud MTA Build tool, download the tool from here.
- For Windows system, install 'MAKE' from here
- Simplest way to install would be by running the command
npm install -g mbt
Note: If you wish to deploy the application using MTA Build tool, then directly skip to the section Building MTAR using MBT
cf api <api>
cf login -o <org> -s <space>
ESPM application requires 2 backing services XSUAA and HANA
- Create XSUAA service using the below command:
cf cs xsuaa application espm-uaa -c xs-security.json
Note: Make sure the application name used in the xs-security.json is unique.
- If you are using a SAP Cloud Platfrom Cloudfoundry trial account then create the HANA service following the below command
cf create-service hanatrial schema espm-hana
If you are using a productive SAP Cloud Platfrom Cloudfoundry account then create the required HANA services as mentioned below:
2.1 Create SAP HANA service instance with plan 64standard as described here : https://help.sap.com/viewer/cc53ad464a57404b8d453bbadbc81ceb/Cloud/en-US/21418824b23a401aa116d9ad42dd5ba6.html
2.2 Create schema in SAP HANA Service instance(created in previous step) by creating an instance of the SAP HANA service broker by running the below command:
cf create-service hana schema espm-hana
If there are multiple instances of SAP HANA Service in the space where you plan to deploy this application, please modify the mta.yaml as shown below. Replace <database_guid> with the id of the databse you would like to bind the application with :
# Hana Schema
- name: espm-hana
parameters:
service: hana
service-plan: schema
config:
database_id: <database_guid>
type: com.sap.xs.hana-schema
2.3 If you are using Hana, set the target database as Hana by uncommenting the same in persistence.xml file.
Open the manifest.yml file and edit the following:
Replace placeholders with your I/D/C numbers
so that the application name and host name is unique in the CF landscape.
DATABASE_TYPE: <DB name>
Replace the <DB name>
with hana
for which you have created the service instance.
Replace the with the hana service instance that you have created above.
Maven build the java application to package into a war file
From the root folder execute mvn clean install
Note: When running the application in internet, follow the below steps to download the ngdbc driver to your local ~.m2 repository, as its not available in central maven
1. You need to download the SAP Hana Cloud Platform SDK from here: https://tools.hana.ondemand.com/#cloud
2. Take the latest "Java Web Tomcat 8" from the download section (a package starting with neo-).
3. Unzip the archive to an arbitrary location on your devbox.
4. Extract the JDBC driver (ngdbc.jar) from the archive (you will find the driver in the archive under: repository/.archive/lib/ngdbc.jar). The driver is closed source, so it is NOT available from public Maven repositories!
5. Put the driver either to your local maven repository with:
**mvn install:install-file -Dfile=<path-to-file> -DgroupId=com.sap.db.jdbc \**
**-DartifactId=ngdbc -Dversion=2.0.13 -Dpackaging=jar**
Go to web/retailer and execute npm install
Go to web/webshop and execute npm install
Make sure you have npm registry = "https://npm.sap.com/"
To setup the registry locally for each command, use the following
npm install --registry=https://npm.sap.com/ -proxy=null
cf push -f manifest.yml
We need to setup the Role collections for the UAA, since the Retailer application needs the template role called "Retailer" assigned to the user, for the application to work.
-
In your trial account, in the left pane select Role collections under the Security tab.
-
Add a new Role collection named, "Retailer"
-
Click on the newly created "Retailer "role collection and add new Role.
-
Select the application identifier name similar to the one you have given in the xs-security.json file.
-
Select the role template and assign the Role you have created in the previous step.
We need to assign the role which we have created in the previous step to the user.
-
In your trial account, in the left pane select "Trust Configuration" under the Security tab.
-
Click on the default IDP service.
-
Enter username/email and click on the add Assignment button.
-
Select the Role as "Retailer" to assign it to the user.
Approuter has been binded to the XSUAA service.
Authentication Method specified in the xs-app.json file with
-
Webshop - AuthenticationType: None
-
Retailer - AuthenticationType: XSUAA
To Secure the backend application, we need to bind the XSUAA service to the backend.
The ESPM application can be packaged as a Multi Target Application which makes it easier to deploy the application. MTA application needs a MTA Development descriptor(mta.yml) which is used to define the elements and dependencies of multi-target application.
Build the application by running following command from root folder of the project: mbt build -p=cf
If CF MTA Plugin is not installed, intall if from here
To Deploy the application navigate to mta_archives folder under your project root folder and run the below command from CLI
`cf deploy ESPM_MTA_1.0.0.mtar`
In case you find a bug/need support please create github issues
Copyright (c) 2018 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file.