MatrixBerryCore
EmailLoggerBuilder.m
Go to the documentation of this file.
1 classdef EmailLoggerBuilder
2  methods (Access=private)
3  function self=EmailLoggerBuilder()
4  end
5  end
6  methods (Static)
7  function emailLogger=fromConfRepoMgr(confRepoMgr,appName,inpSubjSuffName,mainLogFileName,fTempDirGetter,varargin)
8  import mxberry.core.throwerror;
9  [~,~,addAttachNameList]=mxberry.core.parseparext(varargin,...
10  {'emailAttachmentNameList';...
11  {};...
12  'iscellofstring(x)'},0);
13  [urlCodeStr,urlStr,branchName,revisionStr]=...
14  mxberry.dev.scm.getrepoparams();
15  %
16  tmpDirName=fTempDirGetter(appName);
17  %zip log file name
18  zipLogFileName=[tmpDirName,filesep,'mainlog.zip'];
19  %
20  dstConfFileName=[tmpDirName,filesep,'cur_conf','.xml'];
21  confRepoMgr.copyConfFile(dstConfFileName,'destIsFile',true);
22  %
23 
24  [~,pidVal,~]=mxberry.system.getpidhost();
25  subjectSuffix=[',pid:',num2str(pidVal),',conf:',...
26  confRepoMgr.getCurConfName(),inpSubjSuffName,...
27  ',',urlCodeStr,':',urlStr];
28  addArgList={};
29  if confRepoMgr.isParam('emailNotification.smtpUserName')
30  addArgList=[addArgList,{'smtpUserName',...
31  confRepoMgr.getParam('emailNotification.smtpUserName')}];
32  if confRepoMgr.isParam('emailNotification.smtpPassword')
33  addArgList=[addArgList,{'smtpPassword',...
34  confRepoMgr.getParam('emailNotification.smtpPassword')}];
35  end
36  elseif confRepoMgr.isParam('emailNotification.smtpPassword')
37  throwerror('wrongInput',['smtpPassword can only be ',...
38  'specified when smtpUser name is specified']);
39  end
40  %
41  if confRepoMgr.isParam('emailNotification.from.isEnabled')
42  fromEmailAddress=confRepoMgr.getParam(...
43  'emailNotification.from.emailAddress');
44  inpArgList={'fromEmailAddress',fromEmailAddress};
45  else
46  inpArgList={};
47  end
48  %
49  emailLogger=mxberry.log.EmailLogger(...
50  'emailDistributionList',...
51  confRepoMgr.getParam('emailNotification.distributionList'),...
52  'emailAttachmentNameList',...
53  [{mainLogFileName,dstConfFileName},addAttachNameList],...
54  'emailAttachmentZippedNameList',...
55  [{zipLogFileName},cell(1,numel(addAttachNameList)+1)],...
56  'smtpServer',confRepoMgr.getParam('emailNotification.smtpServer'),...
57  'subjectSuffix',subjectSuffix,...
58  'loggerName',...
59  [appName,':',branchName,':',revisionStr],addArgList{:},...
60  'dryRun',...
61  ~confRepoMgr.getParam('emailNotification.isEnabled'),...
62  inpArgList{:});
63  end
64  end
65 end
function filesep()
function throwerror(in msgTag, in varargin)
THROWERROR works similarly to built-in ERROR function in case when there is no output arguments but s...
function parseparext(in args, in propNameValMat, in varargin)
PARSEPAREXT behaves in the same way as mxberry.core.parseparams but returns property values in a more...