Click HERE to see how Saviynt Intelligence is transforming the industry. |
04/02/2024 07:38 PM
We have configured SFTP connector to transfer file from analytics generated to customer SFTP location.
We see SFTP connector sending zip formated file to SFTP location from Saviynt analytics location after job execution successfully.
But customer is expecting us to send file in csv formmated file in specific file name not the analytics generated random name contains <reportname>hkey***.zip.
We are looking for help what would be approach we can use with the available options in Saviynt to achieve this.
Appreciated help.
Solved! Go to Solution.
04/02/2024 07:40 PM
You need to use custom jar code to extract zip file and send required file to client sftp.
04/02/2024 07:49 PM
Thank you for your quick response.
Am new to Saviynt and need your help how to configure custom jar to extract zip from analytics location. Let me know if you have any sample java file to connect analytics and extract zip, place it back with right file name. It would be great if you can help me on this. I have searched all over to forum posts and didn't get right direction on this. Thank you.
04/02/2024 07:56 PM
Use saviynt APIs
Refer sample Java Code
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class ZipExtractor {
public static void main(String[] args) {
String zipFilePath = "path/to/your/zipfile.zip";
String csvFileName = "example.csv";
try {
ZipFile zipFile = new ZipFile(zipFilePath);
ZipEntry entry = zipFile.getEntry(csvFileName);
if (entry != null) {
InputStream inputStream = zipFile.getInputStream(entry);
OutputStream outputStream = new FileOutputStream(new File(csvFileName));
byte[] buffer = new byte[1024];
int length;
while ((length = inputStream.read(buffer)) > 0) {
outputStream.write(buffer, 0, length);
}
outputStream.close();
inputStream.close();
zipFile.close();
System.out.println("CSV file extracted successfully.");
} else {
System.out.println("CSV file not found in the ZIP archive.");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
04/02/2024 08:10 PM
Thank you so much and it's really great info for me to start. I will try this and let you know how that goes.
Is the zipFilePath in sample code just need to be /Analytics/<reportname> or am I missing something here.
04/02/2024 08:14 PM
/saviynt_shared/reports/Archive/Analytics/ReportName.zip
ReportName remove spaces - You can download report from UI to check report naming convention
04/03/2024 05:55 AM
Are Step#1 an Step#3 really need if analytics job scheduled to run and step#2 doing file rename? To upload file after extract and renamed from zip to csv (step#2), we will be using SFTP File Transfer Job through connector to SFTP location.
We use trigger chain job to run all of these steps in order. Let me know if my understanding or approach is not correct.
04/03/2024 08:08 PM
You can follow triggerchain
04/04/2024 04:36 PM
Thank you, i have done some changes to your java code to read zip file from the folder above and created jar with java version 11.0.18 (OpenJDK).
Am getting below error after running external jar job with this jar class. Does this mean uploaded jar (compiled class) not supported with saviynt java version? Could you please let me know whats the saviynt support java version, so that i will create jar with that JDK version and upload jar again.
2024-04-04T23:26:00.12169025Z stdout F org.quartz.JobExecutionException: com/test/ZipExtractor has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 (unable to load class [com.test.ZipExtractor]) [See nested exception: java.lang.UnsupportedClassVersionError: com/test/ZipExtractor has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 (unable to load class [com.onetrust.modernhealth.ZipExtractor])]
04/04/2024 05:31 PM - edited 04/04/2024 05:32 PM
Now, i have uploaded the jar file compiled on JDK1.8. Am not seeing above error now. Could you please let me know what do i need to pass Method name and arguments where my class has only
2024-04-05T00:23:41.829641953Z stdout F 2024-04-05 00:23:41,829 [quartzScheduler_Worker-3] DEBUG jobs.ExternalJarJob - START ExternalJarJob |
2024-04-05T00:23:41.841099356Z stdout F 2024-04-05 00:23:41,841 [quartzScheduler_Worker-3] DEBUG jobs.ExternalJarJob - Lets Invoke Class Namecom.test.ZipExtractor method |
2024-04-05T00:23:41.841141556Z stdout F 2024-04-05 00:23:41,841 [quartzScheduler_Worker-3] DEBUG jobs.ExternalJarJob - arguments: |
2024-04-05T00:23:41.857504202Z stdout F 2024-04-05 00:23:41,841 [quartzScheduler_Worker-3] ERROR jobs.ExternalJarJob - Error: |
2024-04-05T00:23:41.857543403Z stdout F groovy.lang.MissingMethodException: No signature of method: com.test.ZipExtractor.() is applicable for argument types: () values: [] |
2024-04-05T00:23:41.857549903Z stdout F Possible solutions: is(java.lang.Object), any(), wait(), find(), use([Ljava.lang.Object;), grep() |
2024-04-05T00:23:41.857554903Z stdout F at ExternalJarJob.execute(ExternalJarJob.groovy:90) |
2024-04-05T00:23:41.857559103Z stdout F at org.quartz.core.JobRunShell.run(JobRunShell.java:199) |
2024-04-05T00:23:41.857563403Z stdout F at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:546) |
04/04/2024 08:41 PM
method name - main
04/04/2024 08:54 PM
Should i need to pass any value for arguments field on job configuration or just leave it blanl since its main method?
04/04/2024 08:56 PM
if your jar needs it then share.
Share Jar for further help
04/04/2024 09:07 PM - edited 04/08/2024 07:05 AM
Here is jar attached. actually we dont need any inputs from arguments in logic to perform. i have added system.out.println statements but i dont see any logs in log viewer, also i have added logger class but that was also not helpful. This what i see when i dont pass arguments field.
2024-04-05T04:10:52.767471605Z stdout F 2024-04-05 04:10:52,767 [quartzScheduler_Worker-2] DEBUG jobs.ExternalJarJob - START ExternalJarJob |
2024-04-05T04:10:52.800555582Z stdout F 2024-04-05 04:10:52,800 [quartzScheduler_Worker-2] DEBUG jobs.ExternalJarJob - Lets Invoke Class Namecom.onetrust.modernhealth.ZipExtractor method main |
2024-04-05T04:10:52.805333722Z stdout F 2024-04-05 04:10:52,805 [quartzScheduler_Worker-2] DEBUG jobs.ExternalJarJob - arguments: |
2024-04-05T04:10:52.821251555Z stdout F 2024-04-05 04:10:52,821 [quartzScheduler_Worker-2] DEBUG jobs.ExternalJarJob - Writing job history to import logs. |
2024-04-05T04:10:52.821282355Z stdout F 2024-04-05 04:10:52,821 [quartzScheduler_Worker-2] DEBUG jobs.ExternalJarJob - Number of log entries to be written : 3 |
2024-04-05T04:10:52.848262181Z stdout F 2024-04-05 04:10:52,848 [quartzScheduler_Worker-2] DEBUG jobs.ExternalJarJob - END ExternalJarJob |
04/04/2024 09:24 PM
There are no arguments needed. If you need further code help you can work with TAM/SI Partner
04/05/2024 09:08 AM
am able to execute code through external jar job, but not sure we can read files from the location as you provided the path above.
04/05/2024 10:29 AM
You can
04/08/2024 07:04 AM
Thank you @rushikeshvartak for all your help. i was able to read saviynt reports folder location and extract zip, rename to csv file succesfully. i was able to copy csv file to same location as well and make it available for SFTP connector.
one change: files can be read from folder location is: /saviynt_shared/reports/Analytics/<analyticsreportname>/ not /saviynt_shared/reports/Archive/Analytics/<analyticsreportname>/
04/08/2024 07:06 AM
Great You can share working jar for others benefits
04/19/2024 12:08 AM - edited 04/19/2024 12:09 AM
Hi @SureshPatike Could you please share working jar and all steps to extract zip file? We have to send csv file to SFTP server.
04/30/2024 01:18 PM
04/30/2024 01:31 PM
Please click the 'Accept As Solution' button on the reply (or replies) that best answered your original question.