private void removeProperty(Session session, String path, String property, String value) { final boolean stats = NotificationContextFactory.getInstance().getStatistics().isStatisticsEnabled(); try { Node node = (Node) session.getItem(path); List<String> values = NotificationUtils.valuesToList(node.getProperty(property).getValues()); if (values.contains(value)) { values.remove(value); if (values.isEmpty()) { values.add(""); } node.setProperty(property, values.toArray(new String[values.size()])); node.save(); // record entity update here if (stats) { NotificationContextFactory.getInstance() .getStatisticsCollector() .updateEntity(NTF_MESSAGE); } } } catch (Exception e) { LOG.warn(String.format("Failed to remove property %s of value %s on node ", property, value)); } }
private NotificationInfo fillModel(Node node) throws Exception { if (node == null) return null; NotificationInfo message = NotificationInfo.instance() .setFrom(node.getProperty(NTF_FROM).getString()) .setOrder(Integer.valueOf(node.getProperty(NTF_ORDER).getString())) .key(node.getProperty(NTF_PROVIDER_TYPE).getString()) .setOwnerParameter(node.getProperty(NTF_OWNER_PARAMETER).getValues()) .setSendToDaily( NotificationUtils.valuesToArray(node.getProperty(NTF_SEND_TO_DAILY).getValues())) .setSendToWeekly( NotificationUtils.valuesToArray(node.getProperty(NTF_SEND_TO_WEEKLY).getValues())) .setLastModifiedDate(node.getProperty(EXO_LAST_MODIFIED_DATE).getDate()) .setId(node.getName()); return message; }