Search in sources :

Example 11 with ModelAndView

use of org.springframework.web.portlet.ModelAndView in project uPortal by Jasig.

the class PortletEntityTranslationController method getPortletDefinition.

@ResourceMapping
@RequestMapping(params = "action=getEntity")
public ModelAndView getPortletDefinition(@RequestParam("id") String portletId, @RequestParam("locale") String locale) throws Exception {
    final IPortletDefinition definition = portletDefinitionDao.getPortletDefinition(portletId);
    final PortletDefinitionTranslation translation = new PortletDefinitionTranslation();
    translation.setId(portletId);
    translation.setLocale(locale);
    translation.setLocalized(new LocalizedPortletDefinition(definition, locale));
    translation.setOriginal(new LocalizedPortletDefinition(definition, null));
    return new ModelAndView("json", "portlet", translation);
}
Also used : ModelAndView(org.springframework.web.portlet.ModelAndView) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) ResourceMapping(org.springframework.web.portlet.bind.annotation.ResourceMapping) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with ModelAndView

use of org.springframework.web.portlet.ModelAndView in project uPortal by Jasig.

the class DirectoryPortletController method findPersonByUsername.

@RenderMapping(params = "action=findByUsername")
public ModelAndView findPersonByUsername(RenderRequest request, @RequestParam String username) {
    // get an authorization principal for the current requesting user
    HttpServletRequest servletRequest = portalRequestUtils.getPortletHttpRequest(request);
    IPerson currentUser = personManager.getPerson(servletRequest);
    // get the set of people matching the search query
    final IPersonAttributes person = this.lookupHelper.findPerson(currentUser, username);
    final boolean isMobile = isMobile(request);
    String viewName = isMobile ? "/jsp/Directory/mobileDirectory" : "/jsp/Directory/directory";
    final Map<String, Object> model = new HashMap<String, Object>();
    model.put("query", username);
    model.put("people", Collections.singletonList(person));
    model.put("attributeNames", this.displayAttributes);
    return new ModelAndView(viewName, model);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) IPersonAttributes(org.jasig.services.persondir.IPersonAttributes) HashMap(java.util.HashMap) ModelAndView(org.springframework.web.portlet.ModelAndView) RenderMapping(org.springframework.web.portlet.bind.annotation.RenderMapping)

Example 13 with ModelAndView

use of org.springframework.web.portlet.ModelAndView in project uPortal by Jasig.

the class DynamicRespondrSkinViewController method displaySkinCssHeader.

/**
     * Display Skin CSS include based on skin's configuration values from portlet preferences.<br>
     * dynamic=false: load the pre-built css file from the skins directory and default skin name;
     * e.g. RELATIVE_ROOT/{defaultSkin}.css dynamic=true: Process the default skin less file if
     * needed at RELATIVE_ROOT/{defaultSkin}.less to create a customized skin css file
     * (RELATIVE_ROOT/skin-ID#.css to load.
     */
@RenderMapping
public ModelAndView displaySkinCssHeader(RenderRequest request, RenderResponse response, Model model) throws IOException {
    if (PortletRequest.RENDER_HEADERS.equals(request.getAttribute(PortletRequest.RENDER_PART))) {
        PortletPreferences prefs = request.getPreferences();
        Boolean enabled = Boolean.valueOf(prefs.getValue(DynamicRespondrSkinConstants.PREF_DYNAMIC, "false"));
        String skinName = prefs.getValue(DynamicRespondrSkinConstants.PREF_SKIN_NAME, DynamicRespondrSkinConstants.DEFAULT_SKIN_NAME);
        String cssUrl = enabled ? calculateDynamicSkinUrlPathToUse(request, skinName) : calculateDefaultSkinCssLocationInWebapp(skinName);
        model.addAttribute(DynamicRespondrSkinConstants.SKIN_CSS_URL_MODEL_ATTRIBUTE_NAME, cssUrl);
        return new ModelAndView("jsp/DynamicRespondrSkin/skinHeader");
    } else {
        // We need to know if this user can CONFIG this skin
        // Default
        boolean canAccessSkinConfig = false;
        final HttpServletRequest httpr = portalRequestUtils.getCurrentPortalRequest();
        final IPerson user = personManager.getPerson(httpr);
        final IAuthorizationPrincipal principal = AuthorizationPrincipalHelper.principalFromUser(user);
        final IPortletWindowId portletWindowId = portletWindowRegistry.getPortletWindowId(httpr, request.getWindowID());
        final IPortletWindow portletWindow = portletWindowRegistry.getPortletWindow(httpr, portletWindowId);
        final IPortletEntity portletEntity = portletWindow.getPortletEntity();
        if (principal.canConfigure(portletEntity.getPortletDefinitionId().toString())) {
            canAccessSkinConfig = true;
        }
        // RENDER_MARKUP
        return new ModelAndView("jsp/DynamicRespondrSkin/skinBody", DynamicRespondrSkinConstants.CAN_ACCESS_SKIN_CONFIG_MODEL_NAME, canAccessSkinConfig);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) ModelAndView(org.springframework.web.portlet.ModelAndView) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) PortletPreferences(javax.portlet.PortletPreferences) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) RenderMapping(org.springframework.web.portlet.bind.annotation.RenderMapping)

Example 14 with ModelAndView

use of org.springframework.web.portlet.ModelAndView in project uPortal by Jasig.

the class SitemapPortletController method displaySitemap.

/**
     * Display the user sitemap.
     *
     * @param request
     * @return "sitemapView" and a supporting model
     * @throws XMLStreamException
     * @throws IllegalStateException if components required for the SiteMap portlet fail to
     *     auto-wire
     */
@RequestMapping
public ModelAndView displaySitemap(PortletRequest request) throws XMLStreamException {
    Map<String, Object> model = new HashMap<String, Object>();
    if (this.xsltPortalUrlProvider == null) {
        throw new IllegalStateException("Sitemap portlet requires a XsltPortalUrlProvider but it failed to " + "auto-wire");
    }
    if (this.attributeIncorporationComponent == null) {
        throw new IllegalStateException("Sitemap portlet requires a StAXPipelineComponent with qualifier structureAttributeIncorporationComponent but it failed to auto-wire");
    }
    if (this.portalRequestUtils == null) {
        throw new IllegalStateException("Sitemap portlet requires an IPortalRequestUtils but it failed to " + "auto-wire");
    }
    // retrieve the user layout with structure attributes applied (required in order to display tab groups)
    final HttpServletRequest httpServletRequest = this.portalRequestUtils.getPortletHttpRequest(request);
    final HttpServletResponse httpServletResponse = this.portalRequestUtils.getOriginalPortalResponse(request);
    final PipelineEventReader<XMLEventReader, XMLEvent> reader = attributeIncorporationComponent.getEventReader(httpServletRequest, httpServletResponse);
    // create a Source from the user's layout document
    StAXSource source = new StAXSource(reader.getEventReader());
    model.put("source", source);
    model.put(XsltPortalUrlProvider.CURRENT_REQUEST, httpServletRequest);
    model.put(XsltPortalUrlProvider.XSLT_PORTAL_URL_PROVIDER, this.xsltPortalUrlProvider);
    model.put(USE_TAB_GROUPS, useTabGroups);
    model.put(USER_LANG, ObjectUtils.toString(request.getLocale()));
    return new ModelAndView("sitemapView", model);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HashMap(java.util.HashMap) XMLEvent(javax.xml.stream.events.XMLEvent) ModelAndView(org.springframework.web.portlet.ModelAndView) HttpServletResponse(javax.servlet.http.HttpServletResponse) XMLEventReader(javax.xml.stream.XMLEventReader) StAXSource(javax.xml.transform.stax.StAXSource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 15 with ModelAndView

use of org.springframework.web.portlet.ModelAndView in project uPortal by Jasig.

the class SearchPortletController method showJSONSearchResults.

/** Display AJAX autocomplete search results for the last query */
@ResourceMapping(value = "retrieveSearchJSONResults")
public ModelAndView showJSONSearchResults(PortletRequest request) {
    PortletPreferences prefs = request.getPreferences();
    int maxTextLength = Integer.parseInt(prefs.getValue(AUTOCOMPLETE_MAX_TEXT_LENGTH_PREF_NAME, "180"));
    final Map<String, Object> model = new HashMap<>();
    List<AutocompleteResultsModel> results = new ArrayList<>();
    final PortletSession session = request.getPortletSession();
    String queryId = (String) session.getAttribute(SEARCH_LAST_QUERY_ID);
    if (queryId != null) {
        final PortalSearchResults portalSearchResults = this.getPortalSearchResults(request, queryId);
        if (portalSearchResults != null) {
            final ConcurrentMap<String, List<Tuple<SearchResult, String>>> resultsMap = portalSearchResults.getResults();
            results = collateResultsForAutoCompleteResponse(resultsMap, maxTextLength);
        }
    }
    model.put("results", results);
    model.put("count", results.size());
    return new ModelAndView("json", model);
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.portlet.ModelAndView) SearchResult(org.apereo.portal.search.SearchResult) PortletSession(javax.portlet.PortletSession) PortletPreferences(javax.portlet.PortletPreferences) List(java.util.List) ArrayList(java.util.ArrayList) ResourceMapping(org.springframework.web.portlet.bind.annotation.ResourceMapping)

Aggregations

ModelAndView (org.springframework.web.portlet.ModelAndView)15 HashMap (java.util.HashMap)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 PortletPreferences (javax.portlet.PortletPreferences)6 ResourceMapping (org.springframework.web.portlet.bind.annotation.ResourceMapping)6 RenderMapping (org.springframework.web.portlet.bind.annotation.RenderMapping)4 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)3 IPerson (org.apereo.portal.security.IPerson)3 ArrayList (java.util.ArrayList)2 Locale (java.util.Locale)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Message (org.apereo.portal.i18n.Message)2 DataTable (com.google.visualization.datasource.datatable.DataTable)1 List (java.util.List)1 PortletSession (javax.portlet.PortletSession)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 DataSource (javax.sql.DataSource)1