Package org.meshcms.util

Examples of org.meshcms.util.Path


  public static WebSite getRootSite(ServletContext sc, boolean alwaysCreate) {
    WebSite rootSite = (WebSite) sc.getAttribute(ROOT_WEBSITE);
   
    if (rootSite == null || alwaysCreate) {
      File rootFile = new File(sc.getRealPath("/"));
      Path cmsPath = new CMSDirectoryFinder(rootFile, false).getCMSPath();
      boolean multisite = false;
      File sitesDir = new File(rootFile, cmsPath + "/sites");
     
      if (sitesDir.isDirectory()) {
        File[] dirs = sitesDir.listFiles();
View Full Code Here


     
      if (chosen == null) {
        chosen = (SiteMap.CodeLocalePair) available.get(0);
      }
     
      return new Path(chosen.getCode());
    }
   
    return null;
  }
View Full Code Here

   * default values if the file doesn't exist.
   */
  public static Configuration load(WebSite webSite) {
    Configuration c = null;
   
    Path configFilePath = webSite.getConfigFilePath();
     
    try {
      c = (Configuration) webSite.loadFromXML(configFilePath);
    } catch (Exception ex) {}

View Full Code Here

  /**
   * Compares two pages. The first criterion is the path of the page: pages
   * are sorted comparing the first different element of the path.
   */
  public int compare(PageInfo pageInfo1, PageInfo pageInfo2) {
    Path path1 = pageInfo1.getPath();
    Path path2 = pageInfo2.getPath();

    if (path1.equals(path2)) { // same path == same page
      return 0;
    }

    if (path1.isRoot()) { // root always come first
      return -1;
    }

    if (path2.isRoot()) { // root always come first
      return 1;
    }

    Path commonPath = path1.getCommonPath(path2);

    if (commonPath.equals(path1)) { // path2 is contained in path1
      return -1;
    }

    if (commonPath.equals(path2)) { // path1 is contained in path2
      return 1;
    }

    // compare the paths up to the first different element. For example, if
    // path1 == /home/subdir/otherdir/page.html, and
    // path2 == /home/subdir/otherpage.html,
    // we compare /home/subdir/otherdir to /home/subdir/otherpage.html
    Path subPath1 = path1.getPartial(commonPath.getElementCount() + 1);
    Path subPath2 = path2.getPartial(commonPath.getElementCount() + 1);
    return compareSameLevel(subPath1, subPath2);
  }
View Full Code Here

      }
    }
  }

  protected boolean preProcessDirectory(File file, Path path) {
    Path targetPath = getTargetPath(path);

    if (targetPath == null) {
      return false;
    }

    File targetDir = targetSite.getFile(targetPath);

    if (targetDir.isFile()) {
      if (targetSite.delete(targetUser, targetPath, false)) {
        write(targetPath + " file deleted");
      } else {
        write(targetPath + " file NOT deleted");
      }
    }

    targetSite.createDir(targetPath);
    File[] targetFiles = targetDir.listFiles();

    if (!path.equals(targetSite.getCMSPath())) {
      for (int i = 0; i < targetFiles.length; i++) {
        File srcFile = new File(file, targetFiles[i].getName());

        if (!((srcFile.isFile() && targetFiles[i].isFile()) ||
            (srcFile.isDirectory() && targetFiles[i].isDirectory()))) {
          Path filePath = targetPath.add(targetFiles[i].getName());

          if (targetSite.delete(targetUser, filePath, true)) {
            write(filePath + " file/folder deleted");
          } else {
            write(filePath + " file/folder NOT deleted");
View Full Code Here

    return true;
  }

  protected void processFile(File file, Path path) {
    Path targetPath = getTargetPath(path);

    if (targetPath == null) {
      return;
    }
View Full Code Here

  private Path getTargetPath(Path sourcePath) {
    if (sourceSite.isSystem(sourcePath)) {
      return null;
    }

    Path targetPath = sourcePath;
    Path sourceCMSPath = sourceSite.getCMSPath();

    if (sourcePath.isContainedIn(sourceCMSPath)) {
      if (!sourcePath.equals(sourceCMSPath)) {
        String elm1 = sourcePath.getElementAt(1);
View Full Code Here

    if (md != null) {
      if (parameters != null) {
        md.parseParameters(parameters);
      }

      Path modulePath = webSite.getModulePath(md.getTemplate());

      if (modulePath != null) {
        md.setPagePath(pagePath);
        md.setModulePath(modulePath);
        md.setDateFormat(date);
        md.setStyle(style);

        String moduleCode = "meshcmsmodule_" + location;
        request.setAttribute(moduleCode, md);

        Path jspPath = modulePath.add(SiteMap.MODULE_INCLUDE_FILE);

        if (WebUtils.verifyJSP(webSite, jspPath)) {
          try {
            pageContext.include("/" + webSite.getServedPath(jspPath) +
                "?modulecode=" + moduleCode);
View Full Code Here

      response.sendError(HttpServletResponse.SC_NOT_FOUND);
      return;
    }

    WebSite webSite = (WebSite) request.getAttribute("webSite");
    Path path = new Path(request.getPathInfo());

    /* if (webSite.isSystem(path)) {
      response.sendError(HttpServletResponse.SC_NOT_FOUND);
      return;
    } */

    File file = webSite.getFile(path);

    if (!file.exists()) {
      response.sendError(HttpServletResponse.SC_NOT_FOUND,
          "File not found on server");
      return;
    }

    response.setContentType("application/x-download");
    String fileName = request.getParameter("filename");

    if (Utils.isNullOrEmpty(fileName)) {
      fileName = path.getLastElement();
    }

    if (!file.isDirectory()) {
      fileName = Utils.removeExtension(fileName);
    }
View Full Code Here

  /**
   * Checks the current thumbnail, and creates it if not available or too old.
   */
  public Path checkAndCreate(WebSite webSite, Path imagePath,
      String thumbnailFileName) {
    Path thumbnailPath = webSite.getGeneratedFilesPath().add(imagePath);
    thumbnailPath = thumbnailPath.add(getClass().getName(), thumbnailFileName);
    File imageFile = webSite.getFile(imagePath);

    if (!imageFile.exists() || imageFile.isDirectory()) {
      return null;
    }
View Full Code Here

TOP

Related Classes of org.meshcms.util.Path

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.