/** * This method retrieves the resource id from the create resource request response and throws the appropriate exceptions in case of failure. * * @param response * @param resourceResponseAction * @param resourceIdXpath * @param resourceIdExceptionMessage * @return * @throws ParserConfigurationException * @throws SAXException * @throws XPathExpressionException * @throws IOException */ private String getResourceId(String response, String resourceResponseAction, String resourceIdXpath, String resourceIdExceptionMessage) throws ParserConfigurationException, SAXException, XPathExpressionException, IOException { if (WSManUtils.isSpecificResponseAction(response, resourceResponseAction)) { String shellId = XMLUtils.parseXml(response, resourceIdXpath); if (StringUtils.isNotBlank(shellId)) { return shellId; } else { throw new RuntimeException(resourceIdExceptionMessage); } } else if (WSManUtils.isFaultResponse(response)) { throw new RuntimeException(WSManUtils.getResponseFault(response)); } else { throw new RuntimeException(UNEXPECTED_SERVICE_RESPONSE + response); } }
/** * This method retrieves the resource id from the create resource request response and throws the appropriate exceptions in case of failure. * * @param response * @param resourceResponseAction * @param resourceIdXpath * @param resourceIdExceptionMessage * @return * @throws ParserConfigurationException * @throws SAXException * @throws XPathExpressionException * @throws IOException */ private String getResourceId(String response, String resourceResponseAction, String resourceIdXpath, String resourceIdExceptionMessage) throws ParserConfigurationException, SAXException, XPathExpressionException, IOException { if (WSManUtils.isSpecificResponseAction(response, resourceResponseAction)) { String shellId = XMLUtils.parseXml(response, resourceIdXpath); if (StringUtils.isNotBlank(shellId)) { return shellId; } else { throw new RuntimeException(resourceIdExceptionMessage); } } else if (WSManUtils.isFaultResponse(response)) { throw new RuntimeException(WSManUtils.getResponseFault(response)); } else { throw new RuntimeException(UNEXPECTED_SERVICE_RESPONSE + response); } }
/** * Deletes the remote shell. * * @param csHttpClient * @param httpClientInputs * @param shellId * @param wsManRequestInputs * @throws RuntimeException * @throws IOException * @throws URISyntaxException * @throws TransformerException * @throws XPathExpressionException * @throws SAXException * @throws ParserConfigurationException */ private void deleteShell(CSHttpClient csHttpClient, HttpClientInputs httpClientInputs, String shellId, WSManRequestInputs wsManRequestInputs) throws RuntimeException, IOException, URISyntaxException, TransformerException, XPathExpressionException, SAXException, ParserConfigurationException { String documentStr = ResourceLoader.loadAsString(DELETE_SHELL_REQUEST_XML); documentStr = createDeleteShellRequestBody(documentStr, httpClientInputs.getUrl(), shellId, String.valueOf(wsManRequestInputs.getMaxEnvelopeSize()), wsManRequestInputs.getWinrmLocale(), String.valueOf(wsManRequestInputs.getOperationTimeout())); Map<String, String> deleteShellResult = executeRequest(csHttpClient, httpClientInputs, documentStr); if (WSManUtils.isSpecificResponseAction(deleteShellResult.get(RETURN_RESULT), DELETE_RESPONSE_ACTION)) { return; } else if (WSManUtils.isFaultResponse(deleteShellResult.get(RETURN_RESULT))) { throw new RuntimeException(WSManUtils.getResponseFault(deleteShellResult.get(RETURN_RESULT))); } else { throw new RuntimeException(UNEXPECTED_SERVICE_RESPONSE + deleteShellResult.get(RETURN_RESULT)); } }
/** * Deletes the remote shell. * * @param csHttpClient * @param httpClientInputs * @param shellId * @param wsManRequestInputs * @throws RuntimeException * @throws IOException * @throws URISyntaxException * @throws TransformerException * @throws XPathExpressionException * @throws SAXException * @throws ParserConfigurationException */ private void deleteShell(HttpClientService csHttpClient, HttpClientInputs httpClientInputs, String shellId, WSManRequestInputs wsManRequestInputs) throws RuntimeException, IOException, URISyntaxException, TransformerException, XPathExpressionException, SAXException, ParserConfigurationException { String documentStr = ResourceLoader.loadAsString(DELETE_SHELL_REQUEST_XML); documentStr = createDeleteShellRequestBody(documentStr, httpClientInputs.getUrl(), shellId, String.valueOf(wsManRequestInputs.getMaxEnvelopeSize()), wsManRequestInputs.getWinrmLocale(), String.valueOf(wsManRequestInputs.getOperationTimeout())); Map<String, String> deleteShellResult = executeRequestWithBody(csHttpClient, httpClientInputs, documentStr); if (WSManUtils.isSpecificResponseAction(deleteShellResult.get(RETURN_RESULT), DELETE_RESPONSE_ACTION)) { return; } else if (WSManUtils.isFaultResponse(deleteShellResult.get(RETURN_RESULT))) { throw new RuntimeException(WSManUtils.getResponseFault(deleteShellResult.get(RETURN_RESULT))); } else { throw new RuntimeException(UNEXPECTED_SERVICE_RESPONSE + deleteShellResult.get(RETURN_RESULT)); } }
WSManUtils.commandExecutionIsDone(receiveResult.get(RETURN_RESULT))) { return processCommandExecutionResponse(receiveResult); } else if (WSManUtils.isFaultResponse(receiveResult.get(RETURN_RESULT))) { throw new RuntimeException(WSManUtils.getResponseFault(receiveResult.get(RETURN_RESULT)));
WSManUtils.commandExecutionIsDone(receiveResult.get(RETURN_RESULT))) { return processCommandExecutionResponse(receiveResult); } else if (WSManUtils.isFaultResponse(receiveResult.get(RETURN_RESULT))) { throw new RuntimeException(WSManUtils.getResponseFault(receiveResult.get(RETURN_RESULT)));