Getting Exception while implementing RowLevelSecurity

87 Views Asked by At

I am Trying to Implement RowLevelSecurity, For Restrict Admin User According to Storage. I have Followed this URL **

http://www.broadleafcommerce.com/docs/core/current/broadleaf-concepts/admin/admin-row-level-security.

** And I had override these methods : addFetchRestrictions() and addFetchRestrictionsRoot() .

So when I logged In in Admin Application, I can access all the link except product link when I clicked on Product link then I am Getting ClassCastException like This:

"java.lang.ClassCastException: org.broadleafcommerce.openadmin.server.security.domain.AdminUserImpl cannot be cast to com.iwn.admin.user.MyAdminUser"

When I debug my application I get to know that I am getting Exception in following lines:

Store adminStore = ((MyAdminuser) currentUser).getStore();

Can anyone help me that how to resolve this issue, Thanks.

1

There are 1 best solutions below

0
On

If you have extended AdminuserImpl to your custom MyAdminuser make sure that you have followed all the instructions in http://www.broadleafcommerce.com/docs/core/current/tutorials/core-tutorials/extending-entities-tutorial.

If you have done that but are still relying on the initial data imports, your data is likely wrong. Assuming that you have a table called MY_ADMIN_USER (that maps to the MyAdminuser Hibernate object), make sure that you have entries in that table for all of the entries in BLC_ADMIN_USER. Otherwise, Hibernate can only give you back instances of AdminUserImpl instead of your extended MyAdminuser.

One easy way to ensure this is with this SQL query:

INSERT INTO MY_ADMIN_USER (ADMIN_USER_ID) (SELECT blc.ADMIN_USER_ID FROM BLC_ADMIN_USER AS blc);