SHOW:
|
|
- or go back to the newest paste.
| 1 | dao class | |
| 2 | ||
| 3 | void SaveResult<User> saveOrUpdateUser (user, actor){ // actor is the person doing the action
| |
| 4 | boolean b = checkIfUserCanSaveOrUpdate(actor); | |
| 5 | if (b){
| |
| 6 | //do the action | |
| 7 | SaveResult<user> saveresult = new SaveResult<user>(user,true); | |
| 8 | ||
| 9 | }else{
| |
| 10 | SaveResult<user> saveresult = new SaveResult<user>(user,false); | |
| 11 | } | |
| 12 | return saveresult | |
| 13 | } | |
| 14 | ||
| 15 | - | boolean getStatus() {
|
| 15 | + | boolean checkIfUserCanSaveOrUpdate(actor){
|
| 16 | - | return status; |
| 16 | + | //dbquery here to check for priviliegs |
| 17 | } | |
| 18 | ||
| 19 | public class SaveResult<T> {
| |
| 20 | T object; | |
| 21 | boolean result; | |
| 22 | ||
| 23 | public SaveResult(T object, boolean result) {
| |
| 24 | this.object = object; | |
| 25 | this.result = result; | |
| 26 | } | |
| 27 | ||
| 28 | T getObject() {
| |
| 29 | return object; | |
| 30 | } | |
| 31 | ||
| 32 | boolean getResult() {
| |
| 33 | return result; | |
| 34 | } | |
| 35 | ||
| 36 | } |