java - How to add custom attributes to the meta model in Olingo? -


for current project, we're using olingo on top of hibernate, , picketlink security , roles.

users different roles have different permissions affects read / write access properties. consider following example:

  • one entity "person" properties "name", "address" , "salary"
  • two roles - "employee" , "manager"

while employee should able edit own address, can't allowed change salary or persons address. , while might allowed see own salary , maybe users address, won't allowed see salary of others, let alone edit it. manager on other hand has full readwrite permissions.

this not problem on backend - can use custom bean validation there enforce write permissions.

but want frontend able reflect users rights - disabling "salary" text field example or not displaying in first place.

for purpose i'd introduce custom attributes based on user permissions odata meta model. instead of

<property name="address" type="edm.string" nullable="false"/> 

i'd receive

<property name="address" type="edm.string" nullable="false" mode="readwrite"/> 

or same effect.

so question is: how introduce custom attributes odata meta model olingo?

please not take above example serious. realize telling interface kindly not show salary of others via meta model inherently insecure ;)

update:

ok, it's not easy. realize now. attributes mentioned earlier called "facets" in cdsl (upon odata rests (pun intended)) , turns out, there fixed set of facet types. consequently, olingo doesn't bother abstraction here, you'll find lots of hardcoded stuff instead. guess still possible add facet type, require touching olingo in many places. , eliminate conformity cdsl / odata - wouldn't care may explain lack of solutions problem.

for looks i'll have either try , introduce facet, or intercept , modify outgoing xml.

i'm not enthusiastic either option, so... hint towards better solution still more welcome!

turns out very easy.

olingo let extend schema implementing jpaedmextension , method extendjpaedmschema. read more here.

this should going, try provide example in near future.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -