Java Code Examples for org.springframework.validation.support.BindingAwareModelMap#get()

The following examples show how to use org.springframework.validation.support.BindingAwareModelMap#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProvidersController.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
@RequestMapping("/add")
public String add(HttpServletRequest request, HttpServletResponse response, Model model) {
    prepare(request, response, model, "add", "providers");
    BindingAwareModelMap newModel = (BindingAwareModelMap)model;
    Long id = (Long)newModel.get("id");
    String service = (String)newModel.get("service");
    if (service == null) {
        List<String> serviceList = Tool.sortSimpleName(new ArrayList<String>(providerService.findServices()));
        model.addAttribute("serviceList", serviceList);
    }
    if (id != null) {
        Provider p = providerService.findProvider(id);
        if (p != null) {
            model.addAttribute("provider", p);
            String parameters = p.getParameters();
            if (parameters != null && parameters.length() > 0) {
                Map<String, String> map = StringUtils.parseQueryString(parameters);
                map.put("timestamp", String.valueOf(System.currentTimeMillis()));
                map.remove("pid");
                p.setParameters(StringUtils.toQueryString(map));
            }
        }
    }
    return "governance/screen/providers/add";
}
 
Example 2
Source File: OverridesController.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
@RequestMapping("")
public String index(HttpServletRequest request, HttpServletResponse response, Model model) {
    prepare(request, response, model, "index", "overrides");
    BindingAwareModelMap newModel = (BindingAwareModelMap)model;
    String service = (String)newModel.get("service");
    String application = (String)newModel.get("app");
    String address = (String)newModel.get("address");
    List<Override> overrides;
    if (StringUtils.isNotEmpty(service)) {
        overrides = overrideService.findByService(service);
    } else if (StringUtils.isNotEmpty(application)) {
        overrides = overrideService.findByApplication(application);
    } else if (StringUtils.isNotEmpty(address)) {
        overrides = overrideService.findByAddress(address);
    } else {
        overrides = overrideService.findAll();
    }
    model.addAttribute("overrides", overrides);
    return "governance/screen/overrides/index";
}
 
Example 3
Source File: WeightsController.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
@RequestMapping("")
public String index(HttpServletRequest request, HttpServletResponse response, Model model) {
    prepare(request, response, model, "index", "weights");
    BindingAwareModelMap newModel = (BindingAwareModelMap)model;
    String service = (String)newModel.get("service");
    String address = (String)newModel.get("address");
    service = StringUtils.trimToNull(service);
    address = Tool.getIP(address);
    List<Weight> weights;
    if (service != null && service.length() > 0) {
        weights = OverrideUtils.overridesToWeights(overrideService.findByService(service));
    } else if (address != null && address.length() > 0) {
        weights = OverrideUtils.overridesToWeights(overrideService.findByAddress(address));
    } else {
        weights = OverrideUtils.overridesToWeights(overrideService.findAll());
    }
    model.addAttribute("weights", weights);
    return "governance/screen/weights/index";
}
 
Example 4
Source File: WeightsController.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
/**
 * load page for the adding
 *
 */
@RequestMapping("/add")
public String add(HttpServletRequest request, HttpServletResponse response, Model model) {
    prepare(request, response, model, "add", "weights");
    BindingAwareModelMap newModel = (BindingAwareModelMap)model;
    String service = (String)newModel.get("service");
    String input = request.getParameter("input");
    if (service != null && service.length() > 0 && !service.contains("*")) {
        List<Provider> providerList = providerService.findByService(service);
        List<String> addressList = new ArrayList<String>();
        for (Provider provider : providerList) {
            addressList.add(provider.getUrl().split("://")[1].split("/")[0]);
        }
        model.addAttribute("addressList", addressList);
        model.addAttribute("service", service);
        model.addAttribute("methods", CollectionUtils.sort(providerService.findMethodsByService(service)));
    } else {
        List<String> serviceList = Tool.sortSimpleName(providerService.findServices());
        model.addAttribute("serviceList", serviceList);
    }
    if (input != null) model.addAttribute("input", input);
    return "governance/screen/weights/add";
}
 
Example 5
Source File: RoutesController.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
/**
 * Routing module home page
 *
 */
@RequestMapping("")
public String index(HttpServletRequest request, HttpServletResponse response, Model model) {
    prepare(request, response, model, "index", "routes");
    BindingAwareModelMap newModel = (BindingAwareModelMap)model;
    String address = (String)newModel.get("address");
    String service = (String)newModel.get("service");
    address = Tool.getIP(address);
    List<Route> routes;
    if (service != null && service.length() > 0
            && address != null && address.length() > 0) {
        routes = routeService.findByServiceAndAddress(service, address);
    } else if (service != null && service.length() > 0) {
        routes = routeService.findByService(service);
    } else if (address != null && address.length() > 0) {
        routes = routeService.findByAddress(address);
    } else {
        routes = routeService.findAll();
    }
    model.addAttribute("routes", routes);
    return "governance/screen/routes/index";
}
 
Example 6
Source File: RoutesController.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
/**
 * Load new route page
 *
 */
@RequestMapping("/add")
public String add(HttpServletRequest request, HttpServletResponse response, Model model) {
    prepare(request, response, model, "add", "routes");
    BindingAwareModelMap newModel = (BindingAwareModelMap)model;
    String service = (String)newModel.get("service");
    if (service != null && service.length() > 0 && !service.contains("*")) {
        model.addAttribute("service", service);
        model.addAttribute("methods", CollectionUtils.sort(new ArrayList<String>(providerService.findMethodsByService(service))));
    } else {
        List<String> serviceList = Tool.sortSimpleName(new ArrayList<String>(providerService.findServices()));
        model.addAttribute("serviceList", serviceList);
    }

    //if (input != null) model.addAttribute("input", input);
    return "governance/screen/routes/add";
}
 
Example 7
Source File: LoadbalancesController.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
@RequestMapping("")
public String index(HttpServletRequest request, HttpServletResponse response, Model model) {
    prepare(request, response, model, "index", "loadbalances");
    BindingAwareModelMap newModel = (BindingAwareModelMap)model;
    String service = (String)newModel.get("service");
    service = StringUtils.trimToNull(service);

    List<LoadBalance> loadbalances;
    if (service != null && service.length() > 0) {
        loadbalances = OverrideUtils.overridesToLoadBalances(overrideService.findByService(service));
    } else {
        loadbalances = OverrideUtils.overridesToLoadBalances(overrideService.findAll());
    }
    model.addAttribute("loadbalances", loadbalances);
    return "governance/screen/loadbalances/index";
}
 
Example 8
Source File: LoadbalancesController.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
@RequestMapping("/add")
public String add(HttpServletRequest request, HttpServletResponse response, Model model) {
    prepare(request, response, model, "add", "loadbalances");
    BindingAwareModelMap newModel = (BindingAwareModelMap)model;
    String service = (String)newModel.get("service");

    if (service != null && service.length() > 0 && !service.contains("*")) {
        List<Provider> providerList = providerService.findByService(service);
        List<String> addressList = new ArrayList<String>();
        for (Provider provider : providerList) {
            addressList.add(provider.getUrl().split("://")[1].split("/")[0]);
        }
        model.addAttribute("addressList", addressList);
        model.addAttribute("service", service);
        model.addAttribute("methods", CollectionUtils.sort(providerService.findMethodsByService(service)));
    } else {
        List<String> serviceList = Tool.sortSimpleName(providerService.findServices());
        model.addAttribute("serviceList", serviceList);
    }
    //if (input != null) model.addAttribute("input", input);
    return "governance/screen/loadbalances/add";
}
 
Example 9
Source File: OwnersController.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@RequestMapping("")
public String index(HttpServletRequest request, HttpServletResponse response, Model model) {
    prepare(request, response, model, "index", "owners");
    List<Owner> owners;
    BindingAwareModelMap newModel = (BindingAwareModelMap)model;
    String service = (String)newModel.get("service");
    if (service != null && service.length() > 0) {
        owners = ownerService.findByService(service);
    } else {
        owners = ownerService.findAll();
    }
    model.addAttribute("owners", owners);
    return "governance/screen/owners/index";
}
 
Example 10
Source File: OwnersController.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/add")
public String add(HttpServletRequest request, HttpServletResponse response, Model model) {
    prepare(request, response, model, "add", "owners");
    BindingAwareModelMap newModel = (BindingAwareModelMap)model;
    String service = (String)newModel.get("service");
    if (service == null || service.length() == 0) {
        List<String> serviceList = Tool.sortSimpleName(new ArrayList<String>(providerService.findServices()));
        model.addAttribute("serviceList", serviceList);
    }
    return "governance/screen/owners/add";
}
 
Example 11
Source File: OverridesController.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/add")
public String add(HttpServletRequest request, HttpServletResponse response, Model model) {
    prepare(request, response, model,"add", "overrides");
    BindingAwareModelMap newModel = (BindingAwareModelMap)model;
    String application = (String)newModel.get("app");
    String service = (String)newModel.get("service");
    List<String> serviceList = new ArrayList<String>();
    List<String> applicationList = new ArrayList<String>();
    if (StringUtils.isNotEmpty(application)) {
        serviceList.addAll(providerService.findServicesByApplication(application));
        serviceList.addAll(consumerService.findServicesByApplication(application));
        model.addAttribute("serviceList", serviceList);
    } else if (StringUtils.isNotEmpty(service)) {
        applicationList.addAll(providerService.findApplicationsByServiceName(service));
        applicationList.addAll(consumerService.findApplicationsByServiceName(service));
        model.addAttribute("applicationList", applicationList);
    } else {
        serviceList.addAll(providerService.findServices());
        serviceList.addAll(consumerService.findServices());
        providerService.findServicesByApplication(application);
        consumerService.findServicesByApplication(application);
    }
    model.addAttribute("serviceList", serviceList);

    if (StringUtils.isNotEmpty(service) && !service.contains("*")) {
        model.addAttribute("methods", CollectionUtils.sort(new ArrayList<String>(providerService.findMethodsByService(service))));
    }
    return "governance/screen/overrides/add";
}
 
Example 12
Source File: ProvidersController.java    From open-capacity-platform with Apache License 2.0 4 votes vote down vote up
@RequestMapping("")
public String index(HttpServletRequest request, HttpServletResponse response, Model model) {


    prepare(request, response, model, "index", "providers");

    String value = "";
    String separators = "....";

    List<Provider> providers = null;
    BindingAwareModelMap newModel = (BindingAwareModelMap)model;
    String service = (String)newModel.get("service");
    String address = (String)newModel.get("address");
    String application = (String)newModel.get("app");

    // service
    if (service != null && service.length() > 0) {
        providers = providerService.findByService(service);

        value = service + separators + request.getRequestURI();
    }
    // address
    else if (address != null && address.length() > 0) {
        providers = providerService.findByAddress(address);

        value = address + separators + request.getRequestURI();
    }
    // application
    else if (application != null && application.length() > 0) {
        providers = providerService.findByApplication(application);

        value = application + separators + request.getRequestURI();
    }
    // all
    else {
        providers = providerService.findAll();
    }

    model.addAttribute("providers", providers);
    model.addAttribute("serviceAppMap", getServiceAppMap(providers));

    // record search history to cookies
    try {
        setSearchHistroy(value, request, response);
    } catch (Exception e) {
        //
    }
    return "governance/screen/providers/index";
}
 
Example 13
Source File: ConsumersController.java    From open-capacity-platform with Apache License 2.0 4 votes vote down vote up
@RequestMapping("")
public String index(HttpServletRequest request, HttpServletResponse response,
                  Model model) {
    prepare(request, response, model, "index", "consumers");
    List<Consumer> consumers;
    List<Override> overrides;
    List<Provider> providers = null;
    List<Route> routes = null;
    BindingAwareModelMap newModel = (BindingAwareModelMap)model;
    String service = (String)newModel.get("service");
    String address = (String)newModel.get("address");
    String application = (String)newModel.get("app");
    // service
    if (service != null && service.length() > 0) {
        consumers = consumerService.findByService(service);
        overrides = overrideService.findByService(service);
        providers = providerService.findByService(service);
        routes = routeService.findByService(service);
    }
    // address
    else if (address != null && address.length() > 0) {
        consumers = consumerService.findByAddress(address);
        overrides = overrideService.findByAddress(Tool.getIP(address));
    }
    // application
    else if (application != null && application.length() > 0) {
        consumers = consumerService.findByApplication(application);
        overrides = overrideService.findByApplication(application);
    }
    // all
    else {
        consumers = consumerService.findAll();
        overrides = overrideService.findAll();
    }
    if (consumers != null && consumers.size() > 0) {
        for (Consumer consumer : consumers) {
            if (service == null || service.length() == 0) {
                providers = providerService.findByService(consumer.getService());
                routes = routeService.findByService(consumer.getService());
            }
            List<Route> routed = new ArrayList<Route>();
            consumer.setProviders(RouteUtils
                .route(consumer.getService(), consumer.getAddress(), consumer.getParameters(), providers, overrides, routes, null, routed));
            consumer.setRoutes(routed);
            OverrideUtils.setConsumerOverrides(consumer, overrides);
        }
    }
    model.addAttribute("consumers", consumers);
    return "governance/screen/consumers/index";
}