use of com.serotonin.m2m2.i18n.ProcessMessage in project ma-core-public by infiniteautomation.
the class Restorer method addFailureMessage.
protected void addFailureMessage(String key, Object... params) {
success = false;
failureMessages.add(new ProcessMessage(key, params));
}
use of com.serotonin.m2m2.i18n.ProcessMessage in project ma-core-public by infiniteautomation.
the class AbstractVoModel method validate.
/*
* (non-Javadoc)
* @see com.serotonin.m2m2.web.mvc.rest.v1.model.AbstractRestModel#validate(com.serotonin.m2m2.web.mvc.rest.v1.message.RestProcessResult)
*/
@Override
public boolean validate() {
ProcessResult validation = new ProcessResult();
this.data.validate(validation);
if (validation.getHasMessages()) {
// Add our messages to the list
for (ProcessMessage message : validation.getMessages()) {
if (message.getGenericMessage() != null) {
this.messages.add(new RestValidationMessage(message.getGenericMessage(), RestMessageLevel.ERROR, ""));
} else {
this.messages.add(new RestValidationMessage(message.getContextualMessage(), RestMessageLevel.ERROR, message.getContextKey()));
}
}
return false;
} else {
// Validated ok
return true;
}
}
use of com.serotonin.m2m2.i18n.ProcessMessage in project ma-core-public by infiniteautomation.
the class StartupDwr method getStartupProgress.
@DwrPermission(anonymous = true)
public ProcessResult getStartupProgress(long since) {
ProcessResult result = new ProcessResult();
IMangoLifecycle lifecycle = Providers.get(IMangoLifecycle.class);
float progress = lifecycle.getStartupProgress();
float shutdownProgress = lifecycle.getShutdownProgress();
List<String> messages = LoggingConsoleRT.instance.getMessagesSince(since);
StringBuilder builder = new StringBuilder();
for (String message : messages) {
builder.append(message);
builder.append("</br>");
}
result.addData("message", builder.toString());
result.addData("startupProgress", progress);
result.addData("shutdownProgress", shutdownProgress);
result.addData("state", getLifecycleStateMessage(lifecycle.getLifecycleState()));
if ((progress >= 100) && (shutdownProgress == 0)) {
WebContext ctx = WebContextFactory.get();
result.addData("startupUri", DefaultPagesDefinition.getLoginUri(ctx.getHttpServletRequest(), ctx.getHttpServletResponse()));
}
// Add the message to describe what process we are in
if ((progress < 100) && (shutdownProgress == 0)) {
result.addData("processMessage", this.translations.translate("startup.startingUp"));
} else if ((shutdownProgress > 0) && (lifecycle.isRestarting())) {
result.addData("processMessage", this.translations.translate("shutdown.restarting"));
} else if (shutdownProgress > 0) {
result.addData("processMessage", this.translations.translate("shutdown.shuttingDown"));
}
if ((progress == 100) && (shutdownProgress == 0)) {
result.addData("processMessage", this.translations.translate("startup.state.running"));
}
return result;
}
use of com.serotonin.m2m2.i18n.ProcessMessage in project ma-core-public by infiniteautomation.
the class DefaultDataPointPropertiesTemplateFactory method saveTemplate.
protected void saveTemplate(DataPointPropertiesTemplateVO template) {
ProcessResult response = new ProcessResult();
template.validate(response);
if (!response.getHasMessages()) {
TemplateDao.instance.save(template);
} else {
String output = new String();
List<ProcessMessage> messages = response.getMessages();
for (ProcessMessage message : messages) {
output += message.toString(Common.getTranslations());
output += "\n";
}
throw new ShouldNeverHappenException(output);
}
}
use of com.serotonin.m2m2.i18n.ProcessMessage in project ma-core-public by infiniteautomation.
the class MangoTestBase method loadConfiguration.
protected void loadConfiguration(File jsonFile) throws JsonException, IOException, URISyntaxException {
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(jsonFile), Common.UTF8_CS));
JsonReader jr = new JsonReader(reader);
JsonObject jo = jr.read(JsonObject.class);
ImportTask task = new ImportTask(jo, Common.getTranslations(), null, false);
task.run(Common.timer.currentTimeMillis());
if (task.getResponse().getHasMessages()) {
for (ProcessMessage message : task.getResponse().getMessages()) {
switch(message.getLevel()) {
case error:
case warning:
fail(message.toString(Common.getTranslations()));
case info:
LOG.info(message.toString(Common.getTranslations()));
}
}
}
}
Aggregations