List of usage examples for org.dom4j DocumentHelper createElement
public static Element createElement(String name)
From source file:com.xebialabs.overthere.winrm.WinRmClient.java
License:Open Source License
public boolean receiveOutput(OutputStream stdout, OutputStream stderr) throws IOException { logger.debug("Sending WinRM Receive Output request for command {} in shell {}", commandId, shellId); final Element bodyContent = DocumentHelper.createElement(QName.get("Receive", Namespaces.NS_WIN_SHELL)); bodyContent.addElement(QName.get("DesiredStream", Namespaces.NS_WIN_SHELL)) .addAttribute("CommandId", commandId).addText("stdout stderr"); final Document requestDocument = getRequestDocument(Action.WS_RECEIVE, ResourceURI.RESOURCE_URI_CMD, null, bodyContent);// ww w . j a v a2 s .co m Document responseDocument = sendRequest(requestDocument, SoapAction.RECEIVE); logger.debug("Received WinRM Receive Output response for command {} in shell {}", commandId, shellId); handleStream(responseDocument, ResponseExtractor.STDOUT, stdout); handleStream(responseDocument, ResponseExtractor.STDERR, stderr); if (chunk == 0) { parseExitCode(responseDocument); } chunk++; /* * We may need to get additional output if the stream has not finished. The CommandState will change from * Running to Done like so: * * @example * * from... <rsp:CommandState CommandId="..." * State="http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Running"/> to... * <rsp:CommandState CommandId="..." * State="http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Done"> * <rsp:ExitCode>0</rsp:ExitCode> </rsp:CommandState> */ final List<?> list = ResponseExtractor.STREAM_DONE.getXPath().selectNodes(responseDocument); if (!list.isEmpty()) { logger.trace("Found CommandState element with State=Done, parsing exit code and returning false."); parseExitCode(responseDocument); return false; } else { logger.trace("Did not find CommandState element with State=Done, returning true."); return true; } }
From source file:com.xebialabs.overthere.winrm.WinRmClient.java
License:Open Source License
public void sendInput(byte[] buf) throws IOException { logger.debug("Sending WinRM Send Input request for command {} in shell {}", commandId, shellId); final Element bodyContent = DocumentHelper.createElement(QName.get("Send", Namespaces.NS_WIN_SHELL)); final Base64 base64 = new Base64(); bodyContent.addElement(QName.get("Stream", Namespaces.NS_WIN_SHELL)).addAttribute("Name", "stdin") .addAttribute("CommandId", commandId).addText(base64.encodeAsString(buf)); final Document requestDocument = getRequestDocument(Action.WS_SEND, ResourceURI.RESOURCE_URI_CMD, null, bodyContent);//from ww w . j a v a 2s . c o m sendRequest(requestDocument, SoapAction.SEND); logger.debug("Sent WinRM Send Input request for command {} in shell {}", commandId, shellId); }
From source file:com.xebialabs.overthere.winrm.WinRmClient.java
License:Open Source License
public void signal() { if (commandId == null) { logger.warn("Not sending WinRM Signal request in shell {} because there is no running command", shellId);//from www.j a v a2 s .co m return; } logger.debug("Sending WinRM Signal request for command {} in shell {}", commandId, shellId); final Element bodyContent = DocumentHelper.createElement(QName.get("Signal", Namespaces.NS_WIN_SHELL)) .addAttribute("CommandId", commandId); bodyContent.addElement(QName.get("Code", Namespaces.NS_WIN_SHELL)) .addText("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/signal/terminate"); final Document requestDocument = getRequestDocument(Action.WS_SIGNAL, ResourceURI.RESOURCE_URI_CMD, null, bodyContent); sendRequest(requestDocument, SoapAction.SIGNAL); logger.debug("Sent WinRM Signal request for command {} in shell {}", commandId, shellId); }
From source file:com.zimbra.cs.client.soap.LmcAddMsgRequest.java
License:Open Source License
protected Element getRequestXML() { Element request = DocumentHelper.createElement(MailConstants.ADD_MSG_REQUEST); addMsg(request, mMsg, null, null, null); return request; }
From source file:com.zimbra.cs.client.soap.LmcAdminAuthRequest.java
License:Open Source License
protected Element getRequestXML() { Element request = DocumentHelper.createElement(AdminConstants.AUTH_REQUEST); DomUtil.addAttr(request, AdminConstants.A_NAME, mUsername); DomUtil.addAttr(request, AdminConstants.E_PASSWORD, mPassword); return request; }
From source file:com.zimbra.cs.client.soap.LmcAuthRequest.java
License:Open Source License
protected Element getRequestXML() { Element request = DocumentHelper.createElement(AccountConstants.AUTH_REQUEST); Element a = DomUtil.add(request, AccountConstants.E_ACCOUNT, mUsername); DomUtil.addAttr(a, AdminConstants.A_BY, AdminConstants.BY_NAME); // XXX should use a constant DomUtil.add(request, AccountConstants.E_PASSWORD, mPassword); return request; }
From source file:com.zimbra.cs.client.soap.LmcBrowseRequest.java
License:Open Source License
protected Element getRequestXML() throws LmcSoapClientException { Element request = DocumentHelper.createElement(MailConstants.BROWSE_REQUEST); DomUtil.addAttr(request, MailConstants.A_BROWSE_BY, mBrowseBy); return request; }
From source file:com.zimbra.cs.client.soap.LmcChangePasswordRequest.java
License:Open Source License
protected Element getRequestXML() { Element request = DocumentHelper.createElement(AccountConstants.CHANGE_PASSWORD_REQUEST); // <account> Element a = DomUtil.add(request, AccountConstants.E_ACCOUNT, mAccount); DomUtil.addAttr(a, AdminConstants.A_BY, BY_NAME); // <old password> DomUtil.add(request, AccountConstants.E_OLD_PASSWORD, mOldPassword); // <password> DomUtil.add(request, AccountConstants.E_PASSWORD, mPassword); return request; }
From source file:com.zimbra.cs.client.soap.LmcCheckSpellingRequest.java
License:Open Source License
protected Element getRequestXML() { Element request = DocumentHelper.createElement(MailConstants.CHECK_SPELLING_REQUEST); request.addText(mText); return request; }
From source file:com.zimbra.cs.client.soap.LmcContactActionRequest.java
License:Open Source License
protected Element getRequestXML() { Element request = DocumentHelper.createElement(MailConstants.CONTACT_ACTION_REQUEST); Element a = DomUtil.add(request, MailConstants.E_ACTION, ""); DomUtil.addAttr(a, MailConstants.A_ID, mIDList); DomUtil.addAttr(a, MailConstants.A_OPERATION, mOp); addAttrNotNull(a, MailConstants.A_TAG, mTag); addAttrNotNull(a, MailConstants.A_FOLDER, mFolder); return request; }