Search This Blog

Monday, September 19, 2016

Create EMAIL Server Profile in 12c

Create EMAIL Server Profile in 12c
import javax.management.openmbean.CompositeDataSupport;
if __name__ == '__main__':
    from wlstModule import *#@UnusedWildImport
print 'starting the script ....'
username = 'weblogic'
password = 'Welcome1'
url='t3://localhost:14001'
profileName='testemail'
MailAccessProtocol = 'IMAP'
OutgoingMailServer = 'localhost'
OutgoingMailServerPort = '25'
OutgoingMailServerSecurity = 'None'
OutgoingDefaultFromAddr = 'bpelsender@localhost'
OutgoingUsername = 'bpelsender@localhost'
OutgoingPassword = 'Welcome1'
IncomingMailServer = 'localhost'
IncomingMailServerPort = '143'
IncomingMailIDs = 'bpelreceiver@localhost'
IncomingUserIDs = 'bpelreceiver@localhost'
IncomingUserPasswords = 'Welcome1'
ASNSDriverEmailFromAddress='bpelsender@localhost'
ASNSDriverEmailRespondAddress='bpelreceiver@localhost'
ASNSDriverEmailReplyAddress='no.reply@yourdomain.com'
HWFMailerNotificationMode='EMAIL'
connect(username,password,url)
servers = cmo.getServers()
domainRuntime()
for server in servers:
    serverName = server.getName()
    print 'server: ' + server.getName()
    EmailProfileConfigobj = ObjectName('oracle.ucs.messaging:type=UmsDomainConfig,name=UmsDomainConfiguration')
    print 'Common Properties for soa_server1'
   
    mbs.invoke(EmailProfileConfigobj,'removeDriverConfig',[profileName,'email'],['java.lang.String','java.lang.String'])
   
    mbs.invoke(EmailProfileConfigobj,'createDriverConfig',[profileName,'email'],['java.lang.String','java.lang.String'])
    print mbs.invoke(EmailProfileConfigobj,'getDriverConfig',[profileName,'email'],['java.lang.String','java.lang.String'])
   
    EmailDriverConfigobj = ObjectName('oracle.ucs.messaging:name='+profileName+',type=UmsDomainConfig.DriverConfig,driverType=email,UmsDomainConfig=UmsDomainConfiguration')
    mbs.invoke(EmailDriverConfigobj,'setProperty',['MailAccessProtocol',MailAccessProtocol],['java.lang.String','java.lang.String'])
    mbs.invoke(EmailDriverConfigobj,'setProperty',['OutgoingMailServer',OutgoingMailServer],['java.lang.String','java.lang.String'])
    mbs.invoke(EmailDriverConfigobj,'setProperty',['OutgoingMailServerPort',OutgoingMailServerPort],['java.lang.String','java.lang.String'])
    mbs.invoke(EmailDriverConfigobj,'setProperty',['OutgoingMailServerSecurity',OutgoingMailServerSecurity],['java.lang.String','java.lang.String'])
    mbs.invoke(EmailDriverConfigobj,'setProperty',['OutgoingDefaultFromAddr',OutgoingDefaultFromAddr],['java.lang.String','java.lang.String'])
    mbs.invoke(EmailDriverConfigobj,'setProperty',['OutgoingUsername',OutgoingUsername],['java.lang.String','java.lang.String'])
    mbs.invoke(EmailDriverConfigobj,'setProperty',['OutgoingPassword',OutgoingPassword],['java.lang.String','java.lang.String'])
    mbs.invoke(EmailDriverConfigobj,'setProperty',['IncomingMailServer',IncomingMailServer],['java.lang.String','java.lang.String'])
    mbs.invoke(EmailDriverConfigobj,'setProperty',['IncomingMailIDs',IncomingMailIDs],['java.lang.String','java.lang.String'])
    mbs.invoke(EmailDriverConfigobj,'setProperty',['IncomingUserIDs',IncomingUserIDs],['java.lang.String','java.lang.String'])
    mbs.invoke(EmailDriverConfigobj,'setProperty',['IncomingUserPasswords',IncomingUserPasswords],['java.lang.String','java.lang.String'])
    props1 = mbs.getAttribute(EmailDriverConfigobj, 'Properties')
   
    for props2 in props1:
            print str(props2.get('name')) +' = ' + str(props2.get('value'))
   
    WorkflowNotificationObj = ObjectName('oracle.as.soainfra.config:Location='+serverName +',name=human-workflow,type=HWFMailerConfig,Application=soa-infra')
    mbs.setAttribute(WorkflowNotificationObj, Attribute('ASNSDriverEmailFromAddress', ASNSDriverEmailFromAddress))
    mbs.setAttribute(WorkflowNotificationObj, Attribute('ASNSDriverEmailRespondAddress', ASNSDriverEmailRespondAddress))
    mbs.setAttribute(WorkflowNotificationObj, Attribute('ASNSDriverEmailReplyAddress', ASNSDriverEmailReplyAddress ))
    mbs.setAttribute(WorkflowNotificationObj, Attribute('HWFMailerNotificationMode', HWFMailerNotificationMode))
   
    print 'HWFMailerNotificationMode' +' = '+ mbs.getAttribute(WorkflowNotificationObj, 'ASNSDriverEmailReplyAddress')
    print 'ASNSDriverEmailFromAddress' +' = '+ mbs.getAttribute(WorkflowNotificationObj, 'ASNSDriverEmailFromAddress')
    print 'ASNSDriverEmailRespondAddress' +' = '+ mbs.getAttribute(WorkflowNotificationObj, 'ASNSDriverEmailRespondAddress')
    print 'HWFMailerNotificationMode' +' = '+ mbs.getAttribute(WorkflowNotificationObj, 'HWFMailerNotificationMode')
   


Tags: Publish
September 19, 2016 at 03:45PM
Open in Evernote

No comments: