Exemplo n.º 1
0
 /**
  * 同步模板资源
  *
  * @return
  */
 public String syncRes() {
   if (site != null
       && site.getIndextemplet() != null
       && site.getIndextemplet().trim().length() > 0
       && site.getId() != null
       && site.getId().trim().length() > 0) {
     templet = templetService.findById(site.getIndextemplet());
     site = siteService.findById(site.getId());
     if (site != null && templet != null) {
       // 复制模板文件夹下resources文件夹到此站点
       try {
         FileUtil.copyDirectiory(
             getHttpRequest().getRealPath("/") + "/templet/" + templet.getId() + "/resources",
             getHttpRequest().getRealPath("/") + "/site/" + site.getSourcepath() + "/resources");
         write("操作成功", "UTF-8");
       } catch (IOException e) {
         e.printStackTrace();
         write("操作失败:" + e.getMessage(), "UTF-8");
       }
     } else {
       write("操作失败:没有传递正确的参数", "UTF-8");
     }
   } else {
     write("操作失败:没有传递正确的参数", "UTF-8");
   }
   return null;
 }
Exemplo n.º 2
0
 /**
  * 删除
  *
  * @return
  */
 public String del() {
   try {
     if (site != null && site.getId() != null && site.getId().trim().length() > 0) {
       site = siteService.findById(site.getId());
       siteService.del(site.getId(), getHttpRequest());
       OperLogUtil.log(getLoginName(), "删除站点 " + site.getName(), getHttpRequest());
       write("<script>alert('操作成功');parent.location.reload();</script>", "utf-8");
     }
   } catch (Exception e) {
     write(e.toString(), "utf-8");
   }
   return null;
 }
Exemplo n.º 3
0
 /**
  * 添加页面
  *
  * @return
  */
 public String edit() {
   if (site != null && site.getId() != null && site.getId().trim().length() > 0) {
     site = siteService.findById(site.getId());
     // 设置模板名称
     if (site.getIndextemplet() != null && site.getIndextemplet().trim().length() > 0) {
       templet = templetService.findById(site.getIndextemplet());
       if (templet != null) {
         site.setIndextempletName(templet.getName());
       }
     }
     init("htmlquartzService");
     htmlquartz = htmlquartzService.findBySiteid(site.getId());
   }
   return "edit";
 }
Exemplo n.º 4
0
 /**
  * 改变所属站点
  *
  * @return
  */
 public String sitePar() {
   try {
     if (site != null && site.getId() != null && site.getId().trim().length() > 0) {
       if (site.getParid() != null && site.getParid().trim().length() > 0) {
         if ("root".equals(site.getParid())) {
           // 改变为一级站点
           site = siteService.findById(site.getId());
           if (site != null) {
             site.setParid("");
             siteService.update(site);
             OperLogUtil.log(
                 getLoginName(), "改变站点 " + site.getName() + " 为 一级站点", getHttpRequest());
             write("<script>alert('操作成功');parent.location.reload();</script>", "UTF-8");
           }
         } else {
           Site parSite = siteService.findById(site.getParid());
           if (parSite != null) {
             site = siteService.findById(site.getId());
             if (site != null) {
               site.setParid(parSite.getId());
               siteService.update(site);
               OperLogUtil.log(
                   getLoginName(),
                   "改变站点 " + site.getName() + " 的所属站点为 " + parSite.getName(),
                   getHttpRequest());
               write("<script>alert('操作成功');parent.location.reload();</script>", "UTF-8");
             }
           }
         }
       }
     }
   } catch (Exception e) {
     write(e.toString(), "UTF-8");
   }
   return null;
 }
Exemplo n.º 5
0
 /**
  * 单个站点授权页面
  *
  * @return
  */
 public String authPage() {
   if (site != null
       && site.getId().trim().length() > 0
       && role != null
       && role.getId().trim().length() > 0) {
     site = siteService.findById(site.getId());
     // 判断是否有站点管理权限
     roleSite = roleSiteService.findBySiteRole(site.getId(), role.getId());
     channelTreeContent = new StringBuffer();
     channelService.createTree(
         channelTreeContent,
         (isAdminLogin() ? "admin" : getLoginRoleIdsSql()),
         site.getId(),
         role.getId(),
         "par",
         null,
         null,
         "checkbox");
   }
   return "authPage";
 }
Exemplo n.º 6
0
 /**
  * 建站向导 初始化站点
  *
  * @return
  */
 public String guideInit() {
   try {
     if (site.getId() != null
         && site.getId().trim().length() > 0
         && site.getIndextemplet() != null
         && site.getIndextemplet().trim().length() > 0) {
       site = siteService.findById(site.getId());
       templet = templetService.findById(site.getIndextemplet());
       if (site != null && templet != null) {
         init("templetChannelService");
         templetChannelService.importSiteChannels(templet, site);
         init("templetLinkService");
         templetLinkService.importSiteLinks(templet, site);
       }
     }
     return guideCompleted();
   } catch (Exception e) {
     e.printStackTrace();
     showMessage = "站点初始化失败:" + e.getMessage();
     return showMessage(showMessage, forwardUrl, forwardSeconds);
   }
 }
Exemplo n.º 7
0
  /**
   * 设置页面处理
   *
   * @return
   */
  public String configDo() {
    try {
      if (site.getName() != null) {
        site.setName(site.getName().replace("'", "‘").replace("\"", "“"));
      }
      if (site.getId() != null && site.getId().trim().length() > 0) {
        // 更新
        Site oldSite = siteService.findById(site.getId());
        // 如果原来有和现在的logo不同则删除原来的logo文件
        if (!oldLogo.equals(oldSite.getLogo())) {
          if (oldSite.getLogo() != null && oldSite.getLogo().trim().length() > 0) {
            FileUtil.del(getHttpRequest().getRealPath("/") + oldSite.getLogo().trim());
          }
        } else {
          site.setLogo(oldLogo);
        }
        if (logo != null) {
          // 生成目标文件
          String root = getHttpRequest().getRealPath("/");
          String ext = FileUtil.getExt(logoFileName).toLowerCase();
          if (!".jpg".equals(ext)
              && !".jpeg".equals(ext)
              && !".gif".equals(ext)
              && !".png".equals(ext)) {
            write(
                "<script>alert('logo只能上传jpg,jpeg,gif,png格式的图片!');history.back();</script>", "GBK");
            return null;
          }
          String id = UUID.randomUUID().toString();
          File targetFile = new File(root + "/upload/" + site.getId() + "/" + id + ext);
          File folder = new File(root + "/upload/" + site.getId() + "/");
          if (!folder.exists()) {
            folder.mkdirs();
          }
          if (!targetFile.exists()) {
            targetFile.createNewFile();
          }
          // 复制到目标文件
          FileUtil.copy(logo, targetFile);

          // 生成访问地址
          site.setLogo("/upload/" + site.getId() + "/" + id + ext);
        }
        if (site.getIndextemplet() != null
            && site.getIndextemplet().trim().length() > 0
            && !site.getIndextemplet().equals(oldSite.getIndextemplet())) {
          templet = templetService.findById(site.getIndextemplet());
          if (templet != null) {
            // 复制模板文件夹下resources文件夹到此站点
            try {
              FileUtil.copyDirectiory(
                  getHttpRequest().getRealPath("/") + "/templet/" + templet.getId() + "/resources",
                  getHttpRequest().getRealPath("/")
                      + "/site/"
                      + site.getSourcepath()
                      + "/resources");
            } catch (IOException e) {
              e.printStackTrace();
            }
          }
        }
        siteService.update(site);
        // 处理静态化调度
        init("htmlquartzService");
        if (htmlquartzService.findBySiteid(site.getId()) != null) {
          htmlquartzService.update(htmlquartz);
        } else {
          htmlquartz.setSiteid(site.getId());
          htmlquartzService.insert(htmlquartz);
        }
        siteService.updateHtmlSiteJob(getServletContext(), site, htmlquartz);
        getHttpSession().setAttribute("manageSite", site);
        OperLogUtil.log(getLoginName(), "站点设置 " + site.getName(), getHttpRequest());
      }
      write(
          "<script>alert('操作成功');location.href='site_config.do?pageFuncId="
              + pageFuncId
              + "';</script>",
          "GBK");
    } catch (Exception e) {
      DBProException(e);
      write(e.toString(), "GBK");
    }

    return null;
  }
Exemplo n.º 8
0
  /**
   * 编辑处理
   *
   * @return
   */
  public String editDo() {
    try {
      if (site.getName() != null) {
        site.setName(site.getName().replace("'", "‘").replace("\"", "“"));
      }
      if (site.getId() != null && site.getId().trim().length() > 0) {
        // 更新
        Site oldSite = siteService.findById(site.getId());
        // 如果原来有和现在的logo不同则删除原来的logo文件
        if (!oldLogo.equals(oldSite.getLogo())) {
          if (oldSite.getLogo() != null && oldSite.getLogo().trim().length() > 0) {
            FileUtil.del(
                getHttpRequest().getRealPath("/").replace("\\", "/") + oldSite.getLogo().trim());
          }
        } else {
          site.setLogo(oldLogo);
        }
        if (logo != null) {
          // 生成目标文件
          String root = getHttpRequest().getRealPath("/").replace("\\", "/");
          String ext = FileUtil.getExt(logoFileName).toLowerCase();
          if (!".jpg".equals(ext)
              && !".jpeg".equals(ext)
              && !".gif".equals(ext)
              && !".png".equals(ext)) {
            write(
                "<script>alert('logo只能上传jpg,jpeg,gif,png格式的图片!');history.back();</script>", "GBK");
            return null;
          }
          String id = UUID.randomUUID().toString();
          File targetFile = new File(root + "/upload/" + site.getId() + "/" + id + ext);
          File folder = new File(root + "/upload/" + site.getId() + "/");
          if (!folder.exists()) {
            folder.mkdirs();
          }
          if (!targetFile.exists()) {
            targetFile.createNewFile();
          }
          // 复制到目标文件
          FileUtil.copy(logo, targetFile);

          // 生成访问地址
          site.setLogo("/upload/" + site.getId() + "/" + id + ext);
        }
        if (site.getIndextemplet() != null
            && site.getIndextemplet().trim().length() > 0
            && !site.getIndextemplet().equals(oldSite.getIndextemplet())) {
          templet = templetService.findById(site.getIndextemplet());
          if (templet != null) {
            // 复制模板文件夹下resources文件夹到此站点
            try {
              FileUtil.copyDirectiory(
                  getHttpRequest().getRealPath("/") + "/templet/" + templet.getId() + "/resources",
                  getHttpRequest().getRealPath("/")
                      + "/site/"
                      + site.getSourcepath()
                      + "/resources");
            } catch (IOException e) {
              e.printStackTrace();
            }
          }
        }
        siteService.update(site);
        // 处理静态化调度
        init("htmlquartzService");
        if (htmlquartzService.findBySiteid(site.getId()) != null) {
          htmlquartzService.update(htmlquartz);
        } else {
          htmlquartz.setSiteid(site.getId());
          htmlquartzService.insert(htmlquartz);
        }
        siteService.updateHtmlSiteJob(getServletContext(), site, htmlquartz);
        OperLogUtil.log(getLoginName(), "更新站点 " + site.getName(), getHttpRequest());
      } else {
        // 添加
        if (siteService.haveSourcePath(site.getSourcepath())) {
          write("<script>alert('此源文件目录已存在');history.back();</script>", "GBK");
          return null;
        }
        if (logo != null) {
          // 生成目标文件
          String root = getHttpRequest().getRealPath("/").replace("\\", "/");
          String ext = FileUtil.getExt(logoFileName).toLowerCase();
          if (!".jpg".equals(ext)
              && !".jpeg".equals(ext)
              && !".gif".equals(ext)
              && !".png".equals(ext)) {
            write(
                "<script>alert('logo只能上传jpg,jpeg,gif,png格式的图片!');history.back();</script>", "GBK");
            return null;
          }
          String id = UUID.randomUUID().toString();
          File targetFile = new File(root + "/upload/" + site.getId() + "/" + id + ext);
          File folder = new File(root + "/upload/" + site.getId() + "/");
          if (!folder.exists()) {
            folder.mkdirs();
          }
          if (!targetFile.exists()) {
            targetFile.createNewFile();
          }
          // 复制到目标文件
          FileUtil.copy(logo, targetFile);
          // 生成访问地址
          site.setLogo("/upload/" + site.getId() + "/" + id + ext);
        }
        // 创建源文件目录
        FileUtil.mkdir(getHttpRequest().getRealPath("/") + "site/" + site.getSourcepath());
        boolean isinit = false;
        if (site.getIndextemplet() != null && site.getIndextemplet().trim().length() > 0) {
          templet = templetService.findById(site.getIndextemplet());
          if (templet != null) {
            // 复制模板文件夹下resources文件夹到此站点
            try {
              FileUtil.copyDirectiory(
                  getHttpRequest().getRealPath("/") + "/templet/" + templet.getId() + "/resources",
                  getHttpRequest().getRealPath("/")
                      + "/site/"
                      + site.getSourcepath()
                      + "/resources");
              // 判断模板是否有初始化数据
              init("templetChannelService");
              if (templetChannelService.count(templet.getId()) > 0) {
                isinit = true;
              } else {
                init("templetLinkService");
                if (templetLinkService.count(templet.getId()) > 0) {
                  isinit = true;
                }
              }
            } catch (IOException e) {
              e.printStackTrace();
            }
          }
        }
        siteService.insert(site);
        // 处理静态化调度
        init("htmlquartzService");
        htmlquartz.setSiteid(site.getId());
        htmlquartzService.insert(htmlquartz);
        siteService.updateHtmlSiteJob(getServletContext(), site, htmlquartz);
        OperLogUtil.log(getLoginName(), "添加站点 " + site.getName(), getHttpRequest());
        if (isinit) {
          return "init";
        }
      }
      write(
          "<script>alert('操作成功');location.href='site_edit.do?site.id="
              + site.getId()
              + "';</script>",
          "GBK");
    } catch (Exception e) {
      DBProException(e);
      write(e.toString(), "GBK");
    }

    return null;
  }
Exemplo n.º 9
0
 /**
  * 建站向导 创建栏目
  *
  * @return
  */
 public String guideCompleted() {
   if (site.getId() != null && site.getId().trim().length() > 0) {
     site = siteService.findById(site.getId());
   }
   return "guideCompleted";
 }
Exemplo n.º 10
0
 /**
  * 建站向导 选择模板
  *
  * @return
  */
 public String guideTemplet() {
   if (site != null && StringUtils.isNotEmpty(site.getId())) {
     site = siteService.findById(site.getId());
     if (site != null) {
       if ("0".equals(type)) {
         // 选择模板
         site.setIndextemplet(templet.getId());
       } else {
         // 创建新模板
         init("templetService");
         templet.setState("1");
         templet.setAdduser(getLoginAdmin().getId());
         site.setIndextemplet(templetService.add(templet));
         String realPath = getHttpRequest().getRealPath("/");
         try {
           FileUtil.copyDirectiory(
               realPath + "/templet/default", realPath + "/templet/" + templet.getId());
         } catch (IOException e) {
           e.printStackTrace();
           showMessage = e.getMessage();
           return showMessage(showMessage, forwardUrl, forwardSeconds);
         }
       }
       // 创建源文件目录
       FileUtil.mkdir(getHttpRequest().getRealPath("/") + "site/" + site.getSourcepath());
       boolean isinit = false;
       if (site.getIndextemplet() != null && site.getIndextemplet().trim().length() > 0) {
         templet = templetService.findById(site.getIndextemplet());
         if (templet != null) {
           // 复制模板文件夹下resources文件夹到此站点
           try {
             FileUtil.copyDirectiory(
                 getHttpRequest().getRealPath("/") + "/templet/" + templet.getId() + "/resources",
                 getHttpRequest().getRealPath("/")
                     + "/site/"
                     + site.getSourcepath()
                     + "/resources");
             // 判断模板是否有初始化数据
             init("templetChannelService");
             if (templetChannelService.count(templet.getId()) > 0) {
               isinit = true;
             } else {
               init("templetLinkService");
               if (templetLinkService.count(templet.getId()) > 0) {
                 isinit = true;
               }
             }
           } catch (IOException e) {
             e.printStackTrace();
           }
         }
       }
       siteService.update(site);
       OperLogUtil.log(getLoginName(), "添加站点 " + site.getName(), getHttpRequest());
       if (isinit) {
         return "guideInit";
       }
       return guideCompleted();
     } else {
       showMessage = "没有找到此站点";
       return showMessage(showMessage, forwardUrl, forwardSeconds);
     }
   } else {
     showMessage = "没有传递站点id参数";
     return showMessage(showMessage, forwardUrl, forwardSeconds);
   }
 }