64e674a9 by Ean Schuessler

Add support for pulling Wiki docs into screen render

1 parent 2e3ebc43
...@@ -19,8 +19,9 @@ ...@@ -19,8 +19,9 @@
19 <screen-factory load-path="screen/" /> 19 <screen-factory load-path="screen/" />
20 20
21 <!-- Load seed data --> 21 <!-- Load seed data -->
22 <entity-factory load-data="data/McpSecuritySeedData.xml" /> 22 <entity-factory load-data="data/McpSecuritySeedData.xml" />
23 <entity-factory load-data="data/McpPromptsData.xml" /> 23 <entity-factory load-data="data/McpPromptsData.xml" />
24 <entity-factory load-data="data/McpScreenDocsData.xml" />
24 25
25 <!-- Webapp Configuration --> 26 <!-- Webapp Configuration -->
26 <webapp-list> 27 <webapp-list>
......
...@@ -94,7 +94,8 @@ Use the following discovery tools to explore available functionality: ...@@ -94,7 +94,8 @@ Use the following discovery tools to explore available functionality:
94 versionName="v1"> 94 versionName="v1">
95 <fileData><![CDATA[# Moqui MCP Server 95 <fileData><![CDATA[# Moqui MCP Server
96 96
97 This server provides access to Moqui ERP through MCP. 97 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.
98 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.
98 99
99 ## Getting Started 100 ## Getting Started
100 101
......
...@@ -1335,11 +1335,11 @@ def wikiInstructions = getWikiInstructions(inputScreenPath) ...@@ -1335,11 +1335,11 @@ def wikiInstructions = getWikiInstructions(inputScreenPath)
1335 } 1335 }
1336 1336
1337 if (dbResourceFile) { 1337 if (dbResourceFile) {
1338 ec.logger.info("BrowseScreens: dbResourceFile.fileData: ${dbResourceFile.fileData ? 'exists, size=' + dbResourceFile.fileData.length : 'null'}") 1338 ec.logger.info("BrowseScreens: dbResourceFile.fileData: ${dbResourceFile.fileData ? 'exists, size=' + dbResourceFile.fileData.length() : 'null'}")
1339 } 1339 }
1340 1340
1341 if (dbResourceFile && dbResourceFile.fileData) { 1341 if (dbResourceFile && dbResourceFile.fileData) {
1342 def content = new String(dbResourceFile.fileData, "UTF-8") 1342 def content = new String(dbResourceFile.fileData.getBytes(new Long(1).longValue(), new Long(dbResourceFile.fileData.length()).intValue()), "UTF-8")
1343 ec.logger.info("BrowseScreens: Found wiki instructions for ${simplePath}, length: ${content?.length()}") 1343 ec.logger.info("BrowseScreens: Found wiki instructions for ${simplePath}, length: ${content?.length()}")
1344 return content 1344 return content
1345 } 1345 }
......
...@@ -16,8 +16,6 @@ package org.moqui.mcp ...@@ -16,8 +16,6 @@ package org.moqui.mcp
16 import groovy.transform.CompileStatic 16 import groovy.transform.CompileStatic
17 import org.moqui.context.* 17 import org.moqui.context.*
18 import org.moqui.context.MessageFacade.MessageInfo 18 import org.moqui.context.MessageFacade.MessageInfo
19 import org.moqui.impl.context.ExecutionContextFactoryImpl
20 import org.moqui.impl.context.ContextJavaUtil
21 import org.slf4j.Logger 19 import org.slf4j.Logger
22 import org.slf4j.LoggerFactory 20 import org.slf4j.LoggerFactory
23 21
...@@ -32,8 +30,8 @@ import java.util.EventListener ...@@ -32,8 +30,8 @@ import java.util.EventListener
32 @CompileStatic 30 @CompileStatic
33 class WebFacadeStub implements WebFacade { 31 class WebFacadeStub implements WebFacade {
34 protected final static Logger logger = LoggerFactory.getLogger(WebFacadeStub.class) 32 protected final static Logger logger = LoggerFactory.getLogger(WebFacadeStub.class)
35 33
36 protected final ExecutionContextFactoryImpl ecfi 34 protected final ExecutionContextFactory ecfi
37 protected final Map<String, Object> parameters 35 protected final Map<String, Object> parameters
38 protected final Map<String, Object> sessionAttributes 36 protected final Map<String, Object> sessionAttributes
39 protected final String requestMethod 37 protected final String requestMethod
...@@ -62,7 +60,7 @@ class WebFacadeStub implements WebFacade { ...@@ -62,7 +60,7 @@ class WebFacadeStub implements WebFacade {
62 protected Object responseJsonObj = null 60 protected Object responseJsonObj = null
63 boolean skipJsonSerialize = false 61 boolean skipJsonSerialize = false
64 62
65 WebFacadeStub(ExecutionContextFactoryImpl ecfi, Map<String, Object> parameters, 63 WebFacadeStub(ExecutionContextFactory ecfi, Map<String, Object> parameters,
66 Map<String, Object> sessionAttributes, String requestMethod, String screenPath = null) { 64 Map<String, Object> sessionAttributes, String requestMethod, String screenPath = null) {
67 this.ecfi = ecfi 65 this.ecfi = ecfi
68 this.parameters = parameters ?: [:] 66 this.parameters = parameters ?: [:]
...@@ -233,7 +231,13 @@ class WebFacadeStub implements WebFacade { ...@@ -233,7 +231,13 @@ class WebFacadeStub implements WebFacade {
233 void sendJsonResponse(Object responseObj) { 231 void sendJsonResponse(Object responseObj) {
234 if (!skipJsonSerialize) { 232 if (!skipJsonSerialize) {
235 this.responseJsonObj = responseObj 233 this.responseJsonObj = responseObj
236 this.responseText = ContextJavaUtil.jacksonMapper.writeValueAsString(responseObj) 234 try {
235 def mapper = new com.fasterxml.jackson.databind.ObjectMapper()
236 this.responseText = mapper.writeValueAsString(responseObj)
237 } catch (Exception e) {
238 logger.warn("Error serializing JSON: ${e.message}")
239 this.responseText = responseObj.toString()
240 }
237 } else { 241 } else {
238 this.responseJsonObj = responseObj 242 this.responseJsonObj = responseObj
239 this.responseText = responseObj.toString() 243 this.responseText = responseObj.toString()
......