// Path: app/models/Rate.java
// @Entity
// public class Rate extends AbstractModel {
// 
//     @OneToOne(optional = false)
//     public Module playModule;
// 
//     @Column(nullable = false)
//     public Integer rating;
// }
// 
// Path: app/models/User.java
// @Entity
// @Table(name = "MPO_USER")
// public class User extends AbstractModel implements RoleHolder
// {
// 
//     @Column(nullable = false, length = 40, unique = true)
//     public String userName;
// 
//     @Column(nullable = false, length = 100)
//     public String displayName;
// 
//     @Column(name = "passwd", nullable = false, length = 64)
//     public String password;
// 
//     @Column(nullable = true, length = 2500)
//     public String avatarUrl;
// 
//     @Column(nullable = false)
//     public Boolean accountActive;
// 
//     @Column(nullable = true, length = 36)
//     public String confirmationCode;
// 
//     @ManyToMany(cascade = {CascadeType.DETACH, CascadeType.REFRESH})
//     public List<UserRole> roles;
// 
//     @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
//     public List<Vote> votes;
// 
//     @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
//     public List<Rate> rates;
// 
//     public static final Finder<Long, User> FIND = new Finder<Long, User>(Long.class,
//             User.class);
// 
//     public static int count() {
//         return FIND.findRowCount();
//     }
// 
//     public static User findByUserName(String userName) {
//         return FIND.where()
//                 .eq("userName", userName)
//                 .findUnique();
//     }
// 
//     public static User authenticate(String userName,
//                                     String password) {
//         return FIND.where()
//                 .eq("userName", userName)
//                 .eq("password", password)
//                 .findUnique();
//     }
// 
//     @Override
//     public List<? extends Role> getRoles()
//     {
//         return roles;
//     }
// 
//     @Override
//     public List<? extends Permission> getPermissions()
//     {
//         // for now, let's go with role-based security.  I don't think we need any fine-grained control.
//         return Collections.emptyList();
//     }
// }
// 
// Path: app/models/UserRole.java
// @Entity
// public class UserRole extends Model implements Role
// {
//     @Id
//     public Long id;
// 
//     @Column(nullable = false, unique = true)
//     public String roleName;
// 
//     @Column(nullable = false, length = 1000)
//     public String description;
// 
//     public static final Finder<Long, UserRole> FIND = new Finder<Long, UserRole>(Long.class,
//                                                                                  UserRole.class);
// 
//     @Override
//     public String getRoleName()
//     {
//         return roleName;
//     }
// 
//     public static UserRole findByRoleName(String roleName)
//     {
//         return FIND.where()
//                    .eq("roleName",
//                        roleName)
//                    .findUnique();
// 
//     }
// }


import models.Rate;
import models.User;
import models.UserRole;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/*
 * Copyright 2012 The Play! Framework
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package services;



/**
 * @author Steve Chaloner (steve@objectify.be)
 */
public class UserServices
{

    public User createUser(String userName,
                           String displayName,
                           String password)
    {
        return createUser(userName,
                          displayName,
                          password,
// Path: app/models/Rate.java
// @Entity
// public class Rate extends AbstractModel {
// 
//     @OneToOne(optional = false)
//     public Module playModule;
// 
//     @Column(nullable = false)
//     public Integer rating;
// }
// 
// Path: app/models/User.java
// @Entity
// @Table(name = "MPO_USER")
// public class User extends AbstractModel implements RoleHolder
// {
// 
//     @Column(nullable = false, length = 40, unique = true)
//     public String userName;
// 
//     @Column(nullable = false, length = 100)
//     public String displayName;
// 
//     @Column(name = "passwd", nullable = false, length = 64)
//     public String password;
// 
//     @Column(nullable = true, length = 2500)
//     public String avatarUrl;
// 
//     @Column(nullable = false)
//     public Boolean accountActive;
// 
//     @Column(nullable = true, length = 36)
//     public String confirmationCode;
// 
//     @ManyToMany(cascade = {CascadeType.DETACH, CascadeType.REFRESH})
//     public List<UserRole> roles;
// 
//     @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
//     public List<Vote> votes;
// 
//     @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
//     public List<Rate> rates;
// 
//     public static final Finder<Long, User> FIND = new Finder<Long, User>(Long.class,
//             User.class);
// 
//     public static int count() {
//         return FIND.findRowCount();
//     }
// 
//     public static User findByUserName(String userName) {
//         return FIND.where()
//                 .eq("userName", userName)
//                 .findUnique();
//     }
// 
//     public static User authenticate(String userName,
//                                     String password) {
//         return FIND.where()
//                 .eq("userName", userName)
//                 .eq("password", password)
//                 .findUnique();
//     }
// 
//     @Override
//     public List<? extends Role> getRoles()
//     {
//         return roles;
//     }
// 
//     @Override
//     public List<? extends Permission> getPermissions()
//     {
//         // for now, let's go with role-based security.  I don't think we need any fine-grained control.
//         return Collections.emptyList();
//     }
// }
// 
// Path: app/models/UserRole.java
// @Entity
// public class UserRole extends Model implements Role
// {
//     @Id
//     public Long id;
// 
//     @Column(nullable = false, unique = true)
//     public String roleName;
// 
//     @Column(nullable = false, length = 1000)
//     public String description;
// 
//     public static final Finder<Long, UserRole> FIND = new Finder<Long, UserRole>(Long.class,
//                                                                                  UserRole.class);
// 
//     @Override
//     public String getRoleName()
//     {
//         return roleName;
//     }
// 
//     public static UserRole findByRoleName(String roleName)
//     {
//         return FIND.where()
//                    .eq("roleName",
//                        roleName)
//                    .findUnique();
// 
//     }
// }


// Path: app/services/UserServices.java
import models.Rate;
import models.User;
import models.UserRole;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/*
 * Copyright 2012 The Play! Framework
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package services;



/**
 * @author Steve Chaloner (steve@objectify.be)
 */
public class UserServices
{

    public User createUser(String userName,
                           String displayName,
                           String password)
    {
        return createUser(userName,
                          displayName,
                          password,
                          Collections.<UserRole>emptyList());