コード例 #1
0
 private List<String> createTags() {
   List<String> tags = new LinkedList<>(properties.getTags());
   if (servletContext != null
       && StringUtils.isNotBlank(servletContext.getContextPath())
       && StringUtils.isNotBlank(servletContext.getContextPath().replaceAll("/", ""))) {
     tags.add("contextPath=" + servletContext.getContextPath());
   }
   return tags;
 }
コード例 #2
0
 public void init(ServletConfig config) throws ServletException {
   /** 此处是系统启动时候执行的,一些读取配置文件,监听端口,初始化连接之类的可以在此处做 */
   log.info("===========================================================================init!");
   application = config.getServletContext();
   application.setAttribute("ctx", application.getContextPath());
   log.info(
       "==========================================================================="
           + application.getContextPath());
   // String baseUrl = config.getInitParameter("baseUrl");
   // log.info("===========================================================================init
   // over! " + baseUrl);
   // new Timer().schedule(new KeepLive(baseUrl), 0, 10 * 60 * 1000);// 10分钟进行一次会话保持
 }
コード例 #3
0
 private static String getContextPath(ServletContext context) {
   // cette m茅thode retourne le contextPath de la webapp
   // en utilisant ServletContext.getContextPath si servlet api 2.5
   // ou en se d茅brouillant sinon
   // (on n'a pas encore pour l'instant de request pour appeler HttpServletRequest.getContextPath)
   if (context.getMajorVersion() == 2 && context.getMinorVersion() >= 5
       || context.getMajorVersion() > 2) {
     // api servlet 2.5 (Java EE 5) minimum pour appeler ServletContext.getContextPath
     return context.getContextPath();
   }
   URL webXmlUrl;
   try {
     webXmlUrl = context.getResource("/WEB-INF/web.xml");
   } catch (final MalformedURLException e) {
     throw new IllegalStateException(e);
   }
   String contextPath = webXmlUrl.toExternalForm();
   contextPath = contextPath.substring(0, contextPath.indexOf("/WEB-INF/web.xml"));
   final int indexOfWar = contextPath.indexOf(".war");
   if (indexOfWar > 0) {
     contextPath = contextPath.substring(0, indexOfWar);
   }
   // tomcat peut renvoyer une url commen莽ant pas "jndi:/localhost"
   // (v5.5.28, webapp dans un r茅pertoire)
   if (contextPath.startsWith("jndi:/localhost")) {
     contextPath = contextPath.substring("jndi:/localhost".length());
   }
   final int lastIndexOfSlash = contextPath.lastIndexOf('/');
   if (lastIndexOfSlash != -1) {
     contextPath = contextPath.substring(lastIndexOfSlash);
   }
   return contextPath;
 }
コード例 #4
0
  private void applyLog4jConfiguration(
      ConfigurableEnvironment environment, ServletContext servletContext) {

    String log4jConfigLocation = "classpath:log4j.properties";

    if (environment.containsProperty("logging.file")) {
      String location = environment.getProperty("logging.file");
      servletContext.log("Setting LOG_FILE: " + location);
      System.setProperty("LOG_FILE", location);
    } else if (environment.containsProperty("logging.path")) {
      String location = environment.getProperty("logging.path");
      servletContext.log("Setting LOG_PATH: " + location);
      System.setProperty("LOG_PATH", location);
    } else if (environment.containsProperty("logging.config")) {
      log4jConfigLocation = environment.getProperty("logging.config");
    }

    try {
      servletContext.log("Loading log4j config from location: " + log4jConfigLocation);
      Log4jConfigurer.initLogging(log4jConfigLocation);
    } catch (FileNotFoundException e) {
      servletContext.log("Error loading log4j config from location: " + log4jConfigLocation, e);
    }

    MDC.put("context", servletContext.getContextPath());
  }
コード例 #5
0
 @Before
 public void setUp() {
   when(servletConfig.getServletContext()).thenReturn(servletContext);
   when(servletContext.getContextPath()).thenReturn("/demo");
   resolver = new DefaultMappingResolver();
   when(servletConfig.getInitParameter(anyString())).thenReturn("com.expressmvc");
 }
コード例 #6
0
ファイル: ErrorPages.java プロジェクト: sparkling/elda
  public static Response respond(
      Bindings b, ServletContext con, String name, String message, int status) {
    try {

      String context = con.getContextPath();
      String baseFilePath = ServletUtils.withTrailingSlash(con.getRealPath("/"));
      String basePrefix = name.startsWith("/") ? "" : baseFilePath;

      String[] filesToTry =
          new String[] {
            "/etc/elda/conf.d/" + context + "/_errors/" + name + ".vm",
            basePrefix + "_errors/" + name + ".vm",
            "/etc/elda/conf.d/" + context + "/_errors/" + "_error" + ".vm",
            basePrefix + "_errors/" + "_error" + ".vm"
          };

      String page = fetchPage(filesToTry, fallBack);

      if (message == null) message = "Odd, no additional information is available.";
      b.put("_message", message);

      String builtPage = apply(b, page, name, message);

      return Response.status(status).entity(builtPage).build();
    } catch (Throwable e) {
      log.error("An exception occurred when rendering an error page:");
      log.error("  " + e.getMessage());
      return Response.status(Status.INTERNAL_SERVER_ERROR).entity(fallBack).build();
    }
  }
コード例 #7
0
 /**
  * Returns a VFSFile for the given path and context.
  *
  * @param context
  * @param relPath The folder path.
  * @return VFSFile from the relPath and context.
  */
 private static VFSFile getRootFile(ServletContext context, String relPath) {
   String rootKey = context.getContextPath() + relPath;
   if (mappedServlets.containsKey(rootKey)) return mappedServlets.get(rootKey).getRoot();
   ServletVFS vfs = new ServletVFS(context, relPath);
   mappedServlets.put(rootKey, vfs);
   return vfs.getRoot();
 }
コード例 #8
0
ファイル: Login4.java プロジェクト: Shamya/mathspring
  public String process(
      Connection conn,
      ServletContext servletContext,
      ServletParams params,
      HttpServletRequest req,
      HttpServletResponse resp,
      StringBuffer servletOutput)
      throws Exception {
    int left = params.getInt(LoginParams.LEFT);
    int right = params.getInt(LoginParams.RIGHT);

    int sessionId = params.getInt(LoginParams.SESSION_ID);
    // Make a DB call to save this info   TODO might want a full servlet path rather than ""
    SessionManager smgr = new SessionManager(conn, sessionId).buildExistingSession();
    DbUser.setFlankingUsers(conn, smgr.getStudentId(), left, right);
    LearningCompanion lc = smgr.getLearningCompanion();
    req.setAttribute("sessionId", sessionId);
    req.setAttribute("learningCompanion", (lc != null) ? lc.getCharactersName() : "");
    // subclass binds clientType so it is either adult or k12.  Store in session row
    ServletInfo si =
        new ServletInfo(
            servletContext,
            null,
            req,
            resp,
            params,
            servletOutput,
            null,
            servletContext.getContextPath(),
            "TutorBrain");
    // new TutorPage(si,smgr).handleRequest(new TutorHomeEvent(sessionId));
    new LandingPage(si, smgr).handleRequest();

    return null;
  }
コード例 #9
0
ファイル: InitializeListener.java プロジェクト: vpcaiyc/qy
  /*1.初始化servlet 容器上下文*/
  public void contextInitialized(ServletContextEvent sce) {
    sc = sce.getServletContext();

    contextPath = sc.getContextPath();

    realPath = sc.getRealPath("/") + "/";

    String quartz_configFile = sc.getInitParameter("quartz-config-file");
    URL quartzConfigFileURL =
        Thread.currentThread().getContextClassLoader().getResource(quartz_configFile);
    if (null != quartzConfigFileURL) {
      logger.info("quartz定时调度线程信息:" + quartzConfigFileURL.getFile());
    }

    String shutdownUnload = sc.getInitParameter("shutdown-on-unload");
    if (null != shutdownUnload) {
      performShutdown = Boolean.valueOf(shutdownUnload).booleanValue();
    }

    /*参数配置*/
    StdSchedulerFactory factory;
    try {
      if (quartz_configFile != null) factory = new StdSchedulerFactory(quartz_configFile);
      else factory = new StdSchedulerFactory();
      scheduler = factory.getScheduler();
      // 添加quartz任务监听日志
      scheduler.addSchedulerListener(new SchedulerListenerImpl());
      scheduler.addJobListener(new JobListenerImpl());
      scheduler.addTriggerListener(new TriggerListenerImpl());
      scheduler.start();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #10
0
 private static String getServletContextIdentifier(ServletContext context) {
   if (context.getMajorVersion() == 2 && context.getMinorVersion() < 5) {
     return context.getServletContextName();
   } else {
     return context.getContextPath();
   }
 }
コード例 #11
0
ファイル: JyroListener.java プロジェクト: torao/jyro
  /** @param e */
  @Override
  public void contextInitialized(ServletContextEvent e) {
    ServletContext context = e.getServletContext();

    // retrieve jyro.home
    String dirName = context.getInitParameter(Jyro.JYRO_HOME);
    if (dirName == null) {
      dirName = System.getProperty(Jyro.JYRO_HOME);
      if (dirName == null) {
        throw new IllegalStateException(
            Jyro.JYRO_HOME + " not specified in servlet or context paramter, system property");
      }
    }

    // resolve relative path
    File dir = new File(dirName);
    if (!dir.isAbsolute()) {
      dirName = context.getRealPath(dirName);
      dir = new File(dirName);
    }
    logger.info(Jyro.JYRO_HOME + "=" + dirName);

    // build and startup Jyro
    String contextPath = context.getContextPath();
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    try {
      platform = new JyroPlatform(contextPath, dir, loader, null);
      platform.startup();
    } catch (Exception ex) {
      throw new IllegalStateException(ex);
    }
  }
コード例 #12
0
ファイル: MailService.java プロジェクト: wendaoke/JFinalShop
 // 获取公共数据
 public Map<String, Object> getCommonData() {
   Map<String, Object> commonData = new HashMap<String, Object>();
   ServletContext servletContext = JFinal.me().getServletContext();
   commonData.put("base", servletContext.getContextPath());
   commonData.put("systemConfig", SystemConfigUtil.getSystemConfig());
   return commonData;
 }
コード例 #13
0
  public static void add(HttpSession session) {
    String sessionId = session.getId();

    if (CompoundSessionIdSplitterUtil.hasSessionDelimiter()) {
      sessionId = CompoundSessionIdSplitterUtil.parseSessionId(sessionId);
    }

    Map<String, HttpSession> sessions = _sessions.get(sessionId);

    if (sessions == null) {
      sessions = new ConcurrentHashMap<String, HttpSession>();

      Map<String, HttpSession> previousSessions = _sessions.putIfAbsent(sessionId, sessions);

      if (previousSessions != null) {
        sessions = previousSessions;
      }
    }

    ServletContext servletContext = session.getServletContext();

    String contextPath = servletContext.getContextPath();

    // ConcurrentHashMap's read is faster than its write. This check is
    // logically unnecessary, but is a performance improvement.

    if (!sessions.containsKey(contextPath)) {
      sessions.put(contextPath, session);
    }
  }
コード例 #14
0
  @Override
  public Map<URL, ScanResult> scan() {

    String separator = servletContext.getContextPath();
    if (separator.length() == 0) {
      // Root context
      separator = WEB_INF;
    }

    Map<URL, ScanResult> resultsMap = super.scan();

    // All previous results for WEB-INF/classes must be ignored
    for (Iterator<Entry<URL, ScanResult>> iterator = resultsMap.entrySet().iterator();
        iterator.hasNext(); ) {
      Entry<URL, ScanResult> entry = iterator.next();
      String path = entry.getKey().toString();
      if (path.contains(WEB_INF_CLASSES_FILE_PATH)
          || path.contains(WEB_INF_CLASSES)
          || !path.contains("Pax-Exam-Probe")) {
        iterator.remove();
      } else {
        entry.getValue().extractBeanArchiveId(separator);
      }
    }

    try {
      // WEB-INF/classes
      URL beansXmlUrl = null;
      for (String resource : RESOURCES) {
        URL resourceUrl;
        resourceUrl = servletContext.getResource(resource);
        if (resourceUrl != null) {
          if (beansXmlUrl != null) {
            WeldServletLogger.LOG.foundBothConfiguration(beansXmlUrl);
          } else {
            beansXmlUrl = resourceUrl;
          }
        }
      }
      if (beansXmlUrl != null) {
        BeansXml beansXml = bootstrap.parse(beansXmlUrl);
        if (accept(beansXml)) {
          File webInfClasses = Servlets.getRealFile(servletContext, WEB_INF_CLASSES);
          if (webInfClasses != null) {
            resultsMap.put(
                beansXmlUrl,
                new ScanResult(beansXml, webInfClasses.getPath()).extractBeanArchiveId(separator));
          } else {
            // The WAR is not extracted to the file system - make use of
            // ServletContext.getResourcePaths()
            resultsMap.put(beansXmlUrl, new ScanResult(beansXml, WEB_INF_CLASSES));
          }
        }
      }
    } catch (MalformedURLException e) {
      throw WeldServletLogger.LOG.errorLoadingResources(e);
    }
    return resultsMap;
  }
コード例 #15
0
 private String getContextPath() {
   String cp = ctx.getContextPath();
   if ((cp == null) || cp.isEmpty()) {
     return "The application";
   } else {
     return cp;
   }
 }
コード例 #16
0
ファイル: Extension.java プロジェクト: jemygraw/Piggydb
 public final void init(ServletContext servletContext, ApplicationContext appContext)
     throws Exception {
   this.warSetting = (WarSetting) appContext.getBean("warSetting");
   this.resourcePaths =
       new WebResourcePaths(servletContext.getContextPath(), warSetting.getPiggydbVersion());
   this.htmlFragments = new HtmlFragments(resourcePaths);
   doInit(servletContext, appContext);
 }
コード例 #17
0
  /** @return the name of this application */
  public String getServletContextName() {

    if (servletContext.getMajorVersion() == 2 && servletContext.getMinorVersion() <= 4) {
      return servletContext.getServletContextName();
    } else {
      return servletContext.getContextPath();
    }
  }
コード例 #18
0
  /** Initialisation. */
  @Before
  public void setUp() {
    Utils.initialize();
    try {
      final Field field = MonitoringFilter.class.getDeclaredField("instanceCreated");
      field.setAccessible(true);
      field.set(null, false);
    } catch (final IllegalAccessException e) {
      throw new IllegalStateException(e);
    } catch (final NoSuchFieldException e) {
      throw new IllegalStateException(e);
    }
    final ServletContext parametersContext = createNiceMock(ServletContext.class);
    expect(parametersContext.getMajorVersion()).andReturn(2).anyTimes();
    expect(parametersContext.getMinorVersion()).andReturn(5).anyTimes();
    expect(parametersContext.getContextPath()).andReturn(CONTEXT_PATH).anyTimes();
    expect(parametersContext.getServletContextName()).andReturn("test webapp").anyTimes();
    expect(parametersContext.getServerInfo()).andReturn("mock").anyTimes();
    replay(parametersContext);
    Parameters.initialize(parametersContext);
    verify(parametersContext);

    final ServletConfig config = createNiceMock(ServletConfig.class);
    final ServletContext context = createNiceMock(ServletContext.class);
    expect(config.getServletContext()).andReturn(context).anyTimes();
    // anyTimes sur getInitParameter car TestJdbcDriver a pu fixer la propriété système à false
    expect(
            context.getInitParameter(
                Parameters.PARAMETER_SYSTEM_PREFIX + Parameter.DISABLED.getCode()))
        .andReturn(null)
        .anyTimes();
    expect(config.getInitParameter(Parameter.DISABLED.getCode())).andReturn(null).anyTimes();
    expect(context.getMajorVersion()).andReturn(2).anyTimes();
    expect(context.getMinorVersion()).andReturn(5).anyTimes();
    expect(context.getContextPath()).andReturn(CONTEXT_PATH).anyTimes();
    expect(context.getAttribute(ReportServlet.FILTER_CONTEXT_KEY))
        .andReturn(new FilterContext())
        .anyTimes();
    reportServlet = new ReportServlet();
    replay(config);
    replay(context);
    reportServlet.init(config);
    verify(config);
    verify(context);
  }
コード例 #19
0
 public void logout() throws IOException {
   FacesContext context = FacesContext.getCurrentInstance();
   ExternalContext externalContext = context.getExternalContext();
   ServletContext servletContext = (ServletContext) context.getExternalContext().getContext();
   faceContext = FacesContext.getCurrentInstance();
   httpServletRequest = (HttpServletRequest) faceContext.getExternalContext().getRequest();
   String redirectPath = "/faces/ositran/logueo.xhtml";
   externalContext.redirect(servletContext.getContextPath() + redirectPath);
 }
コード例 #20
0
 public void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
     throws IOException {
   LOGGER.info("DO GET");
   PrintWriter writer = httpServletResponse.getWriter();
   String nombreServlet = getServletName();
   writer.println("Nombre Servlet:" + nombreServlet);
   ServletContext servletContext = getServletContext();
   writer.println("Nombre Server:" + servletContext.getServerInfo());
   writer.println("Contexto Servlet:" + servletContext.getContextPath());
 }
コード例 #21
0
ファイル: WebAppManager.java プロジェクト: kasunbg/jaggery
 public static void clearInterval(
     final Context cx, final Scriptable thisObj, Object[] args, Function funObj)
     throws ScriptException {
   JaggeryContext context = CommonManager.getJaggeryContext();
   ServletContext servletContext = (ServletContext) context.getProperty(Constants.SERVLET_CONTEXT);
   String contextPath = servletContext.getContextPath();
   RhinoTopLevel.clearTimeout(cx, thisObj, args, funObj);
   List<String> taskIds = intervals.get(contextPath);
   taskIds.remove(String.valueOf(args[0]));
 }
コード例 #22
0
  protected void initComplete(ServletContext servletContext) {
    // Get Web Root
    webRoot = servletContext.getContextPath();

    // Check Text resolvers
    if (textResolvers == null) initTextResolvers();

    // done
    log.info("FacesApplication initialization complete");
  }
コード例 #23
0
  public void logoutSesionInvalidate() throws IOException {
    faceContext = FacesContext.getCurrentInstance();

    ExternalContext externalContext = faceContext.getExternalContext();
    ServletContext servletContext = (ServletContext) faceContext.getExternalContext().getContext();
    httpServletRequest = (HttpServletRequest) faceContext.getExternalContext().getRequest();
    HttpSession session = httpServletRequest.getSession();
    session.invalidate();
    String redirectPath = "/faces/ositran/logueo.xhtml";
    externalContext.redirect(servletContext.getContextPath() + redirectPath);
  }
コード例 #24
0
 public void listarUsuarios() {
   try {
     FacesContext context = FacesContext.getCurrentInstance();
     ServletContext servletContext =
         (ServletContext) context.getCurrentInstance().getExternalContext().getContext();
     context
         .getExternalContext()
         .redirect(servletContext.getContextPath() + "/faces/usuario/List.xhtml");
   } catch (IOException ex) {
     Logger.getLogger(HomeManagedBean.class.getName()).log(Level.SEVERE, null, ex);
   }
 }
コード例 #25
0
  public void testDeployedSkinModules() {
    assertNotNull(skinService.getAvailableSkinNames());
    assertTrue(skinService.getAvailableSkinNames().contains("TestSkin"));

    Collection<SkinConfig> skinConfigs = skinService.getPortalSkins("TestSkin");
    assertNotNull(skinConfigs);

    SkinConfig portalSkin = null;
    for (SkinConfig config : skinConfigs) {
      if ("TestSkin".equals(config.getName())) {
        portalSkin = config;
        break;
      }
    }
    assertNotNull(portalSkin);
    assertEquals(
        mockServletContext.getContextPath() + "/skin/Stylesheet.css", portalSkin.getCSSPath());

    SkinConfig firstPortletSkin = skinService.getSkin("mockwebapp/FirstPortlet", "TestSkin");
    assertNotNull(firstPortletSkin);
    assertEquals(
        mockServletContext.getContextPath() + "/skin/portlet/FirstPortlet/Stylesheet.css",
        firstPortletSkin.getCSSPath());
  }
コード例 #26
0
ファイル: WebAppManager.java プロジェクト: kasunbg/jaggery
 public static String setInterval(
     final Context cx, final Scriptable thisObj, Object[] args, Function funObj)
     throws ScriptException {
   JaggeryContext context = CommonManager.getJaggeryContext();
   ServletContext servletContext = (ServletContext) context.getProperty(Constants.SERVLET_CONTEXT);
   String contextPath = servletContext.getContextPath();
   String taskId = RhinoTopLevel.setInterval(cx, thisObj, args, funObj);
   List<String> taskIds = intervals.get(contextPath);
   if (taskIds == null) {
     taskIds = new ArrayList<String>();
     intervals.put(contextPath, taskIds);
   }
   taskIds.add(taskId);
   return taskId;
 }
コード例 #27
0
  protected String checkLinkPath(String link) {
    if (StringUtils.isNullOrEmpty(link) || link.startsWith("http") || link.startsWith("https")) {
      return link;
    }

    ServletContext servletContext =
        ComponentProvider.getInstance().getComponent(ServletContext.class);

    if (!link.startsWith("/")) {
      link = String.format("/%s", link);
    }

    String url = String.format("%s%s", servletContext.getContextPath(), link);
    return url;
  }
コード例 #28
0
  public void contextInitialized(ServletContextEvent event) {

    if (AbortStartup.isStartupAborted(event.getServletContext())) {
      return;
    }

    ServletContext sc = event.getServletContext();
    sc.setAttribute("themeToConfigMap", new HashMap<String, Configuration>());
    BaseTemplateModel.setServletContext(sc);
    FreemarkerComponentGenerator.setServletContext(sc);
    UrlBuilder.contextPath = sc.getContextPath();

    FreemarkerConfigurationLoader loader = new FreemarkerConfigurationLoader(sc);

    log.info("Freemarker templating system initialized.");
  }
コード例 #29
0
  @Override
  public void init(FilterConfig filterConfig) throws ServletException {
    if (System.getProperty("pippo.hideLogo") == null) {
      log.info(PippoUtils.getPippoLogo());
    }

    // check for runtime mode in filter init parameter
    String mode = filterConfig.getInitParameter(MODE_PARAM);
    if (!StringUtils.isNullOrEmpty(mode)) {
      System.setProperty(PippoConstants.SYSTEM_PROPERTY_PIPPO_MODE, mode);
    }

    if (application == null) {
      createApplication(filterConfig);
      log.debug("Created application '{}'", application);
    }

    ServletContext servletContext = filterConfig.getServletContext();
    application.setServletContext(servletContext);

    try {
      String contextPath = StringUtils.addStart(servletContext.getContextPath(), "/");
      application.getRouter().setContextPath(contextPath);

      if (filterPath == null) {
        initFilterPath(filterConfig);
      }
      String applicationPath =
          StringUtils.addEnd(contextPath, "/") + StringUtils.removeStart(filterPath, "/");
      application.getRouter().setApplicationPath(applicationPath);

      if (!contextPath.equals(applicationPath)) {
        log.debug("Context path is '{}'", contextPath);
      }
      log.debug("Serving application on path '{}'", applicationPath);

      log.debug("Initializing Route Dispatcher");
      routeDispatcher = new RouteDispatcher(application);
      routeDispatcher.init();

      String runtimeMode = application.getRuntimeMode().toString().toUpperCase();
      log.info("Pippo started ({})", runtimeMode);
    } catch (Exception e) {
      destroy();
      throw new ServletException(e);
    }
  }
コード例 #30
0
  // 压缩
  @RequestMapping("compress")
  public String compress(
      @RequestParam(value = "parentPath") String parentPath,
      @RequestParam(value = "paths") String[] paths,
      RedirectAttributes redirectAttributes)
      throws IOException {

    String rootPath = sc.getRealPath(ROOT_DIR);
    parentPath = URLDecoder.decode(parentPath, Constants.ENCODING);

    Date now = new Date();
    String pattern = "yyyyMMddHHmmss";

    String compressPath =
        parentPath
            + File.separator
            + "[系统压缩]"
            + DateFormatUtils.format(now, pattern)
            + "-"
            + System.nanoTime()
            + ".zip";

    for (int i = 0, l = paths.length; i < l; i++) {
      String path = paths[i];
      path = URLDecoder.decode(path, Constants.ENCODING);
      paths[i] = rootPath + File.separator + path;
    }

    try {
      CompressUtils.zip(rootPath + File.separator + compressPath, paths);
      String msg =
          "压缩成功,<a href='%s/%s?path=%s' target='_blank' class='btn btn-primary'>点击下载</a>,下载完成后,请手工删除生成的压缩包";
      redirectAttributes.addFlashAttribute(
          Constants.MESSAGE,
          String.format(
              msg,
              sc.getContextPath(),
              viewName("download"),
              URLEncoder.encode(compressPath, Constants.ENCODING)));

    } catch (Exception e) {
      redirectAttributes.addFlashAttribute(Constants.ERROR, e.getMessage());
    }

    redirectAttributes.addAttribute("path", URLEncoder.encode(parentPath, Constants.ENCODING));
    return redirectToUrl(viewName("list"));
  }