Returns a view of the marketplace landing page

@param webRequest
@param portletRequest
@param model
@param initialFilter - optional request paramter. Use to init filter on initial view
@return a string representing the initial view.
8849
@RenderMapping
    public String initializeView(
            WebRequest webRequest,
            PortletRequest portletRequest,
            Model model,
            @RequestParam(required = false) String initialFilter) {
        this.setUpInitialView(webRequest, portletRequest, model, initialFilter);
        return "jsp/Marketplace/portlet/view";
    }
1294895
public static void filterRequest(ContainerRequestContext requestContext, Predicate<String> predicate) {
        //NOT a CORS request
        String requestOrigin = requestContext.getHeaderString(Headers.ORIGIN);
        if (requestOrigin == null) {
            return;
        }

        if (!predicate.test(requestOrigin)) {
            requestContext.abortWith(Response.status(Response.Status.BAD_REQUEST).build());
            return;
        }

        //It is a CORS pre-flight request, there is no route for it, just return 200
        if (requestContext.getMethod().equalsIgnoreCase(HttpMethod.OPTIONS)) {
            requestContext.abortWith(Response.status(Response.Status.OK).build());
        }
    }
681064
@RequestMapping(method = RequestMethod.POST, params = "action=addPortlet")
    public ModelAndView addPortlet(HttpServletRequest request, HttpServletResponse response)
            throws IOException, PortalException {

        IUserInstance ui = userInstanceManager.getUserInstance(request);
        UserPreferencesManager upm = (UserPreferencesManager) ui.getPreferencesManager();
        IUserLayoutManager ulm = upm.getUserLayoutManager();
        final Locale locale = RequestContextUtils.getLocale(request);

        // gather the parameters we need to move a channel
        String destinationId = request.getParameter("elementID");
        String sourceId = request.getParameter("channelID");
        String method = request.getParameter("position");
        String fname = request.getParameter("fname");

        if (destinationId == null) {
            String tabName = request.getParameter("tabName");
            if (tabName != null) {
                destinationId = getTabIdFromName(ulm.getUserLayout(), tabName);
            }
        }

        IPortletDefinition definition;
        if (sourceId != null) definition = portletDefinitionRegistry.getPortletDefinition(sourceId);
        else if (fname != null)
            definition = portletDefinitionRegistry.getPortletDefinitionByFname(fname);
        else {
            logger.error("SourceId or fname invalid when adding a portlet");
            response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
            return new ModelAndView(
                    "jsonView", Collections.singletonMap("error", "SourceId or fname invalid"));
        }

        IUserLayoutChannelDescription channel = new UserLayoutChannelDescription(definition);

        IUserLayoutNodeDescription node;
        if (isTab(ulm, destinationId)) {
            node = addNodeToTab(ulm, channel, destinationId);

        } else {
            boolean isInsert = method != null && method.equals("insertBefore");

            // If neither an insert or type folder - Can't "insert into" non-folder
            if (!(isInsert || isFolder(ulm, destinationId))) {
                logger.error("Cannot insert into portlet element");
                response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
                return new ModelAndView(
                        "jsonView",
                        Collections.singletonMap("error", "Cannot insert into portlet element"));
            }

            String siblingId = isInsert ? destinationId : null;
            String target = isInsert ? ulm.getParentId(destinationId) : destinationId;

            // move the channel into the column
            node = ulm.addNode(channel, target, siblingId);
        }

        if (node == null) {
            response.setStatus(HttpServletResponse.SC_FORBIDDEN);
            return new ModelAndView(
                    "jsonView",
                    Collections.singletonMap(
                            "error",
                            getMessage("error.add.element", "Unable to add element", locale)));
        }

        String nodeId = node.getId();

        try {
            // save the user's layout
            ulm.saveUserLayout();
            if (addedWindowState != null) {
                IPortletWindow portletWindow =
                        this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(
                                request, channel.getFunctionalName());
                portletWindow.setWindowState(addedWindowState);
                this.portletWindowRegistry.storePortletWindow(request, portletWindow);
            }
        } catch (PortalException e) {
            return handlePersistError(request, response, e);
        }

        Map<String, String> model = new HashMap<>();
        model.put("response", getMessage("success.add.portlet", "Added a new channel", locale));
        model.put("newNodeId", nodeId);
        return new ModelAndView("jsonView", model);
    }
1001042
@RequestMapping(params = "action=export")
    public ModelAndView getExportView(PortletRequest request) {
        Map<String, Object> model = new HashMap<String, Object>();

        // add a list of all permitted export types
        final Iterable<IPortalDataType> exportPortalDataTypes =
                this.portalDataHandlerService.getExportPortalDataTypes();
        final List<IPortalDataType> types =
                getAllowedTypes(request, IPermission.EXPORT_ACTIVITY, exportPortalDataTypes);
        model.put("supportedTypes", types);

        return new ModelAndView("/jsp/ImportExportPortlet/export", model);
    }
678493
protected String getResultUrl(
            HttpServletRequest httpServletRequest,
            SearchResult result,
            IPortletWindowId portletWindowId) {
        final String externalUrl = result.getExternalUrl();
        if (externalUrl != null) {
            return externalUrl;
        }

        UrlType urlType = UrlType.RENDER;

        final PortletUrl portletUrl = result.getPortletUrl();
        if (portletUrl != null) {
            final PortletUrlType type = portletUrl.getType();
            if (type != null) {
                switch (type) {
                    case ACTION:
                        {
                            urlType = UrlType.ACTION;
                            break;
                        }
                    default:
                    case RENDER:
                        {
                            urlType = UrlType.RENDER;
                            break;
                        }
                    case RESOURCE:
                        {
                            urlType = UrlType.RESOURCE;
                            break;
                        }
                }
            }
        }

        final IPortalUrlBuilder portalUrlBuilder =
                this.portalUrlProvider.getPortalUrlBuilderByPortletWindow(
                        httpServletRequest, portletWindowId, urlType);
        final IPortletUrlBuilder portletUrlBuilder =
                portalUrlBuilder.getTargetedPortletUrlBuilder();

        if (portletUrl != null) {
            final String portletMode = portletUrl.getPortletMode();
            if (portletMode != null) {
                portletUrlBuilder.setPortletMode(PortletUtils.getPortletMode(portletMode));
            }
            final String windowState = portletUrl.getWindowState();
            if (windowState != null) {
                portletUrlBuilder.setWindowState(PortletUtils.getWindowState(windowState));
            }
            for (final PortletUrlParameter param : portletUrl.getParam()) {
                final String name = param.getName();
                final List<String> values = param.getValue();
                portletUrlBuilder.addParameter(name, values.toArray(new String[values.size()]));
            }
        }

        return portalUrlBuilder.getUrlString();
    }
319111
@Override
    public void onStartup(Set<Class<?>> arg0, ServletContext servletContext) throws ServletException {
        FilterRegistration.Dynamic dynamic =
                        servletContext.addFilter("com.ibm.ws.security.jaspi.servlet.filter", JaspiServletFilter.class);
        dynamic.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*");
        dynamic.setAsyncSupported(true);
    }
976256
private FilterMappingDescriptor createFilterMapping(FilterMappingType filterMappingType, Map<String, FilterDescriptor> filters,
            Map<String, ServletDescriptor> servlets, Store store) {
        FilterMappingDescriptor filterMappingDescriptor = store.create(FilterMappingDescriptor.class);
        FilterNameType filterName = filterMappingType.getFilterName();
        FilterDescriptor filterDescriptor = getOrCreateNamedDescriptor(FilterDescriptor.class, filterName.getValue(), filters, store);
        filterDescriptor.getMappings().add(filterMappingDescriptor);
        for (Object urlPatternOrServletName : filterMappingType.getUrlPatternOrServletName()) {
            if (urlPatternOrServletName instanceof UrlPatternType) {
                UrlPatternType urlPatternType = (UrlPatternType) urlPatternOrServletName;
                UrlPatternDescriptor urlPatternDescriptor = createUrlPattern(urlPatternType, store);
                filterMappingDescriptor.getUrlPatterns().add(urlPatternDescriptor);
            } else if (urlPatternOrServletName instanceof ServletNameType) {
                ServletNameType servletNameType = (ServletNameType) urlPatternOrServletName;
                ServletDescriptor servletDescriptor = getOrCreateNamedDescriptor(ServletDescriptor.class, servletNameType.getValue(), servlets, store);
                filterMappingDescriptor.setServlet(servletDescriptor);
            }
        }
        for (DispatcherType dispatcherType : filterMappingType.getDispatcher()) {
            DispatcherDescriptor dispatcherDescriptor = store.create(DispatcherDescriptor.class);
            dispatcherDescriptor.setValue(dispatcherType.getValue());
            filterMappingDescriptor.getDispatchers().add(dispatcherDescriptor);
        }

        return filterMappingDescriptor;
    }
161258
public ApiResponse<ApiSuccessResponse> initProvisioningWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = initProvisioningValidateBeforeCall(null, null);
        Type localVarReturnType = new TypeToken<ApiSuccessResponse>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }
421480
@GetMapping
  public String init(Model model) {

    final UriComponents uriComponents =
        ServletUriComponentsBuilder.fromCurrentContextPath().build();
    model.addAttribute("molgenisUrl", uriComponents.toUriString() + URI + "/swagger.yml");
    model.addAttribute("baseUrl", uriComponents.toUriString());

    final String currentUsername = SecurityUtils.getCurrentUsername();
    if (currentUsername != null) {
      model.addAttribute(
          "token", tokenService.generateAndStoreToken(currentUsername, "For Swagger UI"));
    }
    return "view-swagger-ui";
  }
635611
public View getView(final HttpServletRequest request,
                        final boolean isSuccess,
                        final WebApplicationService service,
                        final Class ownerClass) {
        val type = getValidationResponseType(request, service);
        if (type == ValidationResponseType.JSON) {
            return getSingleInstanceView(ServiceValidationViewTypes.JSON);
        }
        return isSuccess
            ? getSuccessView(ownerClass.getSimpleName())
            : getFailureView(ownerClass.getSimpleName());
    }
698625
@RequestMapping(params = "action=delete")
    public ModelAndView getDeleteView(PortletRequest request) {
        Map<String, Object> model = new HashMap<String, Object>();

        // add a list of all permitted deletion types
        final Iterable<IPortalDataType> deletePortalDataTypes =
                this.portalDataHandlerService.getDeletePortalDataTypes();
        final List<IPortalDataType> types =
                getAllowedTypes(request, IPermission.DELETE_ACTIVITY, deletePortalDataTypes);
        model.put("supportedTypes", types);

        return new ModelAndView("/jsp/ImportExportPortlet/delete", model);
    }
163980
@RequestMapping(value = "/portletList", method = RequestMethod.GET)
    public ModelAndView listChannels(
            WebRequest webRequest,
            HttpServletRequest request,
            @RequestParam(value = "type", required = false) String type) {

        if (TYPE_MANAGE.equals(type)) {
            throw new UnsupportedOperationException(
                    "Moved to PortletRESTController under /api/portlets.json");
        }

        final IPerson user = personManager.getPerson(request);
        final Map<String, SortedSet<?>> registry = getRegistryOriginal(webRequest, user);

        // Since type=manage was deprecated channels is always empty but retained for backwards
        // compatibility
        registry.put("channels", new TreeSet<ChannelBean>());

        return new ModelAndView("jsonView", "registry", registry);
    }
374438
@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);
    }
779490
@Override
    public void startPortletRender(
            IPortletWindowId portletWindowId,
            HttpServletRequest request,
            HttpServletResponse response) {
        this.startPortletRenderInternal(portletWindowId, request, response);
    }
786580
private String calculateSearchLaunchUrl(RenderRequest request, RenderResponse response) {
        final HttpServletRequest httpRequest =
                this.portalRequestUtils.getPortletHttpRequest(request);
        final IPortalUrlBuilder portalUrlBuilder =
                this.portalUrlProvider.getPortalUrlBuilderByPortletFName(
                        httpRequest, "search", UrlType.ACTION);
        return portalUrlBuilder.getUrlString();
    }
621537
protected PageFilter getPageFilter(SlingHttpServletRequest request) {

    // check for predicate filter
    String predicateName = RequestParam.get(request, RP_PREDICATE);
    if (StringUtils.isNotEmpty(predicateName)) {
      PredicateProvider predicateProvider = getPredicateProvider();
      if (predicateProvider == null) {
        throw new RuntimeException("PredicateProvider service not available.");
      }
      Predicate predicate = predicateProvider.getPredicate(predicateName);
      if (predicate == null) {
        throw new RuntimeException("Predicate '" + predicateName + "' not available.");
      }
      return new PredicatePageFilter(predicate, true, true);
    }

    return null;
  }
1083685
@RequestMapping(value = "/filter", method = RequestMethod.GET)
    public ResponseEntity<List<E>> findBySimpleFilter(@RequestParam MultiValueMap<String, String> requestParams) {

        final List<E> resultList = this.service.findBySimpleFilter(requestParams);

        if (resultList != null && !resultList.isEmpty()) {
            LOG.trace("Found a total of " + resultList.size()
                + " entities of type "
                + resultList.get(0).getClass().getSimpleName());
        }

        return new ResponseEntity<List<E>>(resultList, HttpStatus.OK);
    }