Package com.netflix.explorers.context

Examples of com.netflix.explorers.context.RequestContext


        else {
            vars = new HashMap<String, Object>();
            vars.put("it", model);
        }

        RequestContext requestContext = new RequestContext();
        requestContext.setHttpServletRequest(requestInvoker != null ? requestInvoker.get() : null);
        vars.put("RequestContext",  requestContext);
        vars.put("Request",         requestInvoker != null ? requestInvoker.get() : null);
       
        Principal ctx = null;
        if (requestInvoker.get() != null) {
            ctx = requestInvoker.get().getUserPrincipal();
            if (ctx == null && requestInvoker.get().getSession(false) != null) {
                final String username = (String) requestInvoker.get().getSession().getAttribute("SSO_UserName");
                if (username != null) {
                    ctx = new Principal() {
                        @Override
                        public String getName() {
                            return username;
                        }
                    };
                }
            }
        }
        vars.put("Principal",  ctx);
       
        // The following are here for backward compatibility and should be deprecated as soon as possible
        Map<String, Object> global = Maps.newHashMap();
       
        if (manager != null) {
            GlobalModelContext globalModel = manager.getGlobalModel();
            global.put("sysenv",    globalModel.getEnvironment());      // TODO: DEPRECATE
        }
        vars.put("global",      global);                            // TODO: DEPRECATE
        vars.put("pathToRoot",  requestContext.getPathToRoot());    // TODO: DEPRECATE
       
        String layout = DEFAULT_LAYOUT;

        Explorer explorer = null;
        final boolean hasExplorerName = !requestContext.getExplorerName().isEmpty();
        try {
            if (hasExplorerName) {
                explorer = manager.getExplorer(requestContext.getExplorerName());
            }
        }
        catch (Exception e) {
            LOG.warn(e.getMessage());
        }
        if (explorer == null) {
            if (hasExplorerName) {
                throw new WebApplicationException(new RuntimeException("Invalid explorer"), Response.Status.NOT_FOUND);
            } else {
                explorer = EmptyExplorer.getInstance();
            }
        }

        layout = explorer.getLayoutName();
        vars.put("Explorer", explorer);
       
        if (vars.containsKey("layout")) {
            layout = (String) vars.get("layout");
        }




        final StringWriter stringWriter = new StringWriter();

        try {
            if (requestContext.getIsAjaxRequest()) {
              fmConfig.getTemplate(resolvedPath).process(vars, stringWriter);
            }
            else {
              if (layout == null) {
                layout = DEFAULT_LAYOUT;
View Full Code Here


        return ComponentScope.PerRequest;
    }

    @Override
    public Explorer getValue(HttpContext c) {
        RequestContext request = new RequestContext();
        request.setHttpServletRequest(requestInvoker.get());
        try {
            return manager.getExplorer(request.getExplorerName());
        }
        catch (Exception e) {
            LOG.warn("Failed to get UserProfileDao", e);
            return null;
        }
View Full Code Here

       
        String ext = StringUtils.substringAfterLast(subResources, ".");
        String mediaType = EXT_TO_MEDIATYPE.get(ext);
       
        final Map<String,Object> vars = new HashMap<String, Object>();
        RequestContext requestContext = new RequestContext();
        vars.put("RequestContext",  requestContext);
        if (manager != null) {
            vars.put("Global",          manager.getGlobalModel());
            vars.put("Explorers",       manager);
        }
View Full Code Here

TOP

Related Classes of com.netflix.explorers.context.RequestContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.