Package com.dotcms.notifications.bean

Examples of com.dotcms.notifications.bean.Notification


                    APILocator.getTimeMachineAPI().startTimeMachine(dhosts, dlangs,inc);

                    try {
                        //Create a new notification to inform the snapshot was created
                        String notificationMessage = LanguageUtil.get( getUser().getLocale(), "TIMEMACHINE-SNAPSHOT-CREATED" );
                        Notification notification = new Notification( notificationMessage, NotificationLevel.INFO, getUser().getUserId() );
                        APILocator.getNotificationAPI().saveNotification( notification );
                    } catch ( Exception e ) {
                        Logger.error( this, "Error creating notification after creation of the Time machine Snapshot.", e );
                    }
View Full Code Here


  public Notification findNotification(String notificationId) throws DotDataException {
      DotConnect dc = new DotConnect();
    dc.setSQL("select * from notification where id = ?");
    dc.addParam(notificationId);

    Notification n = null;
    List<Map<String, Object>> results = dc.loadObjectResults();

    if(results!=null && !results.isEmpty()) {
      Map<String, Object> row = results.get(0);
      n = new Notification();
      n.setId((String)row.get("id"));
      n.setMessage((String)row.get("message"));
      n.setType(NotificationType.valueOf((String)row.get("notification_type")));
      n.setLevel(NotificationLevel.valueOf((String)row.get("notification_level")));
      n.setUserId((String)row.get("user_id"));
      n.setTimeSent((Date)row.get("time_sent"));
      n.setWasRead((DbConnectionFactory.isDBTrue(row.get("was_read").toString())));
    }

    return n;
  }
View Full Code Here

    List<Map<String, Object>> results = dc.loadObjectResults();
    List<Notification> notifications = new ArrayList<Notification>();

    for (Map<String, Object> row : results) {
      Notification n = new Notification();
      n.setId((String)row.get("id"));
      n.setMessage((String)row.get("message"));
      n.setType(NotificationType.valueOf((String)row.get("notification_type")));
      n.setLevel(NotificationLevel.valueOf((String)row.get("notification_level")));
      n.setUserId((String)row.get("user_id"));
      n.setTimeSent((Date)row.get("time_sent"));
      n.setWasRead((DbConnectionFactory.isDBTrue(row.get("was_read").toString())));
      notifications.add(n);
    }

    return notifications;
  }
View Full Code Here


  @Test
  public void testSaveDeleteNotification() throws Exception {
    User sysuser=APILocator.getUserAPI().getSystemUser();
    Notification n = new Notification("NotificationTest1", NotificationLevel.ERROR, sysuser.getUserId());
    n.setId(UUID.randomUUID().toString());

    try {
      HibernateUtil.startTransaction();
      APILocator.getNotificationAPI().saveNotification(n);
      Notification lastest = APILocator.getNotificationAPI().findNotification(n.getId());
      assertTrue(n.getMessage().equals(lastest.getMessage()));

      APILocator.getNotificationAPI().deleteNotification(lastest.getId());
      assertNull(APILocator.getNotificationAPI().findNotification(lastest.getId()));
      HibernateUtil.commitTransaction();
    } catch (DotDataException e) {
      try {
        HibernateUtil.rollbackTransaction();
      } catch (DotHibernateException e1) {
View Full Code Here

    User sysuser=APILocator.getUserAPI().getSystemUser();

    try {
      HibernateUtil.startTransaction();
      for(int i=0; i<10; i++) {
        Notification n = new Notification("NotificationTest"+i, NotificationLevel.ERROR, sysuser.getUserId());
        n.setId(UUID.randomUUID().toString());
        APILocator.getNotificationAPI().saveNotification(n);
      }

      assertTrue(APILocator.getNotificationAPI().getNewNotificationsCount(sysuser.getUserId())==10);
View Full Code Here

    try {
      HibernateUtil.startTransaction();

      for(int i=0; i<10; i++) {
        Notification n = new Notification("NotificationTest"+i, NotificationLevel.ERROR, sysuser.getUserId());
        n.setId(UUID.randomUUID().toString());
        APILocator.getNotificationAPI().saveNotification(n);
      }

      List<Notification> notifications = APILocator.getNotificationAPI().getNotifications(sysuser.getUserId(), 0, 5);
      assertTrue(notifications.size()==5);
View Full Code Here

        offset += limit;
        contenletSearchList = contentletAPI.searchIndex(luceneQuery, limit, offset, "random", user, false);
      }
      //Send Notification
      String notificationMessage = LanguageUtil.get(user.getLocale(), "notifications_structure_identifiers_updated");
      Notification n = new Notification(notificationMessage, NotificationLevel.INFO, user.getUserId());
      APILocator.getNotificationAPI().saveNotification(n);
     
    } catch (DotDataException e) {
      Logger.error(this, e.getMessage(), e);
      throw new DotRuntimeException(e.getMessage(), e);
View Full Code Here

        } catch (Exception e) {
          // send notification
          try {
            String errorMessage = LanguageUtil.format(user.getLocale(), "notifications_host_deletion_error",new String[]{host.getHostname()},false);
            errorMessage += e.getMessage();
            Notification n = new Notification(errorMessage, NotificationLevel.ERROR, user.getUserId());
            APILocator.getNotificationAPI().saveNotification(n);

          } catch (LanguageException e1) {
            Logger.error(HostAPIImpl.class, "error formating notification", e);
          } catch (DotDataException e1) {
View Full Code Here

        } catch (Exception e) {
          // send notification
          try {
            String errorMessage = LanguageUtil.format(user.getLocale(), "notifications_host_deletion_error",new String[]{host.getHostname()},false);
            errorMessage += e.getMessage();
            Notification n = new Notification(errorMessage, NotificationLevel.ERROR, user.getUserId());
            APILocator.getNotificationAPI().saveNotification(n);

          } catch (LanguageException e1) {
            Logger.error(HostAPIImpl.class, "error formating notification", e);
          } catch (DotDataException e1) {
View Full Code Here

            }
            if(cannotDelete && con.getMap().get(Contentlet.DONT_VALIDATE_ME) == null){
                Logger.warn(this, "Cannot delete content that has a working copy in another language");
               
                String notificationMessage = "Cannot delete content with inode: "+ con.getInode() +" that has a working copy in another language";
              Notification n = new Notification(notificationMessage, NotificationLevel.INFO, user.getUserId());
              APILocator.getNotificationAPI().saveNotification(n);
             
                perCons.remove(con);
                break;
            } else {
View Full Code Here

TOP

Related Classes of com.dotcms.notifications.bean.Notification

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.