use of com.serotonin.m2m2.i18n.TranslatableMessage in project ma-core-public by infiniteautomation.
the class TranslatableMessageSerializer method serialize.
/* (non-Javadoc)
* @see com.fasterxml.jackson.databind.JsonSerializer#serialize(java.lang.Object, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider)
*/
@Override
public void serialize(TranslatableMessage msg, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
if (msg != null) {
User user = Common.getHttpUser();
Locale locale = user == null ? Common.getLocale() : user.getLocaleObject();
jgen.writeString(msg.translate(Translations.getTranslations(locale)));
} else
jgen.writeNull();
}
use of com.serotonin.m2m2.i18n.TranslatableMessage in project ma-core-public by infiniteautomation.
the class DataPointDao method checkAddPoint.
public void checkAddPoint() {
IMangoLifecycle lifecycle = Providers.get(IMangoLifecycle.class);
Integer limit = lifecycle.dataPointLimit();
if (limit != null && this.countMonitor.getValue() >= limit) {
String licenseType;
if (Common.license() != null)
licenseType = Common.license().getLicenseType();
else
licenseType = "Free";
throw new LicenseViolatedException(new TranslatableMessage("license.dataPointLimit", licenseType, limit));
}
}
use of com.serotonin.m2m2.i18n.TranslatableMessage in project ma-core-public by infiniteautomation.
the class PointValueDaoSQL method updatePointValueAnnotation.
private void updatePointValueAnnotation(long id, int dataType, String svalue, SetPointSource source) {
if (svalue == null && dataType == DataTypes.IMAGE)
svalue = Long.toString(id);
// Check if we need to create an annotation.
TranslatableMessage sourceMessage = null;
if (source != null)
sourceMessage = source.getSetPointSourceMessage();
if (svalue != null || sourceMessage != null) {
String shortString = null;
String longString = null;
if (svalue != null) {
if (svalue.length() > 128)
longString = svalue;
else
shortString = svalue;
}
//
ejt.update(//
POINT_VALUE_ANNOTATION_UPDATE + "WHERE pointValueId = ?", //
new Object[] { shortString, longString, writeTranslatableMessage(sourceMessage), id }, new int[] { Types.VARCHAR, Types.CLOB, Types.CLOB, Types.INTEGER });
}
}
use of com.serotonin.m2m2.i18n.TranslatableMessage in project ma-core-public by infiniteautomation.
the class UserDao method deleteUser.
public void deleteUser(final int userId) {
User user = getTransactionTemplate().execute(new TransactionCallback<User>() {
@Override
public User doInTransaction(TransactionStatus status) {
User user = get(userId);
Object[] args = new Object[] { userId };
ejt.update("UPDATE userComments SET userId=null WHERE userId=?", args);
ejt.update("DELETE FROM mailingListMembers WHERE userId=?", args);
ejt.update("DELETE FROM userEvents WHERE userId=?", args);
ejt.update("UPDATE events SET ackUserId=null, alternateAckSource=? WHERE ackUserId=?", new Object[] { new TranslatableMessage("events.ackedByDeletedUser").serialize(), userId });
ejt.update("DELETE FROM users WHERE id=?", args);
return user;
}
});
AuditEventType.raiseDeletedEvent(AuditEventType.TYPE_USER, user);
countMonitor.decrement();
if (handler != null)
handler.notify("delete", user);
// Update User In Session
MangoSecurityConfiguration.sessionRegistry.exireSessionsForUser(user);
userCache.remove(user.getUsername());
}
use of com.serotonin.m2m2.i18n.TranslatableMessage in project ma-core-public by infiniteautomation.
the class SetPointHandlerRT method raiseFailureEvent.
private void raiseFailureEvent(TranslatableMessage message, EventType et) {
if (et != null && et.isSystemMessage()) {
if (((SystemEventType) et).getSystemEventType().equals(SystemEventType.TYPE_SET_POINT_HANDLER_FAILURE)) {
// The set point attempt failed for an event that is a set point handler failure in the first place.
// Do not propagate the event, but rather just write a log message.
LOG.warn("A set point event due to a set point handler failure itself failed. The failure event " + "has been discarded: " + message.translate(Common.getTranslations()));
return;
}
}
SystemEventType eventType = new SystemEventType(SystemEventType.TYPE_SET_POINT_HANDLER_FAILURE, vo.getId());
if (StringUtils.isBlank(vo.getAlias()))
message = new TranslatableMessage("event.setPointFailed", message);
else
message = new TranslatableMessage("event.setPointFailed.alias", vo.getAlias(), message);
SystemEventType.raiseEvent(eventType, Common.timer.currentTimeMillis(), false, message);
}
Aggregations