Obtener información del sistema invocando el servicio web REST
# Instantiate a utility to handle IO
#set($IOUtils = $ClassTool.newInstance("org.apache.commons.io.IOUtils"))
# Instantiate a URL to the getInfo service of LogicalDOC
#set($clazzUrl = $context.getClass().forName("java.net.URL"))
#set($clazzString = $context.getClass().forName("java.lang.String"))
# Adjust the url to point to your LogicalDOC installation
#set($url = $clazzUrl.getConstructor($clazzString).newInstance("http://localhost:8080/services/rest/system/getInfo"))
$log.info("url: $url")
# Open the connection to the remote server
#set ($con = $url.openConnection())
# Send a GET request and print the response status
$con.setRequestMethod("GET");
#set ($status = $con.getResponseCode())
$log.info("status: $status")
# Get the body of the response and store it in a variable
#set ($result = '')
#if ($status > 299)
#set ($result = $IOUtils.toString($con.getErrorStream(), "UTF-8"))
#else
#set ($result = $IOUtils.toString($con.getInputStream(), "UTF-8"))
#end
# Print the result
$log.info("result: $result");
Este procedimiento está diseñado para demostrar la invocación de un método de servicio web REST externo. Simplemente invoca una URL e imprime el resultado, en este caso usamos el punto final del servicio web REST System.getInfo disponible en cada instalación de LogicalDOC.
Reemplaze http://localhost:8080 con la URL base de su instalación.