2.2 OFSLL Wrapper customization

Note:

Note: From the current release onwards, no additional jar file needs to be added since Maven – Pom.xml based model has been implemented.

Follow the below steps for OFSLL wrapper customization:

  1. Import project into eclipse and modify channel. Properties to update below properties.
    ofsll.baseURL = <OFSLL REST service base URL 
    <http://<host>:<port>/OfsllRestWS/service/api/resources>>
    ofsll.username = <OFSLL username>
    ofsll.password = <OFSLL pass>
    ofsll.suffix = htm
    ofsll.otmHttpUrl=https://docs.oracle.com/cd/
    ofsll.fIndex=/findex.htm
    ofsll.index=index.htm
    ofsll.video=/videos.htm
    ofsll.ofsllReleaseNotes=/pdf/refdocs/ofsll_release_notes.pdf
    ofsll.ofsllReleaseDoc=https://docs.oracle.com/en/industries/financial-services/financial-lending-leasing/index.html
    ofsll.splitSeperator==
    ofsll.maxHitsResults=<max number of results returned>
    ofsll.indexDir = <Release index directory path of server >
    ofsll.releaseVersionUrl= <Release Part number>
    ofsll.releaseNo=<Release No>
    ofsll.releaseHighlights=/pdf/refdocs/release_highlights.htm
  2. To add any new service modify com.ofss.ofsll.chatbot.restclient.ChatRestClient.java file.
    • Inside ChatRestClient Class add a new method with required actions
    • Add supporting JAXB files.
    • Use the available supporting methods -- readInputStream, setChatBotResponse, createConnection, stringToJaxb etc.

    Example for document search functionality is indicated below:

    @Consumes(MediaType.APPLICATION_JSON)
        @Produces(MediaType.APPLICATION_JSON)
        @POST
        @Path("/lucenesearch")
        public Response lucenesearch(ODARequestDTO ibcsRequest) throws IOException {
        final IChatbotAssembler chatbotAssembler = ChatbotAssemblerFactory.getInstance().getChatbotAssembler("ODA");
        final HashMap < String,
        Object > map = (HashMap < String, Object > ) ibcsRequest.getProperties();
        String searchQuery = "";
        Properties prop = new Properties();
        try (InputStream propertiesFile = this.getClass().getClassLoader().getResourceAsStream("channel.properties")) {
    prop.load(propertiesFile);
        }
        if (map != null && map.containsKey("query")) {
        searchQuery = (String) map.get("query");
        }
        ResponseDTO ibcsResponse = null;
        try {
        ChatbotResponseDTO chatbotResponse = new ChatbotResponseDTO();
        String indexDirPath = prop.getProperty("ofsll.indexDir")+prop.getProperty("ofsll.releaseNo");
        String releaseVersionUrl = prop.getProperty("ofsll.releaseVersionUrl");
        String urlPrefix = prop.getProperty("ofsll.otmHttpUrl");
        String splitSeperator = prop.getProperty("ofsll.splitSeperator");
        String releaseNo = prop.getProperty("ofsll.releaseNo");
        String urlPrefixPath = urlPrefix + releaseVersionUrl;
        String findexPath = prop.getProperty("ofsll.fIndex");
        String indexPath = prop.getProperty("ofsll.index");
        String videoPath = prop.getProperty("ofsll.video");
        String ofsllReleaseNotesPath = prop.getProperty("ofsll.ofsllReleaseNotes");
        String ofsllReleaseDocPath = prop.getProperty("ofsll.ofsllReleaseDoc");
        Integer maxHitsResults = Integer.parseInt(prop.getProperty("ofsll.maxHitsResults"));
        File fileIndexDirPath = new File(indexDirPath);
        LuceneSearchHighlighter luceneSearchHighlighter = new LuceneSearchHighlighter();
        List<String> fileList = new ArrayList <> ();
        if ((searchQuery.toLowerCase().trim().contains("#ofsll release document")) || 
    (searchQuery.toLowerCase().trim().contains("navigate to index page")) || 
    (searchQuery.toLowerCase().trim().contains("#video gallery")) || 
    (searchQuery.toLowerCase().trim().contains("#ofsll release notes")) || 
    (searchQuery.toLowerCase().trim().contains("#index page"))) {
        if ((searchQuery.toLowerCase().trim().contains("#ofsll release document"))) {
        releaseNo="All Release Version";
        fileList.add(searchQuery + splitSeperator + ofsllReleaseDocPath + splitSeperator+searchQuery+ splitSeperator+releaseNo);
        }
        if ((searchQuery.toLowerCase().trim().contains("navigate to index page"))) {
        fileList.add(searchQuery + splitSeperator + urlPrefixPath + findexPath + splitSeperator+searchQuery+ splitSeperator+releaseNo);
        }
        if ((searchQuery.toLowerCase().trim().contains("#index page"))) {
        searchQuery = indexPath;
        fileList = luceneSearchHighlighter.searchsinglepage(fileIndexDirPath, searchQuery, maxHitsResults, splitSeperator);
        }
        if ((searchQuery.toLowerCase().trim().contains("#video gallery"))) {
        fileList.add(searchQuery + splitSeperator + urlPrefixPath + videoPath + splitSeperator+searchQuery+ splitSeperator+releaseNo);
        }
        if ((searchQuery.toLowerCase().trim().contains("#ofsll release notes"))) {
        fileList.add(searchQuery + splitSeperator + urlPrefixPath + ofsllReleaseNotesPath + splitSeperator+searchQuery+ splitSeperator+releaseNo);
        }
        } else {
        searchQuery = searchQuery.replaceAll("#", "");
        fileList = luceneSearchHighlighter.search(fileIndexDirPath, searchQuery, maxHitsResults, splitSeperator);
        }
        String serviceOutputForChatBot = "";
        for (String obj: fileList) {
        if (serviceOutputForChatBot == "") {
        serviceOutputForChatBot = obj.replace("\\", "/");
        } else {
        serviceOutputForChatBot = serviceOutputForChatBot + "\n---\n" + obj.replace("\\", "/");
        }
        }
        if (fileList.isEmpty()) {
        String errorOutputForChatBot = "Search is not found for : " + searchQuery;
        setChatBotResponse("failure", errorOutputForChatBot, chatbotResponse, "response", "request");
        } else {
        List < String > srhchoices = new ArrayList < >();
        for (String obj: fileList) {
        srhchoices.add(obj.replace("\\", "/"));
        }
        setChatBotResponse("success", srhchoices, chatbotResponse, "acc_srh", "acc_srh");
        }
        ibcsResponse = chatbotAssembler.fromChatbotResponseDTO((RequestDTO) ibcsRequest, chatbotResponse);
        } catch(Exception e) {
        LOGGER.log(Level.SEVERE, e.getMessage());
        }
        return Response.status(Response.Status.OK).entity((Object) this.buildResponse((Object) ibcsResponse)).build();
    }
  3. Export project as war file.
  4. Deploy <WL_Home>/wlserver/common/deployable-libraries/jax-rs-2.0.war as Library on weblogic.
  5. Deploy generated WAR (OracleFSLLChatBot.war) in step 3 onto weblogic server.
  6. Note down base service URL that is required while publishing in ODA.
    Example: http://<host>:<port>/ofsll/v1/fulfillment