Routing in play! framework based on database information - java

I'm using play! framework 1.2.5 for a multi-tenancy application. Tenants are resolved on domain base and are kept as Models. There are multiple types of tenants, that don't share all of the functionality the applicaiton provides, so controllers are organized in packages, namespaced by their corresponding tenant types.
Now I try to map some urls to variable target actions, defined by the currently active tenant, without passing the tenant's namespace inside the url.
I know that it is possible to execute scripts inside of play's routes file, so I'm wondering if there's any possibility to pass tenant information (thus database information) to the routes file.
Do you know any way how to do this?
And if not:
How can I realize routing approach without providing extra namespace information and without re-inventing play's request parameter binding?

Related

Any way to specify Spring Data endpoint programatically at runtime?

I am forced to discover my database endpoint at run-time. Specifically I have to discover cassandra contact points (not nodes, the actual contact points) via a web service before I can connect to cassandra. There is currently no way for me to pre-load the contact points into a properties file prior to launch.
I am currently discovering end-points and then manually initializing the db driver, and it's cumbersome and error-prone.
I would really, really like to use a JPA-like model for data access, and I'm fond of using Spring Data for straight sql, but the only ways I can find to initialize Spring data are through spring configuration initialization.
Is there a way to delay initialization of spring data, overwrite initialization, or in any other way start up spring data after i have retrieved the contact points from an httpclient call?

How to allow/disallow tenant to access API in multi tenant system based on subscription of plan

I'm designing a multi-tenant system in which individual tenant registers in the system and selects the plan which enables them to access modules based on those plans.
Currently, Tenant uses the system from the website but REST APIs are also exposed so the tenant can call any API.
I want to restrict the tenant using such modules API for which they haven't subscribed yet.
REST APIs are developed in Spring boot, JAVA.
Could anyone have an idea how to implement it in the backend.
On a highlevel,
1. Mark Allowed subscription plans for individual REST API endpoints either through Annotation or config xmls.
2. Resolve the Request User's subscription plan at the Authorization Filter level
3. Have a generic access controller which matches request user's attributes against REST API attributes and allows based on the match

Working on Java with application that uses jsonapi

I'm integrating my java application with a service that uses json:api specification.
It has rather complex responses due to some service information(links, page info, relationship etc). The problem that I faced is that creating corresponding DTOsfor all the service info plus payload so that jaxb can map that adds a lot of complexity.
As a client I use Spring RestTemplate that is responsible for performing requests and getting response. I need to be able to map the response in a way that all the objects are mapped into appropriate DTOs and service info is also available so that I can use it for making further requests.
I was thing about several options here:
Making parameterized class that can hold different types of payload and also provide service info.
Parsing sections manually(extracting payload and service info) and setting it to some object that holds both - payload and service info.
Using external library to serialize/deserialize data. Here I found several options: winterchord/jsonapi and jasminb/jsonapi-converter.
What approach is more common and applicable for solving this task and having reliable, but still light-weight solution?

what does it mean to build LDAP V3 compliant application?

I have a requirement to build build a few REST api that interface with an LDAP V3 compliant server such as open LDAP/ AD. My primary question is if a server is LDAP v3 compliant, does it have its attributes defined per a standard L[as opposed to something like samAccount in AD]? that way it is possible to build a single integration code that integrates with all LDAP V3 severs. so if I have to create/query a user on any LDAP V3 server, I use that same code using standard LDAP attributes and not use vendor specific attributes such as "samaaccount ", or "memberOf". Is this possible at all [just like if I were to write JPA compliant code I could use both hibernate, eclipselink as ORM providers]? or have I misinterpreted LDAP v3 compliance?
LDAPv3 is about capabilities, not about attributes. Depending on which Schemata are used the attributes an LDAP-Server can hold differ. Therefore you can not expect an LDAPv3-compatible server to identify users with a fix attribute-type. You can expect an LDAPv3-compatible server to be capable of understanding SASL, Referrals or Controls. But you will need to make the attributes you need to use configurable depending on the used LDAP-Backend.
The attributes that are used are going to vary from directory to directory and even amongst implementations of the same directory. Every application I've seen that does this properly provides a screen or configuration file for the administrator to map the attributes in the application to the corresponding LDAP directory attributes.
LDAPv3 is a standard protocol, data model and schema that can be extended.
In my opinion, building a service to access an LDAPv3 compliant server must use the protocol and data model, and understand the default/ standard schema, but must be configurable on the attributes, the objectclasses and the directory structure.

Sending the data from one webapplication to different web application?

I am using java/GWT/GXT/Spring and Hibernate. I have two webapplications deployed in tomcat as below.
WebApp1 - is webapplication with GWT/Spring/Hibernate
WebApp2 - is webapplication with JSF and spring
Now i have to send some data from WebApp1 to WebApp2 and that data has to be displayed in one screen which is there in WebApp2. For that i can provide a link in WebApp1 to WebApp2. My question is is it possible to send data from one web application to another web application?
WebApp1 will have a link to WebApp2
Thanks!
For platform independent data representation was invented the xml. Use it! A simple HTTP Post and is done.
If you want to optimize and take off the overhead, you can that too.
You will need a shared resource where you can store the information in between. For Example Database, File, System, JNDI-Tree, JMS, etc.
Be careful with accessing those resources, especially file system needs a synchronization.
a direct communication via JVM is not possible.
You can also use a REST Service to get the information transfered.
Example: WEB-APP2 needs infos from WEB-APP1, then WEB-APP2 calls Service inside WEB-APP1
If you try to build two independent views on the same dataset you have to use shared resource like I mentioned already.
Yes this is possible, try out Spring Web Services
http://static.springsource.org/spring-ws/sites/2.0/
It will allow you to speak in terms of java object from both ends. Internally it converts request to XML Soap messages but this is transparent to you as the programmer and won't have to worry about it.
I got it working using the JAXB Marshaller using STS. You can right click on the xml schema file and select the jaxb option to generate the object automatically for you. So in the end, the only thing you need to generate youself is the XML Schema file. Spring WebServices can automatically generate the .wdsl for you also.

Categories

Resources