Package com.liusoft.dlog4j.beans

Examples of com.liusoft.dlog4j.beans.DiaryBean


   * @throws IOException
   */
  public static void forceDelete(int log_id) throws Exception{
    Session ssn = getSession();
    try{
      DiaryBean log = (DiaryBean)ssn.load(DiaryBean.class, new Integer(log_id));
      beginTransaction();
      //����������ռ����Ӧ�ķ����ռ�����һ
      if(log.getStatus()==DiaryBean.STATUS_NORMAL){
        log.getCatalog().incArticleCount(-1);
      }
      //ɾ����ǩ
      TagDAO.deleteTagByRefId(log_id, TagBean.TYPE_DIARY);
     
      //ɾ������
      FCKUploadFileDAO.deleteFilesByRef(ssn, log.getSite().getId(), log_id,
          DiaryBean.TYPE_DIARY);

      //���в������Ƭ�����ߵ������������һ
      cleanupReplies(ssn, log_id);
     
View Full Code Here


   * @param diary
   */
  public void fill_diary_content(_DiaryBase diary){   
    String text = TextCacheManager.getTextContent(DiaryBean.TYPE_DIARY, diary.getId());
    if(text==null){
      DiaryBean db = DiaryDAO.getDiaryByID(diary.getId());
      diary.setContent(db.getContent());
      if(diary!=null && diary.getStatus()==DiaryBean.STATUS_NORMAL){
        TextCacheManager.updateTextContent(DiaryBean.TYPE_DIARY, diary.getId(), diary.getContent());
      }
    }
    else{
View Full Code Here

    //super.validateClientId(request, diaryForm);
    UserBean loginUser = super.getLoginUser(request, response);
    if (loginUser == null) {
      msgs.add("editlog", new ActionMessage("error.user_not_login"));
    } else {
      DiaryBean diary = DiaryDAO.getDiaryByID(diaryForm.getId());
      if (diary == null) {
        msgs
            .add("editlog", new ActionMessage(
                "error.diary_not_exists"));
      } else if (!DiaryDAO.canUserEditDiary(loginUser, diary)) {
        msgs.add("editlog", new ActionMessage("error.access_deny"));
      } else {
        boolean catalog_can_access = false;
        if (diary.getCatalog().getId() != diaryForm.getCatalogId()) {
          SiteBean site = diary.getSite();
          CatalogBean catalog = null;
          // վ�����Է���վ�ڵ��κη���
          if (site.isOwner(loginUser)) {
            catalog = CatalogDAO.getCatalogByID(diaryForm
                .getCatalogId());
            if (catalog.getSite().getId() == site.getId())
              catalog_can_access = true;
          } else {
            // �г��û��ڸ�վ��ɷ��ʵ��ռǷ���
            List catalogs = CatalogDAO.listCatalogs(site, loginUser, true);
            for (int i = 0; catalogs != null && i < catalogs.size(); i++) {
              CatalogBean t_catalog = (CatalogBean) catalogs
                  .get(i);
              if (t_catalog.getId() == diaryForm.getCatalogId()) {
                catalog = t_catalog;
                catalog_can_access = true;
                break;
              }
            }
          }
          // �����ռ���������
          if (catalog != null) {
            diary.getCatalog().incArticleCount(-1);
            diary.setCatalog(catalog);
            catalog.incArticleCount(1);
          }
        } else
          catalog_can_access = true;
        if (catalog_can_access) {
          SiteBean site = diary.getSite();
          // �����ռ�
          boolean updateTags = false;
          if (!StringUtils.equals(diary.getKeyword(), diaryForm
              .getTags())) {
            updateTags = true;
            if (StringUtils.isNotEmpty(diaryForm.getTags()))
              diary.setKeyword(super.autoFiltrate(site, diaryForm.getTags()));
            else {
              diary.setKeyword(null);
            }
          }
          diary.setTitle(super.autoFiltrate(site,diaryForm.getTitle()));
          if (!StringUtils.equals(diaryForm.getContent(), diary.getContent())) {
            diary.setContent(super.autoFiltrate(site,diaryForm.getContent()));
            diary.setSize(diaryForm.getContent().getBytes().length);
            //�����ı�����(Winter Lau, 2006-5-12)
            if(diary.getStatus() == DiaryBean.STATUS_NORMAL)
              TextCacheManager.updateTextContent(DiaryBean.TYPE_DIARY, diary.getId(), diary.getContent());
          }
          diary.setAuthor(diaryForm.getAuthor());
          if (StringUtils.isNotEmpty(diaryForm.getAuthorUrl()))
            diary.setAuthorUrl(diaryForm.getAuthorUrl());
          diary.setMoodLevel(diaryForm.getMoodLevel());
          if (StringUtils.isNotEmpty(diaryForm.getRefUrl()))
            diary.setRefUrl(diaryForm.getRefUrl());
          diary.setReplyNotify(diaryForm.getNotify());
          diary.setWeather(diaryForm.getWeather());
          diary.setModifyTime(new Date());
          if (diaryForm.getBgSound() != -1) {
            // ��鱳�������Ƿ���Ч
            MusicBean song = MusicDAO.getMusicByID(diaryForm.getBgSound());
            if (song != null
                && song.getSite().getId() == diary.getSite().getId()) {
              diary.setBgSound(song);
            }
          }
          try {
            // �����ϴ�����Ϣ
            pickupUploadFileItems(request, response, loginUser
                .getId(), diary.getSite(), diary.getId(), DiaryBean.TYPE_DIARY);
            DiaryDAO.update(diary, updateTags);
          } catch (Exception e) {
            context().log("update diary failed.", e);
            msgs.add("editlog", new ActionMessage("error.database",
                e.getMessage()));
View Full Code Here

    UserBean loginUser = super.getLoginUser(request, response);
    String msg = null;
    if (loginUser == null) {
      msg = getMessage(request, null, "error.user_not_login");
    } else {
      DiaryBean diary = DiaryDAO.getDiaryByID(diaryForm.getId());
      if (diary == null) {
        msg = getMessage(request, null, "error.diary_not_exists");
      } else if (!DiaryDAO.canUserEditDiary(loginUser, diary)) {
        msg = getMessage(request, null, "error.access_deny");
      } else {
View Full Code Here

    UserBean loginUser = super.getLoginUser(request, response);
    String msg = null;
    if (loginUser == null) {
      msg = getMessage(request, null, "error.user_not_login");
    } else {
      DiaryBean diary = DiaryDAO.getDiaryByID(diaryForm.getId());
      if (diary == null) {
        msg = getMessage(request, null, "error.diary_not_exists");
      } else if (!DiaryDAO.canUserEditDiary(loginUser, diary)) {
        msg = getMessage(request, null, "error.access_deny");
      } else {
View Full Code Here

    UserBean loginUser = super.getLoginUser(request, response);
    String msg = null;
    if (loginUser == null) {
      msg = getMessage(request, null, "error.user_not_login");
    } else {
      DiaryBean diary = DiaryDAO.getDiaryByID(diaryForm.getId());
      if (diary == null) {
        msg = getMessage(request, null, "error.diary_not_exists");
      } else if (!DiaryDAO.canUserEditDiary(loginUser, diary)) {
        msg = getMessage(request, null, "error.access_deny");
      } else {
View Full Code Here

    UserBean loginUser = super.getLoginUser(request, response);
    String msg = null;
    if (loginUser == null) {
      msg = getMessage(request, null, "error.user_not_login");
    } else {
      DiaryBean diary = DiaryDAO.getDiaryByID(diaryForm.getId());
      if (diary == null) {
        msg = getMessage(request, null, "error.diary_not_exists");
      } else if (!DiaryDAO.canUserEditDiary(loginUser, diary)) {
        msg = getMessage(request, null, "error.access_deny");
      } else {
        try {
          DiaryDAO.delete(diary);
          SearchProxy.remove(diary);
          TextCacheManager.deleteTextContent(DiaryBean.TYPE_DIARY, diary.getId());
          msg = getMessage(request, null, "diary.deleted");
        } catch (Exception e) {
          context().log("delete diary failed.", e);
          msg = getMessage(request, null, "error.database", e
              .getMessage());
View Full Code Here

      if (StringUtils.isEmpty(log.getAuthorUrl()))
        log.setAuthorUrl(null);
      if (StringUtils.isEmpty(log.getRefUrl()))
        log.setRefUrl(null);
      // ����JournalBean
      DiaryBean journal = new DiaryBean();
      journal.setOwner(loginUser);
      journal.setSite(site);
      journal.setAuthor(super.autoFiltrate(site, log.getAuthor()));
      journal.setAuthorUrl(log.getAuthorUrl());
      journal.setCatalog(catalog);
      journal.setClient(new ClientInfo(request, log.getClientType()));
      // ������վ�İ�ȫ��־�����Ƿ�����ݽ��������ִʹ���

      String ssn_id = RequestUtils.getDlogSessionId(request);
      boolean wml = WML_IDENTITY.equalsIgnoreCase(identity);
      String content = autoCompileContent(request, site, log.getContent(), loginUser.getId(), ssn_id, wml);
      journal.setContent(content);
      journal.setSize(content.getBytes().length);
      journal.setTitle(super.autoFiltrate(site, log.getTitle()));
      journal.setKeyword(super.autoFiltrate(site, log.getTags()));
     
      journal.setMoodLevel(log.getMoodLevel());
      journal.setRefUrl(log.getRefUrl());
      journal.setReplyNotify(log.getNotify());
      journal.setStatus(DiaryBean.STATUS_NORMAL);
      journal.setWeather(log.getWeather());
      journal.setWriteTime(DateUtils.mergeDateTime(log.getWriteDate(), log.getWriteTime()).getTime());
      Date curTime = new Date();
      if(journal.getWriteTime().after(curTime))
        journal.setWriteTime(curTime);
      // ��鱳�������Ƿ���Ч
      MusicBean song = MusicDAO.getMusicByID(log.getBgSound());
      if (song != null && song.getSite().getId() == site.getId()) {
        journal.setBgSound(song);
      }
      DiaryDAO.create(journal, log.getBookmark() == 1);
      // �����ϴ�����Ϣ
      pickupUploadFileItems(request, response, loginUser.getId(), site, journal
          .getId(), DiaryBean.TYPE_DIARY);

      if (log.getRefUrl() != null) {
        trackBack(journal, log.getRefUrl());
      }
View Full Code Here

      if (site == null) {
        msgs.add("log", new ActionMessage("error.site_not_available"));
        break;
      }
      // �û����������ռǷ��౻����
      DiaryBean journal = DiaryDAO.getDiaryByID(log.getId());
      if (journal == null
          || journal.getStatus() != DiaryBean.STATUS_DRAFT
          || journal.getOwner().getId() != loginUser.getId()) {
        msgs.add("draft", new ActionMessage("error.draft_not_exists"));
        break;
      }
      boolean catalog_can_access = false;
      // վ�����Է���վ�ڵ��κη���
      if (site.isOwner(loginUser)) {
        catalog_can_access = true;
      } else {
        // �г��û��ڸ�վ��ɷ��ʵ��ռǷ���
        List catalogs = CatalogDAO.listCatalogs(site, loginUser, true);
        for (int i = 0; catalogs != null && i < catalogs.size(); i++) {
          CatalogBean t_catalog = (CatalogBean) catalogs.get(i);
          if (t_catalog.getId() == log.getCatalogId()) {
            catalog_can_access = true;
            break;
          }
        }
      }
      if (!catalog_can_access) {
        msgs.add("log", new ActionMessage("error.catalog_deny",
            new Integer(log.getCatalogId())));
        break;
      }
      // ��ȡ�����²ݸ����Ȼ���״̬��Ϊ����
      journal.setClient(new ClientInfo(request, log.getClientType()));
      journal.setViewCount(0);
      journal.setStatus(DiaryBean.STATUS_NORMAL);
      journal.setWriteTime(new Date());
      DiaryDAO.flush();
      break;
    }
    if (!msgs.isEmpty()) {
      saveMessages(request, msgs);
View Full Code Here

        msgs.add("log", new ActionMessage("error.catalog_deny",
            new Integer(log.getCatalogId())));
        break;
      }
      // �û����������ռǷ��౻����
      DiaryBean journal = DiaryDAO.getDiaryByID(log.getId());
      if (journal == null
          || journal.getStatus() != DiaryBean.STATUS_DRAFT) {
        msgs.add("draft", new ActionMessage("error.draft_not_exists"));
        break;
      }
      // ��鱳�������Ƿ���Ч
      MusicBean song = MusicDAO.getMusicByID(log.getBgSound());
      if (song != null && song.getSite().getId() == site.getId()) {
        journal.setBgSound(song);
      }
      if (StringUtils.isEmpty(log.getWeather()))
        journal.setWeather(DEFAULT_WEATHER);
      else
        journal.setWeather(log.getWeather());
      if (StringUtils.isEmpty(log.getAuthor()))
        journal.setAuthor(loginUser.getNickname());
      else
        journal.setAuthor(log.getAuthor());
      if (StringUtils.isEmpty(log.getTags()))
        journal.setKeyword(null);
      else
        journal.setKeyword(log.getTags());
      if (StringUtils.isEmpty(log.getAuthorUrl()))
        journal.setAuthorUrl(null);
      else
        journal.setAuthorUrl(log.getAuthorUrl());
      if (StringUtils.isEmpty(log.getRefUrl()))
        journal.setRefUrl(null);
      else
        journal.setRefUrl(log.getRefUrl());
      // ��ȡ�����²ݸ����Ȼ���״̬��Ϊ����
      journal.setCatalog(catalog);
      journal.setClient(new ClientInfo(request, log.getClientType()));
      String ssn_id = RequestUtils.getDlogSessionId(request);
      boolean wml = WML_IDENTITY.equalsIgnoreCase(identity);
      String content = autoCompileContent(request, site, log.getContent(), loginUser.getId(), ssn_id, wml);
      journal.setContent(content);
      journal.setSize(content.getBytes().length);
      journal.setMoodLevel(log.getMoodLevel());
      journal.setReplyNotify(log.getNotify());
      journal.setViewCount(0);
      journal.setStatus(DiaryBean.STATUS_NORMAL);
      journal.setTitle(log.getTitle());
      journal.setWriteTime(new Date());
      DiaryDAO.create(journal, log.getBookmark() == 1);
      // �����ϴ�����Ϣ
      pickupUploadFileItems(request, response, loginUser.getId(), site, journal
          .getId(), DiaryBean.TYPE_DIARY);
      break;
    }
    if (!msgs.isEmpty()) {
      saveMessages(request, msgs);
View Full Code Here

TOP

Related Classes of com.liusoft.dlog4j.beans.DiaryBean

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.