Skip to content

Commit

Permalink
added new resource loader in sunbird-vci-plugin initilize method
Browse files Browse the repository at this point in the history
Signed-off-by: Mohd Kaif Siddique <[email protected]>
  • Loading branch information
kaifk468 committed Jan 10, 2024
1 parent cd6f370 commit b5f86cf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package io.mosip.esignet.sunbirdrc.integration.service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.mosip.esignet.api.dto.*;
import io.mosip.esignet.api.exception.KycAuthException;
Expand Down Expand Up @@ -177,7 +176,7 @@ private RegistrySearchRequestDto createRegistrySearchRequestDto(String challenge
registrySearchRequestDto.setOffset(0);
Map<String,Map<String,String>> filter=new HashMap<>();

Map<String, String> challengeMap = objectMapper.readValue(challenge, new TypeReference<Map<String, String>>() {});
Map<String, String> challengeMap = objectMapper.readValue(challenge, Map.class);


for(Map<String,String> fieldDetailMap: fieldDetailList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
package io.mosip.esignet.sunbirdrc.integration.service;


import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.net.URL;
import java.net.URLConnection;
import java.time.LocalDateTime;
import java.util.*;

Expand All @@ -17,6 +21,7 @@
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.resource.loader.URLResourceLoader;
import org.json.JSONArray;
Expand Down Expand Up @@ -83,10 +88,21 @@ public class SunbirdRCVCIssuancePlugin implements VCIssuancePlugin {

@PostConstruct
public void initialize() throws VCIExchangeException {

vEngine = new VelocityEngine();
URLResourceLoader urlResourceLoader = new URLResourceLoader() {
@Override
public InputStream getResourceStream(String name) throws ResourceNotFoundException {
try {
URL url = new URL(name);
URLConnection connection = url.openConnection();
return connection.getInputStream();
} catch (IOException e) {
throw new ResourceNotFoundException("Unable to find resource '" + name + "'");
}
}
};
vEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "url");
vEngine.setProperty("url.resource.loader.class", URLResourceLoader.class.getName());
vEngine.setProperty("url.resource.loader.instance", urlResourceLoader);
vEngine.init();
//Validate all the supported VC
for (String credentialType : supportedCredentialTypes) {
Expand Down

0 comments on commit b5f86cf

Please sign in to comment.