use of com.serotonin.m2m2.i18n.TranslatableJsonException in project ma-core-public by infiniteautomation.
the class EmailRecipientResolver method resolve.
@Override
public Type resolve(JsonValue jsonValue) throws JsonException {
if (jsonValue == null)
return null;
JsonObject json = jsonValue.toJsonObject();
String text = json.getString("recipientType");
if (text == null)
throw new TranslatableJsonException("emport.error.recipient.missing", "recipientType", EmailRecipient.TYPE_CODES);
int type = EmailRecipient.TYPE_CODES.getId(text);
if (!EmailRecipient.TYPE_CODES.isValidId(type))
throw new TranslatableJsonException("emport.error.recipient.invalid", "recipientType", text, EmailRecipient.TYPE_CODES.getCodeList());
if (type == EmailRecipient.TYPE_MAILING_LIST)
return MailingList.class;
if (type == EmailRecipient.TYPE_USER)
return UserEntry.class;
return AddressEntry.class;
}
use of com.serotonin.m2m2.i18n.TranslatableJsonException in project ma-core-public by infiniteautomation.
the class UserEntry method jsonRead.
@Override
public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
super.jsonRead(reader, jsonObject);
String username = jsonObject.getString("username");
if (username == null)
throw new TranslatableJsonException("emport.error.recipient.missing.reference", "username");
user = UserDao.instance.getUser(username);
if (user == null)
throw new TranslatableJsonException("emport.error.recipient.invalid.reference", "username", username);
userId = user.getId();
}
use of com.serotonin.m2m2.i18n.TranslatableJsonException in project ma-core-public by infiniteautomation.
the class TimeoutDetectorVO method jsonRead.
@Override
public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
super.jsonRead(reader, jsonObject);
String text = jsonObject.getString("durationType");
if (text == null)
throw new TranslatableJsonException("emport.error.ped.missing", "durationType", Common.TIME_PERIOD_CODES.getCodeList());
durationType = Common.TIME_PERIOD_CODES.getId(text);
if (!Common.TIME_PERIOD_CODES.isValidId(durationType))
throw new TranslatableJsonException("emport.error.ped.invalid", "durationType", text, Common.TIME_PERIOD_CODES.getCodeList());
duration = getInt(jsonObject, "duration");
}
use of com.serotonin.m2m2.i18n.TranslatableJsonException in project ma-core-public by infiniteautomation.
the class PointFolder method jsonRead.
@Override
public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
JsonArray jsonPoints = jsonObject.getJsonArray("points");
if (jsonPoints != null) {
points.clear();
DataPointDao dataPointDao = DataPointDao.instance;
for (JsonValue jv : jsonPoints) {
String xid = jv.toString();
DataPointVO dp = dataPointDao.getDataPoint(xid);
if (dp == null)
throw new TranslatableJsonException("emport.error.missingPoint", xid);
points.add(new DataPointSummary(dp));
}
}
}
use of com.serotonin.m2m2.i18n.TranslatableJsonException in project ma-core-public by infiniteautomation.
the class DataSourceVO method readUpdatePeriodType.
protected Integer readUpdatePeriodType(JsonObject json) throws JsonException {
String text = json.getString("updatePeriodType");
if (text == null)
return null;
int value = Common.TIME_PERIOD_CODES.getId(text);
if (value == -1)
throw new TranslatableJsonException("emport.error.invalid", "updatePeriodType", text, Common.TIME_PERIOD_CODES.getCodeList());
return value;
}
Aggregations