use of com.serotonin.m2m2.i18n.TranslatableMessage in project ma-core-public by infiniteautomation.
the class SystemSettingsDwr method sendTestEmail.
@DwrPermission(admin = true)
public Map<String, Object> sendTestEmail(String host, int port, String from, String name, boolean auth, String username, String password, boolean tls, int contentType) {
// Save the settings
saveEmailSettings(host, port, from, name, auth, username, password, tls, contentType);
// Get the web context information
User user = Common.getHttpUser();
Map<String, Object> result = new HashMap<>();
try {
Translations translations = getTranslations();
Map<String, Object> model = new HashMap<>();
model.put("message", new TranslatableMessage("systemSettings.testEmail"));
MangoEmailContent cnt = new MangoEmailContent("testEmail", model, translations, translations.translate("ftl.testEmail"), Common.UTF8);
EmailWorkItem.queueEmail(user.getEmail(), cnt);
result.put("message", new TranslatableMessage("common.testEmailSent", user.getEmail()));
} catch (Exception e) {
result.put("exception", e.getMessage());
}
return result;
}
use of com.serotonin.m2m2.i18n.TranslatableMessage in project ma-core-public by infiniteautomation.
the class M2M2ContextListener method constantsInitialize.
//
//
// Constants
//
private void constantsInitialize(ServletContext ctx) {
ctx.setAttribute("constants.Common.NEW_ID", Common.NEW_ID);
ctx.setAttribute("constants.DataTypes.BINARY", DataTypes.BINARY);
ctx.setAttribute("constants.DataTypes.MULTISTATE", DataTypes.MULTISTATE);
ctx.setAttribute("constants.DataTypes.NUMERIC", DataTypes.NUMERIC);
ctx.setAttribute("constants.DataTypes.ALPHANUMERIC", DataTypes.ALPHANUMERIC);
ctx.setAttribute("constants.DataTypes.IMAGE", DataTypes.IMAGE);
ctx.setAttribute("constants.Permissions.DataPointAccessTypes.NONE", Permissions.DataPointAccessTypes.NONE);
ctx.setAttribute("constants.Permissions.DataPointAccessTypes.READ", Permissions.DataPointAccessTypes.READ);
ctx.setAttribute("constants.Permissions.DataPointAccessTypes.SET", Permissions.DataPointAccessTypes.SET);
ctx.setAttribute("constants.Permissions.DataPointAccessTypes.DATA_SOURCE", Permissions.DataPointAccessTypes.DATA_SOURCE);
ctx.setAttribute("constants.Permissions.DataPointAccessTypes.ADMIN", Permissions.DataPointAccessTypes.ADMIN);
ctx.setAttribute("constants.EventType.EventTypeNames.DATA_POINT", EventType.EventTypeNames.DATA_POINT);
ctx.setAttribute("constants.EventType.EventTypeNames.DATA_SOURCE", EventType.EventTypeNames.DATA_SOURCE);
ctx.setAttribute("constants.EventType.EventTypeNames.SYSTEM", EventType.EventTypeNames.SYSTEM);
ctx.setAttribute("constants.EventType.EventTypeNames.PUBLISHER", EventType.EventTypeNames.PUBLISHER);
ctx.setAttribute("constants.EventType.EventTypeNames.AUDIT", EventType.EventTypeNames.AUDIT);
ctx.setAttribute("constants.SystemEventType.TYPE_SYSTEM_STARTUP", SystemEventType.TYPE_SYSTEM_STARTUP);
ctx.setAttribute("constants.SystemEventType.TYPE_SYSTEM_SHUTDOWN", SystemEventType.TYPE_SYSTEM_SHUTDOWN);
ctx.setAttribute("constants.SystemEventType.TYPE_MAX_ALARM_LEVEL_CHANGED", SystemEventType.TYPE_MAX_ALARM_LEVEL_CHANGED);
ctx.setAttribute("constants.SystemEventType.TYPE_USER_LOGIN", SystemEventType.TYPE_USER_LOGIN);
ctx.setAttribute("constants.SystemEventType.TYPE_SET_POINT_HANDLER_FAILURE", SystemEventType.TYPE_SET_POINT_HANDLER_FAILURE);
ctx.setAttribute("constants.SystemEventType.TYPE_EMAIL_SEND_FAILURE", SystemEventType.TYPE_EMAIL_SEND_FAILURE);
ctx.setAttribute("constants.SystemEventType.TYPE_PROCESS_FAILURE", SystemEventType.TYPE_PROCESS_FAILURE);
ctx.setAttribute("constants.SystemEventType.TYPE_LICENSE_CHECK", SystemEventType.TYPE_LICENSE_CHECK);
ctx.setAttribute("constants.SystemEventType.TYPE_UPGRADE_CHECK", SystemEventType.TYPE_UPGRADE_CHECK);
ctx.setAttribute("constants.AuditEventType.TYPE_DATA_SOURCE", AuditEventType.TYPE_DATA_SOURCE);
ctx.setAttribute("constants.AuditEventType.TYPE_DATA_POINT", AuditEventType.TYPE_DATA_POINT);
ctx.setAttribute("constants.AuditEventType.TYPE_EVENT_DETECTOR", AuditEventType.TYPE_EVENT_DETECTOR);
ctx.setAttribute("constants.AuditEventType.TYPE_EVENT_HANDLER", AuditEventType.TYPE_EVENT_HANDLER);
ctx.setAttribute("constants.UserComment.TYPE_EVENT", UserCommentVO.TYPE_EVENT);
ctx.setAttribute("constants.UserComment.TYPE_POINT", UserCommentVO.TYPE_POINT);
String[] codes = { "common.access.read", "common.access.set", "common.alarmLevel.none", "common.alarmLevel.info", "common.alarmLevel.important", "common.alarmLevel.warning", "common.alarmLevel.urgent", "common.alarmLevel.critical", "common.alarmLevel.lifeSafety", "common.alarmLevel.doNotLog", "common.alarmLevel.ignore", "common.disabled", "common.administrator", "common.user", "common.disabledToggle", "common.enabledToggle", "common.maximize", "common.minimize", "common.loading", "js.help.error", "js.help.related", "js.help.lastUpdated", "common.sendTestEmail", "js.email.noRecipients", "js.email.addMailingList", "js.email.addUser", "js.email.addAddress", "js.email.noRecipForEmail", "js.email.testSent", "events.silence", "events.unsilence", "header.mute", "header.unmute" };
Map<String, TranslatableMessage> messages = new HashMap<>();
for (String code : codes) messages.put(code, new TranslatableMessage(code));
ctx.setAttribute("clientSideMessages", messages);
SessionCookieConfig sessionCookieConfig = ctx.getSessionCookieConfig();
sessionCookieConfig.setHttpOnly(true);
sessionCookieConfig.setName(Common.getCookieName());
}
use of com.serotonin.m2m2.i18n.TranslatableMessage in project ma-core-public by infiniteautomation.
the class AnalogChangeDetectorVO method getConfigurationDescription.
/* (non-Javadoc)
* @see com.serotonin.m2m2.vo.event.detector.AbstractEventDetectorVO#getConfigurationDescription()
*/
@Override
protected TranslatableMessage getConfigurationDescription() {
if (dataPoint == null)
dataPoint = DataPointDao.instance.getDataPoint(sourceId);
String prettyLimit = dataPoint.getTextRenderer().getText(limit, TextRenderer.HINT_SPECIFIC);
TranslatableMessage durationDescription = getDurationDescription();
if (checkIncrease && checkDecrease)
return new TranslatableMessage("event.detectorVo.analogChangePeriod", prettyLimit, durationDescription);
else if (checkIncrease)
return new TranslatableMessage("event.detectorVo.analogIncreasePeriod", prettyLimit, durationDescription);
else if (checkDecrease)
return new TranslatableMessage("event.detectorVo.analogDecreasePeriod", prettyLimit, durationDescription);
else
throw new ShouldNeverHappenException("Illegal state for analog change detector" + xid);
}
use of com.serotonin.m2m2.i18n.TranslatableMessage in project ma-core-public by infiniteautomation.
the class PublisherVO method getEventTypes.
public List<EventTypeVO> getEventTypes() {
List<EventTypeVO> eventTypes = new ArrayList<>();
eventTypes.add(new EventTypeVO(EventType.EventTypeNames.PUBLISHER, null, getId(), PublisherRT.POINT_DISABLED_EVENT, new TranslatableMessage("event.pb.pointMissing"), getAlarmLevel(PublisherRT.POINT_DISABLED_EVENT, AlarmLevels.URGENT)));
eventTypes.add(new EventTypeVO(EventType.EventTypeNames.PUBLISHER, null, getId(), PublisherRT.QUEUE_SIZE_WARNING_EVENT, new TranslatableMessage("event.pb.queueSize"), getAlarmLevel(PublisherRT.QUEUE_SIZE_WARNING_EVENT, AlarmLevels.URGENT)));
getEventTypesImpl(eventTypes);
return eventTypes;
}
use of com.serotonin.m2m2.i18n.TranslatableMessage in project ma-core-public by infiniteautomation.
the class MonitoredValuesTest method loadTest.
public void loadTest() {
// Setup a Timer
RealTimeTimer timer = new OrderedRealTimeTimer();
ThreadPoolExecutor executor = new OrderedThreadPoolExecutor(0, 100, 30L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), new MangoThreadFactory("high", Thread.MAX_PRIORITY), new RejectedExecutionHandler() {
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
System.out.println("Rejected: " + r.toString());
}
}, false, timer.getTimeSource());
timer.init(executor);
// Create a monitor
IntegerMonitor monitor = new IntegerMonitor(MONITOR_ID, new TranslatableMessage("internal.monitor.BATCH_ENTRIES"), new ValueMonitorOwner() {
@Override
public void reset(String monitorId) {
IntegerMonitor mon = (IntegerMonitor) MONITORED_VALUES.getValueMonitor(MONITOR_ID);
mon.reset();
}
});
MONITORED_VALUES.addIfMissingStatMonitor(monitor);
// Start a task to count up
new TimeoutTask(new FixedRateTrigger(0, period), new TimeoutClient() {
@Override
public void scheduleTimeout(long fireTime) {
IntegerMonitor mon = (IntegerMonitor) MONITORED_VALUES.getValueMonitor(MONITOR_ID);
mon.addValue(1);
}
@Override
public String getThreadName() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getTaskId() {
// TODO Auto-generated method stub
return null;
}
@Override
public int getQueueSize() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void rejected(RejectedTaskReason reason) {
// TODO Auto-generated method stub
}
}, timer);
// Start a task to count down
new TimeoutTask(new FixedRateTrigger(0, period), new TimeoutClient() {
@Override
public void scheduleTimeout(long fireTime) {
IntegerMonitor mon = (IntegerMonitor) MONITORED_VALUES.getValueMonitor(MONITOR_ID);
mon.addValue(-1);
}
@Override
public String getThreadName() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getTaskId() {
// TODO Auto-generated method stub
return null;
}
@Override
public int getQueueSize() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void rejected(RejectedTaskReason reason) {
// TODO Auto-generated method stub
}
}, timer);
// Start a task to read
new TimeoutTask(new FixedRateTrigger(0, period), new TimeoutClient() {
@Override
public void scheduleTimeout(long fireTime) {
IntegerMonitor mon = (IntegerMonitor) MONITORED_VALUES.getValueMonitor(MONITOR_ID);
mon.getValue();
}
@Override
public String getThreadName() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getTaskId() {
// TODO Auto-generated method stub
return null;
}
@Override
public int getQueueSize() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void rejected(RejectedTaskReason reason) {
// TODO Auto-generated method stub
}
}, timer);
// Start a task to reset
new TimeoutTask(new FixedRateTrigger(0, period), new TimeoutClient() {
@Override
public void scheduleTimeout(long fireTime) {
IntegerMonitor mon = (IntegerMonitor) MONITORED_VALUES.getValueMonitor(MONITOR_ID);
mon.reset();
}
@Override
public String getThreadName() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getTaskId() {
// TODO Auto-generated method stub
return null;
}
@Override
public int getQueueSize() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void rejected(RejectedTaskReason reason) {
// TODO Auto-generated method stub
}
}, timer);
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Aggregations