Skip to Main Content

Analytics Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to send emails via jython code though FDMEE with attachments

2886698Mar 30 2016 — edited Apr 5 2016

I am in the process of trying to code an email notification from FDMEE with attached log files after a load completes.

After doing lots of research on the web i have a couple of questions regarding where in the jython code i specify the actual log or specific directory i want to pick up my files from.

I found this code that was nicely put together and am trying to get it to work in eclipse first. I would appreciate some pointers in the right direction as i am completely new to jython.

Here is what i have:

def send_email_with_attachment(

subject, body_text, to_emails,
                               cc_emails, bcc_emails, file_to_attach):
    import os, string, smtplib, sys
    from email.mime.multipart import MIMEMultipart
    from email.mime.base import MIMEBase
    from email.mime.text import MIMEText
    from email.utils import formatdate
    from email import encoders
    """
    Send an email with an attachment
    """
    header = 'Content-Disposition', 'attachment; filename="%s"' % os.path.basename(C:\Oracle\Middleware\FDMEE\outbox\logs\HFM_100.log)
    # extract server and from_addr from config
    host = "smtp.mydomain.com"
    from_addr = "my.email@somedomain.com"
    # create the message
    msg = MIMEMultipart()
    msg["From"] = from_addr
    msg["Subject"] = subject
    msg["Date"] = formatdate(localtime=True)
    if body_text:
        msg.attach( MIMEText(body_text)
    msg["To"] = ', '.join(to_emails)
    msg["cc"] = ', '.join(cc_emails)
    attachment = MIMEBase('application', "octet-stream")
    try:
        attachment.set_payload(open(file_to_attach, "rb").read())
        encoders.encode_base64(attachment)
        attachment.add_header(*header)
        msg.attach(attachment)
    except IOError:
        msg = "Error opening attachment file %s" % file_to_attach
        fdmAPI.logError(msg)
        sys.exit(1)
    emails = to_emails + cc_emails
    server = smtplib.SMTP(host)
    server.sendmail(from_addr, emails, msg.as_string())
    server.quit()
# Email parameters
to_emails = ["xxxx@xxxxx","xxxxx@xxxxx"]
cc_emails = []
bcc_emails = []
# Get Status
status = fdmAPI.getProcessStates(fdmContext["LOADID"])
if str(status["EXPSTATUS"]) == "1":
    subject = "Rule %s executed successfully" % str(fdmContext["RULENAME"])
    body_text = "FDMEE process log has been attached in case you want to review it"
    path = fdmContext["OUTBOXDIR"] + "\\logs\\" + str(fdmContext["TARGETAPPNAME"]) + "_" + str(fdmContext["LOADID"]) + ".log"
else:
    subject = "Rule %s executed with errors" % str(fdmContext["RULENAME"])
    body_text = "Please check FDMEE process log attached"
    path = fdmContext["OUTBOXDIR"] + "\\logs\\" + str(fdmContext["TARGETAPPNAME"]) + "_" + str(fdmContext["LOADID"]) + ".log"
# Send email
send_email_with_attachment(subject, body_text, to_emails,cc_emails, bcc_emails, path)

Comments

Hello

The Subtree Delete Control (1.2.840.113556.1.4.805) supported by OUD (Supported LDAP Controls - Oracle Fusion Middleware Architecture Reference for Oracle Unified Directory)  might fit your needs.

This control is attached to a delete request to indicate that the specified entry and all descendant entries are to be deleted.

You must have appropriate privileges to do that (admin account)

You can attached control to a ldapdelete using the -J option as described in ldapdelete - Oracle Fusion Middleware Command-Line Usage Guide for Oracle Unified Directory

Sylvain

------

When closing a thread as answered remember to mark the correct and helpful posts to make it easier for others to find them

900846

Thanks Sylvain.

I tried with this command to delete entries

ldapdelete -J subtreedelete -h localhost -p 1389 -D "cn=Directory Manager" -w password -x ou=ext,ou=users,dc=example,dc=com

There are about 2 lakhs entries inside this OU and it is taking infact it is running since a hr and still it has not completed the operation.

Is there some other setting which i need to do.

regards,

Ram

Hello,

There is no additional thing to do, adding the control should work.

If it takes a very long time to delete thats one thing, if  it never completes and seem to hang this is another thing.

Has it deleted some entries or does it seem to hang w/o deleting any entry ?

Current implementation may be slow with large trees.

If the problem persists, I would encourage you to contact the Oracle Support so that they can investigate

Sylvain

------

When closing a thread as answered remember to mark the correct and helpful posts to make it easier for others to find them

900846

Thanks Sylvain, i have raised an SR and awaiting for the response

1 - 4
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 3 2016
Added on Mar 30 2016
1 comment
1,604 views