// Path: app/models/actions/Action.java
// public abstract class Action {
// 
//     private static Map<String,Action> actions = Maps.newHashMap();
//     private String name;
// 
//     public abstract Boolean apply(
//             Request request,
//             User    user,
//             Map<String, String> params
//             );
// 
//     public static Boolean doAction(String acName,
//             Request request,
//             User    user,
//             Map<String, String> params) {
//         Action action = actions.get(acName.toLowerCase());
//         if (action == null) {
//             Logger.info("No Action found for action string:" + acName);
//             return Boolean.FALSE;
//         } else {
//             Logger.info("Action found for action string:" + acName);
//             return action.apply(request, user, params);
//         }
//     }
// 
//     // instantiate all Actions
//     public static void start() {
//         for (Class c : 
//                 Collections2.filter(MongoEntity.getClasses("models.actions"),
//                     new Predicate<Class>() {
//                     public boolean apply(Class t) {
//                         return ! "models.actions.Action".equals(t.getName());
//                     }
//                 })
//             )
//             actions.put(c.getSimpleName().toLowerCase(), getByName(c.getName()));
//     }
//     
//     private static <T extends Action> T getByName(String name) {
//         Logger.info("Action.getByName::" + name);
//         T le = null;
//         try {
//             Class<T> fu = (Class<T>) Class.forName(name);
//             le = fu.newInstance();
//         } catch (Exception ex) {
//             Logger.info("Action.getByName::" + name + ex.toString());
//         }
//         return le;
//     }
// 
//     protected String getName() {
//         return name;
//     }
// 
//     private void setName(String newName) {
//         name = newName;
//     }
// 
// }
// 
// Path: app/models/MongoEntity.java
// public static ObjectId toId(String x) {
//     ObjectId bubu = null;
//     try { bubu = new ObjectId(x);} catch (Exception e ) {};
//     return bubu;
// }


import models.actions.Action;
import java.util.Map;
import org.bson.types.ObjectId;
import java.io.File;
import play.mvc.*;
import play.Logger;
import models.*;
import play.cache.Cache;
import play.mvc.Controller;
import static models.MongoEntity.toId;
    }

    // Actions
    public static void friend(String uid)
    {
        checkAuthenticity();
        Logger.info("Add friend :: " + uid);
        getUser().addFriend(toId(uid));
        showUser(uid);
    }

    public static void ignore(String uid)
    {
        checkAuthenticity();
        Logger.info("Add ignore :: " + uid);
        getUser().addIgnore(toId(uid));
        showUser(uid);
    }

    public static void ignoreMail(String uid)
    {
        checkAuthenticity();
        Logger.info("Add ignoreMail :: " + uid);
        getUser().addIgnoreMail(toId(uid));
        showUser(uid);
    }

    public static void book(String id, String type)
    {
        checkAuthenticity();
// Path: app/models/actions/Action.java
// public abstract class Action {
// 
//     private static Map<String,Action> actions = Maps.newHashMap();
//     private String name;
// 
//     public abstract Boolean apply(
//             Request request,
//             User    user,
//             Map<String, String> params
//             );
// 
//     public static Boolean doAction(String acName,
//             Request request,
//             User    user,
//             Map<String, String> params) {
//         Action action = actions.get(acName.toLowerCase());
//         if (action == null) {
//             Logger.info("No Action found for action string:" + acName);
//             return Boolean.FALSE;
//         } else {
//             Logger.info("Action found for action string:" + acName);
//             return action.apply(request, user, params);
//         }
//     }
// 
//     // instantiate all Actions
//     public static void start() {
//         for (Class c : 
//                 Collections2.filter(MongoEntity.getClasses("models.actions"),
//                     new Predicate<Class>() {
//                     public boolean apply(Class t) {
//                         return ! "models.actions.Action".equals(t.getName());
//                     }
//                 })
//             )
//             actions.put(c.getSimpleName().toLowerCase(), getByName(c.getName()));
//     }
//     
//     private static <T extends Action> T getByName(String name) {
//         Logger.info("Action.getByName::" + name);
//         T le = null;
//         try {
//             Class<T> fu = (Class<T>) Class.forName(name);
//             le = fu.newInstance();
//         } catch (Exception ex) {
//             Logger.info("Action.getByName::" + name + ex.toString());
//         }
//         return le;
//     }
// 
//     protected String getName() {
//         return name;
//     }
// 
//     private void setName(String newName) {
//         name = newName;
//     }
// 
// }
// 
// Path: app/models/MongoEntity.java
// public static ObjectId toId(String x) {
//     ObjectId bubu = null;
//     try { bubu = new ObjectId(x);} catch (Exception e ) {};
//     return bubu;
// }


// Path: app/controllers/Application.java
import models.actions.Action;
import java.util.Map;
import org.bson.types.ObjectId;
import java.io.File;
import play.mvc.*;
import play.Logger;
import models.*;
import play.cache.Cache;
import play.mvc.Controller;
import static models.MongoEntity.toId;

    }

    // Actions
    public static void friend(String uid)
    {
        checkAuthenticity();
        Logger.info("Add friend :: " + uid);
        getUser().addFriend(toId(uid));
        showUser(uid);
    }

    public static void ignore(String uid)
    {
        checkAuthenticity();
        Logger.info("Add ignore :: " + uid);
        getUser().addIgnore(toId(uid));
        showUser(uid);
    }

    public static void ignoreMail(String uid)
    {
        checkAuthenticity();
        Logger.info("Add ignoreMail :: " + uid);
        getUser().addIgnoreMail(toId(uid));
        showUser(uid);
    }

    public static void book(String id, String type)
    {
        checkAuthenticity();
        Bookmark.add(toId(id), getUser(), type);