com.yworks.yfiles.server.graphml.support
Class GraphRoundtripSupport

java.lang.Object
  extended bycom.yworks.yfiles.server.graphml.support.AbstractGraphRoundtripSupport
      extended bycom.yworks.yfiles.server.graphml.support.GraphRoundtripSupportBase
          extended bycom.yworks.yfiles.server.graphml.support.GraphRoundtripSupport
All Implemented Interfaces:
RoundtripSupport, ServletRoundtripSupport
Direct Known Subclasses:
ExternalizableGraph.CustomGraphRoundtripSupport

public class GraphRoundtripSupport
extends GraphRoundtripSupportBase
implements ServletRoundtripSupport

Utility class that helps during Graph roundtrips to the client. This instance can be used to create a temporary graph, receive it from a client's request and send it back to the client.

This class adds support for servlets to its base class GraphRoundtripSupportBase.


Nested Class Summary
 
Nested classes inherited from class com.yworks.yfiles.server.graphml.support.GraphRoundtripSupportBase
GraphRoundtripSupportBase.RoundtripGraphMLLayoutGraphIOHandler
 
Field Summary
 
Fields inherited from class com.yworks.yfiles.server.graphml.support.GraphRoundtripSupportBase
EDGE_LABELS_DPKEY, EDGE_SOURCE_PORT_DPKEY, EDGE_STYLE_DPKEY, EDGE_TARGET_PORT_DPKEY, EDGE_Z_ORDER_DPKEY, NODE_LABELS_DPKEY, NODE_PORTS_DPKEY, NODE_STYLE_DPKEY, NODE_Z_ORDER_DPKEY, SHARED_DATA_DPKEY, TABLE_DPKEY
 
Fields inherited from class com.yworks.yfiles.server.graphml.support.AbstractGraphRoundtripSupport
EDGE_2_ID_DPKEY, mappers, NODE_2_ID_DPKEY, objectMappers, PARAM_GRAPH, RESPONSE_DOCUMENT_TAG, USERTAGS_DPKEY
 
Constructor Summary
GraphRoundtripSupport()
           
 
Method Summary
 boolean readGraph(HttpServletRequest request, Graph graph)
          If the request contains the AbstractGraphRoundtripSupport.PARAM_GRAPH parameter, the parameter value is used for updating the graph instance currently stored in the session.
 void sendError(java.lang.String message, HttpServletResponse response)
          Send an error to the client.
 void sendGraph(Graph graph, HttpServletResponse response)
          Send the current graph to the client in GraphML format using UTF-8 encoding.
protected  void setLocalRoot(HttpServletRequest request, Graph graph)
          Uses the localRoot request parameter (if available), to set the local root node.
 
Methods inherited from class com.yworks.yfiles.server.graphml.support.GraphRoundtripSupportBase
addDeserializer, addRegisteredHandlers, addSerializer, configureHandler, configureRoundtripGraph, createHandler, createRoundtripGraph, createSharedDataOutputHandler, getDefaultNodeSize, getGraphMLVersion, getSharedInstanceProvider, isAutoReadMapperData, isAutoWriteMapperData, isCommitPortLocations, isDocumentFragmentMode, isFoldingEnabled, isIgnoreMissingDeserializer, isLocalViewMode, isMapLabelModels, isParseGraphMLVersion, isSupportTables, isSupportZOrder, readGraph, readGraph, sendGraph, setAutoReadMapperData, setAutoWriteMapperData, setCommitPortLocations, setDefaultNodeSize, setDocumentFragmentMode, setFoldingEnabled, setGraphMLVersion, setIgnoreMissingDeserializer, setLocalViewMode, setMapLabelModels, setParseGraphMLVersion, setSharedInstanceProvider, setSupportTables, setSupportZOrder
 
Methods inherited from class com.yworks.yfiles.server.graphml.support.AbstractGraphRoundtripSupport
addMapper, addObjectMapper, createAutoMapperInputHandlerProvider, createAutoMapperOutputHandlerProvider, createDefaultElementTagWrapper, createInputHandlerProvider, createObjectInputHandlerProvider, createObjectOutputHandlerProvider, createOutputHandlerProvider, createTagInputHandlerProvider, createTagOutputHandler, createXmlWriter, getGraphDecoder, getTagInputHandlerProvider, getTagOutputHandler, isSupportUserTags, sendError, setSupportUserTags
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.yworks.yfiles.server.graphml.support.RoundtripSupport
addMapper, addObjectMapper, createRoundtripGraph, isSupportUserTags, readGraph, readGraph, sendError, sendGraph, setSupportUserTags
 

Constructor Detail

GraphRoundtripSupport

public GraphRoundtripSupport()
Method Detail

readGraph

public boolean readGraph(HttpServletRequest request,
                         Graph graph)
                  throws java.io.IOException
Description copied from interface: ServletRoundtripSupport
If the request contains the AbstractGraphRoundtripSupport.PARAM_GRAPH parameter, the parameter value is used for updating the graph instance currently stored in the session.

To decide whether the value of the AbstractGraphRoundtripSupport.PARAM_GRAPH parameter has to be decoded and decompressed, the "graphEncoding" parameter is used. For example, to indicate base64-encoded, zlib-compressed and URI-encoded data, the value has to be "base64/zlib/encodeURIComponent".

Specified by:
readGraph in interface ServletRoundtripSupport
Parameters:
request - The servlet request
Returns:
whether the request contained a graph that was read.
Throws:
java.io.IOException - If parsing goes wrong.

setLocalRoot

protected void setLocalRoot(HttpServletRequest request,
                            Graph graph)
Uses the localRoot request parameter (if available), to set the local root node.

This method is called when a graph is read from a servlet request and folding support is enabled.

Parameters:
request - A servlet request that contains the localRoot request parameter, specifying the id of the local root node.
graph - A graph for which the local root node should be set.
See Also:
GraphRoundtripSupportBase.isFoldingEnabled()

sendGraph

public void sendGraph(Graph graph,
                      HttpServletResponse response)
               throws java.io.IOException
Description copied from interface: ServletRoundtripSupport
Send the current graph to the client in GraphML format using UTF-8 encoding. This method will close the response stream.

The response content type is set to "text/xml".

Specified by:
sendGraph in interface ServletRoundtripSupport
Parameters:
graph - The current graph.
response - The response that will be sent to the client.
Throws:
java.io.IOException - If something goes wrong during GraphML export.

sendError

public void sendError(java.lang.String message,
                      HttpServletResponse response)
               throws java.io.IOException
Send an error to the client. The error is sent in XML format:
  <?xml version="1.0" encoding="UTF-8"?>
  <response>
    <errors>
      <error>
       <![CDATA[
          error message
        ]]>
      </error>
    </errors>
 </response>
 

Specified by:
sendError in interface ServletRoundtripSupport
Parameters:
message - The error message.
response - The response.
Throws:
java.io.IOException - If writing to the response writer fails.


Copyright © 2000-2013 yWorks GmbH. All rights reserved