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;
}
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;
}
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);
}
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);
}
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);
}
}
}
}
Aggregations