public void importGPX(final File file) {
   if (StringUtils.endsWithIgnoreCase(file.getName(), GPX_FILE_EXTENSION)) {
     new ImportGpxFileThread(file, listId, importStepHandler, progressHandler).start();
   } else if (StringUtils.endsWithIgnoreCase(file.getName(), ZIP_FILE_EXTENSION)) {
     new ImportGpxZipFileThread(file, listId, importStepHandler, progressHandler).start();
   } else {
     new ImportLocFileThread(file, listId, importStepHandler, progressHandler).start();
   }
 }
  public static String readFileContent(String fileName, InputStream is) {
    try {
      if (StringUtils.endsWithIgnoreCase(fileName, ".java")) {
        return readFileContent(is, javaFileSettings);
      }

      if (StringUtils.endsWithIgnoreCase(fileName, ".xhtml")) {
        return readFileContent(is, xhtmlFileSettings);
      }

      // Show all files
      return readFileContent(is, new FileContentSettings());
    } catch (Exception e) {
      throw new IllegalStateException("Internal error: file " + fileName + " could not be read", e);
    }
  }
 // 1234567.gpx -> 1234567-wpts.gpx
 static String getWaypointsFileNameForGpxFileName(String name) {
   if (StringUtils.endsWithIgnoreCase(name, GPX_FILE_EXTENSION)
       && (StringUtils.length(name) > GPX_FILE_EXTENSION.length())) {
     return StringUtils.substringBeforeLast(name, ".") + WAYPOINTS_FILE_SUFFIX_AND_EXTENSION;
   } else {
     return null;
   }
 }
 // 1234567.zip -> 1234567.gpx
 static String getGpxFileNameForZipFileName(String name) {
   if (StringUtils.endsWithIgnoreCase(name, ZIP_FILE_EXTENSION)
       && (StringUtils.length(name) > ZIP_FILE_EXTENSION.length())) {
     return StringUtils.substringBeforeLast(name, ".") + GPX_FILE_EXTENSION;
   } else {
     return null;
   }
 }
 public void importGPX(final IAbstractActivity fromActivity, final File file) {
   createProgressDialog(fromActivity);
   if (StringUtils.endsWithIgnoreCase(file.getName(), GPX_FILE_EXTENSION)) {
     new ImportGpxFileThread(file, listId, importStepHandler, progressHandler).start();
   } else {
     new ImportLocFileThread(file, listId, importStepHandler, progressHandler).start();
   }
 }
Example #6
0
  @PostConstruct
  public void init() {
    String genreFileName = PropertyTools.getProperty("yamj3.genre.fileName");
    if (StringUtils.isBlank(genreFileName)) {
      LOG.trace("No valid genre file name configured");
      return;
    }
    if (!StringUtils.endsWithIgnoreCase(genreFileName, "xml")) {
      LOG.warn("Invalid genre file name specified: {}", genreFileName);
      return;
    }

    File xmlFile;
    if (StringUtils.isBlank(FilenameUtils.getPrefix(genreFileName))) {
      // relative path given
      String path = System.getProperty("yamj3.home");
      if (StringUtils.isEmpty(path)) {
        path = ".";
      }
      xmlFile = new File(FilenameUtils.concat(path, genreFileName));
    } else {
      // absolute path given
      xmlFile = new File(genreFileName);
    }

    if (!xmlFile.exists() || !xmlFile.isFile()) {
      LOG.warn("Genres file does not exist: {}", xmlFile.getPath());
      return;
    }
    if (!xmlFile.canRead()) {
      LOG.warn("Genres file not readble: {}", xmlFile.getPath());
      return;
    }

    LOG.debug("Initialize genres from file: {}", xmlFile.getPath());

    try {
      XMLConfiguration c = new XMLConfiguration(xmlFile);

      List<HierarchicalConfiguration> genres = c.configurationsAt("genre");
      for (HierarchicalConfiguration genre : genres) {
        String masterGenre = genre.getString("[@name]");
        List<Object> subGenres = genre.getList("subgenre");
        for (Object subGenre : subGenres) {
          LOG.debug("New genre added to map: {} -> {}", subGenre, masterGenre);
          GENRES_MAP.put(((String) subGenre).toLowerCase(), masterGenre);
        }
      }

      try {
        this.commonStorageService.updateGenresXml(GENRES_MAP);
      } catch (Exception ex) {
        LOG.warn("Failed update genres xml in database", ex);
      }
    } catch (Exception ex) {
      LOG.error("Failed parsing genre input file: " + xmlFile.getPath(), ex);
    }
  }
 // 1234567.gpx -> 1234567-wpts.gpx
 static File getWaypointsFileForGpx(File file) {
   final String name = file.getName();
   if (StringUtils.endsWithIgnoreCase(name, GPX_FILE_EXTENSION)
       && (StringUtils.length(name) > GPX_FILE_EXTENSION.length())) {
     final String wptsName =
         StringUtils.substringBeforeLast(name, ".") + WAYPOINTS_FILE_SUFFIX_AND_EXTENSION;
     return new File(file.getParentFile(), wptsName);
   } else {
     return null;
   }
 }
Example #8
0
 @Override
 protected boolean filenameBelongsToList(final String filename) {
   if (super.filenameBelongsToList(filename)) {
     if (StringUtils.endsWithIgnoreCase(filename, GPXImporter.ZIP_FILE_EXTENSION)) {
       for (IConnector connector : ConnectorFactory.getConnectors()) {
         if (connector.isZippedGPXFile(filename)) {
           return true;
         }
       }
       return false;
     }
     // filter out waypoint files
     return !StringUtils.containsIgnoreCase(filename, GPXImporter.WAYPOINTS_FILE_SUFFIX);
   }
   return false;
 }
Example #9
0
  @Override
  public boolean accept(Path entry) {

    String[] extensions =
        new String[] {
          ".avi", ".mkv", ".mp4", ".mpg", ".mpeg", ".m2ts", ".mov", ".iso", ".divx", ".ts"
        };

    if (Files.isDirectory(entry)) {
      return true;
    }

    for (String extension : extensions) {
      if (StringUtils.endsWithIgnoreCase(entry.getFileName().toString(), extension)) {
        return true;
      }
    }

    return false;
  }
Example #10
0
  @RequestMapping("/jump")
  public void jump(HttpServletRequest request, HttpServletResponse response) {
    logger.debug("---------------------------jump----------------------");
    LoginContext loginContext = RequestUtils.getLoginContext(request);
    if (loginContext == null) {
      try {
        response.sendRedirect(request.getContextPath() + ViewProperties.getString("loginUrl"));
        return;
      } catch (Exception ex) {
      }
    }
    String menuId = request.getParameter("menuId");
    if (menuId != null) {
      menuId = RequestUtils.decodeString(menuId);
    }
    logger.debug("menuId:" + menuId);
    if (menuId != null && StringUtils.isNumeric(menuId)) {
      SysApplication app = sysApplicationService.findById(Long.parseLong(menuId));
      if (app != null) {
        boolean accessable = false;
        if (loginContext.isSystemAdministrator()) {
          accessable = true;
        } else {
          AuthorizeBean bean = new AuthorizeBean();
          SysUser sysUser = bean.getUser(loginContext.getActorId());
          if (sysUser != null) {
            accessable = sysUser.hasApplicationAccess(app.getId());
          }
        }
        logger.debug("accessable:" + accessable);
        if (accessable) {
          try {
            String url = app.getUrl();
            if (url != null) {
              if (!(url.toLowerCase().startsWith("http://")
                  || url.toLowerCase().startsWith("https://"))) {
                if (url.startsWith("/")) {
                  url = request.getContextPath() + url;
                } else {
                  url = request.getContextPath() + "/" + url;
                }
              }
              if (url.indexOf("?") != -1) {
                url = url + "&time=" + System.currentTimeMillis();
              } else {
                url = url + "?time=" + System.currentTimeMillis();
              }

              String key = SystemProperties.getDefaultSecurityKey();

              String actorId = SecurityUtils.encode(key, loginContext.getActorId());

              if (StringUtils.endsWithIgnoreCase(app.getLinkFileName(), ".cpt")) {
                url = SystemConfig.getString("report_service_url");
                String cpt_path = "fileId=" + app.getLinkFileId();
                String dsJson = DBConfiguration.encodeJsonCurrentSystem();
                if (url.indexOf("?") == -1) {
                  url = url + "?q=1";
                }
                url = url + "&" + cpt_path + "&datasourceJson=" + dsJson;
                if (app.getRefId1() != null) {
                  url = url + "&refId1=" + app.getRefId1() + "&treedot_index_id=" + app.getRefId1();
                }
                if (app.getRefId2() != null) {
                  url =
                      url + "&refId2=" + app.getRefId2() + "&treepinfo_index_id=" + app.getRefId2();
                }

                if (StringUtils.isNotEmpty(app.getLinkParam())) {
                  url = url + "&" + app.getLinkParam();
                }
              }

              if (StringUtils.endsWithIgnoreCase(app.getPrintFileName(), ".cpt")) {
                url = url + "&printFileId=" + app.getPrintFileId();
                if (StringUtils.isNotEmpty(app.getPrintParam())) {
                  url = url + "&" + app.getPrintParam();
                }
              }

              url = url + "&security_actorId=" + actorId;
              logger.debug(url);
              response.sendRedirect(url);
            } else {
              return;
            }
          } catch (Exception ex) {
            ex.printStackTrace();
          }
        }
      }
    }
    try {
      request.getRequestDispatcher("/WEB-INF/views/404.jsp").forward(request, response);
    } catch (Exception e) {
    }
  }