on 09-14-2016 7:06 PM
HI all ,
i have a requirement , i need to decrypt the PGP file and place it in a local NFS directory, with out any mapping
Scenario: file (NFS) to file (NFS)
initally the file will be like BR_AXBT_123.csv.pgp , after decrypting the file , the file should be placed in the target with the file name BR_AXBT_123.csv
please help me on this, how to achieve this
Thanks,
Viany.
Hi Vinay,
Hope, you got solution for this thread. If yes, please close the thread.
Thanks !
Regards,
Gaurav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vinay,
First you need PGPDecryption module in sender file adapter as shown in this blog
This will decrypt the the contents but will not change the filename. To change the filename you need either custom adapter module as shown in this blog http://scn.sap.com/docs/DOC-61728
or you need java mapping as shown below
ESR steps
-----------------
1) Create a Data Type
<DT_Structure>
<Data>
</Data>
</DT_Structure>
2) Create a Message Type, MT_Structure and refer DT_Structure.
3) Create an Outbound Service Interface, SI_Structure_Out and refer MT_Structure.
4) Create an Inbound Service Interface, SI_Structure_In and refer MT_Structure.
5) Create an Operational Mapping, OM_Structure. Refer SI_Structure_Out and SI_Structure_In.
6) Create a zip or jar file of below Java Mapping ‘DynamicFileName_JavaMapping’ (compiled). Import it into ESR as imported archive. Refer this Java Mapping in OM_Structure.
ID steps
------------
1) Create a File Sender channel. In ‘Advance’ tab, select ‘Use Adapter-Specific Message Attributes’ and ‘File Name’.
2) In Receiver channel. In ‘Advance’ tab, select ‘Use Adapter-Specific Message Attributes’ and ‘File Name’.
3) Create Sender and Receiver Communication Components. Create ‘Integrated Configuration’ Object to run scenario in Advance Adapter Engine
4) When input is non-XML, and you are using ICO. Delete SWCV from ICO object.
Regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vinay,
As Manoj mentioned, there is no slandered way to achieve this without mapping. You can try with java mapping.
I had same requirement and implemented with java mapping.
Regards,
Gaurav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vinay,
You can try with the below java code. It will work perfectly fine for your requirement.
create a jar file and import it to imported archive.
Code:
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.DynamicConfiguration;
import com.sap.aii.mapping.api.DynamicConfigurationKey;
import com.sap.aii.mapping.api.StreamTransformationConstants;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
public class DynamicFileName_JavaMapping extends AbstractTransformation
{
public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput)
throws StreamTransformationException
{
try
{
InputStream inputstream = transformationInput.getInputPayload().getInputStream();
OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream();
Map mapParameters = (Map) transformationInput.getInputHeader().getAll();
// a) Set Output File name
mapParameters.put(DynamicConfigurationKey.create("http://sap.com/xi/XI/Dynamic",StreamTransformationConstants.DYNAMIC_CONFIGURATION), "");
DynamicConfiguration conf = (DynamicConfiguration) mapParameters.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
String Fname=conf.get(key);
int length=Fname.length();
int index=length-8;
String newName=Fname.substring(0,index);
//Depending on your requirement edit this logic. Here, NewDynamicName + CurrentDate will be output file name.
conf.put(key, (newName+".csv")); //or we can try .txt
// b) Just copy Input file content to Output file content
byte[] b = new byte[inputstream.available()];
inputstream.read(b);
outputstream.write(b);
} catch (Exception exception)
{
getTrace().addDebugMessage(exception.getMessage());
throw new StreamTransformationException(exception.toString());
}
}
}
you can check the below blog as well for this requirement.
Regards,
Gaurav
Hi Vinay,
I know Guarav already supplied a mapping but here is a different implementation that works for both adding and removing extensions in the case you later have to add an extension for a PGP encrypted file. It makes use of two parameters for the mapping named MODE and VALUE.
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.DynamicConfiguration;
import com.sap.aii.mapping.api.DynamicConfigurationKey;
import com.sap.aii.mapping.api.MappingTrace;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
public class DynamicConfigurationMap extends AbstractTransformation
{
private MappingTrace trace;
private static final DynamicConfigurationKey KEY_FILENAME =
DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
@Override
public void transform(TransformationInput in, TransformationOutput out)
throws StreamTransformationException
{
// Initialize variables, objects for processing
trace = getTrace();
BufferedInputStream bis = new BufferedInputStream(in.getInputPayload().getInputStream());
BufferedOutputStream bos = new BufferedOutputStream(out.getOutputPayload().getOutputStream());
// access dynamic configuration
DynamicConfiguration conf = in.getDynamicConfiguration();
String filename = conf.get(DynamicConfigurationMap.KEY_FILENAME);
if(filename == null || filename.compareTo("") == 0)
{
throw new StreamTransformationException("Invalid or missing filename");
}
// Getting java mapping input parameter for mode and value
String mode = in.getInputParameters().getString("MODE");
String value = in.getInputParameters().getString("VALUE");
if(mode.compareToIgnoreCase("append") == 0)
conf.put(DynamicConfigurationMap.KEY_FILENAME, filename + value);
else if(mode.compareToIgnoreCase("remove") == 0)
conf.put(DynamicConfigurationMap.KEY_FILENAME, filename.replaceFirst(value, ""));
else
{
throw new StreamTransformationException("Unsupported mode: " + mode);
}
// Transfer input stream to output stream without modification
int theInt;
try {
while((theInt = bis.read()) != -1)
{
bos.write(theInt);
}
bos.flush();
bis.close();
bos.close();
} catch (IOException e) {
throw new StreamTransformationException("Error transferring input stream to output stream", e);
}
}
}
Regards,
Ryan Crosby
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.