use of com.zimbra.cs.account.XMPPComponent in project zm-mailbox by Zimbra.
the class GetAllXMPPComponents method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
List<XMPPComponent> components = prov.getAllXMPPComponents();
AdminAccessControl aac = AdminAccessControl.getAdminAccessControl(zsc);
Element response = zsc.createElement(AdminConstants.GET_ALL_XMPPCOMPONENTS_REQUEST);
for (XMPPComponent comp : components) {
if (aac.hasRightsToList(comp, Admin.R_listXMPPComponent, null))
GetXMPPComponent.encodeXMPPComponent(response, comp, null, aac.getAttrRightChecker(comp));
}
return response;
}
use of com.zimbra.cs.account.XMPPComponent in project zm-mailbox by Zimbra.
the class LdapProvisioning method getXMPPComponentByName.
private XMPPComponent getXMPPComponentByName(String name, boolean nocache) throws ServiceException {
if (!nocache) {
XMPPComponent x = xmppComponentCache.getByName(name);
if (x != null)
return x;
}
try {
String dn = mDIT.xmppcomponentNameToDN(name);
ZAttributes attrs = helper.getAttributes(LdapUsage.GET_XMPPCOMPONENT, dn);
XMPPComponent x = new LdapXMPPComponent(dn, attrs, this);
xmppComponentCache.put(x);
return x;
} catch (LdapEntryNotFoundException e) {
return null;
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to lookup xmpp component by name: " + name + " message: " + e.getMessage(), e);
}
}
use of com.zimbra.cs.account.XMPPComponent in project zm-mailbox by Zimbra.
the class LdapProvisioning method createXMPPComponent.
@Override
public XMPPComponent createXMPPComponent(String name, Domain domain, Server server, Map<String, Object> inAttrs) throws ServiceException {
name = name.toLowerCase().trim();
// sanity checking
removeAttrIgnoreCase("objectclass", inAttrs);
removeAttrIgnoreCase(A_zimbraDomainId, inAttrs);
removeAttrIgnoreCase(A_zimbraServerId, inAttrs);
CallbackContext callbackContext = new CallbackContext(CallbackContext.Op.CREATE);
AttributeManager.getInstance().preModify(inAttrs, null, callbackContext, true);
ZLdapContext zlc = null;
try {
zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.CREATE_XMPPCOMPONENT);
ZMutableEntry entry = LdapClient.createMutableEntry();
entry.mapToAttrs(inAttrs);
entry.setAttr(A_objectClass, "zimbraXMPPComponent");
String compId = LdapUtil.generateUUID();
entry.setAttr(A_zimbraId, compId);
entry.setAttr(A_zimbraCreateTimestamp, LdapDateUtil.toGeneralizedTime(new Date()));
entry.setAttr(A_cn, name);
String dn = mDIT.xmppcomponentNameToDN(name);
entry.setDN(dn);
entry.setAttr(A_zimbraDomainId, domain.getId());
entry.setAttr(A_zimbraServerId, server.getId());
zlc.createEntry(entry);
XMPPComponent comp = getXMPPComponentById(compId, zlc, true);
AttributeManager.getInstance().postModify(inAttrs, comp, callbackContext);
return comp;
} catch (LdapEntryAlreadyExistException nabe) {
throw AccountServiceException.IM_COMPONENT_EXISTS(name);
} finally {
LdapClient.closeContext(zlc);
}
}
use of com.zimbra.cs.account.XMPPComponent in project zm-mailbox by Zimbra.
the class GetXMPPComponent method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
Set<String> reqAttrs = getReqAttrs(request, AttributeClass.xmppComponent);
Element id = request.getElement(AdminConstants.E_XMPP_COMPONENT);
String byStr = id.getAttribute(AdminConstants.A_BY);
String name = id.getText();
if (name == null || name.equals(""))
throw ServiceException.INVALID_REQUEST("must specify a value for a xmppcomponent", null);
Key.XMPPComponentBy by = Key.XMPPComponentBy.valueOf(byStr);
XMPPComponent comp = prov.get(by, name);
if (comp == null)
throw AccountServiceException.NO_SUCH_XMPP_COMPONENT(name);
AdminAccessControl aac = checkRight(zsc, context, comp, AdminRight.PR_ALWAYS_ALLOW);
Element response = zsc.createElement(AdminConstants.GET_XMPPCOMPONENT_RESPONSE);
encodeXMPPComponent(response, comp, reqAttrs, aac.getAttrRightChecker(comp));
return response;
}
use of com.zimbra.cs.account.XMPPComponent in project zm-mailbox by Zimbra.
the class DeleteXMPPComponent method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
Element id = request.getElement(AdminConstants.E_XMPP_COMPONENT);
String byStr = id.getAttribute(AdminConstants.A_BY);
String name = id.getText();
if (name == null || name.equals(""))
throw ServiceException.INVALID_REQUEST("must specify a value for a xmppcomponent", null);
Key.XMPPComponentBy by = Key.XMPPComponentBy.valueOf(byStr);
XMPPComponent comp = prov.get(by, name);
if (comp == null) {
throw AccountServiceException.NO_SUCH_XMPP_COMPONENT(name);
}
checkRight(zsc, context, comp, Admin.R_deleteXMPPComponent);
prov.deleteXMPPComponent(comp);
Element response = zsc.createElement(AdminConstants.DELETE_XMPPCOMPONENT_RESPONSE);
return response;
}
Aggregations