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