/** * Convert this request to a JSON object, which can be used as a part of a return value. * * @return JSON object representing this base request object */ public JSONObject toJSON() { JSONObject ret = new JSONObject(); ret.put("type",type.getName()); if (targetConfig != null) { ret.put("target", targetConfig.toJSON()); } if (pathParts != null) { try { ret.put("path",getPath()); } catch (UnsupportedOperationException exp) { // Happens when request doesnt support paths } } return ret; }
/** * Constructor used for {@link HttpMethod#POST} requests, which receive a JSON payload. * * @param pMap map containing requests parameters * @param pInitParams optional processing parameters (obtained as query parameters or from within the * JSON request) */ public JmxRequest(Map<String, ?> pMap, ProcessingParameters pInitParams) { this(RequestType.getTypeByName((String) pMap.get("type")), HttpMethod.POST, EscapeUtil.parsePath((String) pMap.get("path")), pInitParams); Map target = (Map) pMap.get("target"); if (target != null) { targetConfig = new ProxyTargetConfig(target); } }
@JsonCreator public static RequestType create (String value) { if(value == null) { return null; } for(RequestType v : values()) { if(value.equals(v.getName())) { return v; } } return null; }
/** * Checker for requests types * * @param pDoc document to examine for declared restrictions */ public RequestTypeChecker(Document pDoc) { NodeList nodes = pDoc.getElementsByTagName("commands"); if (nodes.getLength() > 0) { // Leave typeSet null if no commands has been given... typeSet = new HashSet<RequestType>(); } for (int i = 0;i<nodes.getLength();i++) { Node node = nodes.item(i); NodeList childs = node.getChildNodes(); for (int j = 0;j<childs.getLength();j++) { Node commandNode = childs.item(j); if (commandNode.getNodeType() != Node.ELEMENT_NODE) { continue; } assertNodeName(commandNode,"command"); String typeName = commandNode.getTextContent().trim(); RequestType type = RequestType.getTypeByName(typeName); typeSet.add(type); } } }
RequestBuilder(RequestType oftype) { pRequestMap.put("type", oftype.getName()); }
/** * Create a single {@link JmxRequest}s from a JSON map representation of a request * * @param pRequestMap JSON representation of a {@link JmxRequest} * @param pProcessingParams additional map of operational parameters. Must not be null. * @return the created {@link JmxRequest} */ public static <R extends JmxRequest> R createPostRequest(Map<String, ?> pRequestMap, ProcessingParameters pProcessingParams) { try { ProcessingParameters paramsMerged = pProcessingParams.mergedParams((Map<String,String>) pRequestMap.get("config")); RequestType type = RequestType.getTypeByName((String) pRequestMap.get("type")); return (R) getCreator(type).create(pRequestMap, paramsMerged); } catch (MalformedObjectNameException e) { throw new IllegalArgumentException("Invalid object name. " + e.getMessage(),e); } }
/** * Convert this request to a JSON object, which can be used as a part of a return value. * * @return JSON object representing this base request object */ public JSONObject toJSON() { JSONObject ret = new JSONObject(); ret.put("type",type.getName()); if (targetConfig != null) { ret.put("target", targetConfig.toJSON()); } if (pathParts != null) { try { ret.put("path",getPath()); } catch (UnsupportedOperationException exp) { // Happens when request doesnt support paths } } return ret; }
type = elements.size() != 0 ? RequestType.getTypeByName(elements.pop()) : RequestType.VERSION;
/** * Convert this request to a JSON object, which can be used as a part of a return value. * * @return JSON object representing this base request object */ public JSONObject toJSON() { JSONObject ret = new JSONObject(); ret.put("type",type.getName()); if (targetConfig != null) { ret.put("target", targetConfig.toJSON()); } if (pathParts != null) { try { ret.put("path",getPath()); } catch (UnsupportedOperationException exp) { // Happens when request doesnt support paths } } return ret; }
/** * Checker for requests types * * @param pDoc document to examine for declared restrictions */ public RequestTypeChecker(Document pDoc) { NodeList nodes = pDoc.getElementsByTagName("commands"); if (nodes.getLength() > 0) { // Leave typeSet null if no commands has been given... typeSet = new HashSet<RequestType>(); } for (int i = 0;i<nodes.getLength();i++) { Node node = nodes.item(i); NodeList childs = node.getChildNodes(); for (int j = 0;j<childs.getLength();j++) { Node commandNode = childs.item(j); if (commandNode.getNodeType() != Node.ELEMENT_NODE) { continue; } assertNodeName(commandNode,"command"); String typeName = commandNode.getTextContent().trim(); RequestType type = RequestType.getTypeByName(typeName); typeSet.add(type); } } }
/** * Constructor used for {@link HttpMethod#POST} requests, which receive a JSON payload. * * @param pMap map containing requests parameters * @param pInitParams optional processing parameters (obtained as query parameters or from within the * JSON request) */ public JmxRequest(Map<String, ?> pMap, ProcessingParameters pInitParams) { this(RequestType.getTypeByName((String) pMap.get("type")), HttpMethod.POST, EscapeUtil.parsePath((String) pMap.get("path")), pInitParams); Map target = (Map) pMap.get("target"); if (target != null) { targetConfig = new ProxyTargetConfig(target); } }
/** * Checker for requests types * * @param pDoc document to examine for declared restrictions */ public RequestTypeChecker(Document pDoc) { NodeList nodes = pDoc.getElementsByTagName("commands"); if (nodes.getLength() > 0) { // Leave typeSet null if no commands has been given... typeSet = new HashSet<RequestType>(); } for (int i = 0;i<nodes.getLength();i++) { Node node = nodes.item(i); NodeList childs = node.getChildNodes(); for (int j = 0;j<childs.getLength();j++) { Node commandNode = childs.item(j); if (commandNode.getNodeType() != Node.ELEMENT_NODE) { continue; } assertNodeName(commandNode,"command"); String typeName = commandNode.getTextContent().trim(); RequestType type = RequestType.getTypeByName(typeName); typeSet.add(type); } } }
/** * Constructor used for {@link HttpMethod#POST} requests, which receive a JSON payload. * * @param pMap map containing requests parameters * @param pInitParams optional processing parameters (obtained as query parameters or from within the * JSON request) */ public JmxRequest(Map<String, ?> pMap, ProcessingParameters pInitParams) { this(RequestType.getTypeByName((String) pMap.get("type")), HttpMethod.POST, EscapeUtil.parsePath((String) pMap.get("path")), pInitParams); Map target = (Map) pMap.get("target"); if (target != null) { targetConfig = new ProxyTargetConfig(target); } }
/** * Create a single {@link JmxRequest}s from a JSON map representation of a request * * @param pRequestMap JSON representation of a {@link JmxRequest} * @param pProcessingParams additional map of operational parameters. Must not be null. * @return the created {@link JmxRequest} */ public static <R extends JmxRequest> R createPostRequest(Map<String, ?> pRequestMap, ProcessingParameters pProcessingParams) { try { ProcessingParameters paramsMerged = pProcessingParams.mergedParams((Map<String,String>) pRequestMap.get("config")); RequestType type = RequestType.getTypeByName((String) pRequestMap.get("type")); return (R) getCreator(type).create(pRequestMap, paramsMerged); } catch (MalformedObjectNameException e) { throw new IllegalArgumentException("Invalid object name. " + e.getMessage(),e); } }
/** * Create a single {@link JmxRequest}s from a JSON map representation of a request * * @param pRequestMap JSON representation of a {@link JmxRequest} * @param pProcessingParams additional map of operational parameters. Must not be null. * @return the created {@link JmxRequest} */ public static <R extends JmxRequest> R createPostRequest(Map<String, ?> pRequestMap, ProcessingParameters pProcessingParams) { try { ProcessingParameters paramsMerged = pProcessingParams.mergedParams((Map<String,String>) pRequestMap.get("config")); RequestType type = RequestType.getTypeByName((String) pRequestMap.get("type")); return (R) getCreator(type).create(pRequestMap, paramsMerged); } catch (MalformedObjectNameException e) { throw new IllegalArgumentException("Invalid object name. " + e.getMessage(),e); } }
type = elements.size() != 0 ? RequestType.getTypeByName(elements.pop()) : RequestType.VERSION;
type = elements.size() != 0 ? RequestType.getTypeByName(elements.pop()) : RequestType.VERSION;