use of com.zimbra.cs.account.Account in project zm-mailbox by Zimbra.
the class TestCalDav method testMkcol4addressBook.
@Test
public void testMkcol4addressBook() throws Exception {
String xml = "<D:mkcol xmlns:D=\"DAV:\" xmlns:C=\"urn:ietf:params:xml:ns:carddav\">" + " <D:set>" + " <D:prop>" + " <D:resourcetype>" + " <D:collection/>" + " <C:addressbook/>" + " </D:resourcetype>" + " <D:displayname>OtherContacts</D:displayname>" + " <C:addressbook-description xml:lang=\"en\">Extra Contacts</C:addressbook-description>" + " </D:prop>" + " </D:set>" + "</D:mkcol>";
Account dav1 = users[1].create();
StringBuilder url = getLocalServerRoot();
url.append(DavServlet.DAV_PATH).append("/").append(dav1.getName()).append("/OtherContacts/");
MkColMethod method = new MkColMethod(url.toString());
addBasicAuthHeaderForUser(method, dav1);
HttpClient client = new HttpClient();
method.addRequestHeader("Content-Type", MimeConstants.CT_TEXT_XML);
method.setRequestEntity(new ByteArrayRequestEntity(xml.getBytes(), MimeConstants.CT_TEXT_XML));
HttpMethodExecutor.execute(client, method, HttpStatus.SC_MULTI_STATUS);
ZMailbox.Options options = new ZMailbox.Options();
options.setAccount(dav1.getName());
options.setAccountBy(AccountBy.name);
options.setPassword(TestUtil.DEFAULT_PASSWORD);
options.setUri(TestUtil.getSoapUrl());
options.setNoSession(true);
ZMailbox mbox = ZMailbox.getMailbox(options);
ZFolder folder = mbox.getFolderByPath("/OtherContacts");
assertEquals("OtherContacts", folder.getName());
assertEquals("OtherContacts default view", View.contact, folder.getDefaultView());
}
use of com.zimbra.cs.account.Account in project zm-mailbox by Zimbra.
the class TestCalDav method testCreateContactWithIfNoneMatchTesting.
@Test
public void testCreateContactWithIfNoneMatchTesting() throws ServiceException, IOException {
Account dav1 = users[1].create();
// Based on UID
String davBaseName = "SCRUFF1.vcf";
String contactsFolderUrl = getFolderUrl(dav1, "Contacts");
String url = String.format("%s%s", contactsFolderUrl, davBaseName);
HttpClient client = new HttpClient();
PutMethod putMethod = new PutMethod(url);
addBasicAuthHeaderForUser(putMethod, dav1);
putMethod.addRequestHeader("Content-Type", "text/vcard");
putMethod.setRequestEntity(new ByteArrayRequestEntity(simpleVcard.getBytes(), MimeConstants.CT_TEXT_VCARD));
// Bug 84246 this used to fail with 409 Conflict because we used to require an If-None-Match header
HttpMethodExecutor.execute(client, putMethod, HttpStatus.SC_CREATED);
// Check that trying to put the same thing again when we don't expect it to exist (i.e. Using If-None-Match
// header) will fail.
putMethod = new PutMethod(url);
addBasicAuthHeaderForUser(putMethod, dav1);
putMethod.addRequestHeader("Content-Type", "text/vcard");
putMethod.addRequestHeader(DavProtocol.HEADER_IF_NONE_MATCH, "*");
putMethod.setRequestEntity(new ByteArrayRequestEntity(simpleVcard.getBytes(), MimeConstants.CT_TEXT_VCARD));
HttpMethodExecutor.execute(client, putMethod, HttpStatus.SC_PRECONDITION_FAILED);
}
use of com.zimbra.cs.account.Account in project zm-mailbox by Zimbra.
the class TestCalDav method testPropFindSupportedReportSetOnOutbox.
@Test
public void testPropFindSupportedReportSetOnOutbox() throws Exception {
Account user1 = users[0].create();
checkPropFindSupportedReportSet(user1, getSchedulingOutboxUrl(user1, user1), UrlNamespace.getSchedulingOutboxUrl(user1.getName(), user1.getName()));
}
use of com.zimbra.cs.account.Account in project zm-mailbox by Zimbra.
the class TestDataSourceServer method setUp.
public void setUp() throws Exception {
cleanUp();
// Remember original polling intervals.
Account account = TestUtil.getAccount(USER_NAME);
Cos cos = account.getCOS();
mOriginalAccountPollingInterval = account.getAttr(Provisioning.A_zimbraDataSourcePollingInterval, false);
if (mOriginalAccountPollingInterval == null) {
mOriginalAccountPollingInterval = "";
}
mOriginalAccountPop3PollingInterval = account.getAttr(Provisioning.A_zimbraDataSourcePop3PollingInterval, false);
if (mOriginalAccountPop3PollingInterval == null) {
mOriginalAccountPop3PollingInterval = "";
}
mOriginalAccountImapPollingInterval = account.getAttr(Provisioning.A_zimbraDataSourceImapPollingInterval, false);
if (mOriginalAccountImapPollingInterval == null) {
mOriginalAccountImapPollingInterval = "";
}
mOriginalCosPollingInterval = cos.getAttr(Provisioning.A_zimbraDataSourcePollingInterval, "");
mOriginalCosPop3PollingInterval = cos.getAttr(Provisioning.A_zimbraDataSourcePop3PollingInterval, "");
mOriginalCosImapPollingInterval = cos.getAttr(Provisioning.A_zimbraDataSourceImapPollingInterval, "");
}
use of com.zimbra.cs.account.Account in project zm-mailbox by Zimbra.
the class WaitSetRequest method parseAddUpdateAccounts.
/**
* @param allowedAccountIds NULL means "all allowed" (admin)
*/
static List<WaitSetAccount> parseAddUpdateAccounts(ZimbraSoapContext zsc, Element elt, Set<MailItem.Type> defaultInterest) throws ServiceException {
List<WaitSetAccount> toRet = new ArrayList<WaitSetAccount>();
if (elt != null) {
for (Iterator<Element> iter = elt.elementIterator(MailConstants.E_A); iter.hasNext(); ) {
Element a = iter.next();
String id;
String name = a.getAttribute(MailConstants.A_NAME, null);
if (name != null) {
Account acct = Provisioning.getInstance().get(AccountBy.name, name);
if (acct != null) {
id = acct.getId();
} else {
WaitSetError err = new WaitSetError(name, WaitSetError.Type.NO_SUCH_ACCOUNT);
continue;
}
} else {
id = a.getAttribute(MailConstants.A_ID);
}
WaitSetMgr.checkRightForAdditionalAccount(id, zsc);
String tokenStr = a.getAttribute(MailConstants.A_TOKEN, null);
SyncToken token = tokenStr != null ? new SyncToken(tokenStr) : null;
Set<MailItem.Type> interests = parseInterestStr(a.getAttribute(MailConstants.A_TYPES, null), defaultInterest);
toRet.add(new WaitSetAccount(id, token, interests));
}
}
return toRet;
}
Aggregations