Generation of a binary file on the fly for FTP

I have a requirement (don't we all?)

I need to pick up a record of fixed length from a FTP server, convert it to a defined XML representation and then place the file within a XML archive .zip and store the results on a second client FTP server pick up.

Everything is going well except that my results are not an archive valid .zip.

I wrote a function defined by the user to manage zipping them upward and have indicated below. I think I'm a bad handling something in the final stages of this process because what is written is not valid.

Anyone tried something like this with success?

package com.f17.customfunction;

import java.io.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import oracle.fabric.common.xml.xpath.IXPathContext;
import oracle.fabric.common.xml.xpath.IXPathFunction;
import oracle.fabric.common.xml.xpath.XPathFunctionException;
import oracle.xml.parser.v2.XMLDocument;
import oracle.xml.parser.v2.XMLDocumentFragment;

public class zipFile implements IXPathFunction {
    public zipFile() {
        super();
    }

    public Object call(IXPathContext iXPathContext,
                       List<?> list) throws XPathFunctionException {
        String contentS;
        String fileName;
        contentS = (String) list.get(0);
        fileName = (String) list.get(1);
        try {
            ByteArrayOutputStream bout = new ByteArrayOutputStream();
            ZipOutputStream zipOutputStream = new ZipOutputStream(bout);
            ZipEntry zipEntry = new ZipEntry(fileName);
            zipOutputStream.putNextEntry(zipEntry);
            ByteArrayInputStream InputStream = new ByteArrayInputStream(contentS.getBytes());
            byte[] buf = new byte[1024];
            int bytesRead;
            while ((bytesRead = InputStream.read(buf)) > 0) {
                    bout.write(buf, 0, bytesRead);
            }
            byte[] binData = bout.toByteArray();
            String outPut;
            outPut = javax.xml.bind.DatatypeConverter.printHexBinary(binData);
            XMLDocument doc = new XMLDocument();
            XMLDocumentFragment docOut = (XMLDocumentFragment)doc.createDocumentFragment();
            docOut.addText("<compressedFile>" + outPut + "</compressedFile>");
            zipOutputStream.closeEntry();
            zipOutputStream.close();
            bout.close();
            return docOut;
        } catch (Exception e) {
            System.out.println(e);
        }
        return null;
    }
}

You must close the input zip, flush and close the ZipOutputStream, ByteArrayOutputStream before read you. In addition, the buffer must be written on ZipOutputStream and not ByteArrayOutputStream. Try:

package com.f17.customfunction;

import java. IO;

import java.util.zip.ZipEntry;

java.util.zip.ZipOutputStream import;

import java.io.ByteArrayOutputStream.

import java.util.List;

Import oracle.fabric.common.xml.xpath.IXPathContext;

Import oracle.fabric.common.xml.xpath.IXPathFunction;

Import oracle.fabric.common.xml.xpath.XPathFunctionException;

Import oracle.xml.parser.v2.XMLDocument;

Import oracle.xml.parser.v2.XMLDocumentFragment;

public class zipFile implements {IXPathFunction}

{} public zipFile()

Super();

}

public call for the object (IXPathContext, iXPathContext,

The list list) get {XPathFunctionException}

The contents of the string;

String fileName;

Content = (String) list.get (0);

fileName (String) = list.get (1);

try {}

ByteArrayOutputStream combat = new ByteArrayOutputStream();

ZipOutputStream zipOutputStream = new ZipOutputStream (end);

ZipEntry zipEntry = new ZipEntry (fileName);

zipOutputStream.putNextEntry (zipEntry);

ByteArrayInputStream InputStream = new ByteArrayInputStream (contentS.getBytes ());

Byte [] buf = new byte [1024];

int bytesRead;

While ((bytesRead = InputStream.read (buf)) > 0) {}

.write zipOutputStream(buf, 0, bytesRead);

}

zipOutputStream.closeEntry ();

zipOutputStream.flush ();

zipOutputStream.close ();

Tip. Flush();

Tip. Close();

Byte [] binData = bout.toByteArray ();

Output string;

Output = javax.xml.bind.DatatypeConverter.printHexBinary (binData);

XMLDocument doc = new XMLDocument();

XMLDocumentFragment docOut = (XMLDocumentFragment) doc.createDocumentFragment ();

docOut.addText ("" + output + "");

return docOut;

} catch (Exception e) {}

System.out.println (e);

}

Returns a null value.

}

}

Tags: Fusion Middleware

Similar Questions

  • I am trying to install a program and I get entry point getdlldirectoryw could not be found in the library of links Dynamics kernel32.dll file and the same for shreggetvaluesw to shlwapi.dll

    I am trying to install a program and I get entry point getdlldirectoryw could not be found in the library of links Dynamics kernel32.dll file and the same for shreggetvaluesw in shlwapi.dll. How can I fix the problem.

    You have all your current updates?
    Go to windows updates and see if there are updates that you do not have installed.
    The error message seems to indicate that your copy of XP has not been updated.

    Updated and let us know if you still receive the error message.

    Thank you

    Marilyn

  • Where are the files in the tutorial for each tutorials?

    Where can I find the files in the tutorial for each video tutorial under each Adobe application? I know that they exist. However, it is confusing to find.

    Thank you.

    Tutorials Adobe Creative cloud for students | Tutorials Adobe Creative Cloud

  • opening a binary file with the right extension

    Hello world

    I developed a real simple VI which allows me to read the first five bytes of a binary file for signature (ASCII) and check if its signature match with planned extensions. If Yes, another VI is called and that not one 2 button error message appears: If the user selects OK, a new dialog box opens to choose another file. and if the user chooses cancel, the same dialog box opens instead of escape from the VI.

    This is because while loop (VI below), but I don't see how I can handle this without him. Until the user has not chosen the right extension, he cannot escape from what is a problem! The real case is to call one another VI, and the first step of the stacked sequence is to display an error of two buttons.

    If you have any ideas, I'm a bit new! Thank you!!

    Hi..., christoph

    See the image as an attachment.

    The case of false contains only a true constant connected to any State.

    Mike

  • Since installing open Office 4.0 I can't open .doc files on the fly, used to work before.

    I've recently upgraded to Open Office 4.0. Now can't open Thunderbird .doc attachments. Can I download the disk and open in Open Office Writer with food office or Windows Explorer in the usual way. I checked the tools/options/attachments and it is set to Open Office Writer. I think that's not relevant, but when I had Open Office 3.0, I've had writer defined as a separate program, but now I use just the master front-end server.

    Works OK with .pdf or .jpg files.
    

    just remove the entry from the windows of the spare part and then try and open a doc file. The entry will be recreated using your answers.

    I'm guessing that the existing Writer is not the correct writer.

  • Download binary files with the RESTful web service = HTTP 500?

    I want to allow access to the photos (BLOBs) stored in the database via a RESTful APEX service.

    I have an API of PL/SQL existing based on wpg_docload.download_file works well when called directly on the URL (for example granted to APEX_PUBLIC_USER). I would like to re - use this API because it a lot of other things, including security and the cache.

    The code looks like:
    ===
    Photo of procedure (id number, v in varchar2) is
    l_blob blob.
    -- ...
    Start
    -security checks
    -extract the data in l_blob...
    -check if the document has been updated (304)
    -- ...
    owa_util.mime_header (l_mime_type, false);
    HTP.p ("Content-length: ' |") DBMS_LOB.GetLength (l_blob));
    HTP.p ("ETag:" | ") l_etag);
    HTP.p ('Cache-Control: public');
    owa_util.http_header_close;
    wpg_docload.download_file (l_blob);
    end;
    ===

    However, when I call this API with APEX 4.2.1 Restful WebService (the GET - PL/SQL source type resource manager) I get a "500 - internal server error" back to the listener of the APEX (2.0.0.354.17.08 - both running standalone or with Tomcat 7) - console log attached.

    A similar approach - APEX RESTful WebService API in PL/SQL call - works fine for the content of the STRING/CLOB. So it must be something to do with the wpg_docload.download_file

    No idea how to work around this bug/feature or a suggestion for an alternative approach will be appreciated.

    Jan

    -----

    February 28, 2013 21:39:03 oracle.dbtools.rt.web.WebErrorResponse internalError
    SEVERE: ORA-22922: non-existent LOB value

    java.io.IOException: ORA-22922: non-existent LOB value
    at oracle.jdbc.driver.OracleBlobInputStream.needBytes(OracleBlobInputStream.java:204)
    at oracle.jdbc.driver.OracleBufferedStream.readInternal(OracleBufferedStream.java:169)
    at oracle.jdbc.driver.OracleBufferedStream.read(OracleBufferedStream.java:143)
    at java.io.FilterInputStream.read (unknown Source)
    to java.nio.channels.Channels$ ReadableByteChannelImpl.read (unknown Source)
    at oracle.dbtools.common.util.StreamCopy.drain(StreamCopy.java:75)
    at oracle.dbtools.common.util.StreamCopy.drain(StreamCopy.java:52)
    at oracle.dbtools.rt.web.ServletResponses.sendResponse(ServletResponses.java:85)
    at oracle.dbtools.rt.web.ServletResponses.sendResponse(ServletResponses.java:130)
    at oracle.dbtools.rt.web.HttpEndpointBase.restfulServices(HttpEndpointBase.java:343)
    at oracle.dbtools.rt.web.HttpEndpointBase.service(HttpEndpointBase.java:125)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    to com.sun.grizzly.http.servlet.ServletAdapter$ FilterChainImpl.doFilter (ServletAdapter.java:1059)
    to com.sun.grizzly.http.servlet.ServletAdapter$ FilterChainImpl.invokeFilterChain (ServletAdapter.java:999)
    at com.sun.grizzly.http.servlet.ServletAdapter.doService(ServletAdapter.java:434)
    at oracle.dbtools.standalone.SecureServletAdapter.doService(SecureServletAdapter.java:65)
    at com.sun.grizzly.http.servlet.ServletAdapter.service(ServletAdapter.java:379)
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
    at com.sun.grizzly.tcp.http11.GrizzlyAdapterChain.service(GrizzlyAdapterChain.java:196)
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    to com.sun.grizzly.util.AbstractThreadPool$ Worker.doWork (AbstractThreadPool.java:532)
    to com.sun.grizzly.util.AbstractThreadPool$ Worker.run (AbstractThreadPool.java:513)
    at java.lang.Thread.run (unknown Source)
    Caused by: java.sql.SQLException: ORA-22922: non-existent LOB value

    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:389)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:382)
    at oracle.jdbc.driver.T4C8TTILob.processError(T4C8TTILob.java:792)
    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:505)
    at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:223)
    at oracle.jdbc.driver.T4C8TTILob.read(T4C8TTILob.java:146)
    at oracle.jdbc.driver.T4CConnection.getBytes(T4CConnection.java:2435)
    at oracle.sql.BLOB.getBytes(BLOB.java:348)
    at oracle.jdbc.driver.OracleBlobInputStream.needBytes(OracleBlobInputStream.java:181)
    ... more than 33

    Hi Pat,

    problem with the "media resource" has been resolved for APEX listener 2.0.1

    See Re: error APEX listener 2.0.1 Standalone CLOB

    Jan

  • Copy the file of the cRIO via ftp

    Hello

    I tried to copy a file of cRIO on my computer using the FTP get file.vi but received the error 56. The 56 error appears to be a timeout error, but I am able to access the cRIO normally the PC using FTP. I just follow the link below

    http://digital.NI.com/public.nsf/allkb/3D985C3C08C12D0B862574BB005A7684

    I have attached the picture with the error code

    Concerning

    SJ

    SJ: Take a look at this code snippet.  In addition to the 'active' setting to False (as Dan_U pointed out), do not forget your mechanical operation of the button OK is changed or you will get the error 8.

    NOTE: for some reason, the process of "snippet" lost the constant error within the cluster enter the ftp read.vi. You can try this back and forth, "" for the user and pw or 'anonymous '.  Anonymous œuvres for me.

  • Transfer current Prime Minister files of the desk for laptop.

    I had to transfer my files first adobi of my office at the top of the page on an external hard drive. I'm trying to transfer these files from the external hard drive to my laptop. It will not be down loaded.  I need your help.  Thank you Star.

    What are the files do you mean?

    Program files do not copy, you must perform a new installation

    The files project and video are just files, you copy them like any other file... you will, of course, need to recreate a link to your project to your files

  • Fatal error: invalid page found in the global storage file in the location for cube BSO

    Hi all

    Due to drive App out of space issue, one of my cube essbase BSO is corrupted and I'm trying to restore it from the backup.


    I deleted files .esm & .tct and all the other temporary files, .pag deleted and index files, .app and .db restored backup files, the cube is not starting and throwing the error below.

    Error: 1270005 error loading application 1054003: [Thu Jan 22 16:01:52 2015] Local/EPM_LGCY / / / 17120/Error (1270005)

    Fatal error: invalid page found in the global storage file in the location [0001.0001.00000002]

    I copied the support environment of backend application and tried to launch the cube but still the same error.

    I tried to delete the cube of EAS and still the same error. No doesn't work on this cube, and every time he throws the same error.

    Could someone please explain what the error "invalid page encountered in the global storage to the location file" means and how to fix this?

    Any information is greatly appreciated.

    Thanks in advance

    Srini

    Try the following support document - "Essbase 11.1.2.3.500 by that Block Storage Option (BSO) Application fails to start the errors related to a global Application of the Option (ASO) storage (Doc ID 1667664.1)"

    Essentially to delete the ASO app under the location of the hybrid - /user_projects//EssbaseServer/essbaseserver1/hybrid /.

    See you soon

    John

    http://John-Goodwin.blogspot.com/

  • Caching of files in the installer for DC AIP Installation of Acrobat using transformations

    I created an agreement in principle on the network and have 2 different transformations to apply to the AIP even to Acrobat Pro DC.

    I've used the Acrobat Customization Wizard to create a transform and want to cache the installation for future updates files.
    The installation works fine, but the only files that end up in the directory C:\Program Files (x 86) of \Adobe\Acrobat 2015\Setup Files\

    There's a subdirectory with the GUID, an empty directory of transformations and a 'Enterprise.mnt', but nothing else.

    The AIP is a tentative agreement extracted and patched.  The MST includes the parameter "Checkbox - ENABLE_CACHE_FILES - YES.

    msiexec /i acropro.msi TRANSFORMS = AutoUpdate.mst / QR

    Any help is appreciated!

    Option "Enable caching of files in the Installer" is specific to setup of caching (via the MSI or Setup.exe road facilities). It will not work for facilities using the AIP.

    If this option would have worked with AIP, it would cache files Installer (package used to create the AIP) and no source AIP files (created via msiexec /a AcroPro.msi)

    For Installations made through AIP, as shares of repairs etc. require source AIP files on the network and not the Installer files.

  • Installation of photoshop elements Associates/changed all the files on the computer for photoshop elements files

    I bought Photoshop Elements for my mother while hospitality during Thanksgiving. When I installed it on his computer, it changed all the files on his computer for photoshop elements files, or rather, it combined all the files in photoshop elements. I don't know that it is an operating system problem. Can someone tell me why this is happening and give me a cure? It uses Windows 7. It is a 64-bit computer, if it's important.

    Thanks for any advice.

    Andy

    Hi Andy,.

    Please, try the steps mentioned in the link below and check out them.

    http://helpx.Adobe.com/Acrobat/KB/application-file-icons-change-Acrobat.html

    Kind regards

    Anand

  • import the request xml file and the xml for mds dataset

    Hello world

    I exported xml default request to the metadata file.
    Then I have the ModifyResourceDataSet.xml and I change the ModifyResourceRequest.xml file to use the dataset file.

    I then edit weblogic.properties.
    metadata_from_loc = / u02/app/oracle/product/fmw/IOM/server/bin/oracle/metadata/iam-features-requestactions/model-data
    metadata_files=/U02/app/Oracle/product/FMW/OIM/Server/bin/Oracle/metadata/IAM-features-requestactions/model-data/ModifyResourceRequest.XML
    I executed weblogic.properties
    Can I edit weblogic.properties file again.
    metadata_from_loc = / u02/app/oracle/product/fmw/IOM/server/bin/oracle/metadata/iam-features-requestactions/model-data
    metadata_files=/U02/app/Oracle/product/FMW/OIM/Server/bin/Oracle/metadata/IAM-features-requestactions/model-data/ModifyResourceDataSet.XML

    But, when I try to create change the provided resource, screen related dateset moved not.
    When the error?
    Or where I'm bored?

    Thank you.

    Hüseyin Carole,
    What message errorr you found? Check the doc for the weblogicImportMetadata command.
    http://docs.Oracle.com/CD/E21764_01/doc.1111/e14309/utils.htm#OMDEV759
    Besides that this request for OIMMetadata should be up.
    -Kuldeep

  • How do we create a configuration file of the plugin for Mac/Win?

    Hello!

    I am a relatively new plugin coder! I have developed successfully a few plug-ins. Now, the general course to do an installation of a plugin is to copy - paste in the folder Plugins of Adobe Photoshop. Is there another method? As, installation, which installs the plugin in the right place! I searched the internet but can't find anything very useful.

    Need help...!

    Thank you!

    We have created a full installer of our plug-ins Windows, using the new set of tools Windows Installer XML (WiX).  We search the registry items and files identifying the different versions of Photoshop (and other editors) and set up a «tree "that allows the user to choose which version of Photoshop, it wants to install in.»

    Remember also, that if you create versions of 32 and 64-bit (to run both 32 and 64-bit Photoshop), you have to deal with getting the files in the appropriate folders. WiX has allowed us to package of 32 and 64-bit versions all in one executable file.

    It's almost a necessity to create a true installer in this era of User Account Control (UAC).  The installer must run with elevated privileges to write in subfolders of Plug-ins, for example.

    -Christmas

  • Generate the Zip file on the fly

    I need to dynamically create a zip by calls images file in a particular directory. Is there any kind of tag coldfusion (possibly custom tag) that will allow me to do this? Thank you.

    Another example for you, in function of the Artur Kordowski zip.cfc.

  • implementation of the Hosts file on the server for the entire network?

    I see a lot of information on how to edit the local Hosts file on individual computers. But, is it possible to edit a Hosts file and have effect throughout the network?

    We have a network of a little over half a dozen of Mac mini, who take their DNS information from another Mac Mini running the application server OSX (under El Capitan). This server is the primary DNS machine for the network. I want to implement a Hosts file for the entire network.

    Parental control seems to be broken in OSX El Capitan, so this seems like the best next to us, short option to buy some third-party service, which I prefer not to do.

    I think that dnsmasq installation on your Mac server and configuration of all your computers to use as your "DNS Server" will achieve what you want.

    See osx https://oracle-base.com/articles/misc/dnsmasq-for-simple-dns-configurations-mac-

    Why do you feel you must do this?

Maybe you are looking for