Search in sources :

Example 11 with XMPPComponent

use of com.zimbra.cs.account.XMPPComponent in project zm-mailbox by Zimbra.

the class CreateXMPPComponent method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    // <CreateXMPPComponentRequest>
    //    <xmppComponent name="name">
    //       <domain [by="id, name, virtualHostname, krb5Realm"]>domainId</domain>
    //       <server[by="id, name, serviceHostname"]>serviceId</domain>
    //       <a n="zimbraXMPPComponentCategory">category (see XEP-0030)</a>
    //       <a n="zimbraXMPPComponentName">long component name</a>
    //       [<a n="zimbraXMPPComponentType">type from XEP-0030</a>]
    //    </xmppComponent>
    //
    Element cEl = request.getElement(AccountConstants.E_XMPP_COMPONENT);
    Map<String, Object> attrs = AdminService.getAttrs(cEl);
    Element domainElt = cEl.getElement(AdminConstants.E_DOMAIN);
    String byStr = domainElt.getAttribute(AdminConstants.A_BY, "id");
    Key.DomainBy domainby = Key.DomainBy.valueOf(byStr);
    Domain domain = Provisioning.getInstance().get(domainby, domainElt.getText());
    Element serverElt = cEl.getElement(AdminConstants.E_SERVER);
    String serverByStr = serverElt.getAttribute(AdminConstants.A_BY);
    Server server = prov.get(Key.ServerBy.fromString(serverByStr), serverElt.getText());
    String name = cEl.getAttribute(AccountConstants.A_NAME);
    if (!name.endsWith(domain.getName())) {
        throw ServiceException.INVALID_REQUEST("Specified component name must be full name, and must be a subdomain of the specified parent", null);
    }
    checkRight(zsc, context, null, Admin.R_createXMPPComponent);
    checkSetAttrsOnCreate(zsc, TargetType.xmppcomponent, name, attrs);
    XMPPComponent comp = prov.createXMPPComponent(name, domain, server, attrs);
    Element response = zsc.createElement(AdminConstants.CREATE_XMPPCOMPONENT_RESPONSE);
    GetXMPPComponent.encodeXMPPComponent(response, comp);
    return response;
}
Also used : Server(com.zimbra.cs.account.Server) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Domain(com.zimbra.cs.account.Domain) XMPPComponent(com.zimbra.cs.account.XMPPComponent) Provisioning(com.zimbra.cs.account.Provisioning) DomainBy(com.zimbra.common.account.Key.DomainBy) Key(com.zimbra.common.account.Key)

Example 12 with XMPPComponent

use of com.zimbra.cs.account.XMPPComponent in project zm-mailbox by Zimbra.

the class TestLdapProvRenameDomain method createXMPPComponent.

private XMPPComponent createXMPPComponent(int xmppIndex, Domain domain) throws Exception {
    Server server = prov.getLocalServer();
    String routableName = XMPPCOMPONENT_NAME(xmppIndex, domain.getName());
    Map<String, Object> xmppAttrs = new HashMap<String, Object>();
    xmppAttrs.put(Provisioning.A_zimbraXMPPComponentClassName, "myclass");
    xmppAttrs.put(Provisioning.A_zimbraXMPPComponentCategory, "mycategory");
    xmppAttrs.put(Provisioning.A_zimbraXMPPComponentType, "mytype");
    XMPPComponent xmpp = prov.createXMPPComponent(routableName, domain, server, xmppAttrs);
    return xmpp;
}
Also used : Server(com.zimbra.cs.account.Server) HashMap(java.util.HashMap) XMPPComponent(com.zimbra.cs.account.XMPPComponent)

Example 13 with XMPPComponent

use of com.zimbra.cs.account.XMPPComponent in project zm-mailbox by Zimbra.

the class TestLdapProvRenameDomain method verifyXMPPComponent.

private void verifyXMPPComponent(int index, Domain newDomain) throws Exception {
    String newRoutableName = XMPPCOMPONENT_NAME(index, newDomain.getName());
    XMPPComponent xmpp = prov.get(Key.XMPPComponentBy.name, newRoutableName);
    assertNotNull(xmpp);
    String domainId = newDomain.getId();
    String xmppDomainId = xmpp.getAttr(Provisioning.A_zimbraDomainId);
    assertEquals(domainId, xmppDomainId);
}
Also used : XMPPComponent(com.zimbra.cs.account.XMPPComponent)

Example 14 with XMPPComponent

use of com.zimbra.cs.account.XMPPComponent in project zm-mailbox by Zimbra.

the class TestLdapProvXMPPComponent method getXMPPComponent.

@Test
public void getXMPPComponent() throws Exception {
    String XMPPCPNT_NAME = Names.makeXMPPName(genXMPPName());
    XMPPComponent xmppCpnt = createXMPPComponent(XMPPCPNT_NAME);
    String xmppCpntId = xmppCpnt.getId();
    xmppCpnt = prov.get(Key.XMPPComponentBy.id, xmppCpntId);
    assertEquals(xmppCpntId, xmppCpnt.getId());
    xmppCpnt = prov.get(Key.XMPPComponentBy.name, XMPPCPNT_NAME);
    assertEquals(xmppCpntId, xmppCpnt.getId());
    // not implemented
    // xmppCpnt = prov.get(XMPPComponentBy.serviceHostname, server.getServiceHostname()); 
    // assertEquals(xmppCpntId, xmppCpnt.getId());
    deleteXMPPComponent(xmppCpnt);
}
Also used : XMPPComponent(com.zimbra.cs.account.XMPPComponent)

Example 15 with XMPPComponent

use of com.zimbra.cs.account.XMPPComponent in project zm-mailbox by Zimbra.

the class RenameDomain method fixupXMPPComponents.

private void fixupXMPPComponents() throws ServiceException {
    int domainLen = mOldDomainName.length();
    for (XMPPComponent xmpp : mProv.getAllXMPPComponents()) {
        if (mOldDomainId.equals(xmpp.getDomainId())) {
            String curName = xmpp.getName();
            if (curName.endsWith(mOldDomainName)) {
                String newName = curName.substring(0, curName.length() - domainLen) + mNewDomainName;
                debug("Renaming XMPP component " + curName + " to " + newName);
                mLdapHelper.renameXMPPComponent(xmpp.getId(), newName);
            }
        }
    }
}
Also used : XMPPComponent(com.zimbra.cs.account.XMPPComponent)

Aggregations

XMPPComponent (com.zimbra.cs.account.XMPPComponent)20 Element (com.zimbra.common.soap.Element)5 LdapXMPPComponent (com.zimbra.cs.account.ldap.entry.LdapXMPPComponent)5 Provisioning (com.zimbra.cs.account.Provisioning)4 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)4 HashMap (java.util.HashMap)4 Key (com.zimbra.common.account.Key)3 AccountServiceException (com.zimbra.cs.account.AccountServiceException)3 Server (com.zimbra.cs.account.Server)3 XMPPComponentBy (com.zimbra.common.account.Key.XMPPComponentBy)2 ServiceException (com.zimbra.common.service.ServiceException)2 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)2 Domain (com.zimbra.cs.account.Domain)2 ArrayList (java.util.ArrayList)2 DomainBy (com.zimbra.common.account.Key.DomainBy)1 XMLElement (com.zimbra.common.soap.Element.XMLElement)1 Account (com.zimbra.cs.account.Account)1 AlwaysOnCluster (com.zimbra.cs.account.AlwaysOnCluster)1 DynamicGroup (com.zimbra.cs.account.DynamicGroup)1 Group (com.zimbra.cs.account.Group)1