[Mars] [HowTO] Row-Level Granting [message #1719683] |
Mon, 11 January 2016 12:57 |
barust Mising name Messages: 57 Registered: February 2014 |
Member |
|
|
Hi, all
Maybe it will be useful to somebody.
If you have completed all the stages of the authorization by the Tutorial and HowTo, like this:
http://wiki.eclipse.org/Scout/Tutorial/5.0/Minicrm/Permissions
http://wiki.eclipse.org/Scout/HowTo/5.0/Create_Permissions
and would like to use Row-Level Granting control by SQL. I think it will help you.
I used the Basic Access Permission approach rather than Fine-Grained Access Permissions.
For instance, I have 2 tables:
- PERSON table with columns (PERSON_NR, LAST_NAME, FIRST_NAME, USERNAME, PODR_ID)
- PODR table with columns (PODR_ID, NAME)
and I want to show the row (PODR table) in accordance with the authorized user (PERSON table).
In Service Operation getPodrTableData() of StandardOutlineService I added the following:
@Override
public PodrTablePageData getPodrTableData() throws ProcessingException {
String userName = ServerSession.get().getUserId();
PodrTablePageData pageData = new PodrTablePageData();
SQL.selectInto("" +
"SELECT P.PODR_ID, P.NAME, PR.PERSON_NR, PR.USERNAME " +
"FROM PODR P, PERSON PR " +
"WHERE P.PODR_ID = PR.PODR_ID " +
"AND PR.USERNAME = :username " +
"INTO :{page.podrNr},:{page.podr},:{page.personNr},:{page.username}",
new NVPair("username", userName), new NVPair("page", pageData));
return pageData;
}
Here, the following significant lines:
- String userName = ServerSession.get().getUserId();
- "WHERE P.PODR_ID = PR.PODR_ID "
- "AND PR.USERNAME = :username "
- new NVPair("username", userName)
That's all.
It turns out that simple.
P.S.: If you are a newbie, spend some time and read this book by Matthias Zimmermann :
https://tools.bsiag.com/scoutbook/4.0/latest/pdf/
Sometimes it helps!
|
|
|
Powered by
FUDForum. Page generated in 0.05006 seconds