@Test void testServeApp() throws Exception { PluginIdentity pluginIdentity = new PluginIdentity(APP_PREFIX + "app1"); when(userPermissionEvaluator.hasPermission(pluginIdentity, VIEW_PLUGIN)).thenReturn(true); mockMvc .perform(get(AppController.URI + "/app1/")) .andExpect(status().isOk()) .andExpect(model().attribute("app", appResponse)) .andExpect(model().attribute("baseUrl", "/test/path")) .andExpect(view().name("view-app")); }
@GetMapping("/{appName}/**") @Nullable @CheckForNull public ModelAndView serveApp( @PathVariable String appName, Model model, HttpServletRequest request, HttpServletResponse response) throws IOException { PluginIdentity pluginIdentity = new PluginIdentity(APP_PREFIX + appName); if (!userPermissionEvaluator.hasPermission(pluginIdentity, VIEW_PLUGIN)) { throw new PluginPermissionDeniedException(appName, VIEW_PLUGIN); } String wildCardPath = extractWildcardPath(request, appName); if (wildCardPath.isEmpty()) { RedirectView redirectView = new RedirectView(findAppMenuURL(appName)); redirectView.setExposePathVariables(false); return new ModelAndView(redirectView); } AppResponse appResponse = appManagerService.getAppByName(appName); if (!appResponse.getIsActive()) { throw new AppIsInactiveException(appName); } else if (isResourceRequest(wildCardPath)) { serveAppResource(response, wildCardPath, appResponse); return null; } else { return serveAppTemplate(appName, model, appResponse); } }
AppController extends PluginController { @GetMapping("/{appName}/**") @Nullable @CheckForNull public ModelAndView serveApp( @PathVariable String appName, Model model, HttpServletRequest request, HttpServletResponse response) throws IOException { PluginIdentity pluginIdentity = new PluginIdentity(APP_PREFIX + appName); if (!userPermissionEvaluator.hasPermission(pluginIdentity, VIEW_PLUGIN)) { throw new PluginPermissionDeniedException(appName, VIEW_PLUGIN); } String wildCardPath = extractWildcardPath(request, appName); if (wildCardPath.isEmpty()) { RedirectView redirectView = new RedirectView(findAppMenuURL(appName)); redirectView.setExposePathVariables(false); return new ModelAndView(redirectView); } AppResponse appResponse = appManagerService.getAppByName(appName); if (!appResponse.getIsActive()) { throw new AppIsInactiveException(appName); } else if (isResourceRequest(wildCardPath)) { serveAppResource(response, wildCardPath, appResponse); return null; } else { return serveAppTemplate(appName, model, appResponse); } } }
AppController extends PluginController { @GetMapping("/{appName}/**") @Nullable @CheckForNull public ModelAndView serveApp( @PathVariable String appName, Model model, HttpServletRequest request, HttpServletResponse response) throws IOException { PluginIdentity pluginIdentity = new PluginIdentity(APP_PREFIX + appName); if (!userPermissionEvaluator.hasPermission(pluginIdentity, VIEW_PLUGIN)) { throw new PluginPermissionDeniedException(appName, VIEW_PLUGIN); } String wildCardPath = extractWildcardPath(request, appName); if (wildCardPath.isEmpty()) { RedirectView redirectView = new RedirectView(findAppMenuURL(appName)); redirectView.setExposePathVariables(false); return new ModelAndView(redirectView); } AppResponse appResponse = appManagerService.getAppByName(appName); if (!appResponse.getIsActive()) { throw new AppIsInactiveException(appName); } else if (isResourceRequest(wildCardPath)) { serveAppResource(response, wildCardPath, appResponse); return null; } else { return serveAppTemplate(appName, model, appResponse); } } AppController(
      AppManagerService appManagerService,
      UserPermissionEvaluator userPermissionEvaluator,
      AppSettings appSettings,
      MenuReaderService menuReaderService,
      FileStore fileStore); }
AppController extends PluginController { @GetMapping("/{appName}/**") @Nullable @CheckForNull public ModelAndView serveApp( @PathVariable String appName, Model model, HttpServletRequest request, HttpServletResponse response) throws IOException { PluginIdentity pluginIdentity = new PluginIdentity(APP_PREFIX + appName); if (!userPermissionEvaluator.hasPermission(pluginIdentity, VIEW_PLUGIN)) { throw new PluginPermissionDeniedException(appName, VIEW_PLUGIN); } String wildCardPath = extractWildcardPath(request, appName); if (wildCardPath.isEmpty()) { RedirectView redirectView = new RedirectView(findAppMenuURL(appName)); redirectView.setExposePathVariables(false); return new ModelAndView(redirectView); } AppResponse appResponse = appManagerService.getAppByName(appName); if (!appResponse.getIsActive()) { throw new AppIsInactiveException(appName); } else if (isResourceRequest(wildCardPath)) { serveAppResource(response, wildCardPath, appResponse); return null; } else { return serveAppTemplate(appName, model, appResponse); } } AppController(
      AppManagerService appManagerService,
      UserPermissionEvaluator userPermissionEvaluator,
      AppSettings appSettings,
      MenuReaderService menuReaderService,
      FileStore fileStore); @GetMapping("/{appName}/**") @Nullable @CheckForNull ModelAndView serveApp(
      @PathVariable String appName,
      Model model,
      HttpServletRequest request,
      HttpServletResponse response); }
AppController extends PluginController { @GetMapping("/{appName}/**") @Nullable @CheckForNull public ModelAndView serveApp( @PathVariable String appName, Model model, HttpServletRequest request, HttpServletResponse response) throws IOException { PluginIdentity pluginIdentity = new PluginIdentity(APP_PREFIX + appName); if (!userPermissionEvaluator.hasPermission(pluginIdentity, VIEW_PLUGIN)) { throw new PluginPermissionDeniedException(appName, VIEW_PLUGIN); } String wildCardPath = extractWildcardPath(request, appName); if (wildCardPath.isEmpty()) { RedirectView redirectView = new RedirectView(findAppMenuURL(appName)); redirectView.setExposePathVariables(false); return new ModelAndView(redirectView); } AppResponse appResponse = appManagerService.getAppByName(appName); if (!appResponse.getIsActive()) { throw new AppIsInactiveException(appName); } else if (isResourceRequest(wildCardPath)) { serveAppResource(response, wildCardPath, appResponse); return null; } else { return serveAppTemplate(appName, model, appResponse); } } AppController(
      AppManagerService appManagerService,
      UserPermissionEvaluator userPermissionEvaluator,
      AppSettings appSettings,
      MenuReaderService menuReaderService,
      FileStore fileStore); @GetMapping("/{appName}/**") @Nullable @CheckForNull ModelAndView serveApp(
      @PathVariable String appName,
      Model model,
      HttpServletRequest request,
      HttpServletResponse response); static final String ID; static final String URI; }