@WebServlet(value="/simpleDiscoverMetamodel") public class JsonSimpleDiscovererServlet extends AbstractJsonDiscoverer
JsonSimpleDiscoverer
.
The servlet answers to POST HTTP calls. Receives as input a JSON document from which a metamodel is discovered. The discovered metamodel is returned as both image and xmi, both of them encoded as base64.
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
folderName
Name of the folder where the temp files will be stored
|
private static long |
serialVersionUID |
static java.lang.String |
SIMPLEDISCOVERER_FOLDER
The ID for this servlet which will be used to access to the working directory
|
dotExePath, jsonParam, properties, serverURL, version, workingDir
Constructor and Description |
---|
JsonSimpleDiscovererServlet() |
Modifier and Type | Method and Description |
---|---|
private java.io.File |
convertToImage(org.eclipse.emf.ecore.EPackage ePackage)
Converts a EPackage into a picture and saves it in disk.
|
private org.eclipse.emf.ecore.EPackage |
discoverMetamodel(java.lang.String jsonCode)
Discover a metamodel from a JSON document.
|
private java.lang.String |
discoverMetamodelBase64(org.eclipse.emf.ecore.EPackage ePackage)
Performs the discovery and returns a picture encoded in BASE64 with the
picture representing the discovered metamodel
The method relies on
convertToImage(EPackage) and
AbstractJsonDiscoverer.encodeToString(File) |
protected void |
doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Performs a POST call to this servlet.
|
void |
init()
Uses the super class init method and additionally initializes
folderName |
addResponseOptions, digestExceptionMessage, doOptions, drawModel, drawModel, drawObjectModel, encodeToString, encodeToString, encodeToString
doDelete, doGet, doHead, doPut, doTrace, getLastModified, service, service
private static final long serialVersionUID
public static final java.lang.String SIMPLEDISCOVERER_FOLDER
private static java.lang.String folderName
public void init() throws javax.servlet.ServletException
folderName
init
in class AbstractJsonDiscoverer
javax.servlet.ServletException
AbstractJsonDiscoverer.init()
protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
Receives a JSON document (in the parameter set in AbstractJsonDiscoverer.jsonParam
)
Discovers a metamodel (using JsonSimpleDiscoverer
) and returns two params:
doPost
in class javax.servlet.http.HttpServlet
request
- The Request of the callresponse
- The Response to the calljavax.servlet.ServletException
java.io.IOException
HttpServlet.doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
private org.eclipse.emf.ecore.EPackage discoverMetamodel(java.lang.String jsonCode) throws javax.servlet.ServletException
THe method uses JsonSimpleDiscoverer
to discover the metamodel (as EPackage
)
jsonCode
- The JSON documentjavax.servlet.ServletException
- Usually triggered with IO-related issuesprivate java.io.File convertToImage(org.eclipse.emf.ecore.EPackage ePackage) throws javax.servlet.ServletException
The method relies on AbstractJsonDiscoverer.drawModel(List, String)
ePackage
- The metamodeljavax.servlet.ServletException
- Something went wrong doing IO thingsprivate java.lang.String discoverMetamodelBase64(org.eclipse.emf.ecore.EPackage ePackage) throws javax.servlet.ServletException
The method relies on convertToImage(EPackage)
and
AbstractJsonDiscoverer.encodeToString(File)
ePackage
- The metamodeljavax.servlet.ServletException
- Something went wrong with IO