This discussion is archived
1 Reply Latest reply: Mar 5, 2010 5:03 AM by olona RSS

How can ftp-adapter override the name rules

olona Newbie
Currently Being Moderated
I have a ftp adaptor, which generate filenames with the following rule NA<%time%>.txt, but I would rather have it be stamped with a more meaninful filename ex NA<accountnumber>.txt.

I am new to Interconnect, IStudio and ftp adaptors...so I have no experience in this. I

I have done some research, and I realise that I might have to overwrite the The FileSenderCustomizer Interface more specifically the generateFilename method.

The question is really, where and how do I do this?

Thanks

Edited by: olona on Mar 3, 2010 4:54 AM

Edited by: olona on Mar 5, 2010 4:53 AM
Move to Integration - Adapters => Integration - Adapters
  • 1. Re: How can ftp-adapter override the name rules
    olona Newbie
    Currently Being Moderated
    An example of a ftp-adapter that will generate a filename based on a value in the file. The file contains CustomerListRecord which again contains multiple Records of Customers, which then contains the actual values.

    import java.util.Date;
    import java.util.ListIterator;
    import java.util.Vector;

    import oracle.oai.agent.adapter.sdk.Agent;
    import oracle.oai.agent.adapter.sdk.AttributeObject;
    import oracle.oai.agent.adapter.sdk.MessageObject;
    import oracle.oai.agent.adapter.transport.TransportMessage;

    public class SlfNaskCustFileSender {

         private final static String objectName = "SLFCustFileSenderStripped";
         private final String fileNameExtension = ".c15";
         private final String keyMasterRecord = "CustomerListRecord";
         private final String keyRecords = "Records";
         private final String keyRecordField = "apar_id";

         public static void main(String args[]) {
              System.out.println("Its alive: " + objectName);
         }

         public String generateFileName(Agent agent, String rule, String app, String partitition, Date time,
                   MessageObject mobj, AttributeObject aobj) {

              // Default filename. Add random element just in case.
              String fileName = "NAC" + (Math.random() * 100) + fileNameExtension;

              // Picking up the buntnumber.
              AttributeObject aoCustListRecords = (AttributeObject) mobj.get(keyMasterRecord);
              Object o = aoCustListRecords.get(keyRecords);
              if (o instanceof Vector) {
                   Vector v = (Vector) o;
                   ListIterator iter = v.listIterator();
                   while (iter.hasNext()) {
                        Object x = iter.next();
                        if (x instanceof AttributeObject) {
                             AttributeObject aoX = (AttributeObject) x;
                             fileName = aoX.get(keyRecordField) + fileNameExtension;
                        }
                   }
              }

              return fileName;
         }

         public void customizeTransportMessage(Agent agent, TransportMessage transportMessage, MessageObject mobj,
                   AttributeObject aobj) {

         }

    }

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points