forked from moqui/moqui-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP : Added Multi-Tenant Functionality #8
Open
AyanF
wants to merge
39
commits into
hotwax:master
Choose a base branch
from
AyanF:#85zru5axq
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AyanF
changed the title
Added : Multi - Tenant Functionality
Added : Multi-Tenant Functionality
Jul 11, 2023
AyanF
changed the title
Added : Multi-Tenant Functionality
WIP : Added Multi-Tenant Functionality
Jul 11, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implemented multi-tenancy in moqui-framework
Major changes
1. Added TenantDefaultData.xml
Contains seed data of "DEFAULT" tenant.
2. EntityEntities.xml
Added field targetTenantId
3. ScreenEntities.xml
4. Added tenantId in ServiceEntities.xml
5. Added TenantEntities.xml
Contains entities to store tenant specific data - Tenant, TenantDataSource, TenantDataSourceXaProp, TenantHostDefault
6. Modified field in EntitySyncServices
Added authTenantId in remoteInMap field in "internalRun" service
7. Modified field in SystemMessageRemote
Added authTenantId in field inMap in SystemMessageJsonRpc#send service
8. Added TenantServices.xml
Services to operate on tenant - disable, enable, create, provision, setup, create admin, provision databases.
9. Modified UserServices.xml
Added field tenantId and called changeTenant method when changes to user are made.
10. CacheFacadeImpl.groovy
Added shared cache map for tenants
Added and modified methods to use cache with tenants - getFullName, isTenantsShare, getCacheInternal, getAllCachesInfo, initCache, createCache
11. ContextJavaUtil.java
Added tenant information to ArtifactHit and Connection Wrapper
12. ExecutionContextFactoryImpl.groovy
13. ExecutionContextImpl.java
14. NotificationMessageImpl.groovy
15. TransactionFacadeImpl.groovy
16. TransactionInternalBitronix.groovy
17. UserFacadeImpl.groovy
Passed tenantId in method pushUser()
Passed tenantId null in pushUserSubject()
Get authTenantId from secure parameters and pass it into loginUser method.
Get tenantId from header, trim it and pass it into loginUserKey method.
Added tenantId parameter methods
Added code to change the tenant in execution context if another tenant has logged in
Added code to remove tenantId and visitId from session
Check for null tenantId and call changeTenant
Passed tenantId in internalLoginUser()
Passed tenantId in method params, new UserInfo and setInfo.
18. EntityCache.groovy
19.EntityDataDocument.groovy
Modified mergeValueToDocMap() to use getEci() and getTenantId()
20. EntityDataFeed.groovy
Modified constructor EntityDataFeed and logs to display tenant Id
21. EntityDataSourceFactoryImpl.groovy
Added tenantId param in init() method
22. EntityDbMeta.groovy
Modified runsqlUpdate to pass "null" in shared connection by default.
23. EntityDefinition.groovy
Modified getCacheOne(), getCacheOneRa(), getCacheOneViewRa(), getCacheList(), getCacheListRa(), getCacheListViewRa(), getCacheCount() to take tenantId parameter.
24. EntityFacadeImpl
25. EntityFindBase.groovy
Modified oneInternal(), listInternal(), iteratorInternal(), countInternal(), updateAllInternal(), deleteAllInternal() - to check tenant and restrict operations on common entities.
26. EntityJavaUtil.java
Modified EntityInfo() to check if transactional group name is tenantcommon.
27. EntityListImpl.java
Modified constructors of EntityListImpl(), writeExternal(), readExternal() - to include tenantId.
27. EntityValueBase.java
28. EntityDatasourceFactory.java
Added tenantId in init().
29. ScreenDefinition.groovy
30. ScreenRenderImpl.groovy
Modified recursiveRunActions(), doActualRender(), renderSubscreen() - to check if the rendered screen is available to current tenant.
31. ScreenTestImpl.groovy
Modified ScreenTestRender render(), run() - to use tenantId
32. ScreenUrlInfo.groovy
33. RestApi.groovy
Added tenant_id header in getSwaggerMap
34. ScheduledJobRunner.groovy
35. ServiceCallAsyncImpl.groovy
Modified AsyncServiceInfo(), writeExternal(), readExternal(), AsyncServiceInfo > runInternal() - to use threadTenantId in for managing tenants.
36. ServiceCallImpl.java
Added authTenantId in validateCall().
37. ServiceCallJobImpl.java
Modified ServiceJobCallable(), writeExternal(), readExternal(), ServiceJobCallable>run() - to use threadTenantId in for managing tenants.
38. ServiceCallSyncImpl.java
39. ServiceFacadeImpl.groovy
40. EntityAutoServiceRunner.groovy
Added authTenantId in otherFieldsToSkip in EntityAutoServiceRunner.groovy
41. MoquiShiroRealm.groovy
Added tenantId parameter in MoquiShiroRealm to facilitate login with tenantId
42. MoquiAbstractEndpoint.groovy
Added method getTenantId
43. MoquiSessionListener.groovy
Updated method closeVisit() to resolve visit Id not found exception in multi-tenant.
44. NotificationWebSocketListener.groovy
Modified registerEndpoint(), deregisterEndpoint(), onMessage() to use tenantId with user.
45. Moqui.java
Modified loadData() to set tenantId.
46. CacheFacade.java
Added getCache() for tenant specific cache.
47. ExecutionContext.java
Added method getTenant(), getTenantId(), changeTenant(), popTenant() - to manage tenant operations.
48. ExecutionContextFactory.java
Modified method for getEntity() to use tenantId.
49. NotificationMessage.java
Added method getTenantId()
50. TransactionalInternal.java
Modified getDataSource() to use tenantId.
51. UserFacade.java
Modified loginUser(), loginUserKey() to use tenantId.
52. EntityDataSourceFactory.java
Modified init() method to use tenantId
54. MoquiDefaultConf.xml
Set default property "entity_add_missing_runtime" to true to enable creating tables when a new tenant is provisioned.
Added tenants-share="true" in caches - service.location, service.rest.api, kie.component.releaseId, kie.session.component, screen.location, screen.location.perm, screen.url, screen.info, screen.info.ref.rev, screen.template.mode, screen.template.location, widget.template.location, screen.find.path, screen.form.db.node, resource.xml-actions.location, resource.groovy.location, resource.javascript.location, resource.ftl.location, resource.gstring.location, resource.wiki.location, resource.markdown.location, resource.text.location, resource.reference.location
Added service file location for TenantServices.xml
Added default properties of transactional database.
Added xa-properties in configuration of transactional database in datasource group-name="transactional"
Added datasource group-name="tenantcommon"
Added entity-location for TenantEntities.xml
Added data location for TenantDefaultData,xml
Add default-runtime-add-missing="true" in 'mysql8' configuration.
55. ResouceFacadeTest.groovy
Replaced moquiVersion with tenantId in evaluate String and evaluate Context Field functions
56. SystemScreenRenderTest.groovy
Updated cacheName from l10n to DEFAULT__l10n in cleanupSpec()
57. Common tests update
Passed tenandId 'null' in loginUser() in all *test.groovy files
58. entity-definition-3.xsd
Added xs:enumeration value="tenantcommon"
59. moqui-conf-3.xsd
Added attribute name="tenants-share" type="boolean" default="false" to element "cache"
60. service-definition-3.xsd
Added authTenantId description.
61.xml-screen-3.xsd
Added attribute "tenantsAllowed"
62. build.gradle
63. Common Changes -
64. MoquiSessionListener.groovy
Issue
Whenever moqui is accessed from a browser, a session is created and stored as visitId is created and stored in the Visitor table, even without logging in.
When the user logs in it goes to the database to update the thru date by this Visit Id.
This causes an error. Because Visit Id is created using DEFAULT tenant and stored in Default tenant's database, After logging in from another tenant it does not find the same value in the tenant's database. Causing null pointer exception
Solution
Added code to destroy the existing VisitId stored in session and to check if Visit Id exists in the database. If it exists then update the through date.