public abstract class AbstractJsonDiscoverer
extends javax.servlet.http.HttpServlet
In particular, this class helps to:
drawModel(List, String)
and drawModel(List, String, GVFigureDescription)
encodeToString(File)
,
encodeToString(EPackage, String)
and encodeToString(List, String)
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
dotExePath
The path to the Graphviz DOT execitable (needed for generating the pictures)
|
(package private) static java.lang.String |
jsonParam
The jsonParam used for discovery (where the json code is stored)
|
(package private) java.util.Properties |
properties |
private static long |
serialVersionUID |
(package private) static java.lang.String |
serverURL
Server for the CORS
|
static java.lang.String |
version
Version of the app
|
static java.io.File |
workingDir
The main path to the working dir (needed for generating the pictures)
|
Constructor and Description |
---|
AbstractJsonDiscoverer() |
Modifier and Type | Method and Description |
---|---|
protected void |
addResponseOptions(javax.servlet.http.HttpServletResponse response)
Generic method to aoid CORS problems.
|
protected java.lang.String |
digestExceptionMessage(java.lang.String message)
Digest an exception message to remove the name of the exception and take
the real message
|
protected void |
doOptions(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Overrides the method to add the CORS headers.
|
(package private) java.io.File |
drawModel(java.util.List<org.eclipse.emf.ecore.EObject> elements,
java.lang.String uniqueId)
Draws a model into a picture following the standard graphical style.
|
(package private) java.io.File |
drawModel(java.util.List<org.eclipse.emf.ecore.EObject> elements,
java.lang.String uniqueId,
org.emftools.emf2gv.graphdesc.GVFigureDescription graphDesc)
Draws a model into a picture, stored a file.
|
(package private) java.io.File |
drawObjectModel(java.util.List<org.eclipse.emf.ecore.EObject> elements,
org.eclipse.emf.ecore.EPackage ePackage,
java.lang.String uniqueId)
Draws a model into a picture with a UML-like graphical style.
|
(package private) java.lang.String |
encodeToString(org.eclipse.emf.ecore.EPackage ePackage,
java.lang.String uniqueId)
Saves the EPackage into a XMI and then read it to return it as String in Base64.
|
(package private) java.lang.String |
encodeToString(java.io.File path)
Encodes a file into BASE64 format.
|
(package private) java.lang.String |
encodeToString(java.util.List<org.eclipse.emf.ecore.EObject> elements,
java.lang.String uniqueId)
Saves a list of EObjects into a XMI and then read it to return it as String in Base64.
|
void |
init()
Initilizes the servlet class.
|
doDelete, doGet, doHead, doPost, doPut, doTrace, getLastModified, service, service
private static final long serialVersionUID
public static java.io.File workingDir
public static java.lang.String dotExePath
public static java.lang.String version
static java.lang.String jsonParam
static java.lang.String serverURL
java.util.Properties properties
public void init() throws javax.servlet.ServletException
It performs the following steps:
init
in class javax.servlet.GenericServlet
javax.servlet.ServletException
GenericServlet.init()
java.lang.String encodeToString(java.io.File path) throws java.io.IOException
In the context of the tool, this method is used to encode generated pictures
(usually with @link drawModel(List, String)
) into
BASE64 format, which is easy to exchange with the web client.
path
- The path to the file to encodejava.io.IOException
- Thrown when the file cannot be writtenjava.lang.String encodeToString(org.eclipse.emf.ecore.EPackage ePackage, java.lang.String uniqueId) throws javax.servlet.ServletException
The workflow followed is:
EPackage
) will be storedString
encoded as Base64Metamodels are saved in a directory that is configred by providing a value to the corresponding property in the config.properties file. The key to retrieve the property is provided in the para uniqueId.
ePackage
- The metamodel (as EPackage
uniqueId
- The key to retrieve the property in the config.properties file setting
the folder where the metamodel will be savedString
encoded in Base64 representing the metamodeljavax.servlet.ServletException
- Something went wrong (usually IO-related problem)java.lang.String encodeToString(java.util.List<org.eclipse.emf.ecore.EObject> elements, java.lang.String uniqueId) throws javax.servlet.ServletException
encodeToString(EPackage, String)
The workflow followed is:
EObject
s will be storedEObject
s in the temp fileString
encoded as Base64
The list of EObject
s are saved in a directory that is configred by providing
a value to the corresponding property in the config.properties file. The key to retrieve
the property is provided in the para uniqueId.
elements
- The list of EObject
suniqueId
- The key to retrieve the property in the config.properties file setting
the folder where the list of EObject
s will be savedString
encoded in Base64 representing the list
of EObject
sjavax.servlet.ServletException
- Something went wrong (usually IO-related problem)java.io.File drawModel(java.util.List<org.eclipse.emf.ecore.EObject> elements, java.lang.String uniqueId, org.emftools.emf2gv.graphdesc.GVFigureDescription graphDesc) throws javax.servlet.ServletException
The process follows these steps:
Files are stored in a folder configured in the config properties file. The name of the property is set by the uniqueId param.
The generation of the picture is delegated to the method StandaloneProcessor.process(EObject, GVFigureDescription, File, String, org.emftools.emf2gv.processor.core.IProcessorCallback, org.emftools.emf2gv.processor.core.IEObjectIconProvider, String, boolean, boolean, String, List, org.emftools.emf2gv.processor.core.ILogger, org.eclipse.core.runtime.IProgressMonitor)
A graphical style has to be provided. See the documentation of EMF2GV to know how to create it.
elements
- List of elements (as EObject
s) to be drawnuniqueId
- Id used to retrieve the folder name from the config properties file to store the filegraphDesc
- Graphical description according to EMF2GV formatjavax.servlet.ServletException
- If any problem appears (usually IO-related problems)java.io.File drawModel(java.util.List<org.eclipse.emf.ecore.EObject> elements, java.lang.String uniqueId) throws javax.servlet.ServletException
This method relies on drawModel(List, String, GVFigureDescription)
Default graphical style will be used. The style is provided by EMF2GV library, please refer to its documentation for further details.
elements
- List of elements (as EObject
s) to be drawnuniqueId
- Id used to retrieve the folder name from the config properties file to store the filejavax.servlet.ServletException
- If any problem appears (usually IO-related problems)java.io.File drawObjectModel(java.util.List<org.eclipse.emf.ecore.EObject> elements, org.eclipse.emf.ecore.EPackage ePackage, java.lang.String uniqueId) throws javax.servlet.ServletException
This method relies on drawModel(List, String, GVFigureDescription)
elements
- List of elements (as EObject
s) to be drawnePackage
- The metamodel (as EPackage
) which the element conform touniqueId
- Id used to retrieve the folder name from the config properties file to store the filejavax.servlet.ServletException
- If any problem appears (usually IO-related problems)protected void addResponseOptions(javax.servlet.http.HttpServletResponse response)
Adds the CORS headers related to access-control-allow settings
The value for the header Access-Control-Allow-Origin is parameterized with the value given in the config.properties with the key serverURL
response
- The response where the headers will be addedprotected void doOptions(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
This method relies on addResponseOptions(HttpServletResponse)
doOptions
in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
java.io.IOException
HttpServlet.doOptions(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
protected java.lang.String digestExceptionMessage(java.lang.String message)
message
- The undigested exception message