// Path: app/actions/CurrentUser.java
// public class CurrentUser extends Action.Simple
// {
//     @Override
//     public Result call(Http.Context ctx) throws Throwable
//     {
//         accessUser(ctx);
//         return delegate.call(ctx);
//     }
// 
//     private static User accessUser(Http.Context ctx)
//     {
//         User user = (User)ctx.args.get("user");
//         if (user == null)
//         {
//             String userName = ctx.session().get("userName");
//             if (!StringUtils.isEmpty(userName))
//             {
//                 user = User.findByUserName(userName);
//                 if (user != null)
//                 {
//                     ctx.args.put("user",
//                                  user);
//                 }
//             }
//         }
// 
//         return user;
//     }
// 
//     public static User currentUser()
//     {
//         return currentUser(Http.Context.current());
//     }
// 
//     public static User currentUser(Http.Context context)
//     {
//         return accessUser(context);
//     }
// }
// 
// Path: app/models/PlayVersion.java
// @Entity
// public class PlayVersion extends AbstractModel {
// 
//     public enum MajorVersion {
//         ONE("1"),
//         TWO("2");
// 
//         private MajorVersion(String numeric) {
//             this.numeric = numeric;
//         }
// 
//         public String numeric;
//     }
// 
// 
//     @Column(nullable = false, unique = true)
//     @Constraints.Required
//     public String name;
// 
//     @Column(nullable = false)
//     @Enumerated(EnumType.STRING)
//     public MajorVersion majorVersion;
// 
//     @Column(nullable = false)
//     @Constraints.Required
//     public String documentationUrl;
//     
//     public static final Finder<Long, PlayVersion> FIND = new Finder<Long, PlayVersion>(Long.class,
//             PlayVersion.class);
// 
//     public static int count() {
//         return FIND.findRowCount();
//     }
// 
//     public static List<PlayVersion> getAll() {
//         return FIND.where()
//                 .order("name ASC")
//                 .findList();
//     }
// 
//     public static PlayVersion findByName(String name) {
//         return FIND.where()
//                 .eq("name", name)
//                 .findUnique();
//     }
// 
//     /**
//      * Allow 1.2 to match 1.2, 1.2.1, 1.2.2, etc
//      *
//      * @param name
//      * @return
//      */
//     public static List<PlayVersion> findByLooseName(String name) {
//         return FIND.where()
//                 .startsWith("name", name)
//                 .findList();
//     }
// 
//     public static List<PlayVersion> findByMajorVersion(MajorVersion majorVersion) {
//         return FIND.where()
//                 .eq("majorVersion", majorVersion)
//                 .findList();
//     }
// }
// 
// Path: app/security/RoleDefinitions.java
// public class RoleDefinitions
// {
//     public static final String ADMIN = "admin";
// 
//     private RoleDefinitions()
//     {
//         // no-op
//     }
// }
// 
// Path: app/actions/CurrentUser.java
// public static User currentUser()
// {
//     return currentUser(Http.Context.current());
// }


import actions.CurrentUser;
import be.objectify.deadbolt.actions.Restrict;
import models.PlayVersion;
import play.data.Form;
import play.libs.Json;
import play.mvc.Controller;
import play.mvc.Result;
import play.mvc.With;
import security.RoleDefinitions;
import views.html.admin.playVersions;
import static actions.CurrentUser.currentUser;

/*
 * 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 controllers;



/**
 * @author Steve Chaloner (steve@obectify.be)
 */
@With(CurrentUser.class)
@Restrict(RoleDefinitions.ADMIN)
public class PlayVersions extends AbstractController
{
    public static Result showPlayVersions()
    {

// Path: app/actions/CurrentUser.java
// public class CurrentUser extends Action.Simple
// {
//     @Override
//     public Result call(Http.Context ctx) throws Throwable
//     {
//         accessUser(ctx);
//         return delegate.call(ctx);
//     }
// 
//     private static User accessUser(Http.Context ctx)
//     {
//         User user = (User)ctx.args.get("user");
//         if (user == null)
//         {
//             String userName = ctx.session().get("userName");
//             if (!StringUtils.isEmpty(userName))
//             {
//                 user = User.findByUserName(userName);
//                 if (user != null)
//                 {
//                     ctx.args.put("user",
//                                  user);
//                 }
//             }
//         }
// 
//         return user;
//     }
// 
//     public static User currentUser()
//     {
//         return currentUser(Http.Context.current());
//     }
// 
//     public static User currentUser(Http.Context context)
//     {
//         return accessUser(context);
//     }
// }
// 
// Path: app/models/PlayVersion.java
// @Entity
// public class PlayVersion extends AbstractModel {
// 
//     public enum MajorVersion {
//         ONE("1"),
//         TWO("2");
// 
//         private MajorVersion(String numeric) {
//             this.numeric = numeric;
//         }
// 
//         public String numeric;
//     }
// 
// 
//     @Column(nullable = false, unique = true)
//     @Constraints.Required
//     public String name;
// 
//     @Column(nullable = false)
//     @Enumerated(EnumType.STRING)
//     public MajorVersion majorVersion;
// 
//     @Column(nullable = false)
//     @Constraints.Required
//     public String documentationUrl;
//     
//     public static final Finder<Long, PlayVersion> FIND = new Finder<Long, PlayVersion>(Long.class,
//             PlayVersion.class);
// 
//     public static int count() {
//         return FIND.findRowCount();
//     }
// 
//     public static List<PlayVersion> getAll() {
//         return FIND.where()
//                 .order("name ASC")
//                 .findList();
//     }
// 
//     public static PlayVersion findByName(String name) {
//         return FIND.where()
//                 .eq("name", name)
//                 .findUnique();
//     }
// 
//     /**
//      * Allow 1.2 to match 1.2, 1.2.1, 1.2.2, etc
//      *
//      * @param name
//      * @return
//      */
//     public static List<PlayVersion> findByLooseName(String name) {
//         return FIND.where()
//                 .startsWith("name", name)
//                 .findList();
//     }
// 
//     public static List<PlayVersion> findByMajorVersion(MajorVersion majorVersion) {
//         return FIND.where()
//                 .eq("majorVersion", majorVersion)
//                 .findList();
//     }
// }
// 
// Path: app/security/RoleDefinitions.java
// public class RoleDefinitions
// {
//     public static final String ADMIN = "admin";
// 
//     private RoleDefinitions()
//     {
//         // no-op
//     }
// }
// 
// Path: app/actions/CurrentUser.java
// public static User currentUser()
// {
//     return currentUser(Http.Context.current());
// }


// Path: app/controllers/PlayVersions.java
import actions.CurrentUser;
import be.objectify.deadbolt.actions.Restrict;
import models.PlayVersion;
import play.data.Form;
import play.libs.Json;
import play.mvc.Controller;
import play.mvc.Result;
import play.mvc.With;
import security.RoleDefinitions;
import views.html.admin.playVersions;
import static actions.CurrentUser.currentUser;

/*
 * 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 controllers;



/**
 * @author Steve Chaloner (steve@obectify.be)
 */
@With(CurrentUser.class)
@Restrict(RoleDefinitions.ADMIN)
public class PlayVersions extends AbstractController
{
    public static Result showPlayVersions()
    {

        return ok(playVersions.render(CurrentUser.currentUser(),
