// Path: testapps/morphia_model/src/main/java/test/model/User.java
// @Entity("user")
// public class User extends MorphiaUserBase<User> implements UserLinked {
// 
//     public String firstName;
//     public String lastName;
// 
//     @Override
//     public boolean isLinkedTo(Principal user) {
//         return S.eq(email, user.getName());
//     }
// 
//     @Stateless
//     public static class Dao extends MorphiaDao<User> {
// 
//         public User findByUsername(String username) {
//             return findOneBy("email", username);
//         }
// 
//         public boolean authenticate(String username, char[] password) {
//             User user = findByUsername(username);
//             if (null == user) {
//                 return false;
//             }
//             return user.verifyPassword(password);
//         }
// 
//     }
// }


import act.controller.annotation.UrlContext;
import act.db.sql.tx.Transactional;
import org.osgl.aaa.AAA;
import org.osgl.mvc.annotation.GetAction;
import org.osgl.mvc.annotation.PostAction;
import test.model.User;
import javax.inject.Inject;
package test.endpoint;



@UrlContext("users")
public class UserService extends ServiceBaseV1 {

    @Inject
    private User.Dao userDao;

    @GetAction
    public Iterable<User> list() {
        AAA.requirePermission("view-users");
        return userDao.findAll();
    }

    @PostAction
    @Transactional
// Path: testapps/morphia_model/src/main/java/test/model/User.java
// @Entity("user")
// public class User extends MorphiaUserBase<User> implements UserLinked {
// 
//     public String firstName;
//     public String lastName;
// 
//     @Override
//     public boolean isLinkedTo(Principal user) {
//         return S.eq(email, user.getName());
//     }
// 
//     @Stateless
//     public static class Dao extends MorphiaDao<User> {
// 
//         public User findByUsername(String username) {
//             return findOneBy("email", username);
//         }
// 
//         public boolean authenticate(String username, char[] password) {
//             User user = findByUsername(username);
//             if (null == user) {
//                 return false;
//             }
//             return user.verifyPassword(password);
//         }
// 
//     }
// }


// Path: testapps/jpa_model/src/main/java/test/endpoint/UserService.java
import act.controller.annotation.UrlContext;
import act.db.sql.tx.Transactional;
import org.osgl.aaa.AAA;
import org.osgl.mvc.annotation.GetAction;
import org.osgl.mvc.annotation.PostAction;
import test.model.User;
import javax.inject.Inject;

package test.endpoint;



@UrlContext("users")
public class UserService extends ServiceBaseV1 {

    @Inject
    private User.Dao userDao;

    @GetAction
    public Iterable<User> list() {
        AAA.requirePermission("view-users");
        return userDao.findAll();
    }

    @PostAction
    @Transactional
    public User create(User user) {