Hello
I am trying to change the save location of the report file.
On Ariscommunity.com I found a topic "Path to Output File"
(https://www.ariscommunity.com/users/martinmiskovic/2015-07-15-path-output-file).
But in this topic, an Excel file was used, and I need to output an XML file.
It's my code:
function outputFileToFolder( folderName, fileName, oData ) {
var oFile = new java.io.File(folderName+fileName);
var oOS = new java.io.FileOutputStream(oFile);
oOS.write(oData); // Error: nullPointerException, because oData is empty
oOS.close();
}
function main() {
var xmlOutput = Context.createXMLOutputObject(Context.getSelectedFile(), "Root");
//then I fill the file with content using methods "addElement" and "setAttribute"
//at the end I do this:
Context.addOutputFileName ("101.xml");
xmlOutput.WriteReport(); // it's default folder
var oData = Context.getFile("101.xml", Constants.LOCATION_OUTPUT); // <- oData // is null, because file "101.xml" not apeared in default folder
outputFileToFolder( "C://TEMP//output", "Data.xml", oData ); // it's my folder
}
But if I run this script without the last two lines,
var oData = Context.getFile("101.xml", Constants.LOCATION_OUTPUT);
outputFileToFolder( "C://TEMP//output", "Data.xml", oData );
then the file "101.xml" appears in the default folder.
Tell me please, how can I set my folder for creation report by script?
Hi,
well perhaps the problem is that the ARIS report creates the output files always on temporary folders on the server and later on, those files are "delivered" to the client pc and the temporary folders (and files) should be deleted.
You could just create an additional output file and use this one:
Context.addOutputFileName(sLogFileName);
This command will add the file names sLogFileName and transfer it to the client pc at the rend of the report.
Regards,
Robert
Hello Robert
Thank you for your answer!
I wanted to set up communication with another system.
I.e.
1) An xml file comes from another system to the "input" folder, the ARIS system processes it - I did it.
2) After processing, the ARIS system generates a response (report file) and places it in the "output" folder from which another system takes this file - I cannot configure the path for saving the report to the "output" folder.
Both "input" and "output" folders are located on the ARIS server. Subsequently, I plan to poll the "input" folder automatically on a schedule.
Well, you could save the file directly on a specific windows folder on the server.
oFile = Context.getFile(Context.getSelectedFile(), Constants.LOCATION_OUTPUT);
oByteArrayInputStream = new java.io.ByteArrayInputStream(oFile);
oInputStream = new java.io.BufferedInputStream(oByteArrayInputStream);
sFileName = g_tOptions.sOutputPath + "/" + sName;
oFile = new java.io.File(sFileName);
oOutputStream = new java.io.FileOutputStream(oFile);
oBufferedOutStream = new java.io.BufferedOutputStream(oOutputStream);
while ((aByte = oInputStream.read()) != -1){
oBufferedOutStream.write(aByte);
}
oBufferedOutStream.close();
Should work like this (more or less)...
Regards,
Robert
Hello, Robert
Thank you very much!
You have really help me!!!
function outputFileToFolder( folderName, fileName, oData ) {
var oFile = Context.getFile(Context.getSelectedFile(), Constants.LOCATION_OUTPUT);
var oByteArrayInputStream = new java.io.ByteArrayInputStream(oFile);
var oInputStream = new java.io.BufferedInputStream(oByteArrayInputStream);
var sFileName = folderName + "/" + fileName;
oFile = new java.io.File(sFileName);
var oOutputStream = new java.io.FileOutputStream(oFile);
var oBufferedOutStream = new java.io.BufferedOutputStream(oOutputStream);
while ((aByte = oInputStream.read()) != -1){
oBufferedOutStream.write(aByte);
}
oBufferedOutStream.close();
}