use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class GetCreateObjectAttrs method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Element eTarget = request.getElement(AdminConstants.E_TARGET);
String targetType = eTarget.getAttribute(AdminConstants.A_TYPE);
Key.DomainBy domainBy = null;
String domain = null;
Element eDomain = request.getOptionalElement(AdminConstants.E_DOMAIN);
if (eDomain != null) {
domainBy = Key.DomainBy.fromString(eDomain.getAttribute(AdminConstants.A_BY));
domain = eDomain.getText();
}
Key.CosBy cosBy = null;
String cos = null;
Element eCos = request.getOptionalElement(AdminConstants.E_COS);
if (eCos != null) {
cosBy = Key.CosBy.fromString(eCos.getAttribute(AdminConstants.A_BY));
cos = eCos.getText();
}
GranteeBy granteeBy = GranteeBy.id;
String grantee = zsc.getRequestedAccountId();
if (!grantee.equals(zsc.getAuthtokenAccountId())) {
checkCheckRightRight(zsc, GranteeType.GT_USER, granteeBy, grantee);
}
RightCommand.EffectiveRights er = RightCommand.getCreateObjectAttrs(Provisioning.getInstance(), targetType, domainBy, domain, cosBy, cos, granteeBy, grantee);
Element resp = zsc.createElement(AdminConstants.GET_CREATE_OBJECT_ATTRS_RESPONSE);
er.toXML_getCreateObjectAttrs(resp);
return resp;
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class GetCurrentVolumes method handle.
private GetCurrentVolumesResponse handle(@SuppressWarnings("unused") GetCurrentVolumesRequest req, Map<String, Object> ctx) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(ctx);
checkRight(zsc, ctx, Provisioning.getInstance().getLocalServer(), Admin.R_manageVolume);
GetCurrentVolumesResponse resp = new GetCurrentVolumesResponse();
VolumeManager mgr = VolumeManager.getInstance();
Volume msgVol = mgr.getCurrentMessageVolume();
if (msgVol != null) {
resp.addVolume(new GetCurrentVolumesResponse.CurrentVolumeInfo(msgVol.getId(), msgVol.getType()));
}
Volume secondaryMsgVol = mgr.getCurrentSecondaryMessageVolume();
if (secondaryMsgVol != null) {
resp.addVolume(new GetCurrentVolumesResponse.CurrentVolumeInfo(secondaryMsgVol.getId(), secondaryMsgVol.getType()));
}
Volume indexVol = mgr.getCurrentIndexVolume();
if (indexVol != null) {
resp.addVolume(new GetCurrentVolumesResponse.CurrentVolumeInfo(indexVol.getId(), indexVol.getType()));
}
return resp;
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class SyncGalAccount method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
ZimbraLog.addToContext(ZimbraLog.C_ANAME, getAuthenticatedAccount(zsc).getName());
for (Element accountEl : request.listElements(AdminConstants.E_ACCOUNT)) {
String accountId = accountEl.getAttribute(AdminConstants.A_ID);
Account account = prov.getAccountById(accountId);
if (account == null) {
throw AccountServiceException.NO_SUCH_ACCOUNT(accountId);
}
ZimbraLog.addToContext(ZimbraLog.C_NAME, account.getName());
for (Element dsEl : accountEl.listElements(AdminConstants.E_DATASOURCE)) {
String by = dsEl.getAttribute(AdminConstants.A_BY);
String name = dsEl.getText();
DataSource ds = by.equals("id") ? account.getDataSourceById(name) : account.getDataSourceByName(name);
if (ds == null) {
throw AccountServiceException.NO_SUCH_DATA_SOURCE(name);
}
if (!ds.getType().equals(DataSourceType.gal)) {
continue;
}
boolean fullSync = dsEl.getAttributeBool(AdminConstants.A_FULLSYNC, false);
boolean reset = dsEl.getAttributeBool(AdminConstants.A_RESET, false);
int fid = ds.getFolderId();
DataImport dataImport = DataSourceManager.getInstance().getDataImport(ds);
if (dataImport instanceof GalImport) {
((GalImport) dataImport).importGal(fid, (reset ? reset : fullSync), reset);
}
//flush domain gal group cache
Domain domain = prov.getDomain(account);
GalGroup.flushCache(domain);
}
}
return zsc.createElement(AdminConstants.SYNC_GAL_ACCOUNT_RESPONSE);
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class UndeployZimlet method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
String name = request.getAttribute(AdminConstants.A_NAME);
String action = request.getAttribute(AdminConstants.A_ACTION, null);
ZAuthToken auth = null;
if (action == null) {
auth = zsc.getRawAuthToken();
}
Element response = zsc.createElement(AdminConstants.UNDEPLOY_ZIMLET_RESPONSE);
//undeploy on local server and LDAP anyway
ZimletUtil.undeployZimletLocally(name);
if (AdminConstants.A_DEPLOYALL.equals(action)) {
//undeploy on remote servers
for (Server server : Provisioning.getInstance().getAllServers()) {
if (!server.isLocalServer()) {
checkRight(zsc, context, server, Admin.R_deployZimlet);
new Thread(new UndeployThread(server, name, auth)).start();
}
}
}
return response;
}
use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.
the class VerifyIndex method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Element mreq = request.getElement(AdminConstants.E_MAILBOX);
String accountId = mreq.getAttribute(AdminConstants.A_ACCOUNTID);
Provisioning prov = Provisioning.getInstance();
Account account = prov.get(AccountBy.id, accountId, zsc.getAuthToken());
if (account == null) {
throw AccountServiceException.NO_SUCH_ACCOUNT(accountId);
}
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account, false);
if (mbox == null) {
throw ServiceException.FAILURE("mailbox not found for account " + accountId, null);
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
boolean status = mbox.index.verify(new PrintStream(out));
Element resp = zsc.createElement(AdminConstants.VERIFY_INDEX_RESPONSE);
resp.addElement(AdminConstants.E_STATUS).addText(String.valueOf(status));
try {
resp.addElement(AdminConstants.E_MESSAGE).addText(out.toString(Charsets.UTF_8.name()));
} catch (UnsupportedEncodingException never) {
assert false;
}
return resp;
}
Aggregations