Package com.isomorphic.rpc

# Class BuiltinRPC

java.lang.Object
com.isomorphic.base.Base
com.isomorphic.rpc.BuiltinRPC

All Implemented Interfaces:
  `com.isomorphic.base.IAutoConfigurable`

Direct Known Subclasses:
  `BuiltinRPC`

public class BuiltinRPC extends com.isomorphic.base.Base
This class implements a set of "built-in" RPC methods that are available to all applications as part of all standard SmartClient distributions. Most of these methods should not be callable from the client in a production setting. By default, all of these are enabled in the smartclientSDK and only the methods flagged as enabled in smartclientRuntime are enabled there by default.

You can control which methods are enabled by listing the enabled methods under the server.properties attribute `RPCManager.enabledBuiltinMethods`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static RPCResponse`
  `appendToFile(String path, String data)`
  Appends the supplied contents to a file under webroot.
  `static RPCResponse`
  `deleteFile(String path)`
  Deletes an arbitrary file under webRoot.
  `static void`
  `downloadClientContent(String fileContents, String fileName, String mimeType, RPCManager rpc, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)`
  Accepts string content and streams it back as a file to the requester via content-disposition: attachment.
  `static void`
  `downloadClientExport(List<? extends Map<String,Object>> records, String exportAs, String fileName, String exportDisplay, Map<String,Object> settings, jakarta.servlet.http.HttpServletResponse response, RPCManager rpc, RPCRequest request)`
  Accepts a List of formatted Record-data, exports it to the specified format and streams it back as a file with the specified fileName to the requester via content-disposition: attachment.
  `static void`
  `downloadWSDL(String url, String format, String fileName, RPCManager rpc, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)`
  Loads a WSDL file from the specified URL, optionally translates it to SmartClient-compatible JS format and streams the file back to the requester via content-disposition: attachment.
  `static void`
  `downloadZip(Map<String,Object> settings, RPCManager rpc, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)`
  This method is used by the Export Project feature in Reify.
  `static RPCResponse`
  `evalJava(String javaCode, RequestContext context)`
  This method is used by the "Evaluate Java" section of the Developer Console (in the Results tab).
  `static Collection`
  `getLogEntries(String logName)`
  Returns the contents of the specified log4j log.
  `static List`
  `getLogNames()`
  Returns the list of available log4j log names.
  `static RPCResponse`
  `loadFile(String path)`
  Returns the contents of any file under webRoot as a String.
  `static RPCResponse`
  `loadSharedXML(String type, String ID)`
  Load a DS, UI, or APP file from the standard search path.
  `static RPCResponse`
  `ping()`
  Convenience method for pinging the server to check whether it's alive.
  `static RPCResponse`
  `saveFile(String path, String data)`
  Saves a file under webRoot with the supplied contents.
  `static RPCResponse`
  `saveSharedXML(String type, String ID, String contents)`
  Writes or overwrites a UI, DS or APP file with the provided contents.
  `static RPCResponse`
  `uploadProgressCheck(jakarta.servlet.http.HttpSession session, String formID)`
  Used by the FileUpload control to periodically check the progress of a file upload.
  `static RPCResponse`
  `xmlToJS(String xmlString, RPCRequest req)`
  Translates XML to JS in exactly the same fashion as done by the <isomorphicXML> JSP tag.

- ## Method Details

  - ### downloadWSDL

    public static void downloadWSDL(String url, String format, String fileName, RPCManager rpc, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws Exception
    Loads a WSDL file from the specified URL, optionally translates it to SmartClient-compatible JS format and streams the file back to the requester via content-disposition: attachment.

    This method is used by the Download feature of the WSDL tab in the Developer Console.

    Parameters:
      `url` - The URL from which to load the WSDL file. Can be relative or absolute.
      `format` - Set to 'xml' to stream the file without translation to JS or 'js' to get translated output.
      `fileName` - This method returns a stream with content-disposition: attachment. This argument specifies the default filename that will be shown to the user in the "save as" dialog that comes up in the browser.
    Throws:
      `Exception`

  - ### downloadClientContent

    public static void downloadClientContent(String fileContents, String fileName, String mimeType, RPCManager rpc, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws Exception
    Accepts string content and streams it back as a file to the requester via content-disposition: attachment.

    This method is used by the Download feature of the DataSourceList in Reify.

    Parameters:
      `fileContents` - The string data to return in a file for saving.
      `fileName` - This method returns a stream with content-disposition: attachment. This argument specifies the default filename that will be shown to the user in the "save as" dialog that comes up in the browser.
      `mimeType` - The MIME type with which to save the fileContents
    Throws:
      `Exception`

  - ### downloadZip

    public static void downloadZip(Map<String,Object> settings, RPCManager rpc, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws Exception
    This method is used by the Export Project feature in Reify.
    Parameters:
      `settings` - data to export
    Throws:
      `Exception`

  - ### xmlToJS

    public static RPCResponse xmlToJS(String xmlString, RPCRequest req) throws Exception
    Translates XML to JS in exactly the same fashion as done by the <isomorphicXML> JSP tag.

    This method is enabled by default in smartclientRuntime

    Parameters:
      `xmlString` - String of XML to be translated to JS.
    Returns:
      The 'data' payload of the RPCResponse is a String containing the translated result. If an error occurs, status is set to STATUS_FAILURE and 'data' contains the error string.
    Throws:
      `Exception`

  - ### ping

    public static RPCResponse ping() throws Exception
    Convenience method for pinging the server to check whether it's alive.
    Returns:
      RPCResponse containing the number 1 as data
    Throws:
      `Exception`

  - ### uploadProgressCheck

    public static RPCResponse uploadProgressCheck(jakarta.servlet.http.HttpSession session, String formID) throws Exception
    Used by the FileUpload control to periodically check the progress of a file upload.

    This method is enabled by default in smartclientRuntime

    Parameters:
      `formID` - The ID of the form uploading the file.
    Returns:
      The 'data' payload of the RPCResponse is a Map that contains two attributes: bytesSoFar and totalBytes. If an error occurs, status is set to STATUS_FAILURE and 'data' contains the error string.
    Throws:
      `Exception`

  - ### deleteFile

    public static RPCResponse deleteFile(String path) throws Exception
    Deletes an arbitrary file under webRoot.

    This method is used by the Reify tool.

    Parameters:
      `path` - file to delete, must be relative to webRoot.
    Returns:
      an RPCResponse with STATUS_SUCCESS if successful, STATUS_FAILURE with 'data' set to the error string otherwise.
    Throws:
      `Exception`

  - ### saveFile

    public static RPCResponse saveFile(String path, String data) throws Exception
    Saves a file under webRoot with the supplied contents.

    This method is used by the Reify tool.

    You can use SKUploadSaveFile datasource for the purpose of saving files. This datasource uses saveFile method so be sure it is enabled in RPCManager.enabledBuiltinMethods property. You can upload files using the datasource with the help of add operation.

    Parameters:
      `path` - location of new file, must be relative to webRoot
      `data` - contents of new file
    Returns:
      an RPCResponse with STATUS_SUCCESS if successful, STATUS_FAILURE with 'data' set to the error string otherwise.
    Throws:
      `Exception`

  - ### appendToFile

    public static RPCResponse appendToFile(String path, String data) throws Exception
    Appends the supplied contents to a file under webroot. If the file does not exist, this method is the same as saveFile.
    Parameters:
      `path` - location of file, must be relative to webRoot
      `data` - text to append to file
    Returns:
      an RPCResponse with STATUS_SUCCESS if successful, STATUS_FAILURE with 'data' set to the error string otherwise.
    Throws:
      `Exception`

  - ### loadFile

    public static RPCResponse loadFile(String path) throws Exception
    Returns the contents of any file under webRoot as a String.

    This method is used by the Reify tool.

    Parameters:
      `path` - location of file to load
    Returns:
      'data' payload of RPCResponse contains the contents of the file. If an error occurs, status is set to STATUS_FAILURE and 'data' contains the error string.
    Throws:
      `Exception`

  - ### evalJava

    public static RPCResponse evalJava(String javaCode, RequestContext context) throws Exception
    This method is used by the "Evaluate Java" section of the Developer Console (in the Results tab). It takes java code and writes it to a temporary JSP, sandwiched by the contents of /shared/jsp/evalJavaHeader.jsp and /shared/jsp/evalJavaFooter.jsp. Then the resulting JSP is loaded via an internal container request. The output of that request is sent back to the browser in the 'data' payload of the RPCResponse.
    Parameters:
      `javaCode` - Arbitrary JSP content, java sections must be enclosed in standard Java escape tags (<% %>).
    Returns:
      'data' payload of RPCResponse contains the result of executing the specified code via the JSP parser. If an error occurs, status is set to STATUS_FAILURE and 'data' contains the error string.
    Throws:
      `Exception`

  - ### loadSharedXML

    public static RPCResponse loadSharedXML(String type, String ID) throws Exception
    Load a DS, UI, or APP file from the standard search path. Returns the source XML and translated JS by default.

    This method is used by the Reify tool.

    Parameters:
      `type` - UI or DS or APP
      `ID` - the ID of the file to load
    Returns:
      The 'data' payload of the RPCResponse contains a Map that contains the 'type' as passed in, the 'ID' as passed in, 'xml' with the XML version of the file, 'js' with the JS version of the file (as translated from XML). If an error occurs, the Map contains an 'error' property that contains the error string.
    Throws:
      `Exception`

  - ### saveSharedXML

    public static RPCResponse saveSharedXML(String type, String ID, String contents) throws Exception
    Writes or overwrites a UI, DS or APP file with the provided contents. Location of the file is based on the file type - these directories are controlled by the server.properties attributes project.(datasources|apps|ui)

    This method is used by the Reify tool.

    Parameters:
      `type` - UI or DS or APP
      `ID` - Specifies the base filename, .ui.xml or .ds.xml or .app.xml is automatically appended, based on the type.
      `contents` - The contents of the file.
    Returns:
      The 'data' payload of the RPCResponse contains a Map with the 'type' and 'ID' properties as passed in. If an error occurs, the Map contains an 'error' property that contains the error string.
    Throws:
      `Exception`

  - ### getLogNames

    public static List getLogNames() throws Exception
    Returns the list of available log4j log names.

    This method is used by the Server Logs tab of the Developer Console.

    Returns:
      The list of available log names.
    Throws:
      `Exception`

  - ### getLogEntries

    public static Collection getLogEntries(String logName) throws Exception
    Returns the contents of the specified log4j log.

    This method is used by the Server Logs tab of the Developer Console.

    Parameters:
      `logName` - The name of the log.
    Returns:
      The contenst of the specified log4j.log.
    Throws:
      `Exception`

  - ### downloadClientExport

    public static void downloadClientExport(List<? extends Map<String,Object>> records, String exportAs, String fileName, String exportDisplay, Map<String,Object> settings, jakarta.servlet.http.HttpServletResponse response, RPCManager rpc, RPCRequest request) throws Exception
    Accepts a List of formatted Record-data, exports it to the specified format and streams it back as a file with the specified fileName to the requester via content-disposition: attachment.

    Parameters:
      `records` - The records to return in a file for saving.
      `exportAs` - The export-format to convert the passed records into
      `fileName` - If parameter exportDisplay is "download", this method returns a stream with content-disposition: attachment. This argument specifies the default filename that will be shown to the user in the "save as" dialog that comes up in the browser.
      `exportDisplay` - Should the content be exported to a file or a browser window
      `settings` - Settings for the export. See `DataBoundComponent.exportClientData` in the client-side documentation for details
    Throws:
      `Exception`