Search in sources :

Example 1 with Account

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());
}
Also used : Account(com.zimbra.cs.account.Account) ZMailbox(com.zimbra.client.ZMailbox) HttpClient(org.apache.commons.httpclient.HttpClient) ZFolder(com.zimbra.client.ZFolder) ByteArrayRequestEntity(org.apache.commons.httpclient.methods.ByteArrayRequestEntity) Test(org.junit.Test)

Example 2 with Account

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);
}
Also used : Account(com.zimbra.cs.account.Account) HttpClient(org.apache.commons.httpclient.HttpClient) PutMethod(org.apache.commons.httpclient.methods.PutMethod) ByteArrayRequestEntity(org.apache.commons.httpclient.methods.ByteArrayRequestEntity) Test(org.junit.Test)

Example 3 with Account

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()));
}
Also used : Account(com.zimbra.cs.account.Account) Test(org.junit.Test)

Example 4 with Account

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, "");
}
Also used : Account(com.zimbra.cs.account.Account) Cos(com.zimbra.cs.account.Cos)

Example 5 with Account

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;
}
Also used : WaitSetAccount(com.zimbra.cs.session.WaitSetAccount) Account(com.zimbra.cs.account.Account) SyncToken(com.zimbra.cs.service.util.SyncToken) WaitSetAccount(com.zimbra.cs.session.WaitSetAccount) Element(com.zimbra.common.soap.Element) ArrayList(java.util.ArrayList) WaitSetError(com.zimbra.cs.session.WaitSetError)

Aggregations

Account (com.zimbra.cs.account.Account)1444 Test (org.junit.Test)691 Mailbox (com.zimbra.cs.mailbox.Mailbox)468 OperationContext (com.zimbra.cs.mailbox.OperationContext)354 ParsedMessage (com.zimbra.cs.mime.ParsedMessage)331 Message (com.zimbra.cs.mailbox.Message)315 DeliveryContext (com.zimbra.cs.mailbox.DeliveryContext)294 Element (com.zimbra.common.soap.Element)280 ServiceException (com.zimbra.common.service.ServiceException)261 ItemId (com.zimbra.cs.service.util.ItemId)248 Provisioning (com.zimbra.cs.account.Provisioning)234 HashMap (java.util.HashMap)179 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)175 Domain (com.zimbra.cs.account.Domain)149 MimeMessage (javax.mail.internet.MimeMessage)125 GuestAccount (com.zimbra.cs.account.GuestAccount)107 MailServiceException (com.zimbra.cs.mailbox.MailServiceException)100 SyntaxException (org.apache.jsieve.exception.SyntaxException)90 AccountServiceException (com.zimbra.cs.account.AccountServiceException)87 Header (javax.mail.Header)84