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