diff --git a/src/main/java/info/bukova/isspst/mail/EntityMessageBuilder.java b/src/main/java/info/bukova/isspst/mail/EntityMessageBuilder.java index b8e54ed6..3803624f 100644 --- a/src/main/java/info/bukova/isspst/mail/EntityMessageBuilder.java +++ b/src/main/java/info/bukova/isspst/mail/EntityMessageBuilder.java @@ -27,6 +27,10 @@ public class EntityMessageBuilder implements MessageBuilder { } private String replaceProperties(String src, Object data) { + if (src == null) { + return ""; + } + int current = 0; List properties = new ArrayList(); boolean found = false; diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java index e0d79886..d4ade762 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java @@ -100,25 +100,7 @@ public abstract class RequirementBaseServiceImpl exte wg = e.getWorkgroup(); } - - try - { - if (wg.getMembers() == null) - { - throw new LazyInitializationException(""); - } - - wg.getMembers().size(); - } - catch (LazyInitializationException ex) - { - Query q = dao.getQuery("from Workgroup where id = :id"); - q.setParameter("id", wg.getId()); - wg = (Workgroup) q.uniqueResult(); - - wg.getMembers().size(); - } - + workgroupService.loadMembers(wg); for (JobMapping jm : wg.getMembers()) { @@ -223,13 +205,16 @@ public abstract class RequirementBaseServiceImpl exte if (e.getOwnedBy().getEmail() != null && !e.getOwnedBy().getEmail().isEmpty() && e.getOwnedBy().isNotify()) { - if (e.getState() == RequirementState.APPROVED) { + if (e.getState() == RequirementState.APPROVED && settings.getConfReqTemplate() != null) { message = messageBuilder.buildMessage(settings.getConfReqTemplate(), e); - } else { + } else if (settings.getAuthReqTemplate() != null) { message = messageBuilder.buildMessage(settings.getAuthReqTemplate(), e); } - message.setTo(e.getOwnedBy().getEmail()); - mailer.send(message); + + if (message != null) { + message.setTo(e.getOwnedBy().getEmail()); + mailer.send(message); + } } }