// 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;
                    p = "Node";
            }
            // .. somehow somewhere throw an error
        }
        // TODO apply ViewTemplate too
        Page page = Page.loadByName(p);
        if (page != null) {
            request.args.put("app-page", page);
        }
    }

    @After
    static void measureTime()
    {
        Long start    = renderArgs.get("reqstart", Long.class);
        Long duration = System.currentTimeMillis() - start;
        Logger.info("Request duration " + duration);
    }

    public static void index() {
        viewPage("main");
    }

    // Actions for view (get) -> Page
//     # whatever1:action : edit(showEditNode), new(viewNodeUpdates), '' -> viewNode
// # pars: page, p (pageNum), ..?

    public static void getNode(String id) {
        String ac = params.get("action"); // or rs
        if (ac != null) { // or something else is wrong
// 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;

                    p = "Node";
            }
            // .. somehow somewhere throw an error
        }
        // TODO apply ViewTemplate too
        Page page = Page.loadByName(p);
        if (page != null) {
            request.args.put("app-page", page);
        }
    }

    @After
    static void measureTime()
    {
        Long start    = renderArgs.get("reqstart", Long.class);
        Long duration = System.currentTimeMillis() - start;
        Logger.info("Request duration " + duration);
    }

    public static void index() {
        viewPage("main");
    }

    // Actions for view (get) -> Page
//     # whatever1:action : edit(showEditNode), new(viewNodeUpdates), '' -> viewNode
// # pars: page, p (pageNum), ..?

    public static void getNode(String id) {
        String ac = params.get("action"); // or rs
        if (ac != null) { // or something else is wrong
            Action.doAction(ac, request, getUser(), params.allSimple());