Search in sources :

Example 11 with UCService

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

the class LdapProvisioning method getAllUCServices.

@Override
public List<UCService> getAllUCServices() throws ServiceException {
    List<UCService> result = new ArrayList<UCService>();
    ZLdapFilter filter = filterFactory.allUCServices();
    try {
        ZSearchResultEnumeration ne = helper.searchDir(mDIT.ucServiceBaseDN(), filter, ZSearchControls.SEARCH_CTLS_SUBTREE());
        while (ne.hasMore()) {
            ZSearchResultEntry sr = ne.next();
            LdapUCService s = new LdapUCService(sr.getDN(), sr.getAttributes(), this);
            result.add(s);
        }
        ne.close();
    } catch (ServiceException e) {
        throw ServiceException.FAILURE("unable to list all servers", e);
    }
    if (result.size() > 0) {
        ucServiceCache.put(result, true);
    }
    Collections.sort(result);
    return result;
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter) LdapUCService(com.zimbra.cs.account.ldap.entry.LdapUCService) UCService(com.zimbra.cs.account.UCService) AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) ZSearchResultEnumeration(com.zimbra.cs.ldap.ZSearchResultEnumeration) LdapUCService(com.zimbra.cs.account.ldap.entry.LdapUCService) ArrayList(java.util.ArrayList) ZSearchResultEntry(com.zimbra.cs.ldap.ZSearchResultEntry)

Example 12 with UCService

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

the class CreateUCService method handle.

public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    String name = request.getElement(AdminConstants.E_NAME).getText().toLowerCase();
    Map<String, Object> attrs = AdminService.getAttrs(request, true);
    checkRight(zsc, context, null, Admin.R_createUCService);
    checkSetAttrsOnCreate(zsc, TargetType.ucservice, name, attrs);
    UCService ucService = prov.createUCService(name, attrs);
    ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "CreateUCService", "name", name }, attrs));
    Element response = zsc.createElement(AdminConstants.CREATE_UC_SERVICE_RESPONSE);
    GetUCService.encodeUCService(response, ucService, null, null);
    return response;
}
Also used : UCService(com.zimbra.cs.account.UCService) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning)

Example 13 with UCService

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

the class ProvTestUtil method createUCService.

public UCService createUCService(String ucServiceName, Map<String, Object> attrs) throws Exception {
    if (attrs == null) {
        attrs = new HashMap<String, Object>();
        attrs.put(Provisioning.A_zimbraUCProvider, DEFAULT_UC_PROVIDER);
    }
    UCService ucService = prov.get(Key.UCServiceBy.name, ucServiceName);
    assertNull(ucService);
    ucService = prov.createUCService(ucServiceName, attrs);
    assertNotNull(ucService);
    ucService = prov.get(Key.UCServiceBy.name, ucServiceName);
    assertNotNull(ucService);
    assertEquals(ucServiceName.toLowerCase(), ucService.getName().toLowerCase());
    createdEntries.add(ucService);
    return ucService;
}
Also used : UCService(com.zimbra.cs.account.UCService)

Example 14 with UCService

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

the class RenameUCService method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext lc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    String id = request.getElement(AdminConstants.E_ID).getText();
    String newName = request.getElement(AdminConstants.E_NEW_NAME).getText();
    UCService ucService = prov.get(UCServiceBy.id, id);
    if (ucService == null) {
        throw AccountServiceException.NO_SUCH_UC_SERVICE(id);
    }
    // check if the admin can rename the uc service
    checkRight(lc, context, ucService, Admin.R_renameUCService);
    String oldName = ucService.getName();
    prov.renameUCService(id, newName);
    ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "RenameUCService", "name", oldName, "newName", newName }));
    // get again with new name...
    ucService = prov.get(Key.UCServiceBy.id, id);
    if (ucService == null) {
        throw ServiceException.FAILURE("unabled to get renamed uc service: " + id, null);
    }
    Element response = lc.createElement(AdminConstants.RENAME_UC_SERVICE_RESPONSE);
    GetUCService.encodeUCService(response, ucService, null, null);
    return response;
}
Also used : UCService(com.zimbra.cs.account.UCService) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning)

Aggregations

UCService (com.zimbra.cs.account.UCService)14 Provisioning (com.zimbra.cs.account.Provisioning)7 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)7 Element (com.zimbra.common.soap.Element)6 LdapUCService (com.zimbra.cs.account.ldap.entry.LdapUCService)5 ServiceException (com.zimbra.common.service.ServiceException)3 AccountServiceException (com.zimbra.cs.account.AccountServiceException)3 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)3 Domain (com.zimbra.cs.account.Domain)2 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 GuestAccount (com.zimbra.cs.account.GuestAccount)1 Server (com.zimbra.cs.account.Server)1 XMPPComponent (com.zimbra.cs.account.XMPPComponent)1 AdminRight (com.zimbra.cs.account.accesscontrol.AdminRight)1 RightCommand (com.zimbra.cs.account.accesscontrol.RightCommand)1 CallbackContext (com.zimbra.cs.account.callback.CallbackContext)1 LdapAccount (com.zimbra.cs.account.ldap.entry.LdapAccount)1