Package org.olat.notifications

Source Code of org.olat.notifications.NotificationsUpgradeManager

/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) frentix GmbH<br>
* http://www.frentix.com<br>
* <p>
*/

package org.olat.notifications;

import java.util.Map;

import org.olat.core.logging.OLATRuntimeException;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.core.util.notifications.NotificationsUpgrade;
import org.olat.core.util.notifications.Publisher;

/**
*
* Description:<br>
*
* <P>
* Initial Date:  7 jan. 2010 <br>
* @author srosse, stephane.rosse@frentix.com
*/
public class NotificationsUpgradeManager {
  private OLog log = Tracing.createLoggerFor(NotificationsUpgradeManager.class);
 
  private Map<String, NotificationsUpgrade> notificationUpgrades;

  public Map<String, NotificationsUpgrade> getNotificationUpgrades() {
    return notificationUpgrades;
  }

  public void setNotificationUpgrades(Map<String, NotificationsUpgrade> notificationUpgrades) {
    this.notificationUpgrades = notificationUpgrades;
  }
 
  public Publisher upgrade(Publisher publisher) {
    if(publisher == null) return null;
    if(publisher.getData() != null && publisher.getData().startsWith("[")) return null;
   
    String type = publisher.getType();
    if (notificationUpgrades == null) {
      throw new OLATRuntimeException("No notification handler configured in the spring configuration. Fix the bean config for " + this.getClass().getName(), null);
    }
   
    NotificationsUpgrade upgrade = notificationUpgrades.get(type);
    if(upgrade == null) {
      log.error("No upgrader for publisher: " + publisher.getType());
      return null;
    }
    return upgrade.ugrade(publisher);
  }
}
TOP

Related Classes of org.olat.notifications.NotificationsUpgradeManager

TOP
Copyright © 2018 www.massapi.com. 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.