com.esri.arcgis.system
Class ServerUtilities

java.lang.Object
  extended by com.esri.arcgis.system.ServerUtilities

public class ServerUtilities
extends Object


Constructor Summary
ServerUtilities()
           
 
Method Summary
static JSONObject createOperation(String operationName, String parameterList, String supportedOutputFormatsList, boolean postOnly)
          Creates an operation that can be called on a REST resource, using specified name, parameter list and output formats list
static JSONObject createResource(String name, String description, boolean isCollection)
          Creates a REST resource based on specified name, description and collection flag
static Envelope getEnvelopeFromJSON(JSONObject jobj)
          Retrieves Envelope from JSON
static JSONObject getJSONFromEnvelope(Envelope env)
          Retrieves JSON from Envelope
static JSONObject getJSONFromFeature(Feature feature)
          Returns JSON representation of a Feature object
static JSONObject getJSONFromMultipoint(Multipoint multipoint)
          Returns JSON representation of a Multipoint object
static JSONObject getJSONFromPoint(Point point)
          Returns JSON representation of a Point object
static JSONObject getJSONFromPolygon(Polygon polygon)
          Returns JSON representation of a Polygon object
static JSONObject getJSONFromPolyline(Polyline polyline)
          Returns JSON representation of a Polyline object
static JSONObject getJSONFromSR(ISpatialReference sr)
          Retrieves JSON from Spatial Reference
static Multipoint getMultipointFromJSON(JSONObject multipointJSON)
          Extracts MultiPoint geometry from specified JSONObject
static Point getPointFromJSON(JSONObject pointJSON)
          Extracts Point geometry from specified JSONObject
static Polygon getPolygonFomJSON(JSONObject polygonJSON)
          Extracts Polygon geometry from specified JSONObject
static Polyline getPolylineFomJSON(JSONObject polylineJSON)
          Extracts Polyline geometry from specified JSONObject
static ILog2 getServerLogger()
          Returns a handle to ArcGIS Server's log file via the ILog2 interface.
static ISpatialReference getSRFromJSON(JSONObject spatialReferenceJSON)
          Retrieves spatial reference from JSON
static ISpatialReference getSRFromString(String spatialReferenceString)
          Retrieves spatial reference from string This method may throw a runtime exception in case of errors
static String sendError(int codeNumber, String errorMessageSummary, String[] errorMessageDetails)
          Sends error message back to client in proper JSON format, which is as follows * { "error": { "code": 400, "message": "Cannot perform query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerUtilities

public ServerUtilities()
Method Detail

getSRFromString

public static ISpatialReference getSRFromString(String spatialReferenceString)
                                         throws Exception
Retrieves spatial reference from string This method may throw a runtime exception in case of errors

Parameters:
spatialReferenceString -
Returns:
ISpatialReference
Throws:
Exception

getSRFromJSON

public static ISpatialReference getSRFromJSON(JSONObject spatialReferenceJSON)
                                       throws Exception
Retrieves spatial reference from JSON

Parameters:
spatialReferenceJSON -
Returns:
ISpatialReference
Throws:
Exception

getJSONFromSR

public static JSONObject getJSONFromSR(ISpatialReference sr)
Retrieves JSON from Spatial Reference

Parameters:
sr -
Returns:

getEnvelopeFromJSON

public static Envelope getEnvelopeFromJSON(JSONObject jobj)
Retrieves Envelope from JSON

Parameters:
jobj -
Returns:

getJSONFromEnvelope

public static JSONObject getJSONFromEnvelope(Envelope env)
Retrieves JSON from Envelope

Parameters:
env -
Returns:

getJSONFromPoint

public static JSONObject getJSONFromPoint(Point point)
                                   throws Exception
Returns JSON representation of a Point object

Parameters:
point - com.esri.arcgis.geometry.Point
Returns:
JSONObject JSON representation of input Point
Throws:
Exception

getJSONFromMultipoint

public static JSONObject getJSONFromMultipoint(Multipoint multipoint)
                                        throws Exception
Returns JSON representation of a Multipoint object

Parameters:
multipoint - com.esri.arcgis.geometry.Multipoint
Returns:
JSONObject JSON representation of input Multipoint
Throws:
Exception

getJSONFromPolyline

public static JSONObject getJSONFromPolyline(Polyline polyline)
                                      throws Exception
Returns JSON representation of a Polyline object

Parameters:
polyline - com.esri.arcgis.geometry.Polyline
Returns:
JSONObject JSON representation of input Polyline
Throws:
Exception

getJSONFromPolygon

public static JSONObject getJSONFromPolygon(Polygon polygon)
                                     throws Exception
Returns JSON representation of a Polygon object

Parameters:
polygon - com.esri.arcgis.geometry.Polygon
Returns:
JSONObject JSON representation of input Polygon
Throws:
Exception

getJSONFromFeature

public static JSONObject getJSONFromFeature(Feature feature)
                                     throws Exception
Returns JSON representation of a Feature object

Parameters:
feature -
Returns:
Throws:
Exception

getPointFromJSON

public static Point getPointFromJSON(JSONObject pointJSON)
                              throws Exception
Extracts Point geometry from specified JSONObject

Parameters:
json - Input JSON object that contains geometry as sole member. Valid JSON format for Point is:

 {
"x" : -118.15, "y" : 33.80, "spatialReference" : {"wkid" : 4326}
}
Returns:
com.esri.arcgis.geometry.Point
Throws:
Exception

getMultipointFromJSON

public static Multipoint getMultipointFromJSON(JSONObject multipointJSON)
                                        throws Exception
Extracts MultiPoint geometry from specified JSONObject

Parameters:
multipointJSON - Input JSON object that contains geometry as sole member. Valid JSON format for Multipoint is:

 {
"points" : [ [-97.06138,32.837], [-97.06133,32.836], [-97.06124,32.834], [-97.06127,32.832] ], "spatialReference" : {"wkid" : 4326} }
Returns:
com.esri.arcgis.geometry.Multipoint
Throws:
Exception

getPolylineFomJSON

public static Polyline getPolylineFomJSON(JSONObject polylineJSON)
                                   throws Exception
Extracts Polyline geometry from specified JSONObject

Parameters:
polylineJSON - Input JSON object that contains geometry as sole member. Valid JSON format for Polyline is:

 {
 "paths" : [ 
  [ [-97.06138,32.837], [-97.06133,32.836], [-97.06124,32.834], [-97.06127,32.832] ], 
 [ [-97.06326,32.759], [-97.06298,32.755] ]
 ],
 "spatialReference" : {"wkid" : 4326}
 }
Returns:
com.esri.arcgis.geometry.Polyline
Throws:
Exception

getPolygonFomJSON

public static Polygon getPolygonFomJSON(JSONObject polygonJSON)
                                 throws Exception
Extracts Polygon geometry from specified JSONObject

Parameters:
polygonJSON - Input JSON object that contains geometry as sole member. Valid JSON format for Polygon is:

 {
        "rings" : [ 
         [ [-97.06138,32.837], [-97.06133,32.836], [-97.06124,32.834], [-97.06127,32.832], [-97.06138,32.837] ], 
         [ [-97.06326,32.759], [-97.06298,32.755], [-97.06153,32.749], [-97.06326,32.759] ]
        ],
        "spatialReference" : {"wkid" : 4326}
        }
        
Returns:
com.esri.arcgis.geometry.Polygon
Throws:
Exception

createResource

public static JSONObject createResource(String name,
                                        String description,
                                        boolean isCollection)
Creates a REST resource based on specified name, description and collection flag

Parameters:
name -
description -
isCollection -
Returns:
REST resource as a JSONObject

createOperation

public static JSONObject createOperation(String operationName,
                                         String parameterList,
                                         String supportedOutputFormatsList,
                                         boolean postOnly)
Creates an operation that can be called on a REST resource, using specified name, parameter list and output formats list

Parameters:
operationName -
parameterList -
supportedOutputFormatsList -
Returns:
Operation as a JSONObject

sendError

public static String sendError(int codeNumber,
                               String errorMessageSummary,
                               String[] errorMessageDetails)
Sends error message back to client in proper JSON format, which is as follows * { "error": { "code": 400, "message": "Cannot perform query. Invalid query parameters.", "details": ["'time' param is invalid"] } }

Parameters:
codeNumber - - Error code. Could be part of a user defined error hierarchy.
message - - Message containing summary of error for the client application. This cannot be null or invalid.
details - - Error details that are not part of summary. This can be null.
Returns:

getServerLogger

public static ILog2 getServerLogger()
Returns a handle to ArcGIS Server's log file via the ILog2 interface. ArcGIS Java extensions running in ArcGIS Server should write to the Server's log file through the ILog2 interface obtained from this method.

Returns:
ILog2 or null if this method is not called from within ArcGIS Server.