├── .cdsrc.json ├── .eslintrc ├── .gitignore ├── .reuse └── dep5 ├── .yo-rc.json ├── CF_CREDS.txt ├── COMMANDS.md ├── LICENSE ├── LICENSES └── Apache-2.0.txt ├── NOTICE ├── README.md ├── app ├── package.json ├── resources │ ├── favicon.ico │ └── index.html └── xs-app.json ├── db ├── README.md ├── build.js.disabled ├── cfg │ ├── .hdiconfig │ └── synonyms │ │ └── COMMON.hdbsynonymconfig ├── csv │ ├── my.bookshop-Authors.csv │ ├── my.bookshop-Books.csv │ └── my.bookshop-Orders.csv ├── data-model.cds ├── package.json └── src │ ├── .hdiconfig │ ├── .hdinamespace │ ├── db_grant_role.hdbprocedure │ ├── defaults │ └── default_access_role.hdbrole │ ├── loads │ ├── .hdiconfig │ ├── .hdinamespace │ ├── config.csv │ └── config.hdbtabledata │ ├── roles │ └── customer_admin.hdbrole │ ├── synonyms │ ├── COMMON-table.hdbgrants │ ├── COMMON.hdbsynonym │ ├── VIEWS.hdbsynonym │ └── sys.hdbsynonym │ └── views │ ├── ORDERS_BAS_CALCVIEW.hdbcalculationview │ ├── ORDERS_VIEW.hdbview │ └── sql.txt ├── db_comm ├── README.md ├── data-model.cds ├── package.json ├── src │ ├── .hdiconfig │ ├── .hdinamespace │ ├── db_grant_role.hdbprocedure │ ├── defaults │ │ └── default_access_role.hdbrole │ ├── loads │ │ ├── currencies.csv │ │ ├── currencies.hdbtabledata │ │ ├── states.csv │ │ └── states.hdbtabledata │ ├── roles │ │ ├── common_admin.hdbrole │ │ ├── external_access.hdbrole │ │ └── external_access_g.hdbrole │ ├── sql │ │ └── verify.sql.txt │ └── synonyms │ │ └── sys.hdbsynonym └── undeploy.json ├── documentation ├── README.md ├── TROUBLESHOOTING.md ├── YO_RECIPE.md └── images │ ├── 023C46EC-73FF-4787-8B96-617B600453F9.png │ ├── 045C7FB1-489E-459F-BFE1-BC1FA8CE63D8.png │ ├── 064F8A9D-CC5E-47B0-AD19-50FD9BBA5D5B.png │ ├── 0811AAAF-589A-49DE-8D01-67EBFF515112.png │ ├── 1718709F-7353-4B4F-BB83-583C1988B7B0.png │ ├── 2263EB6A-FA11-489B-8FC7-148B91B045DD.png │ ├── 23E66DCA-3A23-41EC-A4FB-609008848C13.png │ ├── 23F114A1-56BD-4A66-927F-8135CD07DFEB.png │ ├── 2B87EA9F-1335-4878-A028-F4DDD5ABE2BA.png │ ├── 2C509F20-B0C3-4754-A1DA-9E72DE3D1536.png │ ├── 2E731498-07B8-4B67-8BD9-F2C5B092E29B.png │ ├── 3319804A-39EC-4BE8-AE15-9710E969452D.png │ ├── 36C4C562-9364-4288-84AB-B7B525C88B57.png │ ├── 3DD05C3C-13A5-4188-8C7E-C66CD421A675.png │ ├── 3DEC6BDF-E042-40E6-873E-94C9E7852BFA.png │ ├── 3F73851B-55B9-4D19-98EF-11E68CCA45C9.png │ ├── 49E941D8-F353-4AC4-AAC9-8686EA331D0A.png │ ├── 4CF86DC4-68EA-4254-8A23-2D80CA0DF301.png │ ├── 53E5265F-A254-4137-B2AC-91D0EEC58AA4.png │ ├── 54F60698-0F57-4E61-BE87-C2477D4343F8.png │ ├── 61CC972F-F9DA-4956-B992-477202FB5010.png │ ├── 653CA465-DE9E-4690-96CF-45A71BD31A6E.png │ ├── 65A7A99C-7B12-4290-8F82-7A39CCC3DDFB.png │ ├── 6D006E9F-80BB-4985-AABF-D9BC695BA69E.png │ ├── 77BD109C-870F-4A90-85CE-1FC9879FB524.png │ ├── 77E3431A-9147-4934-B6B9-AA555E6CCDE1.png │ ├── 825AA1A9-8A5C-4D28-8148-84A64D6947F5.png │ ├── 842229F4-C86E-4072-AEA3-A8B1BC2D0301.png │ ├── 8A6C71D4-822E-43E0-9EFD-D1FC0ECF09D5.png │ ├── 8E3D6B2B-652E-443F-8D3B-6B9A7BF2C3BB.png │ ├── 8F16E5F1-A512-4D07-B395-D882AF8C34A2.png │ ├── A0A79BB0-0B6C-443A-A63F-0823D368B043.png │ ├── A46B71F5-DB61-45FC-BCAC-EDCC7FE1EF7B.png │ ├── A61BEFB7-461B-41FD-BDDB-DC0328C1760B.png │ ├── A6490FB9-DC22-469C-B7E6-41EE1AD51F05.png │ ├── A989C357-305A-46C7-A562-719221BB2F24.png │ ├── B063B834-0E53-408A-AE24-FF128E87741D.png │ ├── B5D44D74-957B-4E32-8A64-C5EF1E1CDCDD.png │ ├── BFF04029-7358-4269-BE0F-95040B50F583.png │ ├── C494F337-2F67-4C2B-BCEC-AC7FAA9CFDEF.png │ ├── D9104708-D688-44BF-9094-E1646399CAB7.png │ ├── DB8D4FBF-927B-42F9-8C56-3149A2CBB52B.png │ ├── F106F27E-3836-4681-8096-8B64E1705E06.png │ ├── F8F8D9CA-4269-4A6E-BFF0-ACF2C8EE6501.png │ └── FC3D0F23-4C58-4E44-B3F2-F18359E6CEA6.png ├── mta.yaml ├── package.json ├── sapcp-cf-trial.mtaext ├── srv ├── README.md ├── build.js.disabled ├── cat-service-auth.cds ├── cat-service.cds ├── handlers │ └── provisioning.js ├── package.json ├── server.js └── src │ └── main │ └── resources │ └── edmx │ ├── CatalogService.xml │ ├── CatalogService_ar.xml │ ├── CatalogService_cs.xml │ ├── CatalogService_da.xml │ ├── CatalogService_de.xml │ ├── CatalogService_en.xml │ ├── CatalogService_es.xml │ ├── CatalogService_fi.xml │ ├── CatalogService_fr.xml │ ├── CatalogService_hu.xml │ ├── CatalogService_it.xml │ ├── CatalogService_ja.xml │ ├── CatalogService_ko.xml │ ├── CatalogService_ms.xml │ ├── CatalogService_nl.xml │ ├── CatalogService_no.xml │ ├── CatalogService_pl.xml │ ├── CatalogService_pt.xml │ ├── CatalogService_ro.xml │ ├── CatalogService_ru.xml │ ├── CatalogService_sv.xml │ ├── CatalogService_th.xml │ ├── CatalogService_tr.xml │ ├── CatalogService_zh_CN.xml │ ├── CatalogService_zh_TW.xml │ └── csn.json ├── test ├── cf-api.http └── saas-registry.http └── tools └── smsi-cli /.cdsrc.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "eslint:recommended", 3 | "env": { 4 | "node": true, 5 | "es6": true, 6 | "jest": true 7 | }, 8 | "parserOptions": { 9 | "ecmaVersion": 2017 10 | }, 11 | "globals": { 12 | "SELECT": true, 13 | "INSERT": true, 14 | "UPDATE": true, 15 | "DELETE": true, 16 | "CREATE": true, 17 | "DROP": true, 18 | "cds": true 19 | }, 20 | "rules": { 21 | "no-console": "off", 22 | "require-atomic-updates": "off" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # CAP killcds 2 | _out 3 | *.db 4 | connection.properties 5 | default-*.json 6 | gen/ 7 | node_modules/ 8 | package-lock.json 9 | target/ 10 | 11 | # Web IDE, App Studio 12 | .che/ 13 | .gen/ 14 | 15 | # MTA 16 | *_mta_build_tmp 17 | *.mtar 18 | mta_archives/ 19 | 20 | # Other 21 | .DS_Store 22 | *.orig 23 | *.log 24 | 25 | *.iml 26 | *.flattened-pom.xml 27 | 28 | # IDEs 29 | .vscode 30 | .idea 31 | 32 | #Misc 33 | CF_CREDS.sh 34 | Makefile* 35 | .env 36 | /mta_archives/ 37 | fioriHtmlRunner.html 38 | .*/fioriHtmlRunner.html 39 | visual_ext_index.html 40 | /webapp/visual_ext_index.html 41 | extended_runnable_file.html 42 | .*/extended_runnable_file.html 43 | sap-ui-cachebuster-info.json 44 | mock_preview_sapui5.html 45 | .*/mock_preview_sapui5.html 46 | UIAdaptation_index.html 47 | changes_preview.js 48 | AppVariant_index.html 49 | AppVariantPreviewPayload.zip 50 | mergedManifestDescriptor.json 51 | APIExternalProducer.js 52 | .*/APIExternalProducer.js 53 | -------------------------------------------------------------------------------- /.reuse/dep5: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: Cloud-CAP-Multitenancy 3 | Upstream-Contact: Andrew Lunde (andrew.lunde@sap.com) 4 | Source: https://github.com/SAP-samples/cloud-cap-multitenancy 5 | Disclaimer: The code in this project may include calls to APIs (“API Calls”) of 6 | SAP or third-party products or services developed outside of this project 7 | (“External Products”). 8 | “APIs” means application programming interfaces, as well as their respective 9 | specifications and implementing code that allows software to communicate with 10 | other software. 11 | API Calls to External Products are not licensed under the open source license 12 | that governs this project. The use of such API Calls and related External 13 | Products are subject to applicable additional agreements with the relevant 14 | provider of the External Products. In no event shall the open source license 15 | that governs this project grant any rights in or to any External Products,or 16 | alter, expand or supersede any terms of the applicable additional agreements. 17 | If you have a valid license agreement with SAP for the use of a particular SAP 18 | External Product, then you may make use of any API Calls included in this 19 | project’s code for that SAP External Product, subject to the terms of such 20 | license agreement. If you do not have a valid license agreement for the use of 21 | a particular SAP External Product, then you may only make use of any API Calls 22 | in this project for that SAP External Product for your internal, non-productive 23 | and non-commercial test and evaluation of such API Calls. Nothing herein grants 24 | you any rights to use or access any SAP External Product, or provide any third 25 | parties the right to use of access any SAP External Product, through API Calls. 26 | 27 | Files: * 28 | Copyright: 2020 SAP SE or an SAP affiliate company and Cloud-CAP-Multitenancy contributors 29 | License: Apache-2.0 30 | -------------------------------------------------------------------------------- /.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "generator-sap-partner-eng": { 3 | "package_version": "0.3.00", 4 | "project_name": "cloud-cap-multitenancy", 5 | "app_name": "capmt", 6 | "app_desc": "Cloud Application Programming(CAP) with Multitenancy using Service Manger Tenant Data Separation", 7 | "router_name": "capmt-app", 8 | "domain_name": "cfapps.us10.hana.ondemand.com", 9 | "router_path": "app", 10 | "database_path": "db", 11 | "services_path": "srv", 12 | "uaa_res_name": "capmt-uaa", 13 | "uaa_svc_name": "CAPMT_UAA", 14 | "database_name": "capmt-hdb", 15 | "db_schema_name": "", 16 | "hdi_res_name": "capmt-hdi", 17 | "hdi_svc_name": "CAPMT_HDI", 18 | "services_type": "nodejs", 19 | "java_package": "my.company", 20 | "services_name": "capmt-srv", 21 | "services_api": "capmt_svc_api", 22 | "services_be": "capmt_svc_be", 23 | "services_route": "catalog", 24 | "tests_path": "integration-tests", 25 | "multitenant_enabled": true, 26 | "reg_res_name": "capmt-reg", 27 | "reg_svc_name": "CAPMT_REG", 28 | "mgd_res_name": "capmt-smc", 29 | "mgd_svc_name": "CAPMT_SMC" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /CF_CREDS.txt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "" 3 | echo "Run these commands after a full deploy." 4 | echo "" 5 | set -o allexport; source .env; set +o allexport 6 | cf set-env capmt-srv CF_API_USER $CF_API_USER 7 | cf set-env capmt-srv CF_API_PW $CF_API_PW 8 | cf restage capmt-srv 9 | cf env capmt-srv | grep CF_API_USER 10 | echo "" 11 | -------------------------------------------------------------------------------- /COMMANDS.md: -------------------------------------------------------------------------------- 1 | #### Commands for Build/Deploy to Cloud Foundry(Shared Mode): 2 | 3 | # Build Command: 4 | ``` 5 | cd cloud-cap-multitenancy ; mkdir -p mta_archives ; mbt build -p=cf -t=mta_archives --mtar=capmt.mtar 6 | ``` 7 | 8 | # Deploy Command: 9 | ``` 10 | cf deploy mta_archives/capmt.mtar -f 11 | ``` 12 | 13 | # Subsequent Build+Deploy Commands: 14 | ``` 15 | mbt build -p=cf -t=mta_archives --mtar=capmt.mtar ; cf deploy mta_archives/capmt.mtar -f ; ./CF_CREDS.sh 16 | ``` 17 | 18 | # Undeploy Command: 19 | ``` 20 | cf undeploy capmt -f --delete-services 21 | ``` 22 | 23 | ``` 24 | cf de capmt-rtc 25 | cat default-env.json | jq . > default-env.jsonx ; cp default-env.jsonx default-env.json ; rm -f default-env.jsonx 26 | hana-cli status 27 | hana-cli querySimple -q "SELECT * FROM MY_BOOKSHOP_BOOKS LIMIT 3" 28 | ``` 29 | 30 | ``` 31 | tools/./ 32 | ./smsi-cli -qv -s sub1 qs -q '"SELECT NOW() FROM DUMMY"' 33 | 34 | ./smsi-cli -s sub1 qs -q '"SELECT NOW() FROM DUMMY"' 35 | 36 | // Get List of all tables 37 | ./smsi-cli -s sub1 tables 38 | 39 | // Get Field details of a specific table 40 | ./smsi-cli -s sub1 ti SCHEMA TABLE 41 | ./smsi-cli -s sub1 it 5922A2BA0669402BB61AA6065450C660 MY_BOOKSHOP_BOOKS 42 | 43 | // List the Top 5 rows of a specific table (in default SCHEMA) 44 | hana-cli qs -q "SELECT ID,TITLE FROM MY_BOOKSHOP_BOOKS LIMIT 4" 45 | hana-cli qs -q "SELECT * FROM MY_BOOKSHOP_BOOKS LIMIT 4" 46 | 47 | // SELECT Statements with wildcard * won't work since bash wants to expand them instead of passing through unchanged to hana-cli 48 | ./smsi-cli -s sub1 qs -q '"SELECT * FROM MY_BOOKSHOP_BOOKS LIMIT 4"' 49 | // You can avoid * 50 | ./smsi-cli -s sub1 qs -q '"SELECT ID,TITLE FROM MY_BOOKSHOP_BOOKS LIMIT 4"' 51 | // OR you can "wrap" hana-cli invocations with smsi-cli using the -b=backup_files and -r=restore_files flags 52 | ./smsi-cli -b -s sub1 ; hana-cli qs -q "SELECT * FROM MY_BOOKSHOP_BOOKS LIMIT 4" ; ./smsi-cli -r -s sub1 53 | 54 | ``` -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2021 SAP 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSES/Apache-2.0.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 SAP SE or an SAP affiliate company. 2 | 3 | ------------------------------------------------------------------------------------------ 4 | 5 | APIs 6 | The code in this project may include calls to APIs ("API Calls") of SAP or third-party 7 | products or services developed outside of this project ("External Products"). 8 | "APIs" means application programming interfaces, as well as their respective specifications 9 | and implementing code that allows software to communicate with other software. 10 | 11 | API Calls to External Products are not licensed under the open source license 12 | that governs this project. The use of such API Calls and related External Products 13 | are subject to applicable additional agreements with the relevant provider of the External 14 | Products. In no event shall the open source license that governs this project grant any 15 | rights in or to any External Products, or alter, expand or supersede any terms of the 16 | applicable additional agreements. 17 | 18 | If you have a valid license agreement with SAP for the use of a particular SAP External 19 | Product, then you may make use of any API Calls included in this project’s code for that 20 | AP External Product, subject to the terms of such license agreement. If you do not have a 21 | valid license agreement for the use of a particular SAP External Product, then you may only 22 | make use of any API Calls in this project for that SAP External Product for your internal, 23 | non-productive and non-commercial test and evaluation of such API Calls. Nothing herein grants 24 | you any rights to use or access any SAP External Product, or provide any third parties the 25 | right to use of access any SAP External Product, through API Calls. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Deprecation Notice 2 | 3 | This public repository is read-only and no longer maintained. 4 | 5 | ![](https://img.shields.io/badge/STATUS-NOT%20CURRENTLY%20MAINTAINED-red.svg?longCache=true&style=flat) 6 | 7 | --- 8 | 13 | [![REUSE status](https://api.reuse.software/badge/github.com/SAP-samples/cloud-cap-multitenancy)](https://api.reuse.software/info/github.com/SAP-samples/cloud-cap-multitenancy) 14 | 15 | 16 | # Cloud CAP Multitenancy 17 | 18 | SAP Cloud Application Programming (CAP) Node.JS sample code project with multitenancy using service manager created HANA containers for tenant data isolation. 19 | 20 | ## Description 21 | 22 | This repository contains a complete Multi-Target Application (MTA) sample project that is an example of using the SAP Cloud Application Programming (CAP) approach and it's multitenancy support library to provide true enterprise multitenant application. 23 | 24 | There are many disparate pieces of information found throughout the SAP documentation as well as the CAP centric documentation, but it is difficult to bring them together as a cohesive whole. This sample code project provides a good starting point for those wanting to build a best-practice multitenant enterprise application on SAP Business Technology Platform. 25 | 26 | This project is implemented completely in the Node.JS programming language. A Java programing language multitenant sample code project can be found in the repository [cloud-cap-samples-java](https://github.com/SAP-samples/cloud-cap-samples-java). See the [Demonstrated Features](https://github.com/SAP-samples/cloud-cap-samples-java#demonstrated-features) section of the README. 27 | 28 | ## Branches 29 | 30 | There are several branches in this repo and a little context is warranted. 31 | 32 | This sample utilizes the CAP multitenancy library (cds-mtx) to handle customer subscriptions which result in the ServiceManager creating run-time HANA hdi-shared containers. In the original master branch this was tested where each subscribing customer would have their own distinct container with no need of joining the customer container with any shared data. If this is your use case, then you'll find this version was saved in the single-container branch which will work with versions of the cds-mtx library < 1.0.27. For use cases where joining per subscriber containers with a singluar common container, a bug was discovered in the library that prevented run-time container deployments upon subscriptions. A work-around is provided in the xcontainer branch that will work with cds-mtx library < 1.0.27. This work-around effectively performs a secondary deploy with the proper environment that accomplishes the desired result. Once a fix was provided in cds-mtx >= 1.0.27, the work-around was no longer needed and the code removed and the fix-things branch was created in order to facilitate testing of the fix. Once the fix was confirmed effective the code was merged back into the master branch. 33 | 34 | The master branch going forward implements the use-case where each run-time container will be joined with a "common container"(as defined in the db_comm folder). The cds-mtx >= 1.0.27 will accomodate this use-case. 35 | 36 | ## Requirements 37 | 38 | - An [SAP Business Technology Platform account](https://account.hana.ondemand.com/) or [SAP Business Technology Platform Trial account](https://account.hanatrial.ondemand.com/cockpit) 39 | 40 | - Quota for HaaS, Application Runtime, SaaS, and Service Manager 41 | 42 | ## Download and Installation 43 | 44 | - Clone this repo [https://github.com/SAP-samples/cloud-cap-multitenancy.git](https://github.com/SAP-samples/cloud-cap.multitenancy.git) into your local system or IDE of choice. 45 | 46 | - Modify the mta.yaml to specify your specific CloudFoundry Credentials configuration (optional). 47 | 48 | ``` 49 | modules: 50 | - name: capmt-srv 51 | type: nodejs 52 | path: srv 53 | ... 54 | properties: 55 | CF_API_USER: user@domain.com 56 | CF_API_PW: xxxxxx 57 | ... 58 | ``` 59 | - OR - after deployment, 60 | 1. Create a file called .env with the following. 61 | ``` 62 | CF_API_USER= 63 | CF_API_PW= 64 | ``` 65 | 2. Run this command to set the ENVIRONMENT with your specifics. 66 | ``` 67 | set -o allexport; source .env; set +o allexport 68 | ``` 69 | 70 | 3. Update the environment for the capmt-srv module in the CF_CDEDS.sh script. 71 | ``` 72 | cf set-env capmt-srv CF_API_USER $CF_API_USER 73 | cf set-env capmt-srv CF_API_PW $CF_API_PW 74 | cf restage capmt-srv 75 | ``` 76 | 77 | ## Project Structure 78 | 79 | File / Folder | Purpose 80 | ---------|---------- 81 | `README.md` | this getting started guide 82 | `COMMANDS.md` | commands for building/deploying 83 | `app/` | content for UI frontends go here 84 | `db/` | database definitions go here 85 | `documentation/` | supplemental documentation 86 | `srv/` | your service module code goes here 87 | `mta.yaml` | project structure and relationships 88 | `package.json` | project metadata and configuration 89 | 90 | ## Instructions 91 | 92 | Replace **.hana.demand.com** with the landscape region variant for your account. 93 | 94 | See the [COMMANDS](COMMANDS.md) file for commands for building and deploying the project. 95 | 96 | 97 | 98 | ## Known Issues 99 | 100 | This example project contains no known issues. 101 | 102 | ## Limitations 103 | 104 | The creation and assignment of Roles to Roll Collections and the assignment of Roll Collections is limited to global accounts with "Feature Set B". 105 | 106 | 107 | ## How to obtain support 108 | 109 | [Create an issue](https://github.com/SAP-samples/cloud-cap-multitenancy/issues) in this repository if you find a bug or have questions about the content. 110 | 111 | For additional support, [ask a question in SAP Community](https://answers.sap.com/questions/ask.html?additionalTagId=723714486627645412834578565527550). 112 | 113 | ## Documentation 114 | 115 | See the Multitenancy section under Cookbook in the CAP documentation. [Multitanancy](https://cap.cloud.sap/docs/guides/multitenancy) 116 | 117 | Also the broader public [CAP Documentation](https://cap.cloud.sap/docs/). 118 | 119 | 120 | 121 | ## Reporting Problems and Contributing Enhancements 122 | 123 | An SAP Code Sample such as this is open software but is not quite a typical full-blown open source project. If you come across a problem, we’d encourage you to check the project’s [issue tracker](https://github.com/SAP-samples/cloud-cap-multitenancy/issues) and to [file a new issue](https://github.com/SAP-samples/cloud-cap-multitenancy/issues/new) if needed. If you are especially passionate about something you’d like to improve, you are welcome to fork the repository and submit improvements or changes as a pull request. 124 | 125 | 126 | ## To-Do (upcoming changes) 127 | 128 | Tools used throughout the development of this project are evolving and my change over time. This may result in discrepancies in the exact procedures or screen-clips in the accompanying blog posts. All efforts will be made to update the content in order to keep pace with the tooling, but cannot be guaranteed. 129 | 130 | 131 | ## Learn more... 132 | 133 | Learn more in the CAP documentation at [CAPIRE](https://cap.cloud.sap/docs/). 134 | 135 | A blog post discussing this code sample can be found on SAP Community. See: [Getting your head into Cloud Application Programming model multitenancy](https://blogs.sap.com/2020/08/20/getting-your-head-into-cloud-application-programming-model-multitenancy/) for a detailed discussion. 136 | 137 | 138 | ## License 139 | Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the [LICENSE](LICENSES/Apache-2.0.txt) file. 140 | -------------------------------------------------------------------------------- /app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "app", 3 | "version": "0.0.1", 4 | "description": "", 5 | "private": true, 6 | "devDependencies": {}, 7 | "dependencies": { 8 | "@sap/approuter": "^7" 9 | }, 10 | "scripts": { 11 | "start": "node node_modules/@sap/approuter/approuter.js" 12 | }, 13 | "files": [ 14 | "resources", 15 | "package.json", 16 | "xs-app.json" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /app/resources/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/app/resources/favicon.ico -------------------------------------------------------------------------------- /app/resources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | cloud-cap-multitenancy 7 | 8 | 9 | cloud-cap-multitenancy
10 |
11 |
12 | 13 | /catalog/ link handled by capmt-srv
14 | /catalog/Authors?$expand=books($select=ID,title) link handled by capmt-srv
15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/xs-app.json: -------------------------------------------------------------------------------- 1 | { 2 | "welcomeFile": "index.html", 3 | "authenticationMethod": "route", 4 | "logout": { 5 | "logoutEndpoint": "/do/logout" 6 | }, 7 | "routes": [ 8 | { 9 | "source": "(mtx/v1/provisioning/tenant/)(.*)", 10 | "destination": "capmt_svc_be", 11 | "httpMethods": ["GET", "PUT", "DELETE"], 12 | "csrfProtection": true, 13 | "authenticationType": "none" 14 | }, 15 | { 16 | "source": "(srv/)(.*)", 17 | "destination": "capmt_svc_be", 18 | "csrfProtection": true, 19 | "authenticationType": "xsuaa" 20 | }, 21 | { 22 | "source": "(catalog/)(.*)", 23 | "destination": "capmt_svc_be", 24 | "csrfProtection": true, 25 | "authenticationType": "xsuaa" 26 | }, 27 | { 28 | "localDir": "resources", 29 | "source": "^/(.*)", 30 | "authenticationType": "none" 31 | } 32 | ] 33 | } 34 | 35 | -------------------------------------------------------------------------------- /db/README.md: -------------------------------------------------------------------------------- 1 | # Defining Domain Models 2 | 3 | Follow Getting Started > in a Nutshell > Defining Domain Models 4 | 5 | https://cap.cloud.sap/docs/get-started/in-a-nutshell#domain-models 6 | 7 | -------------------------------------------------------------------------------- /db/build.js.disabled: -------------------------------------------------------------------------------- 1 | // Executes the CDS build depending on whether we have a top-level package.json. 2 | // Package.json is not available when we are called by CF/XSA buildpack. In this case we don't do anything 3 | // and just assume our model was already built and is available as part of this DB app. 4 | // 5 | // This is a workaround that will be replaced by a solution where CDS generates the DB module along with package.json. 6 | 7 | const fs = require('fs'); 8 | const childproc = require('child_process'); 9 | 10 | if (fs.existsSync('../package.json')) { 11 | // true at build-time, false at CF staging time 12 | childproc.execSync('npm install && npm run build', { 13 | cwd: '..', 14 | stdio: 'inherit' 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /db/cfg/.hdiconfig: -------------------------------------------------------------------------------- 1 | { 2 | "file_suffixes" : { 3 | "hdbmigrationtable" : { 4 | "plugin_name" : "com.sap.hana.di.table.migration" 5 | }, 6 | "hdbsystemversioning" : { 7 | "plugin_name" : "com.sap.hana.di.systemversioning" 8 | }, 9 | "hdbsynonym" : { 10 | "plugin_name" : "com.sap.hana.di.synonym" 11 | }, 12 | "hdbsynonymconfig" : { 13 | "plugin_name" : "com.sap.hana.di.synonym.config" 14 | }, 15 | "hdbtable" : { 16 | "plugin_name" : "com.sap.hana.di.table" 17 | }, 18 | "hdbdropcreatetable" : { 19 | "plugin_name" : "com.sap.hana.di.dropcreatetable" 20 | }, 21 | "hdbvirtualtable" : { 22 | "plugin_name" : "com.sap.hana.di.virtualtable" 23 | }, 24 | "hdbvirtualtableconfig" : { 25 | "plugin_name" : "com.sap.hana.di.virtualtable.config" 26 | }, 27 | "hdbindex" : { 28 | "plugin_name" : "com.sap.hana.di.index" 29 | }, 30 | "hdbconstraint" : { 31 | "plugin_name" : "com.sap.hana.di.constraint" 32 | }, 33 | "hdbtrigger" : { 34 | "plugin_name" : "com.sap.hana.di.trigger" 35 | }, 36 | "hdbstatistics" : { 37 | "plugin_name" : "com.sap.hana.di.statistics" 38 | }, 39 | "hdbview" : { 40 | "plugin_name" : "com.sap.hana.di.view" 41 | }, 42 | "hdbcalculationview" : { 43 | "plugin_name" : "com.sap.hana.di.calculationview" 44 | }, 45 | "hdbprojectionview" : { 46 | "plugin_name" : "com.sap.hana.di.projectionview" 47 | }, 48 | "hdbprojectionviewconfig" : { 49 | "plugin_name" : "com.sap.hana.di.projectionview.config" 50 | }, 51 | "hdbresultcache" : { 52 | "plugin_name" : "com.sap.hana.di.resultcache" 53 | }, 54 | "hdbfunction" : { 55 | "plugin_name" : "com.sap.hana.di.function" 56 | }, 57 | "hdbvirtualfunction" : { 58 | "plugin_name" : "com.sap.hana.di.virtualfunction" 59 | }, 60 | "hdbvirtualfunctionconfig" : { 61 | "plugin_name" : "com.sap.hana.di.virtualfunction.config" 62 | }, 63 | "hdbtabletype" : { 64 | "plugin_name" : "com.sap.hana.di.tabletype" 65 | }, 66 | "hdbprocedure" : { 67 | "plugin_name" : "com.sap.hana.di.procedure" 68 | }, 69 | "hdbvirtualprocedure" : { 70 | "plugin_name" : "com.sap.hana.di.virtualprocedure" 71 | }, 72 | "hdbvirtualprocedureconfig" : { 73 | "plugin_name" : "com.sap.hana.di.virtualprocedure.config" 74 | }, 75 | "hdblibrary" : { 76 | "plugin_name" : "com.sap.hana.di.library" 77 | }, 78 | "hdbsequence" : { 79 | "plugin_name" : "com.sap.hana.di.sequence" 80 | }, 81 | "hdbrole" : { 82 | "plugin_name" : "com.sap.hana.di.role" 83 | }, 84 | "hdbroleconfig" : { 85 | "plugin_name" : "com.sap.hana.di.role.config" 86 | }, 87 | "hdbstructuredprivilege" : { 88 | "plugin_name" : "com.sap.hana.di.structuredprivilege" 89 | }, 90 | "hdbanalyticprivilege" : { 91 | "plugin_name" : "com.sap.hana.di.analyticprivilege" 92 | }, 93 | "hdbtabledata" : { 94 | "plugin_name" : "com.sap.hana.di.tabledata" 95 | }, 96 | "csv" : { 97 | "plugin_name" : "com.sap.hana.di.tabledata.source" 98 | }, 99 | "properties" : { 100 | "plugin_name" : "com.sap.hana.di.tabledata.properties" 101 | }, 102 | "tags" : { 103 | "plugin_name" : "com.sap.hana.di.tabledata.properties" 104 | }, 105 | "hdbgraphworkspace" : { 106 | "plugin_name" : "com.sap.hana.di.graphworkspace" 107 | }, 108 | "hdbflowgraph" : { 109 | "plugin_name" : "com.sap.hana.di.flowgraph" 110 | }, 111 | "hdbreptask" : { 112 | "plugin_name" : "com.sap.hana.di.reptask" 113 | }, 114 | "hdbsearchruleset" : { 115 | "plugin_name" : "com.sap.hana.di.searchruleset" 116 | }, 117 | "txt" : { 118 | "plugin_name" : "com.sap.hana.di.copyonly" 119 | } 120 | } 121 | } -------------------------------------------------------------------------------- /db/cfg/synonyms/COMMON.hdbsynonymconfig: -------------------------------------------------------------------------------- 1 | { 2 | "COMMON_STATES": { 3 | "target": { 4 | "object": "COMMON_STATES", 5 | "schema.configure" : "POC_log-table-grantor/schema" 6 | } 7 | }, 8 | "MY_BOOKSHOP_STATES": { 9 | "target": { 10 | "object": "COMMON_STATES", 11 | "schema.configure" : "POC_log-table-grantor/schema" 12 | } 13 | }, 14 | "COMMON_CURRENCIES": { 15 | "target": { 16 | "object": "COMMON_CURRENCIES", 17 | "schema.configure" : "POC_log-table-grantor/schema" 18 | } 19 | }, 20 | "MY_BOOKSHOP_CURRENCIES": { 21 | "target": { 22 | "object": "COMMON_CURRENCIES", 23 | "schema.configure" : "POC_log-table-grantor/schema" 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /db/csv/my.bookshop-Authors.csv: -------------------------------------------------------------------------------- 1 | ID,NAME 2 | 1,F. Scott Fitzgerald 3 | 2,George Orwell 4 | 3,J. D. Salinger 5 | -------------------------------------------------------------------------------- /db/csv/my.bookshop-Books.csv: -------------------------------------------------------------------------------- 1 | ID,TITLE,AUTHOR_ID,STOCK 2 | 310,The Great Gatsby,1,241 3 | 311,Tender Is the Night,1,12 4 | 312,This Side of Paradise,1,5 5 | 320,1984,2,565 6 | 321,Animal Farm,2,14 7 | 330,The Catcher in the Rye,3,55 8 | -------------------------------------------------------------------------------- /db/csv/my.bookshop-Orders.csv: -------------------------------------------------------------------------------- 1 | ID,CREATEDBY,CREATEDAT,QUANTITY,BOOK_ID,SOLD_ON,PRICE_USD,STATE_CODE 2 | 46262d7a-0fe3-11e8-b642-0ed5f89f718b,Buyer 1,2020-02-01T00:00:00,1,330,2020-01-01,9.99,AZ 3 | 46263108-0fe3-11e8-b642-0ed5f89f718b,Buyer 1,2020-02-01T00:00:00,2,320,2020-01-01,8.99,AL 4 | 46263356-0fe3-11e8-b642-0ed5f89f718b,Buyer 5,2020-02-01T00:00:00,3,310,2020-01-01,10.00,GA 5 | 46262daa-0fe3-11e8-b642-0ed5f89f718b,Buyer 1,2020-02-01T00:00:00,2,330,2020-02-01,9.99,CA 6 | 462631a8-0fe3-11e8-b642-0ed5f89f718b,Buyer 1,2020-02-01T00:00:00,3,320,2020-02-01,8.99,NY 7 | 462633a6-0fe3-11e8-b642-0ed5f89f718b,Buyer 5,2020-02-01T00:00:00,4,310,2020-02-01,11.00,ID 8 | 46262dba-0fe3-11e8-b642-0ed5f89f718b,Buyer 1,2020-02-01T00:00:00,3,330,2020-03-01,9.99,AK 9 | 462631b8-0fe3-11e8-b642-0ed5f89f718b,Buyer 1,2020-02-01T00:00:00,4,320,2020-03-01,8.99,MO 10 | 462633b6-0fe3-11e8-b642-0ed5f89f718b,Buyer 5,2020-02-01T00:00:00,5,310,2020-03-01,12.00,FL 11 | 46262dca-0fe3-11e8-b642-0ed5f89f718b,Buyer 1,2020-02-01T00:00:00,3,330,2020-04-01,9.99,SD 12 | 462631c8-0fe3-11e8-b642-0ed5f89f718b,Buyer 1,2020-02-01T00:00:00,3,320,2020-04-01,8.99,ND 13 | 462633c6-0fe3-11e8-b642-0ed5f89f718b,Buyer 5,2020-02-01T00:00:00,2,310,2020-04-01,11.00,DC 14 | -------------------------------------------------------------------------------- /db/data-model.cds: -------------------------------------------------------------------------------- 1 | namespace my.bookshop; 2 | using { User, Country, managed } from '@sap/cds/common'; 3 | 4 | entity Books { 5 | key ID : Integer; 6 | title : localized String; 7 | author : Association to Authors; 8 | stock : Integer; 9 | } 10 | 11 | entity Authors { 12 | key ID : Integer; 13 | name : String; 14 | books : Association to many Books on books.author = $self; 15 | } 16 | 17 | entity Orders : managed { 18 | key ID : UUID; 19 | book : Association to Books; 20 | country : Country; 21 | sold_on : Date; 22 | quantity : Integer; 23 | Price_USD : Double; 24 | state : Association to States; 25 | } 26 | 27 | @cds.persistence.exists 28 | entity Currencies { 29 | key code : String(3); 30 | name : String(128); 31 | UperUSD : Double; 32 | USDperU : Double; 33 | } 34 | 35 | @cds.persistence.exists 36 | entity States { 37 | key code : String(2); 38 | abbrev : String(6); 39 | name : String(24); 40 | } 41 | 42 | // entity OrdersWithState as projection on Orders { 43 | // Orders.ID as ID, 44 | // Orders.book.title as Title, 45 | // Orders.quantity as Quantity, 46 | // Orders.sold_on as Sold_On, 47 | // Orders.Price_USD as Price_USD, 48 | // Orders.state.name as State 49 | // } 50 | 51 | @cds.persistence.exists 52 | entity Orders_View { 53 | key ID : Integer; 54 | title : String(5000); 55 | quantity : Integer; 56 | sold_on : Date; 57 | state_code : String(2); 58 | price_USD : Double; 59 | total_USD : Double; 60 | total_EUR : Double; 61 | total_VES : Double; 62 | total_GLD : Double; 63 | } 64 | 65 | // entity OrdersInGLD as 66 | // select from Orders_View 67 | // join States 68 | // on Orders_View.state_code = States.code 69 | // { 70 | // Orders_View.ID as ID, 71 | // Orders_View.title as Title, 72 | // Orders_View.quantity as Quantity, 73 | // Orders_View.sold_on as Sold_On, 74 | // Orders_View.total_GLD as Price_GLD, 75 | // States.name as State 76 | // } 77 | // order by 78 | // Orders_View.sold_on asc; 79 | 80 | entity config { 81 | key name : String(12); 82 | value : String(24); 83 | } -------------------------------------------------------------------------------- /db/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "deploy", 3 | "dependencies": { 4 | "@sap/hdi-deploy": "^3" 5 | }, 6 | "scripts": { 7 | "start": "node node_modules/@sap/hdi-deploy/deploy.js" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /db/src/.hdiconfig: -------------------------------------------------------------------------------- 1 | { 2 | "file_suffixes" : { 3 | "hdbmigrationtable" : { 4 | "plugin_name" : "com.sap.hana.di.table.migration" 5 | }, 6 | "hdbsystemversioning" : { 7 | "plugin_name" : "com.sap.hana.di.systemversioning" 8 | }, 9 | "hdbsynonym" : { 10 | "plugin_name" : "com.sap.hana.di.synonym" 11 | }, 12 | "hdbsynonymconfig" : { 13 | "plugin_name" : "com.sap.hana.di.synonym.config" 14 | }, 15 | "hdbtable" : { 16 | "plugin_name" : "com.sap.hana.di.table" 17 | }, 18 | "hdbdropcreatetable" : { 19 | "plugin_name" : "com.sap.hana.di.dropcreatetable" 20 | }, 21 | "hdbvirtualtable" : { 22 | "plugin_name" : "com.sap.hana.di.virtualtable" 23 | }, 24 | "hdbvirtualtableconfig" : { 25 | "plugin_name" : "com.sap.hana.di.virtualtable.config" 26 | }, 27 | "hdbindex" : { 28 | "plugin_name" : "com.sap.hana.di.index" 29 | }, 30 | "hdbconstraint" : { 31 | "plugin_name" : "com.sap.hana.di.constraint" 32 | }, 33 | "hdbtrigger" : { 34 | "plugin_name" : "com.sap.hana.di.trigger" 35 | }, 36 | "hdbstatistics" : { 37 | "plugin_name" : "com.sap.hana.di.statistics" 38 | }, 39 | "hdbview" : { 40 | "plugin_name" : "com.sap.hana.di.view" 41 | }, 42 | "hdbcalculationview" : { 43 | "plugin_name" : "com.sap.hana.di.calculationview" 44 | }, 45 | "hdbprojectionview" : { 46 | "plugin_name" : "com.sap.hana.di.projectionview" 47 | }, 48 | "hdbprojectionviewconfig" : { 49 | "plugin_name" : "com.sap.hana.di.projectionview.config" 50 | }, 51 | "hdbresultcache" : { 52 | "plugin_name" : "com.sap.hana.di.resultcache" 53 | }, 54 | "hdbfunction" : { 55 | "plugin_name" : "com.sap.hana.di.function" 56 | }, 57 | "hdbvirtualfunction" : { 58 | "plugin_name" : "com.sap.hana.di.virtualfunction" 59 | }, 60 | "hdbvirtualfunctionconfig" : { 61 | "plugin_name" : "com.sap.hana.di.virtualfunction.config" 62 | }, 63 | "hdbtabletype" : { 64 | "plugin_name" : "com.sap.hana.di.tabletype" 65 | }, 66 | "hdbprocedure" : { 67 | "plugin_name" : "com.sap.hana.di.procedure" 68 | }, 69 | "hdbvirtualprocedure" : { 70 | "plugin_name" : "com.sap.hana.di.virtualprocedure" 71 | }, 72 | "hdbvirtualprocedureconfig" : { 73 | "plugin_name" : "com.sap.hana.di.virtualprocedure.config" 74 | }, 75 | "hdblibrary" : { 76 | "plugin_name" : "com.sap.hana.di.library" 77 | }, 78 | "hdbsequence" : { 79 | "plugin_name" : "com.sap.hana.di.sequence" 80 | }, 81 | "hdbrole" : { 82 | "plugin_name" : "com.sap.hana.di.role" 83 | }, 84 | "hdbroleconfig" : { 85 | "plugin_name" : "com.sap.hana.di.role.config" 86 | }, 87 | "hdbstructuredprivilege" : { 88 | "plugin_name" : "com.sap.hana.di.structuredprivilege" 89 | }, 90 | "hdbanalyticprivilege" : { 91 | "plugin_name" : "com.sap.hana.di.analyticprivilege" 92 | }, 93 | "hdbtabledata" : { 94 | "plugin_name" : "com.sap.hana.di.tabledata" 95 | }, 96 | "csv" : { 97 | "plugin_name" : "com.sap.hana.di.tabledata.source" 98 | }, 99 | "properties" : { 100 | "plugin_name" : "com.sap.hana.di.tabledata.properties" 101 | }, 102 | "tags" : { 103 | "plugin_name" : "com.sap.hana.di.tabledata.properties" 104 | }, 105 | "hdbgraphworkspace" : { 106 | "plugin_name" : "com.sap.hana.di.graphworkspace" 107 | }, 108 | "hdbflowgraph" : { 109 | "plugin_name" : "com.sap.hana.di.flowgraph" 110 | }, 111 | "hdbreptask" : { 112 | "plugin_name" : "com.sap.hana.di.reptask" 113 | }, 114 | "hdbsearchruleset" : { 115 | "plugin_name" : "com.sap.hana.di.searchruleset" 116 | }, 117 | "txt" : { 118 | "plugin_name" : "com.sap.hana.di.copyonly" 119 | } 120 | } 121 | } -------------------------------------------------------------------------------- /db/src/.hdinamespace: -------------------------------------------------------------------------------- 1 | { 2 | "name": "", 3 | "subfolder": "ignore" 4 | } 5 | -------------------------------------------------------------------------------- /db/src/db_grant_role.hdbprocedure: -------------------------------------------------------------------------------- 1 | PROCEDURE "db_grant_role" ( 2 | in in_user nvarchar(80), 3 | in in_role nvarchar(80), 4 | out ex_message NVARCHAR(255)) 5 | LANGUAGE SQLSCRIPT 6 | SQL SECURITY DEFINER 7 | AS 8 | 9 | lv_schema nvarchar(80); 10 | 11 | BEGIN 12 | /************************************* 13 | Write your procedure logic 14 | *************************************/ 15 | SELECT CURRENT_SCHEMA into lv_schema FROM "DUMMY"; 16 | exec 'GRANT "' || 17 | lv_schema || 18 | '"."' || :in_role || '" to ' || :in_user ; 19 | ex_message = 'Granted role' || lv_schema || '.' || :in_role || ' to ' || :in_user ; 20 | -- exec :in_user; 21 | END 22 | -------------------------------------------------------------------------------- /db/src/defaults/default_access_role.hdbrole: -------------------------------------------------------------------------------- 1 | { 2 | "role":{ 3 | "name": "default_access_role", 4 | "schema_roles": [{ 5 | "names": ["customer_admin"] 6 | }] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /db/src/loads/.hdiconfig: -------------------------------------------------------------------------------- 1 | { 2 | "file_suffixes": { 3 | "csv": { 4 | "plugin_name": "com.sap.hana.di.tabledata.source" 5 | }, 6 | "hdbtable": { 7 | "plugin_name": "com.sap.hana.di.table" 8 | }, 9 | "hdbtabledata": { 10 | "plugin_name": "com.sap.hana.di.tabledata" 11 | }, 12 | "hdbview": { 13 | "plugin_name": "com.sap.hana.di.view" 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /db/src/loads/.hdinamespace: -------------------------------------------------------------------------------- 1 | { 2 | "name": "", 3 | "subfolder": "ignore" 4 | } -------------------------------------------------------------------------------- /db/src/loads/config.csv: -------------------------------------------------------------------------------- 1 | "Name","Value" 2 | "DB_VER","0.0.0" 3 | "REL_VER","Initial" -------------------------------------------------------------------------------- /db/src/loads/config.hdbtabledata: -------------------------------------------------------------------------------- 1 | { 2 | "format_version": 1, 3 | "imports": [{ 4 | "column_mappings": { 5 | "NAME": "Name", 6 | "VALUE": "Value" 7 | }, 8 | "import_settings": { 9 | "import_columns": [ 10 | "NAME", 11 | "VALUE" 12 | ], 13 | "include_filter": [] 14 | }, 15 | "source_data": { 16 | "data_type": "CSV", 17 | "file_name": "config.csv", 18 | "has_header": true 19 | }, 20 | "target_table": "MY_BOOKSHOP_CONFIG" 21 | }] 22 | } -------------------------------------------------------------------------------- /db/src/roles/customer_admin.hdbrole: -------------------------------------------------------------------------------- 1 | { 2 | "role":{ 3 | "name": "customer_admin", 4 | "schema_privileges": [{ 5 | "privileges": ["SELECT METADATA", 6 | "SELECT CDS METADATA", 7 | "SELECT", 8 | "INSERT", 9 | "EXECUTE", 10 | "DELETE", 11 | "UPDATE", 12 | "CREATE TEMPORARY TABLE" 13 | ] 14 | }] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /db/src/synonyms/COMMON-table.hdbgrants: -------------------------------------------------------------------------------- 1 | { 2 | "POC_log-table-grantor": { 3 | "object_owner": { 4 | "container_roles": [ 5 | "POC_XXX::external_access_g#" 6 | ] 7 | }, 8 | "application_user": { 9 | "container_roles": [ 10 | "POC_XXX::external_access" 11 | ] 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /db/src/synonyms/COMMON.hdbsynonym: -------------------------------------------------------------------------------- 1 | { 2 | "COMMON_STATES": {}, 3 | "COMMON_CURRENCIES": {}, 4 | "MY_BOOKSHOP_STATES" : {}, 5 | "MY_BOOKSHOP_CURRENCIES" : {} 6 | } -------------------------------------------------------------------------------- /db/src/synonyms/VIEWS.hdbsynonym: -------------------------------------------------------------------------------- 1 | { 2 | "MY_BOOKSHOP_ORDERS_VIEW" : { 3 | "target": { 4 | "object" : "ORDERS_VIEW" 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /db/src/synonyms/sys.hdbsynonym: -------------------------------------------------------------------------------- 1 | { 2 | "DUMMY": { 3 | "target": { 4 | "object": "DUMMY", 5 | "schema": "SYS" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /db/src/views/ORDERS_BAS_CALCVIEW.hdbcalculationview: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ORDERS_VIEW 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | TITLE 60 | State 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | {shape_greg_time} 80 | 81 | 82 | -------------------------------------------------------------------------------- /db/src/views/ORDERS_VIEW.hdbview: -------------------------------------------------------------------------------- 1 | VIEW "ORDERS_VIEW" AS SELECT 2 | "O"."ID" AS "ID", 3 | "B"."TITLE" AS "TITLE", 4 | "O"."QUANTITY" AS "Quantity", 5 | "O"."SOLD_ON" AS "Sold_On", 6 | "S"."NAME" AS "State", 7 | "O"."PRICE_USD" AS "Price_USD", 8 | ("O"."PRICE_USD" * "O"."QUANTITY" * (SELECT "UPERUSD" FROM "COMMON_CURRENCIES" WHERE "CODE"='USD')) AS "Total_USD", 9 | ("O"."PRICE_USD" * "O"."QUANTITY" * (SELECT "UPERUSD" FROM "COMMON_CURRENCIES" WHERE "CODE"='EUR')) AS "Total_EUR", 10 | ("O"."PRICE_USD" * "O"."QUANTITY" * (SELECT "UPERUSD" FROM "COMMON_CURRENCIES" WHERE "CODE"='VES')) AS "Total_VES", 11 | ("O"."PRICE_USD" * "O"."QUANTITY" * (SELECT "UPERUSD" FROM "COMMON_CURRENCIES" WHERE "CODE"='GLD')) AS "Total_GLD" 12 | FROM "MY_BOOKSHOP_ORDERS" AS "O" 13 | JOIN "MY_BOOKSHOP_BOOKS" AS "B" ON "O"."BOOK_ID" = "B"."ID" 14 | JOIN "COMMON_STATES" AS "S" ON "O"."STATE_CODE" = "S"."CODE" -------------------------------------------------------------------------------- /db/src/views/sql.txt: -------------------------------------------------------------------------------- 1 | SELECT * FROM VIEWS WHERE VIEW_TYPE='CALC' -------------------------------------------------------------------------------- /db_comm/README.md: -------------------------------------------------------------------------------- 1 | # Defining Domain Models 2 | 3 | Follow Getting Started > in a Nutshell > Defining Domain Models 4 | 5 | https://cap.cloud.sap/docs/get-started/in-a-nutshell#domain-models 6 | 7 | -------------------------------------------------------------------------------- /db_comm/data-model.cds: -------------------------------------------------------------------------------- 1 | namespace common; 2 | using { User, Country, cuid, managed } from '@sap/cds/common'; 3 | 4 | entity States { 5 | key code : String(2); 6 | abbrev : String(6); 7 | name : String(24); 8 | } 9 | 10 | entity Currencies { 11 | key code : String(3); 12 | name : String(128); 13 | UperUSD : Double; 14 | USDperU : Double; 15 | } 16 | 17 | entity Subscribers : cuid { 18 | SAChostname : String(255); 19 | email : String(255); 20 | globalAccountGUID : String(64); 21 | subscribedSubaccountId : String(64); 22 | subscribedSubdomain : String(64); 23 | subscribedTenantId : String(64); 24 | subscriptionAppId : String(64); 25 | subscriptionAppName : String(96); 26 | userId : String(64); 27 | } 28 | -------------------------------------------------------------------------------- /db_comm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "deploy", 3 | "dependencies": { 4 | "@sap/hdi-deploy": "^3" 5 | }, 6 | "scripts": { 7 | "start": "node node_modules/@sap/hdi-deploy/deploy.js" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /db_comm/src/.hdiconfig: -------------------------------------------------------------------------------- 1 | { 2 | "file_suffixes": { 3 | "hdbsystemversioning": { 4 | "plugin_name": "com.sap.hana.di.systemversioning" 5 | }, 6 | "hdbsynonym": { 7 | "plugin_name": "com.sap.hana.di.synonym" 8 | }, 9 | "hdbsynonymconfig": { 10 | "plugin_name": "com.sap.hana.di.synonym.config" 11 | }, 12 | "hdbtable": { 13 | "plugin_name": "com.sap.hana.di.table" 14 | }, 15 | "hdbdropcreatetable": { 16 | "plugin_name": "com.sap.hana.di.dropcreatetable" 17 | }, 18 | "hdbvirtualtable": { 19 | "plugin_name": "com.sap.hana.di.virtualtable" 20 | }, 21 | "hdbvirtualtableconfig": { 22 | "plugin_name": "com.sap.hana.di.virtualtable.config" 23 | }, 24 | "hdbindex": { 25 | "plugin_name": "com.sap.hana.di.index" 26 | }, 27 | "hdbconstraint": { 28 | "plugin_name": "com.sap.hana.di.constraint" 29 | }, 30 | "hdbtrigger": { 31 | "plugin_name": "com.sap.hana.di.trigger" 32 | }, 33 | "hdbstatistics": { 34 | "plugin_name": "com.sap.hana.di.statistics" 35 | }, 36 | "hdbview": { 37 | "plugin_name": "com.sap.hana.di.view" 38 | }, 39 | "hdbcalculationview": { 40 | "plugin_name": "com.sap.hana.di.calculationview" 41 | }, 42 | "hdbprojectionview": { 43 | "plugin_name": "com.sap.hana.di.projectionview" 44 | }, 45 | "hdbprojectionviewconfig": { 46 | "plugin_name": "com.sap.hana.di.projectionview.config" 47 | }, 48 | "hdbresultcache": { 49 | "plugin_name": "com.sap.hana.di.resultcache" 50 | }, 51 | "hdbfunction": { 52 | "plugin_name": "com.sap.hana.di.function" 53 | }, 54 | "hdbvirtualfunction": { 55 | "plugin_name": "com.sap.hana.di.virtualfunction" 56 | }, 57 | "hdbvirtualfunctionconfig": { 58 | "plugin_name": "com.sap.hana.di.virtualfunction.config" 59 | }, 60 | "hdbtabletype": { 61 | "plugin_name": "com.sap.hana.di.tabletype" 62 | }, 63 | "hdbprocedure": { 64 | "plugin_name": "com.sap.hana.di.procedure" 65 | }, 66 | "hdbvirtualprocedure": { 67 | "plugin_name": "com.sap.hana.di.virtualprocedure" 68 | }, 69 | "hdbvirtualprocedureconfig": { 70 | "plugin_name": "com.sap.hana.di.virtualprocedure.config" 71 | }, 72 | "hdblibrary": { 73 | "plugin_name": "com.sap.hana.di.library" 74 | }, 75 | "hdbsequence": { 76 | "plugin_name": "com.sap.hana.di.sequence" 77 | }, 78 | "hdbrole": { 79 | "plugin_name": "com.sap.hana.di.role" 80 | }, 81 | "hdbroleconfig": { 82 | "plugin_name": "com.sap.hana.di.role.config" 83 | }, 84 | "hdbstructuredprivilege": { 85 | "plugin_name": "com.sap.hana.di.structuredprivilege" 86 | }, 87 | "hdbanalyticprivilege": { 88 | "plugin_name": "com.sap.hana.di.analyticprivilege" 89 | }, 90 | "hdbtabledata": { 91 | "plugin_name": "com.sap.hana.di.tabledata" 92 | }, 93 | "csv": { 94 | "plugin_name": "com.sap.hana.di.tabledata.source" 95 | }, 96 | "properties": { 97 | "plugin_name": "com.sap.hana.di.tabledata.properties" 98 | }, 99 | "tags": { 100 | "plugin_name": "com.sap.hana.di.tabledata.properties" 101 | }, 102 | "hdbgraphworkspace": { 103 | "plugin_name": "com.sap.hana.di.graphworkspace" 104 | }, 105 | "hdbflowgraph": { 106 | "plugin_name": "com.sap.hana.di.flowgraph" 107 | }, 108 | "hdbreptask": { 109 | "plugin_name": "com.sap.hana.di.reptask" 110 | }, 111 | "hdbsearchruleset": { 112 | "plugin_name": "com.sap.hana.di.searchruleset" 113 | }, 114 | "txt": { 115 | "plugin_name": "com.sap.hana.di.copyonly" 116 | } 117 | } 118 | } -------------------------------------------------------------------------------- /db_comm/src/.hdinamespace: -------------------------------------------------------------------------------- 1 | { 2 | "name": "", 3 | "subfolder": "ignore" 4 | } 5 | -------------------------------------------------------------------------------- /db_comm/src/db_grant_role.hdbprocedure: -------------------------------------------------------------------------------- 1 | PROCEDURE "db_grant_role" ( 2 | in in_user nvarchar(80), 3 | in in_role nvarchar(80), 4 | out ex_message NVARCHAR(255)) 5 | LANGUAGE SQLSCRIPT 6 | SQL SECURITY DEFINER 7 | AS 8 | 9 | lv_schema nvarchar(80); 10 | 11 | BEGIN 12 | /************************************* 13 | Write your procedure logic 14 | *************************************/ 15 | SELECT CURRENT_SCHEMA into lv_schema FROM "DUMMY"; 16 | exec 'GRANT "' || 17 | lv_schema || 18 | '"."' || :in_role || '" to ' || :in_user ; 19 | ex_message = 'Granted role' || lv_schema || '.' || :in_role || ' to ' || :in_user ; 20 | -- exec :in_user; 21 | END 22 | -------------------------------------------------------------------------------- /db_comm/src/defaults/default_access_role.hdbrole: -------------------------------------------------------------------------------- 1 | { 2 | "role":{ 3 | "name": "default_access_role", 4 | "schema_roles": [{ 5 | "names": ["common_admin"] 6 | }] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /db_comm/src/loads/currencies.csv: -------------------------------------------------------------------------------- 1 | "Code","Name","Units per USD","USD per Unit" 2 | "USD","US Dollar",1,1 3 | "EUR","Euro",0.847710211,1.179648407 4 | "GBP","British Pound",0.766594681,1.304470308 5 | "INR","Indian Rupee",73.73544923,0.013561998 6 | "JPY","Japanese Yen",105.953149,0.009438134 7 | "VES","Venezuelan Bolívar",336395.3181,2.9727E-06 8 | "GLD","Gold Oz",0.00051889,1927.17 9 | "SLV","Silver Oz",0.0373413,26.78 -------------------------------------------------------------------------------- /db_comm/src/loads/currencies.hdbtabledata: -------------------------------------------------------------------------------- 1 | { 2 | "format_version": 1, 3 | "imports": [{ 4 | "column_mappings": { 5 | "CODE": "Code", 6 | "NAME": "Name", 7 | "UPERUSD": "Units per USD", 8 | "USDPERU": "USD per Unit" 9 | }, 10 | "import_settings": { 11 | "import_columns": [ 12 | "CODE", 13 | "NAME", 14 | "UPERUSD", 15 | "USDPERU" 16 | ], 17 | "include_filter": [] 18 | }, 19 | "source_data": { 20 | "data_type": "CSV", 21 | "file_name": "currencies.csv", 22 | "has_header": true 23 | }, 24 | "target_table": "COMMON_CURRENCIES" 25 | }] 26 | } -------------------------------------------------------------------------------- /db_comm/src/loads/states.csv: -------------------------------------------------------------------------------- 1 | "State","Abbrev","Code" 2 | "Alabama","Ala.","AL" 3 | "Alaska","Alaska","AK" 4 | "Arizona","Ariz.","AZ" 5 | "Arkansas","Ark.","AR" 6 | "California","Calif.","CA" 7 | "Colorado","Colo.","CO" 8 | "Connecticut","Conn.","CT" 9 | "Delaware","Del.","DE" 10 | "District of Columbia","D.C.","DC" 11 | "Florida","Fla.","FL" 12 | "Georgia","Ga.","GA" 13 | "Hawaii","Hawaii","HI" 14 | "Idaho","Idaho","ID" 15 | "Illinois","Ill.","IL" 16 | "Indiana","Ind.","IN" 17 | "Iowa","Iowa","IA" 18 | "Kansas","Kans.","KS" 19 | "Kentucky","Ky.","KY" 20 | "Louisiana","La.","LA" 21 | "Maine","Maine","ME" 22 | "Maryland","Md.","MD" 23 | "Massachusetts","Mass.","MA" 24 | "Michigan","Mich.","MI" 25 | "Minnesota","Minn.","MN" 26 | "Mississippi","Miss.","MS" 27 | "Missouri","Mo.","MO" 28 | "Montana","Mont.","MT" 29 | "Nebraska","Nebr.","NE" 30 | "Nevada","Nev.","NV" 31 | "New Hampshire","N.H.","NH" 32 | "New Jersey","N.J.","NJ" 33 | "New Mexico","N.M.","NM" 34 | "New York","N.Y.","NY" 35 | "North Carolina","N.C.","NC" 36 | "North Dakota","N.D.","ND" 37 | "Ohio","Ohio","OH" 38 | "Oklahoma","Okla.","OK" 39 | "Oregon","Ore.","OR" 40 | "Pennsylvania","Pa.","PA" 41 | "Rhode Island","R.I.","RI" 42 | "South Carolina","S.C.","SC" 43 | "South Dakota","S.D.","SD" 44 | "Tennessee","Tenn.","TN" 45 | "Texas","Tex.","TX" 46 | "Utah","Utah","UT" 47 | "Vermont","Vt.","VT" 48 | "Virginia","Va.","VA" 49 | "Washington","Wash.","WA" 50 | "West Virginia","W.Va.","WV" 51 | "Wisconsin","Wis.","WI" 52 | "Wyoming","Wyo.","WY" -------------------------------------------------------------------------------- /db_comm/src/loads/states.hdbtabledata: -------------------------------------------------------------------------------- 1 | { 2 | "format_version": 1, 3 | "imports": [{ 4 | "column_mappings": { 5 | "NAME": "State", 6 | "ABBREV": "Abbrev", 7 | "CODE": "Code" 8 | }, 9 | "import_settings": { 10 | "import_columns": [ 11 | "NAME", 12 | "ABBREV", 13 | "CODE" 14 | ], 15 | "include_filter": [] 16 | }, 17 | "source_data": { 18 | "data_type": "CSV", 19 | "file_name": "states.csv", 20 | "has_header": true 21 | }, 22 | "target_table": "COMMON_STATES" 23 | }] 24 | } -------------------------------------------------------------------------------- /db_comm/src/roles/common_admin.hdbrole: -------------------------------------------------------------------------------- 1 | { 2 | "role":{ 3 | "name": "common_admin", 4 | "schema_privileges": [{ 5 | "privileges": ["SELECT METADATA", 6 | "SELECT CDS METADATA", 7 | "SELECT", 8 | "INSERT", 9 | "EXECUTE", 10 | "DELETE", 11 | "UPDATE", 12 | "CREATE TEMPORARY TABLE" 13 | ] 14 | }] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /db_comm/src/roles/external_access.hdbrole: -------------------------------------------------------------------------------- 1 | { 2 | "role": { 3 | "name": "POC_XXX::external_access", 4 | "object_privileges": [ 5 | { 6 | "name":"COMMON_STATES", 7 | "type":"TABLE", 8 | "privileges":[ "SELECT" ] 9 | }, 10 | { 11 | "name":"COMMON_CURRENCIES", 12 | "type":"TABLE", 13 | "privileges":[ "SELECT" ] 14 | } 15 | ] 16 | } 17 | } -------------------------------------------------------------------------------- /db_comm/src/roles/external_access_g.hdbrole: -------------------------------------------------------------------------------- 1 | { 2 | "role": { 3 | "name": "POC_XXX::external_access_g#", 4 | "object_privileges": [ 5 | { 6 | "name":"COMMON_STATES", 7 | "type":"TABLE", 8 | "privileges_with_grant_option":[ "SELECT" ] 9 | }, 10 | { 11 | "name":"COMMON_CURRENCIES", 12 | "type":"TABLE", 13 | "privileges_with_grant_option":[ "SELECT" ] 14 | } 15 | ] 16 | } 17 | } -------------------------------------------------------------------------------- /db_comm/src/sql/verify.sql.txt: -------------------------------------------------------------------------------- 1 | -- Verify if and access_role and an external_privileges_role were created 2 | SELECT * FROM ROLES WHERE SUBSTRING(ROLE_NAME, 0, 32) = SUBSTRING((SELECT CURRENT_SCHEMA FROM "DUMMY"), 0, 32); 3 | 4 | -- Create a new user (AS DBADMIN) 5 | CREATE USER COMMON_USER PASSWORD Whatever8642 NO FORCE_FIRST_PASSWORD_CHANGE; 6 | 7 | -- Grant the same role(permissions) as the container user to COMMON_USER 8 | CALL "db_grant_role"(IN_USER => 'COMMON_USER',IN_ROLE => 'common_admin',EX_MESSAGE => ?); 9 | 10 | -- Verify that the needed users are assigned those ROLES 11 | SELECT * FROM GRANTED_ROLES WHERE ROLE_NAME = 'common_admin'; 12 | 13 | -- Verify that the grants necessary for cross container access are created (AS DBADMIN) 14 | SELECT * FROM ROLES WHERE SUBSTRING(ROLE_NAME, 0, 7) = 'POC_XXX'; 15 | -------------------------------------------------------------------------------- /db_comm/src/synonyms/sys.hdbsynonym: -------------------------------------------------------------------------------- 1 | { 2 | "DUMMY": { 3 | "target": { 4 | "object": "DUMMY", 5 | "schema": "SYS" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /db_comm/undeploy.json: -------------------------------------------------------------------------------- 1 | [ 2 | "src/.DS_Store" 3 | ] -------------------------------------------------------------------------------- /documentation/README.md: -------------------------------------------------------------------------------- 1 | # Supplimental documentation 2 | 3 | - [Yeoman Recipe for the project sample](YO_RECIPE.md) 4 | 5 | - [Troubleshooting Hints](TROUBLESHOOTING.md) 6 | 7 | -------------------------------------------------------------------------------- /documentation/TROUBLESHOOTING.md: -------------------------------------------------------------------------------- 1 | # Subscription Issues 2 | 3 | ## Name already registered: 4 | 5 | Remember that for your app to be made subscribable, it has to be registered with an app name that is unique in the landscape. 6 | This holds true also if you want to deploy your app in another space or org within your account. 7 | 8 | If you're getting messages that look like this in your capmt-srv logs, Try adjusting the appName in the mta.yaml file. 9 | 10 | ``` 11 | Service operation failed: Controller operation failed: 502 Updating service "CAPMT_REG" failed: Bad Gateway: Error creating service "CAPMT_REG" from offering "saas-registry" and plan "application": CF-ServiceBrokerBadResponse(10001): Service broker error: Service broker saas-registry failed with: SaaS application/service with the same appName (its value is: capmt) already registered in SaaS 12 | Proceeding with automatic retry... (3 of 3 attempts left) 13 | ``` 14 | ![appName](images/2E731498-07B8-4B67-8BD9-F2C5B092E29B.png) 15 | 16 | ## Registration Fails: 17 | 18 | If the url that was provided during SaaS registration doesn't match with the srv module's url then subcriptions will fail. Check it with the following to make sure they are the same. 19 | ``` 20 | cf app capmt-srv | grep routes 21 | cf env capmt-srv | grep onSubscription 22 | ``` 23 | ![capmt-srv](images/23F114A1-56BD-4A66-927F-8135CD07DFEB.png) 24 | 25 | 26 | ## Subscriber route doesn't exist: 27 | 28 | If when you subscribe and it's completed, then click the "Go to Application" link, but that fails with a "route not found" error, check that the route for that subaccount's subdomain exists and points to the capmt-app. In this example the subaccoun't subdomain is **capmt-sub1** 29 | 30 | ``` 31 | cf r 32 | ``` 33 | ![route](images/3DD05C3C-13A5-4188-8C7E-C66CD421A675.png) 34 | 35 | If it doesn't then you probably didn't set your credentials the CF_CREDS.sh file and run it. 36 | 37 | ``` 38 | ./CF_CREDS.sh 39 | ``` 40 | 41 | Or you may need to manually create a router for the subscriber subaccount. 42 | ``` 43 | cf map-route capmt-app cfapps.ap10.hana.ondemand.com --hostname=capmt-sub1-dev-capmt-app 44 | ``` 45 | ## Unauthorized: 46 | 47 | If you finally get to the app and when you click on the links you get an unauthorized message, then it's likely that you haven't created a Role Collection and added the capmt Roles to it and assigned your user to that Role Collection. Check the [Getting your head into Cloud Application Programming model multitenancy](https://blogs.sap.com/2020/08/20/getting-your-head-into-cloud-application-programming-model-multitenancy/) blog post for a details. 48 | 49 | Even if you do this for your own user, you will have to sign out of Cloud Platform and sign back in again to get the new roll collection effective for your user. 50 | 51 | ## Other stuff: 52 | 53 | Watch the logs while attempting a subscription. If the logs are to verbose, you can turn that down by commenting out **NODE_DEBUG: 'instance-manager'** in the mta.yaml file. You should see messages that have this in them. 54 | ``` 55 | [INFO ][ON_UPDATE_TENANT] XXX_Starting Subscription for capmt-sub1 56 | ``` 57 | You can also just watch for log entries with 'XXX' in them. 58 | ``` 59 | cf logs capmt-srv | grep -A 2 XXX 60 | ``` 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /documentation/YO_RECIPE.md: -------------------------------------------------------------------------------- 1 | # Yeoman Recipe for the project sample 2 | 3 | ## Yeoman is installed in the Business Application Studio or install it locally with.. 4 | ``` 5 | npm install -g yo 6 | ``` 7 | 8 | ## Install this exact version of the partner engineering yeoman generator 9 | 10 | ``` 11 | npm install -g generator-sap-partner-eng@0.3.7 12 | ``` 13 | 14 | ## Verify generator version (if already installed) 15 | 16 | ``` 17 | npm ls -g --depth=0 generator-sap-partner-eng 18 | ``` 19 | 20 | generator-sap-partner-eng@0.3.7 21 | 22 | ## Run the yeoman generator to create the project folder and approuter 23 | **Note:** The answers given below were the ones used to create this sample code repository. You may use your own component/file naming convention to make it easier to integrate this code the generated code into your project. 24 | 25 | 26 | ``` 27 | yo sap-partner-eng 28 | ``` 29 | ![](images/842229F4-C86E-4072-AEA3-A8B1BC2D0301.png) 30 | 31 | 32 | Continue answering the prompts. 33 | ``` 34 | ? Enter your project folder name (will be created if necessary). cloud-cap-multitenancy 35 | ? Enter your project application name (will be used for defaults). capmt 36 | ? Enter your project application description. Cloud Application Programming(CAP) with Multitenancy using Service Manger Tenant Data Separation 37 | ? Application router internal module name. capmt-app 38 | This list of domain names is based on the current 'cf domains' command. 39 | Domain name. cfapps.us10.hana.ondemand.com 40 | ? Application router path app 41 | ? Domain/Database model path db 42 | ? Services definition path srv 43 | ? UAA resource name capmt-uaa 44 | ? UAA service name CAPMT_UAA 45 | ... 46 | ``` 47 | Change into the folder just created and continue. 48 | ``` 49 | cd cloud-cap-multitenancy 50 | ``` 51 | ## Run the yeoman db-cap sub-generator to create the db and srv folders and files 52 | 53 | 54 | Now from within the project folder run the sub-generator for db-cap with this command. 55 | ``` 56 | yo sap-partner-eng:db-cap 57 | ``` 58 | Continue answering the prompts. 59 | ``` 60 | Start Prompting. 61 | What is: foo! 62 | Using app_name: capmt 63 | Using router_name: capmt-app 64 | Using router_path: app 65 | Using database_path: db 66 | Using services_path: srv 67 | ? DB Module Name. capmt-hdb 68 | Leave this blank if you want the system to generate the schema name. 69 | DB Schema Name. 70 | ? HDI resource name capmt-hdi 71 | Implement the service module as nodejs/(java) module type. 72 | Module type. nodejs 73 | ? HDI service name. CAPMT_HDI 74 | ? Services Module Name. capmt-srv 75 | ? Services Module API (Internal Reference). capmt_svc_api 76 | ? Services Module Back End (AppRouter Destination). capmt_svc_be 77 | ? Route path(after first /) that your module will handle catalog 78 | ? Use this NodeJS module to handle CDS-MTX style subscription requests? Yes 79 | ? Registry Resource Name. capmt-reg 80 | ? Registry Service Name. CAPMT_REG 81 | ? Managed(HDI) Resource Name. capmt-smc 82 | ? Managed(HDI) Service Name. CAPMT_SMC 83 | Using domain_name: cfapps.us10.hana.ondemand.com 84 | Using uaa_res_name: capmt-uaa 85 | force .yo-rc.json 86 | create db/.build.js 87 | create db/data-model.cds 88 | ... 89 | create srv/package.json 90 | conflict mta.yaml 91 | ? Overwrite mta.yaml? (Answer "a" for Overwrite all) 92 | force mta.yaml 93 | force app/xs-app.json 94 | force app/resources/index.html 95 | ``` 96 | -------------------------------------------------------------------------------- /documentation/images/023C46EC-73FF-4787-8B96-617B600453F9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/023C46EC-73FF-4787-8B96-617B600453F9.png -------------------------------------------------------------------------------- /documentation/images/045C7FB1-489E-459F-BFE1-BC1FA8CE63D8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/045C7FB1-489E-459F-BFE1-BC1FA8CE63D8.png -------------------------------------------------------------------------------- /documentation/images/064F8A9D-CC5E-47B0-AD19-50FD9BBA5D5B.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/064F8A9D-CC5E-47B0-AD19-50FD9BBA5D5B.png -------------------------------------------------------------------------------- /documentation/images/0811AAAF-589A-49DE-8D01-67EBFF515112.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/0811AAAF-589A-49DE-8D01-67EBFF515112.png -------------------------------------------------------------------------------- /documentation/images/1718709F-7353-4B4F-BB83-583C1988B7B0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/1718709F-7353-4B4F-BB83-583C1988B7B0.png -------------------------------------------------------------------------------- /documentation/images/2263EB6A-FA11-489B-8FC7-148B91B045DD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/2263EB6A-FA11-489B-8FC7-148B91B045DD.png -------------------------------------------------------------------------------- /documentation/images/23E66DCA-3A23-41EC-A4FB-609008848C13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/23E66DCA-3A23-41EC-A4FB-609008848C13.png -------------------------------------------------------------------------------- /documentation/images/23F114A1-56BD-4A66-927F-8135CD07DFEB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/23F114A1-56BD-4A66-927F-8135CD07DFEB.png -------------------------------------------------------------------------------- /documentation/images/2B87EA9F-1335-4878-A028-F4DDD5ABE2BA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/2B87EA9F-1335-4878-A028-F4DDD5ABE2BA.png -------------------------------------------------------------------------------- /documentation/images/2C509F20-B0C3-4754-A1DA-9E72DE3D1536.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/2C509F20-B0C3-4754-A1DA-9E72DE3D1536.png -------------------------------------------------------------------------------- /documentation/images/2E731498-07B8-4B67-8BD9-F2C5B092E29B.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/2E731498-07B8-4B67-8BD9-F2C5B092E29B.png -------------------------------------------------------------------------------- /documentation/images/3319804A-39EC-4BE8-AE15-9710E969452D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/3319804A-39EC-4BE8-AE15-9710E969452D.png -------------------------------------------------------------------------------- /documentation/images/36C4C562-9364-4288-84AB-B7B525C88B57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/36C4C562-9364-4288-84AB-B7B525C88B57.png -------------------------------------------------------------------------------- /documentation/images/3DD05C3C-13A5-4188-8C7E-C66CD421A675.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/3DD05C3C-13A5-4188-8C7E-C66CD421A675.png -------------------------------------------------------------------------------- /documentation/images/3DEC6BDF-E042-40E6-873E-94C9E7852BFA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/3DEC6BDF-E042-40E6-873E-94C9E7852BFA.png -------------------------------------------------------------------------------- /documentation/images/3F73851B-55B9-4D19-98EF-11E68CCA45C9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/3F73851B-55B9-4D19-98EF-11E68CCA45C9.png -------------------------------------------------------------------------------- /documentation/images/49E941D8-F353-4AC4-AAC9-8686EA331D0A.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/49E941D8-F353-4AC4-AAC9-8686EA331D0A.png -------------------------------------------------------------------------------- /documentation/images/4CF86DC4-68EA-4254-8A23-2D80CA0DF301.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/4CF86DC4-68EA-4254-8A23-2D80CA0DF301.png -------------------------------------------------------------------------------- /documentation/images/53E5265F-A254-4137-B2AC-91D0EEC58AA4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/53E5265F-A254-4137-B2AC-91D0EEC58AA4.png -------------------------------------------------------------------------------- /documentation/images/54F60698-0F57-4E61-BE87-C2477D4343F8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/54F60698-0F57-4E61-BE87-C2477D4343F8.png -------------------------------------------------------------------------------- /documentation/images/61CC972F-F9DA-4956-B992-477202FB5010.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/61CC972F-F9DA-4956-B992-477202FB5010.png -------------------------------------------------------------------------------- /documentation/images/653CA465-DE9E-4690-96CF-45A71BD31A6E.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/653CA465-DE9E-4690-96CF-45A71BD31A6E.png -------------------------------------------------------------------------------- /documentation/images/65A7A99C-7B12-4290-8F82-7A39CCC3DDFB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/65A7A99C-7B12-4290-8F82-7A39CCC3DDFB.png -------------------------------------------------------------------------------- /documentation/images/6D006E9F-80BB-4985-AABF-D9BC695BA69E.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/6D006E9F-80BB-4985-AABF-D9BC695BA69E.png -------------------------------------------------------------------------------- /documentation/images/77BD109C-870F-4A90-85CE-1FC9879FB524.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/77BD109C-870F-4A90-85CE-1FC9879FB524.png -------------------------------------------------------------------------------- /documentation/images/77E3431A-9147-4934-B6B9-AA555E6CCDE1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/77E3431A-9147-4934-B6B9-AA555E6CCDE1.png -------------------------------------------------------------------------------- /documentation/images/825AA1A9-8A5C-4D28-8148-84A64D6947F5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/825AA1A9-8A5C-4D28-8148-84A64D6947F5.png -------------------------------------------------------------------------------- /documentation/images/842229F4-C86E-4072-AEA3-A8B1BC2D0301.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/842229F4-C86E-4072-AEA3-A8B1BC2D0301.png -------------------------------------------------------------------------------- /documentation/images/8A6C71D4-822E-43E0-9EFD-D1FC0ECF09D5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/8A6C71D4-822E-43E0-9EFD-D1FC0ECF09D5.png -------------------------------------------------------------------------------- /documentation/images/8E3D6B2B-652E-443F-8D3B-6B9A7BF2C3BB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/8E3D6B2B-652E-443F-8D3B-6B9A7BF2C3BB.png -------------------------------------------------------------------------------- /documentation/images/8F16E5F1-A512-4D07-B395-D882AF8C34A2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/8F16E5F1-A512-4D07-B395-D882AF8C34A2.png -------------------------------------------------------------------------------- /documentation/images/A0A79BB0-0B6C-443A-A63F-0823D368B043.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/A0A79BB0-0B6C-443A-A63F-0823D368B043.png -------------------------------------------------------------------------------- /documentation/images/A46B71F5-DB61-45FC-BCAC-EDCC7FE1EF7B.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/A46B71F5-DB61-45FC-BCAC-EDCC7FE1EF7B.png -------------------------------------------------------------------------------- /documentation/images/A61BEFB7-461B-41FD-BDDB-DC0328C1760B.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/A61BEFB7-461B-41FD-BDDB-DC0328C1760B.png -------------------------------------------------------------------------------- /documentation/images/A6490FB9-DC22-469C-B7E6-41EE1AD51F05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/A6490FB9-DC22-469C-B7E6-41EE1AD51F05.png -------------------------------------------------------------------------------- /documentation/images/A989C357-305A-46C7-A562-719221BB2F24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/A989C357-305A-46C7-A562-719221BB2F24.png -------------------------------------------------------------------------------- /documentation/images/B063B834-0E53-408A-AE24-FF128E87741D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/B063B834-0E53-408A-AE24-FF128E87741D.png -------------------------------------------------------------------------------- /documentation/images/B5D44D74-957B-4E32-8A64-C5EF1E1CDCDD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/B5D44D74-957B-4E32-8A64-C5EF1E1CDCDD.png -------------------------------------------------------------------------------- /documentation/images/BFF04029-7358-4269-BE0F-95040B50F583.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/BFF04029-7358-4269-BE0F-95040B50F583.png -------------------------------------------------------------------------------- /documentation/images/C494F337-2F67-4C2B-BCEC-AC7FAA9CFDEF.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/C494F337-2F67-4C2B-BCEC-AC7FAA9CFDEF.png -------------------------------------------------------------------------------- /documentation/images/D9104708-D688-44BF-9094-E1646399CAB7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/D9104708-D688-44BF-9094-E1646399CAB7.png -------------------------------------------------------------------------------- /documentation/images/DB8D4FBF-927B-42F9-8C56-3149A2CBB52B.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/DB8D4FBF-927B-42F9-8C56-3149A2CBB52B.png -------------------------------------------------------------------------------- /documentation/images/F106F27E-3836-4681-8096-8B64E1705E06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/F106F27E-3836-4681-8096-8B64E1705E06.png -------------------------------------------------------------------------------- /documentation/images/F8F8D9CA-4269-4A6E-BFF0-ACF2C8EE6501.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/F8F8D9CA-4269-4A6E-BFF0-ACF2C8EE6501.png -------------------------------------------------------------------------------- /documentation/images/FC3D0F23-4C58-4E44-B3F2-F18359E6CEA6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/cloud-cap-multitenancy/0ac47ad95d6103efed0c90b2592bf1550f043862/documentation/images/FC3D0F23-4C58-4E44-B3F2-F18359E6CEA6.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "capmt", 3 | "version": "0.0.1", 4 | "description": "Cloud Application Programming(CAP) with Multitenancy using Service Manger Tenant Data Separation", 5 | "repository": "", 6 | "license": "UNLICENSED", 7 | "private": true, 8 | "dependencies": { 9 | "@sap/cds": "^4", 10 | "@sap/hana-client": "^2.4.177", 11 | "express": "^4" 12 | }, 13 | "devDependencies": { 14 | "@sap/cds-dk": "^3", 15 | "sqlite3": "^4" 16 | }, 17 | "scripts": { 18 | "build": "cds build/all --clean", 19 | "deploy": "cds deploy", 20 | "start": "cds run", 21 | "deploy:cf:trial": "cf deploy mta_archives/capmt.mtar -e sapcp-cf-trial.mtaext" 22 | }, 23 | "cds": { 24 | "comment": "Anything defined outside of a [profile] will apply to all profiles.", 25 | "requires": { 26 | "db": { 27 | "kind": "hana", 28 | "model": [ 29 | "db", 30 | "srv" 31 | ] 32 | } 33 | }, 34 | "build": { 35 | "target": ".", 36 | "tasks": [ 37 | { 38 | "for": "hana", 39 | "src": "db", 40 | "options": { 41 | "model": [ 42 | "db", 43 | "srv" 44 | ] 45 | } 46 | }, 47 | { 48 | "for": "hana", 49 | "src": "db_comm", 50 | "options": { 51 | "model": [ 52 | "db_comm" 53 | ] 54 | } 55 | }, 56 | { 57 | "for": "node-cf", 58 | "src": "srv", 59 | "options": { 60 | "model": [ 61 | "db", 62 | "srv" 63 | ] 64 | } 65 | }, 66 | { 67 | "for": "mtx", 68 | "src": ".", 69 | "dest": "srv", 70 | "options": { 71 | "model": [ 72 | "db", 73 | "srv" 74 | ] 75 | } 76 | } 77 | ] 78 | }, 79 | "[development]": { 80 | "comment": "Anything defined inside of [development] will overrided prior values.", 81 | "requires": { 82 | "db": { 83 | "kind": "sqlite" 84 | } 85 | } 86 | }, 87 | "[qa]": { 88 | "comment": "Anything defined inside of [qa] will overrided prior values." 89 | }, 90 | "[production]": { 91 | "comment": "Anything defined inside of [production] will overrided prior values.", 92 | "requires": { 93 | "db": { 94 | "kind": "hana" 95 | } 96 | } 97 | }, 98 | "odata": { 99 | "version": "v4" 100 | }, 101 | "hana": { 102 | "deploy-format": "hdbtable" 103 | }, 104 | "features": { 105 | "snapi": true 106 | } 107 | }, 108 | "files": [ 109 | "app", 110 | "db", 111 | "handlers", 112 | "integration-tests", 113 | "srv", 114 | "cdsrc.json", 115 | "eslintrc", 116 | "gitignore", 117 | "vscode", 118 | "mta.yaml" 119 | ] 120 | } 121 | -------------------------------------------------------------------------------- /sapcp-cf-trial.mtaext: -------------------------------------------------------------------------------- 1 | _schema-version: '3.1' 2 | ID: capmt.extension 3 | extends: capmt 4 | 5 | resources: 6 | - name: capmt-hdi 7 | parameters: 8 | service: hanatrial -------------------------------------------------------------------------------- /srv/README.md: -------------------------------------------------------------------------------- 1 | # Defining Services 2 | 3 | Follow Getting Started > in a Nutshell > Defining Services 4 | 5 | https://cap.cloud.sap/docs/get-started/in-a-nutshell#defining-services 6 | 7 | -------------------------------------------------------------------------------- /srv/build.js.disabled: -------------------------------------------------------------------------------- 1 | // Executes the CDS build depending on whether we have a top-level package.json. 2 | // Package.json is not available when we are called by CF/XSA buildpack. In this case we don't do anything 3 | // and just assume our model was already built and is available as part of this DB app. 4 | // 5 | // This is a workaround that will be replaced by a solution where CDS generates the DB module along with package.json. 6 | 7 | const fs = require('fs'); 8 | const childproc = require('child_process'); 9 | 10 | if (fs.existsSync('../package.json')) { 11 | // true at build-time, false at CF staging time 12 | childproc.execSync('npm install && npm run build', { 13 | cwd: '..', 14 | stdio: 'inherit' 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /srv/cat-service-auth.cds: -------------------------------------------------------------------------------- 1 | using { CatalogService } from './cat-service'; 2 | 3 | // Re-run the following command after changing any @(requires: []) definition 4 | // Run this from the root of the project. 5 | // cds compile srv/ --to xsuaa,json > cds-security.json 6 | 7 | annotate CatalogService with @(requires: ['system-user','Admin','User']); 8 | 9 | annotate CatalogService.Orders with @(restrict: [ 10 | { grant: ['READ','WRITE'], to: 'Admin' }, 11 | { grant: ['READ'], to: 'User' } 12 | ]); 13 | -------------------------------------------------------------------------------- /srv/cat-service.cds: -------------------------------------------------------------------------------- 1 | 2 | using { my.bookshop, sap.common } from '../db/data-model'; 3 | 4 | service CatalogService { 5 | entity Books @readonly as projection on bookshop.Books; 6 | entity Authors @readonly as projection on bookshop.Authors; 7 | entity Orders @insertonly as projection on bookshop.Orders; 8 | entity Currencies @readonly as projection on bookshop.Currencies; 9 | // entity States @readonly as projection on bookshop.States; 10 | } -------------------------------------------------------------------------------- /srv/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "capmt-srv", 3 | "description": "Generated from ../package.json, do not change!", 4 | "version": "1.0.0", 5 | "engines": { 6 | "node": ">=8.0.0 <11.0.0" 7 | }, 8 | "saved_deps": { 9 | "@sap/cds": "latest", 10 | "@sap/cds-mtx": "git://github.wdf.sap.corp/I830671/cds-mtx.git#e2dd61a19e7e7e02ecd25ca93c545dc34836d0e6", 11 | "@sap/instance-manager": "2.1.0", 12 | "other": "latest" 13 | }, 14 | "external_deps": { 15 | "@sap/cds-mtx": "git://github.com/andrewlunde/cds-mtx.git#fix/suburl", 16 | "@sap/instance-manager": "git://github.com/andrewlunde/node-instance-manager#poc-sm", 17 | "@sap/hdi-deploy": "git://github.com/andrewlunde/hdideploy.js.git", 18 | "other": "latest" 19 | }, 20 | "deploy_deps3": { 21 | "@sap/cds": "3.34.2", 22 | "@sap/cds-mtx": "1.0.13", 23 | "@sap/instance-manager": "^2.2", 24 | "other": "not_latest_but_working" 25 | }, 26 | "deploy_deps4": { 27 | "@sap/cds": "^4", 28 | "@sap/cds-mtx": "1.0.16", 29 | "@sap/instance-manager": "^2.2", 30 | "other": "latest_but_not_working" 31 | }, 32 | "push_deps": { 33 | "push_cmd": "cd srv ; npm install --production ; cd .. ; cf push mtxsm-srv -p srv -n conciletime-dev-mtxsm-srv -d cfapps.us10.hana.ondemand.com -k 1024M -m 512M", 34 | "@sap/cds": "3.34.2", 35 | "@sap/cds-mtx": "git://github.wdf.sap.corp/I830671/cds-mtx.git#fix/suburl", 36 | "@sap/instance-manager": "git://github.wdf.sap.corp/I830671/node-instance-manager#poc-sm", 37 | "xhdb": "^0.17.2", 38 | "other": "latest" 39 | }, 40 | "dependencies": { 41 | "@sap/xsenv": "latest", 42 | "@sap/xssec": "^3", 43 | "@sap/cds": "^4", 44 | "@sap/cds-mtx": ">=1.0.26", 45 | "@sap/instance-manager": "^2.2", 46 | "@sap/hana-client": "^2.7", 47 | "@sap/hdi-deploy": "^4", 48 | "nodemon": "^2", 49 | "cfenv": "latest", 50 | "passport": "^0.4.1", 51 | "express": "^4.17.1", 52 | "body-parser": "latest" 53 | }, 54 | "devDependencies": {}, 55 | "scripts": { 56 | "xpostinstall": "npm dedupe && node .build.js", 57 | "debugstart": "node --inspect server.js", 58 | "start": "nodemon server.js", 59 | "watch": "nodemon -w . -i node_modules/**,.git/** -e cds -x npm run build" 60 | }, 61 | "private": true, 62 | "cds": { 63 | "mtx": { 64 | "app": { 65 | "urlpart": "-dev-capmt-app.cfapps.us10.hana.ondemand.com" 66 | }, 67 | "api": { 68 | "model": true, 69 | "provisioning": true, 70 | "metadata": true 71 | }, 72 | "element-prefix": [ 73 | "Z_", 74 | "ZZ_" 75 | ], 76 | "namespace-blacklist": [ 77 | "com.sap.", 78 | "sap." 79 | ], 80 | "entity-whitelist": [ 81 | "my.bookshop.Books" 82 | ], 83 | "service-whitelist": [] 84 | }, 85 | "auth": { 86 | "passport": { 87 | "strategy": "JWT" 88 | } 89 | }, 90 | "odata": { 91 | "version": "v4" 92 | }, 93 | "hana": { 94 | "deploy-format": "hdbtable" 95 | }, 96 | "query": { 97 | "limit": { 98 | "max": 4000 99 | } 100 | }, 101 | "requires": { 102 | "db": { 103 | "kind": "hana", 104 | "pool": { 105 | "acquireTimeoutMillis_doc": "max milliseconds an acquire call will wait for a resource before timing out. (default no limit), if supplied should non-zero positive integer.", 106 | "acquireTimeoutMillis": 4000, 107 | "softIdleTimeoutMillis_doc": "amount of time an object may sit idle in the pool before it is eligible for eviction by the idle object evictor (if any), with the extra condition that at least 'min idle' object instances remain in the pool. Default -1 (nothing can get evicted)", 108 | "softIdleTimeoutMillis": 80000, 109 | "evictionRunIntervalMillis_doc": "How often to run eviction checks. Default: 0 (does not run).", 110 | "evictionRunIntervalMillis": 0, 111 | "max_doc": "maximum number of resources to create at any given time. (default=1)", 112 | "max": 3000, 113 | "xmin_doc": "minimum number of resources to keep in pool at any given time. If this is set >= max, the pool will silently set the min to equal max. (default=0)", 114 | "min": 10 115 | }, 116 | "model": [ 117 | "gen" 118 | ], 119 | "multiTenant": true, 120 | "vcap": { 121 | "label": "service-manager" 122 | } 123 | }, 124 | "uaa": { 125 | "kind": "xsuaa" 126 | } 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /srv/server.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable capitalized-comments */ 2 | const app = require("express")(); 3 | const cds = require("@sap/cds"); 4 | //const mtx = require("@sap/cds-mtx"); 5 | 6 | const axios = require('axios'); 7 | const bodyParser = require('body-parser'); 8 | 9 | 10 | var cds_mtx_way = true; 11 | 12 | // OLD WAY BEGIN 13 | var myLogger = function (req, res, next) { 14 | console.log('XXX_LOGGED'); 15 | console.log("XXX_==== method: " + req.method + " + " + req.url); 16 | console.log("XXX_==== headers:" + JSON.stringify(req.headers) + "===="); 17 | console.log("XXX_==== body:" + JSON.stringify(req.body) + "===="); 18 | next(); 19 | } 20 | 21 | async function mockSubscribe() { 22 | var result = ""; 23 | //const appurl = process.env.MTXSM_APP_URL; 24 | const appurl = 'http://localhost:8001/mtx/v1/provisioning/tenant/123'; 25 | 26 | var config = { 27 | method: 'post', 28 | url: appurl, 29 | // Hardcoded for localized testing against CF 30 | headers: { 31 | 'Accept': '*/*', 32 | 'content-type': 'application/json' 33 | } 34 | }; 35 | 36 | var response = {}; 37 | var data = {}; 38 | try { 39 | response = await axios(config); 40 | result += "OK now stuff from the axios get.
"; 41 | result += "title: " + response.data.title + "
"; 42 | } catch (error) { 43 | result += "error: " + error + ".
"; 44 | } 45 | 46 | return result; 47 | } 48 | 49 | 50 | if (!cds_mtx_way) { 51 | const bodyParser = require('body-parser'); 52 | const cfenv = require('cfenv'); 53 | const appEnv = cfenv.getAppEnv(); 54 | 55 | const xsenv = require('@sap/xsenv'); 56 | xsenv.loadEnv(); 57 | const services = xsenv.getServices({ 58 | uaa: { tag: 'xsuaa' }, 59 | registry: { tag: 'SaaS' } 60 | }); 61 | 62 | const xssec = require('@sap/xssec'); 63 | const passport = require('passport'); 64 | passport.use('JWT', new xssec.JWTStrategy(services.uaa)); 65 | app.use(passport.initialize()); 66 | app.use(passport.authenticate('JWT', { 67 | session: false 68 | })); 69 | 70 | app.use(bodyParser.json()); 71 | 72 | app.use((req, res, next) => { 73 | console.log("req: " + req.method + " : " + req.url); 74 | next(); // this will invoke next middleware function 75 | }); 76 | 77 | // subscribe/onboard a subscriber tenant 78 | app.get("/mtx/v1/provisioning/tenant/*", function(req, res) { 79 | var responseStr = ""; 80 | responseStr += 81 | "CAP-MTX

CAP-MTX

WARNING!


"; 82 | responseStr += 83 | "Tenant callback endpoint only allows PUT and DELETE methods to facilitate subscribe/unsubscribe.
"; 84 | responseStr += ""; 85 | console.log("Tenant callback endpoint only allows PUT and DELETE methods to facilitate subscribe/unsubscribe"); 86 | res.status(200).send(responseStr); 87 | }); 88 | 89 | app.get("/admin", function(req, res) { 90 | res.status(200).send(""); 91 | }); 92 | 93 | // subscribe/onboard a subscriber tenant 94 | app.put("/mtx/v1/provisioning/tenant/*", function(req, res) { 95 | let tenantHost = req.body.subscribedSubdomain + '-' + appEnv.app.space_name.toLowerCase().replace(/_/g,'-') + '-' + services.registry.appName.toLowerCase().replace(/_/g,'-') + '-app'; 96 | let tenantURL = 'https:\/\/' + tenantHost + /\.(.*)/gm.exec(appEnv.app.application_uris[0])[0]; 97 | 98 | console.log("==== Tenant URL: " + tenantURL + "===="); 99 | console.log("==== headers:" + JSON.stringify(req.headers) + "===="); 100 | console.log("==== body:" + JSON.stringify(req.body) + "===="); 101 | 102 | res.status(200).send(tenantURL); 103 | }); 104 | 105 | // unsubscribe/offboard a subscriber tenant 106 | app.delete("/mtx/v1/provisioning/tenant/*", function(req, res) { 107 | let tenantHost = req.body.subscribedSubdomain + '-' + appEnv.app.space_name.toLowerCase().replace(/_/g,'-') + '-' + services.registry.appName.toLowerCase().replace(/_/g,'-') + '-app'; 108 | 109 | res.status(200).send(""); 110 | }); 111 | // OLD WAY END 112 | 113 | } else { 114 | 115 | // NEW WAY BEGIN 116 | app.use(myLogger); 117 | 118 | const cfenv = require('cfenv'); 119 | const appEnv = cfenv.getAppEnv(); 120 | 121 | const xsenv = require('@sap/xsenv'); 122 | const services = xsenv.getServices({ 123 | uaa: { tag: 'xsuaa' }, 124 | registry: { tag: 'SaaS' } 125 | }); 126 | 127 | const xssec = require('@sap/xssec'); 128 | const passport = require('passport'); 129 | passport.use('JWT', new xssec.JWTStrategy(services.uaa)); 130 | app.use(passport.initialize()); 131 | app.use(passport.authenticate('JWT', { 132 | session: false 133 | })); 134 | 135 | app.use(bodyParser.json()); 136 | 137 | app.get("/test/*", function(req, res) { 138 | 139 | var responseStr = ""; 140 | responseStr += 141 | "CAP-MTX

CAP-MTX

WARNING!


"; 142 | responseStr += "Testing....
"; 143 | 144 | let c = cds.env.for('app'); // use cds config framework to read app specific config node 145 | let appuri = typeof c.urlpart === "undefined" ? ' ' : c.urlpart; 146 | 147 | responseStr += "POST: " + "FINISHED" + ".
"; 148 | 149 | //responseStr += "appuri: " + c.urlpart + "
"; 150 | 151 | mockSubscribe().then( 152 | function (res2) { 153 | responseStr += ""; 154 | console.log("XXX_Testing... " + 'OK' + ""); 155 | responseStr += "POST: " + "OK" + ".
"; 156 | responseStr += "RES: " + res2 + ".
"; 157 | res.status(200).send(responseStr); 158 | }, 159 | function (err) { 160 | responseStr += ""; 161 | console.log("XXX_Testing... " + 'BAD' + ""); 162 | responseStr += "POST: " + "BAD" + ".
"; 163 | responseStr += "ERR: " + err + ".
"; 164 | res.status(200).send(responseStr); 165 | }); 166 | }); 167 | 168 | 169 | // connect to datasource 'db' which must be the HANA instance manager 170 | cds.connect.to('db'); 171 | // serve cds-mtx APIs 172 | //cds.mtx.in(app); 173 | 174 | cds.mtx.in(app).then(async() => { 175 | console.log("XXX_Overriding Default Provisioning... "); 176 | const provisioning = await cds.connect.to('ProvisioningService'); 177 | provisioning.impl(require('./handlers/provisioning')); 178 | }); 179 | 180 | // cd srv/node_modules/@sap/cds-mtx/lib/tenant 181 | // cp srv/handlers/tenant_index.js srv/node_modules/@sap/cds-mtx/lib/tenant/index.js 182 | // vi srv/node_modules/@sap/cds-mtx/lib/tenant/index.js 183 | // vi node_modules/@sap/cds-mtx/lib/tenant/index.js 184 | // cf push capmt-srv -p srv -n org-space-capmt-srv -d cfapps.us10.hana.ondemand.com -k 1024M -m 512M 185 | 186 | // serve application defined services: in combination with a CAP Java server, this won't appear here. 187 | cds.serve('all').in(app); 188 | /* 189 | // serve cds-mtx APIs (required for tenant provisioning) 190 | cds.mtx.in(app).then(() => { 191 | const provisioning = cds.connect.to('ProvisioningService'); 192 | // provisioning.impl(require('./srv/provisioning')); // Nope 193 | // provisioning.impl(require('./provisioning')); // Nope 194 | // provisioning.impl(require('./srv/provisioning.js')); // Nope 195 | provisioning.impl(require('./handlers/provisioning')); 196 | }); 197 | */ 198 | // NEW WAY END 199 | 200 | } 201 | 202 | const PORT = process.env.PORT || 4444; 203 | console.log("Listening on: " + PORT); 204 | app.listen(PORT); -------------------------------------------------------------------------------- /srv/src/main/resources/edmx/CatalogService_cs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | -------------------------------------------------------------------------------- /srv/src/main/resources/edmx/CatalogService_da.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | -------------------------------------------------------------------------------- /srv/src/main/resources/edmx/CatalogService_ja.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | -------------------------------------------------------------------------------- /srv/src/main/resources/edmx/CatalogService_ko.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | -------------------------------------------------------------------------------- /srv/src/main/resources/edmx/CatalogService_sv.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | -------------------------------------------------------------------------------- /srv/src/main/resources/edmx/CatalogService_zh_CN.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | -------------------------------------------------------------------------------- /srv/src/main/resources/edmx/CatalogService_zh_TW.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | -------------------------------------------------------------------------------- /test/cf-api.http: -------------------------------------------------------------------------------- 1 | ### Read API Info 2 | # @name apiInfo 3 | GET {{$dotenv cf_api}}/info 4 | ### Fill Variables from Response 5 | @authorization_endpoint = {{apiInfo.response.body.authorization_endpoint}} 6 | ### Get Access Token 7 | # @name requestAccessToken 8 | POST {{authorization_endpoint}}/oauth/token?grant_type=password 9 | Content-Type: application/x-www-form-urlencoded;charset=utf-8 10 | Accept: application/json 11 | Authorization: Basic Y2Y6 12 | 13 | username={{$dotenv username}} 14 | &password={{$dotenv password}} 15 | 16 | ### Fill Variables from Response 17 | @bearerToken = {{requestAccessToken.response.body.access_token}} 18 | 19 | ### Read Application Registration Details 20 | GET {{$dotenv saas_registry_url}}/saas-manager/v1/application 21 | Authorization: {{bearerToken}} -------------------------------------------------------------------------------- /test/saas-registry.http: -------------------------------------------------------------------------------- 1 | ### Get Access Token 2 | # @name requestAccessToken 3 | POST {{$dotenv url}}/oauth/token 4 | Content-Type: application/x-www-form-urlencoded 5 | Authorization: Basic {{$dotenv clientid}}:{{$dotenv clientsecret}} 6 | 7 | grant_type=client_credentials&client_id={{$dotenv clientid}} 8 | 9 | ### Fill Variables from Response 10 | @bearerToken = {{requestAccessToken.response.body.access_token}} 11 | 12 | ### Read Application Registration Details 13 | GET {{$dotenv saas_registry_url}}/saas-manager/v1/application 14 | Authorization: {{bearerToken}} -------------------------------------------------------------------------------- /tools/smsi-cli: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | do_run=1 # Execute(evaluate) the commands 3 | #do_run=0 # Don't evaluate any commands 4 | 5 | backup_files_flag='false' 6 | restore_files_flag='false' 7 | dry_run_flag='false' 8 | subdomain='admin' 9 | verbose='false' 10 | 11 | print_usage() { 12 | printf "Usage: smsi-cli [-brdv] -s ..." 13 | } 14 | 15 | while getopts 'brds:v' flag; do 16 | case "${flag}" in 17 | b) backup_files_flag='true' ;; 18 | r) restore_files_flag='true' ;; 19 | d) dry_run_flag='true' ;; 20 | s) subdomain="${OPTARG}" ;; 21 | v) verbose='true' ;; 22 | *) print_usage 23 | exit 1 ;; 24 | esac 25 | done 26 | 27 | if [ $verbose = 'true' ]; then echo 'Verbose: ON'; else echo 'Verbose: OFF'; fi 28 | 29 | cmd='echo subdomain: '$subdomain 30 | if [ $verbose = 'true' ]; then echo $cmd; fi 31 | if [ $dry_run_flag = 'false' ]; then eval $cmd; fi 32 | 33 | # Inspect OPTIND 34 | if [ $verbose = 'true' ]; then echo "OPTIND: $OPTIND"; fi 35 | 36 | argsleft=$(($#-$OPTIND+1)) 37 | if [ $verbose = 'true' ]; then echo "argsleft: "$argsleft; fi 38 | 39 | hana_cli_args=${@:$OPTIND:$argsleft} 40 | 41 | tmp_folder='.smsi' 42 | 43 | if [ $restore_files_flag = 'false' ]; then 44 | 45 | if [ $verbose = 'true' ]; then echo; echo "Make "$tmp_folder" folder."; fi 46 | cmd='mkdir -p '$tmp_folder 47 | if [ $verbose = 'true' ]; then echo $cmd; fi 48 | if [ $dry_run_flag = 'false' ]; then eval $cmd; fi 49 | 50 | FILE='.env' 51 | if [ $verbose = 'true' ]; then echo; echo "Move "$FILE" into "$tmp_folder" folder."; fi 52 | cmd='mv '$FILE' '$tmp_folder 53 | if [ $verbose = 'true' ]; then echo $cmd; fi 54 | if [ $dry_run_flag = 'false' ]; then if [[ -f $FILE ]]; then eval $cmd; fi; fi 55 | 56 | FILE='default-env.json' 57 | if [ $verbose = 'true' ]; then echo; echo "Move "$FILE" into "$tmp_folder" folder."; fi 58 | cmd='mv '$FILE' '$tmp_folder 59 | if [ $verbose = 'true' ]; then echo $cmd; fi 60 | if [ $dry_run_flag = 'false' ]; then if [[ -f $FILE ]]; then eval $cmd; fi; fi 61 | 62 | if [ $verbose = 'true' ]; then echo; echo "Move default-env-"$subdomain".json to default-env.json"; fi 63 | cmd='mv default-env-'$subdomain'.json default-env.json' 64 | if [ $verbose = 'true' ]; then echo $cmd; fi 65 | if [ $dry_run_flag = 'false' ]; then eval $cmd; fi 66 | 67 | fi 68 | 69 | if ! ( [ $backup_files_flag = 'true' ] || [ $restore_files_flag = 'true' ] ); then 70 | 71 | if [ $verbose = 'true' ]; then echo; echo "Exec hana-cli "$hana_cli_args" against "$subdomain; fi 72 | cmd='hana-cli '$hana_cli_args'' 73 | if [ $verbose = 'true' ]; then echo $cmd; fi 74 | if [ $dry_run_flag = 'false' ]; then eval $cmd; fi 75 | 76 | fi 77 | 78 | if [ $backup_files_flag = 'false' ]; then 79 | 80 | if [ $verbose = 'true' ]; then echo; echo "Move default-env.json to default-env-"$subdomain".json"; fi 81 | cmd='mv default-env.json default-env-'$subdomain'.json' 82 | if [ $verbose = 'true' ]; then echo $cmd; fi 83 | if [ $dry_run_flag = 'false' ]; then eval $cmd; fi 84 | 85 | FILE='default-env.json' 86 | if [ $verbose = 'true' ]; then echo; echo "Move "$FILE" from "$tmp_folder" folder."; fi 87 | cmd='mv '$tmp_folder'/'$FILE' .' 88 | if [ $verbose = 'true' ]; then echo $cmd; fi 89 | if [ $dry_run_flag = 'false' ]; then if [[ -f $tmp_folder'/'$FILE ]]; then eval $cmd; fi; fi 90 | 91 | FILE='.env' 92 | if [ $verbose = 'true' ]; then echo; echo "Move "$FILE" from "$tmp_folder" folder."; fi 93 | cmd='mv '$tmp_folder'/'$FILE' .' 94 | if [ $verbose = 'true' ]; then echo $cmd; fi 95 | if [ $dry_run_flag = 'false' ]; then if [[ -f $tmp_folder'/'$FILE ]]; then eval $cmd; fi; fi 96 | 97 | if [ $verbose = 'true' ]; then echo; echo "Remove "$tmp_folder" folder."; fi 98 | 99 | cmd='rmdir '$tmp_folder 100 | if [ $verbose = 'true' ]; then echo $cmd; fi 101 | if [ $dry_run_flag = 'false' ]; then eval $cmd; fi 102 | 103 | fi --------------------------------------------------------------------------------