List of usage examples for com.liferay.portal.kernel.notifications UserNotificationManagerUtil addUserNotificationDefinition
public static void addUserNotificationDefinition(String portletId, UserNotificationDefinition userNotificationDefinition)
From source file:com.liferay.notifications.hook.events.StartupAction.java
License:Open Source License
protected void addUserNotificationDefinitions(String xml, String portletId) throws Exception { Class<?> clazz = getClass(); xml = JavaFieldsParser.parse(clazz.getClassLoader(), xml); Document document = SAXReaderUtil.read(xml); Element rootElement = document.getRootElement(); for (Element definitionElement : rootElement.elements("definition")) { String modelName = definitionElement.elementText("model-name"); long classNameId = 0; if (Validator.isNotNull(modelName)) { classNameId = PortalUtil.getClassNameId(modelName); }//from www .j a va 2s. c om int notificationType = GetterUtil.getInteger(definitionElement.elementText("notification-type")); String description = GetterUtil.getString(definitionElement.elementText("description")); UserNotificationDefinition userNotificationDefinition = new UserNotificationDefinition(portletId, classNameId, notificationType, description); for (Element deliveryTypeElement : definitionElement.elements("delivery-type")) { String name = deliveryTypeElement.elementText("name"); int type = GetterUtil.getInteger(deliveryTypeElement.elementText("type")); boolean defaultValue = GetterUtil.getBoolean(deliveryTypeElement.elementText("default")); boolean modifiable = GetterUtil.getBoolean(deliveryTypeElement.elementText("modifiable")); userNotificationDefinition.addUserNotificationDeliveryType( new UserNotificationDeliveryType(name, type, defaultValue, modifiable)); } UserNotificationManagerUtil.addUserNotificationDefinition(portletId, userNotificationDefinition); } }