Package org.cesecore.core.ejb.log

Examples of org.cesecore.core.ejb.log.LogSessionLocal


   * Only supports the MailActionInfo otherwise is ActionException thrown.
   *
   * @see org.ejbca.core.model.services.IAction#performAction(org.ejbca.core.model.services.ActionInfo)
   */
  public void performAction(ActionInfo actionInfo, Map<Class<?>, Object> ejbs) throws ActionException {
    LogSessionLocal logSession = ((LogSessionLocal)ejbs.get(LogSessionLocal.class));
    checkConfig(actionInfo);
   
    MailActionInfo mailActionInfo = (MailActionInfo) actionInfo;
    String senderAddress = properties.getProperty(PROP_SENDERADDRESS);
   
    String reciverAddress = mailActionInfo.getReciever();
    if(reciverAddress== null){
      reciverAddress = properties.getProperty(PROP_RECIEVERADDRESS);
    }
       
    if(reciverAddress == null || reciverAddress.trim().equals("")){
      String msg = intres.getLocalizedMessage("services.mailaction.errorreceiveraddress");
      throw new ActionException(msg);
    }
           
        try {
          MailSender.sendMailOrThrow(senderAddress, Arrays.asList(reciverAddress), MailSender.NO_CC, mailActionInfo.getSubject(), mailActionInfo.getMessage(), MailSender.NO_ATTACHMENTS);
          if (mailActionInfo.isLoggingEnabled()) {
            String logmsg = intres.getLocalizedMessage("services.mailaction.sent", reciverAddress);
            logSession.log(admin, admin.getCaId(), LogConstants.MODULE_APPROVAL, new java.util.Date(), null, null, LogConstants.EVENT_INFO_NOTIFICATION, logmsg);
          }
        } catch (Exception e) {
      String msg = intres.getLocalizedMessage("services.mailaction.errorsend", reciverAddress);
            log.error(msg, e);
            try{
                if (mailActionInfo.isLoggingEnabled()) {
                  logSession.log(admin, admin.getCaId(), LogConstants.MODULE_APPROVAL, new java.util.Date(),null, null, LogConstants.EVENT_ERROR_NOTIFICATION, msg);
                }
            }catch(Exception f){
                throw new EJBException(f);
            }
        }
View Full Code Here

TOP

Related Classes of org.cesecore.core.ejb.log.LogSessionLocal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.