Exemplo n.º 1
0
  @Override
  public AnnouncementsEntry addEntry(
      long userId,
      long classNameId,
      long classPK,
      String title,
      String content,
      String url,
      String type,
      int displayDateMonth,
      int displayDateDay,
      int displayDateYear,
      int displayDateHour,
      int displayDateMinute,
      boolean displayImmediately,
      int expirationDateMonth,
      int expirationDateDay,
      int expirationDateYear,
      int expirationDateHour,
      int expirationDateMinute,
      int priority,
      boolean alert)
      throws PortalException {

    // Entry

    User user = userPersistence.findByPrimaryKey(userId);

    Date displayDate = new Date();

    if (!displayImmediately) {
      displayDate =
          PortalUtil.getDate(
              displayDateMonth,
              displayDateDay,
              displayDateYear,
              displayDateHour,
              displayDateMinute,
              user.getTimeZone(),
              EntryDisplayDateException.class);
    }

    Date expirationDate =
        PortalUtil.getDate(
            expirationDateMonth,
            expirationDateDay,
            expirationDateYear,
            expirationDateHour,
            expirationDateMinute,
            user.getTimeZone(),
            EntryExpirationDateException.class);

    validate(title, content, url);

    long entryId = counterLocalService.increment();

    AnnouncementsEntry entry = announcementsEntryPersistence.create(entryId);

    entry.setCompanyId(user.getCompanyId());
    entry.setUserId(user.getUserId());
    entry.setUserName(user.getFullName());
    entry.setClassNameId(classNameId);
    entry.setClassPK(classPK);
    entry.setTitle(title);
    entry.setContent(content);
    entry.setUrl(url);
    entry.setType(type);
    entry.setDisplayDate(displayDate);
    entry.setExpirationDate(expirationDate);
    entry.setPriority(priority);
    entry.setAlert(alert);

    announcementsEntryPersistence.update(entry);

    // Resources

    resourceLocalService.addResources(
        user.getCompanyId(),
        0,
        user.getUserId(),
        AnnouncementsEntry.class.getName(),
        entry.getEntryId(),
        false,
        false,
        false);

    return entry;
  }
Exemplo n.º 2
0
  @Override
  public AnnouncementsEntry updateEntry(
      long userId,
      long entryId,
      String title,
      String content,
      String url,
      String type,
      int displayDateMonth,
      int displayDateDay,
      int displayDateYear,
      int displayDateHour,
      int displayDateMinute,
      boolean displayImmediately,
      int expirationDateMonth,
      int expirationDateDay,
      int expirationDateYear,
      int expirationDateHour,
      int expirationDateMinute,
      int priority)
      throws PortalException {

    // Entry

    User user = userPersistence.findByPrimaryKey(userId);

    Date displayDate = new Date();

    if (!displayImmediately) {
      displayDate =
          PortalUtil.getDate(
              displayDateMonth,
              displayDateDay,
              displayDateYear,
              displayDateHour,
              displayDateMinute,
              user.getTimeZone(),
              EntryDisplayDateException.class);
    }

    Date expirationDate =
        PortalUtil.getDate(
            expirationDateMonth,
            expirationDateDay,
            expirationDateYear,
            expirationDateHour,
            expirationDateMinute,
            user.getTimeZone(),
            EntryExpirationDateException.class);

    validate(title, content, url);

    AnnouncementsEntry entry = announcementsEntryPersistence.findByPrimaryKey(entryId);

    entry.setTitle(title);
    entry.setContent(content);
    entry.setUrl(url);
    entry.setType(type);
    entry.setDisplayDate(displayDate);
    entry.setExpirationDate(expirationDate);
    entry.setPriority(priority);

    announcementsEntryPersistence.update(entry);

    // Flags

    announcementsFlagLocalService.deleteFlags(entry.getEntryId());

    return entry;
  }