use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class RemoteFreeBusyProvider method addResults.
@Override
public void addResults(Element response) {
Provisioning prov = Provisioning.getInstance();
for (Map.Entry<String, StringBuilder> entry : mRemoteAccountMap.entrySet()) {
// String server = entry.getKey();
String paramStr = entry.getValue().toString();
String[] idStrs = paramStr.split(",");
try {
Element req = mSoapCtxt.getRequestProtocol().getFactory().createElement(MailConstants.GET_FREE_BUSY_REQUEST);
req.addAttribute(MailConstants.A_CAL_START_TIME, mStart);
req.addAttribute(MailConstants.A_CAL_END_TIME, mEnd);
req.addAttribute(MailConstants.A_UID, paramStr);
// hack: use the ID of the first user
Account acct = prov.get(AccountBy.name, idStrs[0], mSoapCtxt.getAuthToken());
if (acct == null)
acct = prov.get(AccountBy.id, idStrs[0], mSoapCtxt.getAuthToken());
if (acct != null) {
Element remoteResponse = proxyRequest(req, acct.getId(), mSoapCtxt);
for (Element thisElt : remoteResponse.listElements()) response.addElement(thisElt.detach());
} else {
ZimbraLog.fb.debug("Account " + idStrs[0] + " not found while searching free/busy");
}
} catch (SoapFaultException e) {
ZimbraLog.fb.error("cannot get free/busy for " + idStrs[0], e);
addFailedAccounts(response, idStrs);
} catch (ServiceException e) {
ZimbraLog.fb.error("cannot get free/busy for " + idStrs[0], e);
addFailedAccounts(response, idStrs);
}
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class MailItemResource method moveORcopyWithOverwrite.
public void moveORcopyWithOverwrite(DavContext ctxt, Collection dest, String newName, boolean deleteOriginal) throws DavException {
try {
if (deleteOriginal)
move(ctxt, dest, newName);
else
copy(ctxt, dest, newName);
} catch (DavException e) {
if (e.getStatus() == HttpServletResponse.SC_PRECONDITION_FAILED) {
// in case of name conflict, delete the existing mail item and
// attempt the move operation again.
// return if the error is not ALREADY_EXISTS
ServiceException se = (ServiceException) e.getCause();
int id = 0;
try {
if (se.getCode().equals(MailServiceException.ALREADY_EXISTS) == false)
throw e;
else {
// get the conflicting item-id
if (se instanceof SoapFaultException) {
// destination belongs other mailbox.
String itemIdStr = ((SoapFaultException) se).getArgumentValue("id");
ItemId itemId = new ItemId(itemIdStr, dest.getItemId().getAccountId());
id = itemId.getId();
} else {
// destination belongs to same mailbox.
String name = null;
for (Argument arg : se.getArgs()) {
if (arg.name != null && arg.value != null && arg.value.length() > 0) {
if (arg.name.equals("name"))
name = arg.value;
/* commented out since the exception is giving wrong itemId for copy.
If the the item is conflicting with an existing item we want the
id of the existing item. But, the exception has the proposed id of
the new item which does not exist yet.
else if (arg.mName.equals("itemId"))
id = Integer.parseInt(arg.mValue);
*/
}
}
if (id <= 0) {
if (name == null && !deleteOriginal) {
// in case of copy get the id from source name since we don't support copy with rename.
name = ctxt.getItem();
}
if (name != null) {
Mailbox mbox = getMailbox(ctxt);
MailItem item = mbox.getItemByPath(ctxt.getOperationContext(), name, dest.getId());
id = item.getId();
} else
throw e;
}
}
}
deleteDestinationItem(ctxt, dest, id);
} catch (ServiceException se1) {
throw new DavException("cannot move/copy item", HttpServletResponse.SC_FORBIDDEN, se1);
}
if (deleteOriginal)
move(ctxt, dest, newName);
else
copy(ctxt, dest, newName);
} else {
throw e;
}
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class ImapServerListener method deleteWaitSet.
private void deleteWaitSet() throws ServiceException {
ZimbraLog.imap.debug("Deleting waitset %s", wsID);
cancelPendingRequest();
if (wsID != null) {
AdminDestroyWaitSetRequest req = new AdminDestroyWaitSetRequest(wsID);
checkAuth();
try {
synchronized (soapProv) {
try {
soapProv.invokeJaxbAsAdminWithRetry(req);
} catch (SoapFaultException ex) {
if (AdminServiceException.NO_SUCH_WAITSET.equalsIgnoreCase(ex.getCode())) {
ZimbraLog.imap.debug("Caught NO_SUCH_WAITSET exception trying to delete a waitset. Waitset may have been deleted by sweeper. Ignoring.");
}
} catch (ServiceException e) {
ZimbraLog.imap.error("Caught unexpected exception trying to delete a waitset.", e);
}
}
} finally {
wsID = null;
unsetWaitSetIdOnMailboxes();
lastSequence.set(0);
}
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestLockoutMailbox method testLockoutSufficientPermissions.
@Test
public void testLockoutSufficientPermissions() throws Exception {
Mailbox mbox = TestUtil.getMailbox(MY_USER);
TestUtil.addMessage(mbox, "test");
TestUtil.waitForMessage(TestUtil.getZMailbox(MY_USER), "test");
List<AdminRight> relatedRights = new ArrayList<AdminRight>();
List<String> notes = new ArrayList<String>();
AdminDocumentHandler handler = new LockoutMailbox();
handler.docRights(relatedRights, notes);
createDelegatedAdmin(relatedRights);
LockoutMailboxRequest req = LockoutMailboxRequest.create(AccountNameSelector.fromName(MY_USER));
req.setOperation(AdminConstants.A_START);
try {
LockoutMailboxResponse resp = delegatedSoapProv.invokeJaxb(req);
assertNotNull("LockoutMailboxResponse should not be null", resp);
} catch (SoapFaultException e) {
fail("should not be getting an exception");
}
req = LockoutMailboxRequest.create(AccountNameSelector.fromName(MY_NON_EXISTING_USER));
req.setOperation(AdminConstants.A_START);
try {
delegatedSoapProv.invokeJaxb(req);
fail("should have caught an exception");
} catch (SoapFaultException e) {
assertEquals("should be getting 'no such account' response", AccountServiceException.NO_SUCH_ACCOUNT, e.getCode());
}
}
use of com.zimbra.common.soap.SoapFaultException in project zm-mailbox by Zimbra.
the class TestLockoutMailbox method testLockAccountEnumeration.
@Test
public void testLockAccountEnumeration() throws Exception {
Mailbox mbox = TestUtil.getMailbox(MY_USER);
TestUtil.addMessage(mbox, "test");
TestUtil.waitForMessage(TestUtil.getZMailbox(MY_USER), "test");
List<AdminRight> relatedRights = new ArrayList<AdminRight>();
List<String> notes = new ArrayList<String>();
AdminDocumentHandler handler = new LockoutMailbox();
handler.docRights(relatedRights, notes);
createDelegatedAdmin(relatedRights);
LockoutMailboxRequest req = LockoutMailboxRequest.create(AccountNameSelector.fromName(OFFLIMITS_NON_EXISTING_USER));
req.setOperation(AdminConstants.A_START);
try {
delegatedSoapProv.invokeJaxb(req);
fail("should have caught an exception");
} catch (SoapFaultException e) {
assertEquals("should be getting 'Permission Denied' response", ServiceException.PERM_DENIED, e.getCode());
}
}
Aggregations