Search in sources :

Example 6 with RemoteManager

use of com.zimbra.cs.rmgmt.RemoteManager in project zm-mailbox by Zimbra.

the class GetMailQueueInfo method handle.

public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    Element serverElem = request.getElement(AdminConstants.E_SERVER);
    String serverName = serverElem.getAttribute(AdminConstants.A_NAME);
    Server server = prov.get(Key.ServerBy.name, serverName);
    if (server == null) {
        throw ServiceException.INVALID_REQUEST("server with name " + serverName + " could not be found", null);
    }
    checkRight(zsc, context, server, Admin.R_manageMailQueue);
    RemoteManager rmgr = RemoteManager.getRemoteManager(server);
    RemoteResult rr = rmgr.execute(RemoteCommands.ZMQSTAT_ALL);
    Map<String, String> queueInfo;
    try {
        queueInfo = RemoteResultParser.parseSingleMap(rr);
    } catch (IOException ioe) {
        throw ServiceException.FAILURE("exception occurred handling command", ioe);
    }
    if (queueInfo == null) {
        throw ServiceException.FAILURE("server " + serverName + " returned no result", null);
    }
    Element response = zsc.createElement(AdminConstants.GET_MAIL_QUEUE_INFO_RESPONSE);
    serverElem = response.addElement(AdminConstants.E_SERVER);
    serverElem.addAttribute(AdminConstants.A_NAME, serverName);
    for (String k : queueInfo.keySet()) {
        Element queue = serverElem.addElement(AdminConstants.E_QUEUE);
        queue.addAttribute(AdminConstants.A_NAME, k);
        queue.addAttribute(AdminConstants.A_N, queueInfo.get(k));
    }
    return response;
}
Also used : RemoteResult(com.zimbra.cs.rmgmt.RemoteResult) Server(com.zimbra.cs.account.Server) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) RemoteManager(com.zimbra.cs.rmgmt.RemoteManager) Element(com.zimbra.common.soap.Element) IOException(java.io.IOException) Provisioning(com.zimbra.cs.account.Provisioning)

Aggregations

RemoteManager (com.zimbra.cs.rmgmt.RemoteManager)6 Provisioning (com.zimbra.cs.account.Provisioning)5 Server (com.zimbra.cs.account.Server)5 RemoteResult (com.zimbra.cs.rmgmt.RemoteResult)4 ServiceException (com.zimbra.common.service.ServiceException)3 Element (com.zimbra.common.soap.Element)3 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ContentDisposition (com.zimbra.common.mime.ContentDisposition)2 AuthToken (com.zimbra.cs.account.AuthToken)2 IOException (java.io.IOException)2 ZMountpoint (com.zimbra.client.ZMountpoint)1 MailServiceException (com.zimbra.cs.mailbox.MailServiceException)1 RemoteMailQueue (com.zimbra.cs.rmgmt.RemoteMailQueue)1 QueueAttr (com.zimbra.cs.rmgmt.RemoteMailQueue.QueueAttr)1 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 Inet4Address (java.net.Inet4Address)1 Inet6Address (java.net.Inet6Address)1 InetAddress (java.net.InetAddress)1