Search in sources :

Example 6 with AlwaysOnCluster

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

the class GetAlwaysOnCluster 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.alwaysOnCluster);
    Element d = request.getElement(AdminConstants.E_ALWAYSONCLUSTER);
    String method = d.getAttribute(AdminConstants.A_BY);
    String name = d.getText();
    if (name == null || name.equals(""))
        throw ServiceException.INVALID_REQUEST("must specify a value for a server", null);
    AlwaysOnCluster cluster = prov.get(Key.AlwaysOnClusterBy.fromString(method), name);
    if (cluster == null)
        throw AccountServiceException.NO_SUCH_ALWAYSONCLUSTER(name);
    AdminAccessControl aac = checkRight(zsc, context, cluster, AdminRight.PR_ALWAYS_ALLOW);
    // reload the server
    prov.reload(cluster);
    Element response = zsc.createElement(AdminConstants.GET_ALWAYSONCLUSTER_RESPONSE);
    encodeAlwaysOnCluster(response, cluster, reqAttrs, aac.getAttrRightChecker(cluster));
    return response;
}
Also used : AlwaysOnCluster(com.zimbra.cs.account.AlwaysOnCluster) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning)

Example 7 with AlwaysOnCluster

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

the class ModifyAlwaysOnCluster method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    String id = request.getAttribute(AdminConstants.E_ID);
    Map<String, Object> attrs = AdminService.getAttrs(request);
    AlwaysOnCluster cluster = prov.get(Key.AlwaysOnClusterBy.id, id);
    if (cluster == null) {
        throw AccountServiceException.NO_SUCH_ALWAYSONCLUSTER(id);
    }
    checkRight(zsc, context, cluster, attrs);
    // pass in true to checkImmutable
    prov.modifyAttrs(cluster, attrs, true);
    ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "ModifyAlwaysOnCluster", "name", cluster.getName() }, attrs));
    Element response = zsc.createElement(AdminConstants.MODIFY_ALWAYSONCLUSTER_RESPONSE);
    GetAlwaysOnCluster.encodeCluster(response, cluster);
    return response;
}
Also used : AlwaysOnCluster(com.zimbra.cs.account.AlwaysOnCluster) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning)

Example 8 with AlwaysOnCluster

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

the class CreateAlwaysOnCluster method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    String name = request.getAttribute(AdminConstants.E_NAME).toLowerCase();
    Map<String, Object> attrs = AdminService.getAttrs(request, true);
    checkRight(zsc, context, null, Admin.R_createAlwaysOnCluster);
    checkSetAttrsOnCreate(zsc, TargetType.alwaysoncluster, name, attrs);
    AlwaysOnCluster cluster = prov.createAlwaysOnCluster(name, attrs);
    ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "CreateAlwaysOnCluster", "name", name }, attrs));
    Element response = zsc.createElement(AdminConstants.CREATE_ALWAYSONCLUSTER_RESPONSE);
    GetAlwaysOnCluster.encodeCluster(response, cluster);
    return response;
}
Also used : AlwaysOnCluster(com.zimbra.cs.account.AlwaysOnCluster) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning)

Example 9 with AlwaysOnCluster

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

the class DeleteAlwaysOnCluster method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    String id = request.getAttribute(AdminConstants.E_ID);
    AlwaysOnCluster cluster = prov.get(Key.AlwaysOnClusterBy.id, id);
    if (cluster == null)
        throw AccountServiceException.NO_SUCH_ALWAYSONCLUSTER(id);
    checkRight(zsc, context, cluster, Admin.R_deleteAlwaysOnCluster);
    prov.deleteAlwaysOnCluster(cluster.getId());
    ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "DeleteAlwaysOnCluster", "name", cluster.getName(), "id", cluster.getId() }));
    Element response = zsc.createElement(AdminConstants.DELETE_ALWAYSONCLUSTER_RESPONSE);
    return response;
}
Also used : AlwaysOnCluster(com.zimbra.cs.account.AlwaysOnCluster) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning)

Example 10 with AlwaysOnCluster

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

the class SoapProvisioning method getAllAlwaysOnClusters.

@Override
public List<AlwaysOnCluster> getAllAlwaysOnClusters() throws ServiceException {
    ArrayList<AlwaysOnCluster> result = new ArrayList<AlwaysOnCluster>();
    GetAllAlwaysOnClustersResponse resp = invokeJaxb(new GetAllAlwaysOnClustersRequest());
    for (AlwaysOnClusterInfo clusterInfo : resp.getAlwaysOnClusterList()) {
        result.add(new SoapAlwaysOnCluster(clusterInfo, this));
    }
    return result;
}
Also used : AlwaysOnCluster(com.zimbra.cs.account.AlwaysOnCluster) AlwaysOnClusterInfo(com.zimbra.soap.admin.type.AlwaysOnClusterInfo) ArrayList(java.util.ArrayList)

Aggregations

AlwaysOnCluster (com.zimbra.cs.account.AlwaysOnCluster)14 LdapAlwaysOnCluster (com.zimbra.cs.account.ldap.entry.LdapAlwaysOnCluster)7 Element (com.zimbra.common.soap.Element)5 Provisioning (com.zimbra.cs.account.Provisioning)5 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)5 ServiceException (com.zimbra.common.service.ServiceException)4 AccountServiceException (com.zimbra.cs.account.AccountServiceException)4 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)4 Account (com.zimbra.cs.account.Account)3 Domain (com.zimbra.cs.account.Domain)3 GuestAccount (com.zimbra.cs.account.GuestAccount)3 Server (com.zimbra.cs.account.Server)3 LdapAccount (com.zimbra.cs.account.ldap.entry.LdapAccount)3 LdapCos (com.zimbra.cs.account.ldap.entry.LdapCos)3 LdapDomain (com.zimbra.cs.account.ldap.entry.LdapDomain)3 LdapServer (com.zimbra.cs.account.ldap.entry.LdapServer)3 InMemoryLdapServer (com.zimbra.cs.ldap.unboundid.InMemoryLdapServer)3 Cos (com.zimbra.cs.account.Cos)2 LdapZimlet (com.zimbra.cs.account.ldap.entry.LdapZimlet)2 Key (com.zimbra.common.account.Key)1