package earlgrey.admin;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Hashtable;

import org.apache.commons.lang3.ArrayUtils;
import org.json.JSONArray;
import org.json.JSONObject;

import earlgrey.annotations.CORS;
import earlgrey.annotations.Console;
import earlgrey.annotations.Controller;
import earlgrey.annotations.ControllerAction;
import earlgrey.annotations.GET;
import earlgrey.annotations.Model;
import earlgrey.annotations.POST;
import earlgrey.annotations.ParamRequire;
import earlgrey.annotations.Policie;
import earlgrey.annotations.Route;
import earlgrey.core.ControllerCore;
import earlgrey.core.HttpRequest;
import earlgrey.core.HttpResponse;
import earlgrey.core.ModelCore;
import earlgrey.core.Properties;
import earlgrey.core.ResourceMaping;
import earlgrey.def.ActionDef;
import earlgrey.def.HttpMethod;
import earlgrey.def.RouteDef;
import earlgrey.def.SessionDef;

@Console(description = "Controller to manage the controllers in console.", name = "Controllers", version = 1)
@Route(route = "/controllers")
@CORS
public class ControllersConsole extends ControllerCore{
	
}

@@ -1174,11 +1174,1504 @@
 rCore%7B%0A%09
+@ControllerAction(description = %22Method use to get the controllers%22, name = %22Get Controllers%22, version = 1)%0A%09@GET%0A%09public static void getControllers(HttpRequest req, HttpResponse res)%7B%0A%09%09JSONArray retorno = new JSONArray();%0A%09%09ResourceMaping resources = ResourceMaping.getInstance();%0A%09%09Hashtable%3CString, Class%3C?%3E%3E controllers = resources.getControllerTable();%0A%09%09Enumeration%3CString%3E keys = controllers.keys();%0A%09%09while(keys.hasMoreElements()) %7B%0A%09%09%09String key = keys.nextElement();%0A%09%09%09// route name%0A%09%09%09JSONObject controller = new JSONObject();%0A%09%09%09Class%3C?%3E ctllr = controllers.get(key);%0A%09%09%09Controller ctr = ctllr.getAnnotation(Controller.class);%0A%09%09%09controller.put(%22name%22, ctr.name());%0A%09%09%09controller.put(%22description%22, ctr.description());%0A%09%09%09controller.put(%22version%22, ctr.version());%0A%09%09%09controller.put(%22class_name%22, ctllr.getName());%0A%09%09%09// actions%0A%09%09%09JSONArray actions = new JSONArray();%0A%09%09%09Method%5B%5D methods = ctllr.getMethods();%0A%09%09%09for(int i=0; i%3Cmethods.length; i++) %7B%0A%09%09%09%09ControllerAction ctr_action = methods%5Bi%5D.getAnnotation(ControllerAction.class); %0A%09%09%09%09if(ctr_action != null) %7B%0A%09%09%09%09%09JSONObject action_obj = new JSONObject();%0A%09%09%09%09%09action_obj.put(%22name%22, ctr_action.name());%0A%09%09%09%09%09action_obj.put(%22description%22, ctr_action.description());%0A%09%09%09%09%09action_obj.put(%22version%22, ctr_action.version());%0A%09%09%09%09%09action_obj.put(%22method_name%22, methods%5Bi%5D.getName());%0A%09%09%09%09%09actions.put(action_obj);%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09controller.put(%22actions%22, actions);%0A%09%09%09retorno.put(controller);%0A%09%09%7D%0A%09%09res.json(retorno);%0A%09%09return;%0A%09%7D
 %0A%7D%0A

Add the controller console endpoint