Josef
Josef

convert DOS files to UNIX
dos2unix (comes with cygwin)
http://www.cygwin.com/
 
If you are processing images.. any reason why FileOutputStream is a better 
handler than FileImageOutputStream
http://docs.oracle.com/javase/6/docs/api/javax/imageio/stream/FileImageOutputStream.html
 
    if (f.exists() && f.canWrite()) {
                f.delete();            }else
{
//use the existing file handle before writing it out..
//you will have to know the exact length of the file before writing it out
}

?
Martin 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.

 

 
Subject: [axis2-mtom] how to deal with line endings among platforms
Date: Thu, 6 Jun 2013 11:01:15 +0200
From: josef.stadelm...@axa-winterthur.ch
To: axis-u...@ws.apache.org






[axis2-mtom] how to deal with line endings among platforms




Hi all,

I have a web service client realized in C#.NET WCF and a Axis2-1-6-1 MTOM web 
service with a up- and download method.

It works perfect and byte transparent as long as I transfer binaries such as 
Word Document, Excel Spread Sheets .docx, doc, .xslx, xls, xlsm, bmp, jpeg, 
etc. files.



Now I have to move .PAS files from my server to the client on a PC for 
development and that’s where I need your recommendations

On the OpenVMS Server a .PAS file is saved with the following file attributes 
RFM:VAR,  RAT:CR 

saying the record format RFM is variable and the record attribute RAT is 
carriage return controlled.

The RFM:VAR says that each record does not need a LF or CR or CRLF to terminate 
the line BUT

but the record starts with a  two byte character count telling how many 
ISO-LATIN1 characters are in the record.

I know that all JAVA used Stream_LF only, I can use that as well to edit by 
i.e. EDT on the Server;



However each time someone edits such a file on a PC, by default Windows/DOS 
appends CRLF to the end of the line, and just moving such a file now with MTOM 
to the server makes the PASCAL compiler complaining about an illegal character 
at the end of the line which is the CR, while the LF is considered by the 
PASCAL compiler.

My question is now;

How can I, best at the server, convert this CRLF to a LF only, or even better 
to a VAR file, by adding a short to the begin of the record

and remove the DOS CRLF line termination. 

Is there a possibility to configure my service client or server side to replace 
each CRLF with a LF i.e. when a certain fikle extension is seen i.e. ".PAS, 
.TXT"



The issue is that MTOM delivers to the service an ImageDepot which is a 
DataHandler which provides stream of bytes, which I processes as all my 
binaries like



    private void processImageDepot(ImageDepot data, String fname, String owner, 
String protection)

            throws Exception, IOException, InterruptedException {

        DataHandler dh = data.getImageData();

        if (dh != null) {

            File f = new File(fname);

            if (f.exists() && f.canWrite()) {

                f.delete();

            }

            FileOutputStream fos = new FileOutputStream(f);

            dh.writeTo(fos);

            fos.flush();

            fos.close();

                // post processing to correct file-attributes, -owner and 
-protection

            if ("OpenVMS".equalsIgnoreCase(this.OperatingSystem)) {

                Process pid;

                String[][] args = {

                    {"/sys$login/test.com", f.getPath(), owner, protection}

                    {"/sys$login/compile.com", f.getPath(), "/DEBUG/NOOPTIMIZE"}

                };

                for (int j = 0; j < args.length; j++) {

                    // j goes over command lines 

                    for (int i = 0; i < args[j].length; i++) {

                        // i goers over aguments in command line

                        log.info("args[" + j + "][" + i + "] " + args[j][i]);

                    }

                    try {

                        pid = Runtime.getRuntime().exec(args[j]);

                        pid.waitFor();

                    } catch (IllegalArgumentException e) {

                        log.error("Don't know how to activate son");

                        log.error(e.getMessage(), e);

                    }

                }

            }

        } else {

            log.error(">> [ERROR] - ImageDepot was not null, but did not 
contain binary data");

        }

                                          

Reply via email to