protected void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { _log.debug("VIEW"); // Portlet preferences PortletPreferences prefs = request.getPreferences(); String users = prefs.getValue("users", "root"); // Business Invocation BlogAPI blogService = blogService(); ArrayList<Blog> blogs = blogService.getBlogs(); // Checking Admin rights if (request.getUserPrincipal() != null && request.getUserPrincipal().getName() != null) { for (String user : users.split(",")) if (user.equals(request.getUserPrincipal().getName())) { request.setAttribute("admin", request.getUserPrincipal().getName()); break; } } else { request.setAttribute("admin", null); } request.setAttribute("blogs", blogs); // Controlling the view String view = "/jsp/management.jsp"; PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher(view); prd.include(request, response); }
/** * @see * org.apache.portals.bridges.velocity.GenericVelocityPortlet#doView(javax.portlet.RenderRequest, * javax.portlet.RenderResponse) */ public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { Context context = getContext(request); IngridResourceBundle messages = new IngridResourceBundle( getPortletConfig().getResourceBundle(request.getLocale()), request.getLocale()); context.put("MESSAGES", messages); // check for just logged in users HttpSession session = ((RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV)) .getRequest() .getSession(true); String loginStarted = (String) session.getAttribute(Settings.SESSION_LOGIN_STARTED); if (loginStarted != null && loginStarted.equals("1")) { session.removeAttribute(Settings.SESSION_LOGIN_STARTED); // do something "after login" stuff // initialize the session preference with persistent data from // personalization IngridSessionPreferences sessionPrefs = Utils.getSessionPreferences( request, IngridSessionPreferences.SESSION_KEY, IngridSessionPreferences.class); if (sessionPrefs != null) { Principal principal = request.getUserPrincipal(); if (principal != null) { HashMap persistentSearchSettings = (HashMap) IngridPersistencePrefs.getPref( principal.getName(), IngridPersistencePrefs.SEARCH_SETTINGS); if (persistentSearchSettings != null) { sessionPrefs.putAll(persistentSearchSettings); } } } } String userName = request.getUserPrincipal().getName(); User user = null; try { user = userManager.getUser(userName); } catch (SecurityException e) { e.printStackTrace(); } if (user != null) { context.put("userAttributes", user.getInfoMap()); } super.doView(request, response); }
/** * @see * org.apache.portals.bridges.velocity.GenericVelocityPortlet#doView(javax.portlet.RenderRequest, * javax.portlet.RenderResponse) */ public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { Context context = getContext(request); IngridResourceBundle messages = new IngridResourceBundle( getPortletConfig().getResourceBundle(request.getLocale()), request.getLocale()); context.put("MESSAGES", messages); PortletPreferences prefs = request.getPreferences(); String titleKey = prefs.getValue("titleKey", "searchSettings.title.rankingAndGrouping"); response.setTitle(messages.getString(titleKey)); UtilsSearch.doViewForPartnerPortlet(request, context); Principal principal = request.getUserPrincipal(); String partnerStr = (String) IngridPersistencePrefs.getPref( principal.getName(), IngridPersistencePrefs.SEARCH_PARTNER); if (partnerStr != null) { PortletSession session = request.getPortletSession(); DisplayTreeNode partnerRoot = (DisplayTreeNode) session.getAttribute("partnerRoot"); Iterator it = partnerRoot.getChildren().iterator(); while (it.hasNext()) { DisplayTreeNode partnerNode = (DisplayTreeNode) it.next(); if (partnerStr.indexOf(Settings.QFIELD_PARTNER.concat(":").concat(partnerNode.getId())) != -1 || partnerNode.get("checked") != null) { partnerNode.put("checked", "true"); } else { partnerNode.remove("checked"); } Iterator it2 = partnerNode.getChildren().iterator(); while (it2.hasNext()) { DisplayTreeNode providerNode = (DisplayTreeNode) it2.next(); if (partnerStr.indexOf(Settings.QFIELD_PROVIDER.concat(":").concat(providerNode.getId())) != -1) { providerNode.put("checked", "true"); partnerNode.setOpen(true); } else { providerNode.remove("checked"); } } } } super.doView(request, response); }