use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.
the class ProvUtil method doReIndexMailbox.
private void doReIndexMailbox(String[] args) throws ServiceException {
if (!(prov instanceof SoapProvisioning)) {
throwSoapOnly();
}
SoapProvisioning sp = (SoapProvisioning) prov;
Account acct = lookupAccount(args[1]);
ReIndexBy by = null;
String[] values = null;
if (args.length > 3) {
try {
by = ReIndexBy.valueOf(args[3]);
} catch (IllegalArgumentException e) {
throw ServiceException.INVALID_REQUEST("invalid reindex-by", null);
}
if (args.length > 4) {
values = new String[args.length - 4];
System.arraycopy(args, 4, values, 0, args.length - 4);
} else {
throw ServiceException.INVALID_REQUEST("missing reindex-by values", null);
}
}
ReIndexInfo info = sp.reIndex(acct, args[2], by, values);
ReIndexInfo.Progress progress = info.getProgress();
console.printf("status: %s\n", info.getStatus());
if (progress != null) {
console.printf("progress: numSucceeded=%d, numFailed=%d, numRemaining=%d\n", progress.getNumSucceeded(), progress.getNumFailed(), progress.getNumRemaining());
}
}
use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.
the class ProvUtil method doGetShareInfo.
private void doGetShareInfo(String[] args) throws ServiceException {
if (!(prov instanceof SoapProvisioning)) {
throwSoapOnly();
}
Account owner = lookupAccount(args[1]);
ShareInfoVisitor.printHeadings();
prov.getShareInfo(owner, new ShareInfoVisitor());
}
use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.
the class ProvUtil method doGetQuotaUsage.
private void doGetQuotaUsage(String[] args) throws ServiceException {
if (!(prov instanceof SoapProvisioning)) {
throwSoapOnly();
}
SoapProvisioning sp = (SoapProvisioning) prov;
List<QuotaUsage> result = sp.getQuotaUsage(args[1]);
for (QuotaUsage u : result) {
console.printf("%s %d %d\n", u.getName(), u.getLimit(), u.getUsed());
}
}
use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.
the class ProvUtil method doRemoveAccountLogger.
private void doRemoveAccountLogger(AccountLoggerOptions alo) throws ServiceException {
if (!(prov instanceof SoapProvisioning)) {
throwSoapOnly();
}
SoapProvisioning sp = (SoapProvisioning) prov;
Account acct = null;
String category = null;
if (alo.args.length == 2) {
// Hack: determine if it's an account or category, based on the name.
String arg = alo.args[1];
if (arg.startsWith("zimbra.") || arg.startsWith("com.zimbra")) {
category = arg;
} else {
acct = lookupAccount(alo.args[1]);
}
}
if (alo.args.length == 3) {
acct = lookupAccount(alo.args[1]);
category = alo.args[2];
}
sp.removeAccountLoggers(acct, category, alo.server);
}
use of com.zimbra.cs.account.soap.SoapProvisioning in project zm-mailbox by Zimbra.
the class ProvUtil method doUnlockMailbox.
private void doUnlockMailbox(String[] args) throws ServiceException {
String accountVal = null;
if (args.length > 1) {
accountVal = args[1];
} else {
usage();
return;
}
if (accountVal != null) {
//will throw NO_SUCH_ACCOUNT if not found
Account acct = lookupAccount(accountVal);
if (!acct.getAccountStatus().isActive()) {
throw ServiceException.FAILURE(String.format("Cannot unlock mailbox for account %s. Account status must be %s. Curent account status is %s. " + "You must change the value of zimbraAccountStatus to '%s' first", accountVal, AccountStatus.active, acct.getAccountStatus(), AccountStatus.active), null);
}
String accName = acct.getName();
String server = acct.getMailHost();
try {
sendMailboxLockoutRequest(accName, server, AdminConstants.A_END);
} catch (ServiceException e) {
if (ServiceException.UNKNOWN_DOCUMENT.equals(e.getCode())) {
throw ServiceException.FAILURE("source server version does not support " + AdminConstants.E_LOCKOUT_MAILBOX_REQUEST, e);
} else if (ServiceException.NOT_FOUND.equals(e.getCode())) {
//if mailbox is not locked, move on
printOutput("Warning: " + e.getMessage());
} else {
throw e;
}
} catch (IOException e) {
throw ServiceException.FAILURE(String.format("Error sending %s (operation = %s) request for %s to %s", AdminConstants.E_LOCKOUT_MAILBOX_REQUEST, AdminConstants.A_END, accountVal, server), e);
}
//unregister moveout if hostname is provided
if (args.length > 2) {
//set account status to maintenance and lock the mailbox to avoid race conditions
acct.setAccountStatus(AccountStatus.maintenance);
try {
sendMailboxLockoutRequest(accName, server, AdminConstants.A_START);
} catch (IOException e) {
throw ServiceException.FAILURE(String.format("Error sending %s (opertion = %s) request for %s to %s.\n Warning: Account is left in maintenance state!", AdminConstants.E_LOCKOUT_MAILBOX_REQUEST, AdminConstants.A_START, accountVal, server), e);
}
//unregister moveout via SOAP
String targetServer = args[2];
try {
UnregisterMailboxMoveOutRequest unregisterReq = UnregisterMailboxMoveOutRequest.create(MailboxMoveSpec.createForNameAndTarget(accName, targetServer));
String url = URLUtil.getAdminURL(server);
ZAuthToken token = ((SoapProvisioning) prov).getAuthToken();
SoapHttpTransport transport = new SoapHttpTransport(url);
transport.setAuthToken(token);
transport.invokeWithoutSession(JaxbUtil.jaxbToElement(unregisterReq));
} catch (ServiceException e) {
if (ServiceException.UNKNOWN_DOCUMENT.equals(e.getCode())) {
throw ServiceException.FAILURE(String.format("target server version does not support %s.", BackupConstants.E_UNREGISTER_MAILBOX_MOVE_OUT_REQUEST), e);
} else {
throw ServiceException.FAILURE("Failed to unregister mailbox moveout", e);
}
} catch (IOException e) {
throw ServiceException.FAILURE(String.format("Error sending %s request for %s to %s.", BackupConstants.E_UNREGISTER_MAILBOX_MOVE_OUT_REQUEST, accountVal, server), e);
} finally {
//unlock mailbox object and end account maintenance even if failed to unregister moveout
try {
sendMailboxLockoutRequest(accName, server, AdminConstants.A_END);
} catch (ServiceException e) {
//print error messages, but don't throw any more exceptions, because we have to set account status back to 'active'
if (ServiceException.UNKNOWN_DOCUMENT.equals(e.getCode())) {
printError("source server version does not support " + AdminConstants.E_LOCKOUT_MAILBOX_REQUEST);
} else {
printError(String.format("Error: failed to unregister mailbox moveout.\n Exception: %s.", e.getMessage()));
}
} catch (IOException e) {
printError(String.format("Error sending %s (operation = %s) request for %s to %s after unregistering moveout. Exception: %s", AdminConstants.E_LOCKOUT_MAILBOX_REQUEST, AdminConstants.A_END, accountVal, server, e.getMessage()));
}
//end account maintenance
acct.setAccountStatus(AccountStatus.active);
}
}
}
}
Aggregations