Reputation: 1
I am using Veeva Vault java sdk. We are trying some vault-triggers and successfully we are able to land in our desired java method. From there we need to call external apis. But the problem is that we cannot use any HTTPClient libraries, as veeva vault do not support any external libraries apart from jdk classes (Even veeva doesn't include jdk network packages). Do anybody know how to use external libraries in Veeva vault?
While in debugger mode, the below code runs, but when we deploy this veeva vault, vault cannot find HttpClient classes. Veeva vault just ask for java files and one xml file which is compressed in .vpk and uploaded in vault.
@RecordTriggerInfo(object = "welotranslate__c", events = {RecordEvent.BEFORE_INSERT})
public class HelloWorld implements RecordTrigger {
public void execute(RecordTriggerContext recordTriggerContext) {
final HttpGet request = new HttpGet("https://www.google.com"); // this class not found
HttpClient httpClient = HttpClients.createDefault(); // this class not found
HttpGet httpGet = new HttpGet("http://www.google.com"); // this class not found
HttpResponse response = null;
try {
response = httpClient.execute(httpGet);
} catch (IOException e) {
throw new RuntimeException(e);
}
String responseString = null;
try {
responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
} catch (IOException e) {
throw new RuntimeException(e);
}
System.out.println(responseString);
RecordService recordService = ServiceLocator.locate(RecordService.class);
List<Record> recordList = VaultCollections.newList();
for (RecordChange inputRecord : recordTriggerContext.getRecordChanges()) {
String name = inputRecord.getNew().getValue("demo__c", ValueType.STRING);
inputRecord.setError("amazing", responseString.substring(0,3));
}
}
[type=INVALID_DATA,message=javasdk/src/main/java/com/veeva/vault/custom/triggers/HelloWorld.java:7: error: package org.apache.http does not exist import org.apache.http.HttpResponse; ^ javasdk/src/main/java/com/veeva/vault/custom/triggers/HelloWorld.java:8: error: package org.apache.http.client does not exist import org.apache.http.client.HttpClient; ^
Upvotes: 0
Views: 77
Reputation: 1
Veeva Vault enforces strict limitations on the Java classes you can use in custom code. Only classes within the Vault Java SDK (com.veeva.vault.sdk.api.*) and a limited set of allowlisted JDK classes are permitted. This is a security measure to ensure the stability and security of the Vault platform.
You cannot include third-party libraries, such as Apache HTTP Client, in your VPK. Vault only allows the Vault Java SDK and a limited number of allowlisted JDK classes.
Vault validates your code during deployment, and if you use non-allowlisted classes, deployment will fail. This validation process checks for references to external libraries.
The correct way to make HTTP requests from within Vault Java SDK is to use the HTTPService provided by the Vault Java SDK. This service allows you to construct request and response objects and send requests:
Example HTTP callout code: https://github.com/veeva/vsdk-service-basics/wiki/Http-Callout-External-Example
Upvotes: 0