BizTalk SourceFileName becomes dehydrated - biztalk

I'm trying to use a custom filename since i need to create two files (a backupfile) so i followed the following tutorial to create filename Here
now when i test this with DELCUS%MessageID%.txt everything works fine but when i change it to DELCUS%SourceFileName%.txt the interface becomes permanently dehydrated.
the only thing i do for the filename is this
fileName = "ContExt" + System.DateTime.Now.ToString();
Message_send_Belspeed_BeautDay_ContExt(FILE.ReceivedFileName) =
fileName;
is there any reason why the use of SourceFileName would cause this to dehydrate?

Found the issue.
after a while the interface did crash and the filename looks like
DELCUS2012 10:50:40.txt
having : in a filename is not good.

This is just a standard windows file naming limitation, you can't name your file using any of these characters "\ / : * ? " < > |". So obviously your instances are going to get stuck!!

Related

How to get rid of the original file path instead of name in PGP encryption with ChoPGP library?

I tried PGP encrypting a file in ChoPGP library. At the end of the process it shows embedded file name along with the whole original file name path.
But I thought it will show only the filename without the whole path. Which I intend to work on and figure out a way to do so?
Doing the following:
using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
{
pgp.EncryptFile(#"\\appdevtest\c$\appstest\Transporter\test\Test.txt",
#"\\appdevtest\c$\appstest\Transporter\test\OSCTestFile_ChoPGP.gpg",
#"\\appdevtest\c$\appstest\Transporter\pgpKey\PublicKey\atorres\atorres_publicKey.asc",
true,
true);
}
which will result in:
But I would like to only extract the Test.txt in the end something
like this:
Looking at this line from the ChoPGP sources: https://github.com/Cinchoo/ChoPGP/blob/7152c7385022823013324408e84cb7e25d33c3e7/ChoPGP/ChoPGPEncryptDecrypt.cs#L221
You may find out that it uses internal function GetFileName, which ends up with this for the FileStream: return ((FileStream)stream).Name;.
And this one, according to documentation, Gets the absolute path of the file opened in the FileStream..
So you should either make fork of ChoPGP and modify this line to extract just filename, or submit a pull request to the ChoPGP. Btw, it's just a wrapper around the BouncyCastle so you may use that instead.

Using Jsch ChannelSftp put to a GDG file on mainframe

I'm currently stuck on trying to find a way to put to a generation data group (GDG) on mainframe(zos) using Jsch.
The command line syntax would be
put myFile.txt GDG.MYGDG(+1)
This I know works fine when using sftp or ftp command via a linux shell. I have not found any way to replicate this via the put method of the ChannelSftp class.
I have searched wide and far looking for examples and not found any which makes me think it is not possible with this framework.
Any help would be appreciated.
UPDATE
adding some example code. This is not the full code but shows what I have tried.
String localFileName = localFile.getName();
String remoteFile = "GDG.GDGROUP1(+1)";
FileInputStream inputStream = new FileInputStream(localFile);
ChannelSftp channelSftp = this.getChannelSftp();
String pwd = channelSftp.pwd();
channelSftp.put(inputStream, remoteFile);
The put call always returns that this is directory. I have also tried this for the remote file:
String remoteFile = localFile + " GDG.GDGROUP1(+1)";
This just returns failure.
I have tried absolute path using // and /-/. So far nothing has worked.

How to change PMD's Copy Paste Detector (CPD) report output

I'd like to modify CPD to only spit out the Found a X line (Y tokens) duplication in the following files: ... when generating a report, i.e. suppress the source lines of code. I have the /src/ files and attempted to modify SimpleRenderer.java in /src/net/sourceforge/pmd/cpd/ by commenting out
String source = match.getSourceCodeSlice();
if (trimLeadingWhitespace) {
String[] lines = source.split("[" + PMD.EOL + "]");
int trimDepth = StringUtil.maxCommonLeadingWhitespaceForAll(lines);
if (trimDepth > 0) {
lines = StringUtil.trimStartOn(lines, trimDepth);
}
for (int i=0; i<lines.length; i++) {
rpt.append(lines[i]).append(PMD.EOL);
}
return;
}
However the report has not changed. I'm a bit of a Java novice, so keep that in mind. Do I need to rebuild the pmd-4.2.x in Eclipse somehow?
There are different ways to achieve this:
Without modifying PMD/CPD at all by using egrep. You can e.g. post-filter the report:
bin/run.sh cpd --minimum-tokens 100 --files src --encoding UTF-8 \
| egrep "^Found a |^Starting at line "
This would output now only the lines which start with "Found a " or "Starting at line ".
Modifying PMD/CPD to adjust the report format. I would however suggest, to implement this modified report format as a separate format, e.g. naming it "text_without_sources", rather than changing the default format. You would then call CPD with bin/run.sh cpd --format text_without_sources ....
In that case, you'll need to build PMD from sources. PMD uses Maven to build (you can use eclipse during development - but the package is built with maven). After a mvn clean package in the top-directory of the cloned sources from https://github.com/pmd/pmd you'll find the binary in the directory pmd-dist/target/.
Look at how the reports are integrated in CPDConfiguration.java - you can add your own version of the SimpleRenderer.
Create a feature-request at https://sourceforge.net/p/pmd/bugs/

reading from dynamically set filenames in R

I am writing a CGI script in Perl with a section of embedded R script which produces a graph. The original data filename is unknown as it has been uploaded by the CGI script and is stored in a Perl variable called $filename.
My question is that I now would like to open that file in R using read.table(). I am using Statistics::R and so I have tried:
my $R = Statistics::R->new();
$R->set('filename',$filename);
my $out1 = $R->run(
q`rm(list=ls())`,
# Fetch data
q`setwd("/var/www/uploads")`,
q`peakdata<-read.table(filename, sep="",col.names=c("mz","intensity","ionsscore","matched","query","index","hit"))`,
q`attach(peakdata)` ...etc
I can get this to work ONLY if I change $filename into something static and known like 'data.txt' before trying to open the file in read.table - is there a way for me to open a file with a variable for a name?
Thank you in advance.
One possible way to do this is by doing a little more work in Perl.
This is untested code, to give you some ideas:
my $filename = 'fileNameIGotFromSomewhere.txt'
my $source_dir = '/var/www/uploads';
my $file = "$source_dir/$fielname";
# make sure we can read it
unless ( -r $file ) {
die 'can read that data file: $!";
}
Then instead of $R->set, you could interpolate the file name into the R program. Where you've used the single-quote operator, use the double-quote operator instead:
So instead of:
q`peakdata<-read.table(filename, sep="",col.names= .... )`
Use:
qq`peakdata<-read.table($filename, sep="",col.names= .... )`
Now this looks like it would be inviting problems similar to SQL/Code Injections, so that's why I put int the logic to insure that the file exists and is readable. You might be able to think other checks to add to safeguard your use of user-supplied info.

Add file at root of zip file using DotNetZip with classic ASP

I have DotNetZip installed and running fine on a Windows 2008 server.
Using a classic ASP page, I want to bundle a bunch of comma-delimited files to a user and send it over in a zip file.
The following code works fine but it stores all the path information so the files inside the zip file are located in some ridiculous directory like C:\Inetpub\wwwroot\appname\_temp\
I'm using the following code:
Set objZip = CreateObject("Ionic.Zip.ZipFile")
sFileArray = Split(sFileArray, "|")
For iCount = 0 To UBound(sFileArray)
If sFileArray(iCount) <> "" Then
objZip.AddFile sFileArray(iCount)
End If
Next
objZip.Name = sFilePath & "test.zip"
objZip.Save()
objZip.Dispose()
Set objZip = Nothing
I see that the AddFile method allows you to specify where you want the added file to reside in the zip file if you add a second parameter. According to the documentation objZip.AddFile sFileArray(iCount), "" should put the file in the root of the zip file.
However, when I add that parameter, I get the following error:
Wrong number of arguments or invalid property assignment: 'objZip.AddFile'
Anyone have any idea what I'm doing wrong?
Thanks.
I think you are misinterperting the documentation. If the second parameter is null then the directory path of the file being added is used. If the second parameter is an empty string "" then the file is added to the root level in the zip. A quick look into the Ioniz.zip.dll shows that the single parameter override of AddFile method simply calls the the double parameter override with the second parameter set to null.
Hence your add file should look like:
objZip.AddFile sFileArray(iCount), ""
to get the result you are after.

Resources