64e674a9 by Ean Schuessler

Add support for pulling Wiki docs into screen render

1 parent 2e3ebc43
......@@ -19,8 +19,9 @@
<screen-factory load-path="screen/" />
<!-- Load seed data -->
<entity-factory load-data="data/McpSecuritySeedData.xml" />
<entity-factory load-data="data/McpSecuritySeedData.xml" />
<entity-factory load-data="data/McpPromptsData.xml" />
<entity-factory load-data="data/McpScreenDocsData.xml" />
<!-- Webapp Configuration -->
<webapp-list>
......
......@@ -94,7 +94,8 @@ Use the following discovery tools to explore available functionality:
versionName="v1">
<fileData><![CDATA[# Moqui MCP Server
This server provides access to Moqui ERP through MCP.
This server provides access to Moqui ERP through MCP. Typically you will be searching for a product by name or by a feature like size or color.
If it is a feature based query it is probably best to use the FindFeature screen to locate the feature and then use FindProduct to search for products with that feature.
## Getting Started
......
......@@ -1335,11 +1335,11 @@ def wikiInstructions = getWikiInstructions(inputScreenPath)
}
if (dbResourceFile) {
ec.logger.info("BrowseScreens: dbResourceFile.fileData: ${dbResourceFile.fileData ? 'exists, size=' + dbResourceFile.fileData.length : 'null'}")
ec.logger.info("BrowseScreens: dbResourceFile.fileData: ${dbResourceFile.fileData ? 'exists, size=' + dbResourceFile.fileData.length() : 'null'}")
}
if (dbResourceFile && dbResourceFile.fileData) {
def content = new String(dbResourceFile.fileData, "UTF-8")
def content = new String(dbResourceFile.fileData.getBytes(new Long(1).longValue(), new Long(dbResourceFile.fileData.length()).intValue()), "UTF-8")
ec.logger.info("BrowseScreens: Found wiki instructions for ${simplePath}, length: ${content?.length()}")
return content
}
......
......@@ -16,8 +16,6 @@ package org.moqui.mcp
import groovy.transform.CompileStatic
import org.moqui.context.*
import org.moqui.context.MessageFacade.MessageInfo
import org.moqui.impl.context.ExecutionContextFactoryImpl
import org.moqui.impl.context.ContextJavaUtil
import org.slf4j.Logger
import org.slf4j.LoggerFactory
......@@ -32,8 +30,8 @@ import java.util.EventListener
@CompileStatic
class WebFacadeStub implements WebFacade {
protected final static Logger logger = LoggerFactory.getLogger(WebFacadeStub.class)
protected final ExecutionContextFactoryImpl ecfi
protected final ExecutionContextFactory ecfi
protected final Map<String, Object> parameters
protected final Map<String, Object> sessionAttributes
protected final String requestMethod
......@@ -62,7 +60,7 @@ class WebFacadeStub implements WebFacade {
protected Object responseJsonObj = null
boolean skipJsonSerialize = false
WebFacadeStub(ExecutionContextFactoryImpl ecfi, Map<String, Object> parameters,
WebFacadeStub(ExecutionContextFactory ecfi, Map<String, Object> parameters,
Map<String, Object> sessionAttributes, String requestMethod, String screenPath = null) {
this.ecfi = ecfi
this.parameters = parameters ?: [:]
......@@ -233,7 +231,13 @@ class WebFacadeStub implements WebFacade {
void sendJsonResponse(Object responseObj) {
if (!skipJsonSerialize) {
this.responseJsonObj = responseObj
this.responseText = ContextJavaUtil.jacksonMapper.writeValueAsString(responseObj)
try {
def mapper = new com.fasterxml.jackson.databind.ObjectMapper()
this.responseText = mapper.writeValueAsString(responseObj)
} catch (Exception e) {
logger.warn("Error serializing JSON: ${e.message}")
this.responseText = responseObj.toString()
}
} else {
this.responseJsonObj = responseObj
this.responseText = responseObj.toString()
......