use of org.apache.airavata.model.appcatalog.computeresource.ResourceJobManagerType in project airavata by apache.
the class EmailBasedMonitor method parse.
private JobStatusResult parse(Message message) throws MessagingException, AiravataException {
Address fromAddress = message.getFrom()[0];
String addressStr = fromAddress.toString();
ResourceJobManagerType jobMonitorType = getJobMonitorType(addressStr);
EmailParser emailParser = emailParserMap.get(jobMonitorType);
if (emailParser == null) {
throw new AiravataException("[EJM]: Un-handle resource job manager type: " + jobMonitorType.toString() + " for email monitoring --> " + addressStr);
}
return emailParser.parseEmail(message);
}
use of org.apache.airavata.model.appcatalog.computeresource.ResourceJobManagerType in project airavata by apache.
the class EmailBasedMonitor method populateAddressAndParserMap.
private void populateAddressAndParserMap(Map<ResourceJobManagerType, ResourceConfig> resourceConfigs) throws AiravataException {
for (Map.Entry<ResourceJobManagerType, ResourceConfig> resourceConfigEntry : resourceConfigs.entrySet()) {
ResourceJobManagerType type = resourceConfigEntry.getKey();
ResourceConfig config = resourceConfigEntry.getValue();
List<String> resourceEmailAddresses = config.getResourceEmailAddresses();
if (resourceEmailAddresses != null && !resourceEmailAddresses.isEmpty()) {
for (String resourceEmailAddress : resourceEmailAddresses) {
addressMap.put(resourceEmailAddress, type);
}
try {
Class<? extends EmailParser> emailParserClass = Class.forName(config.getEmailParser()).asSubclass(EmailParser.class);
EmailParser emailParser = emailParserClass.getConstructor().newInstance();
emailParserMap.put(type, emailParser);
} catch (Exception e) {
throw new AiravataException("Error while instantiation email parsers", e);
}
}
}
}
Aggregations