Search in sources :

Example 1 with Server

use of com.zimbra.cs.account.Server in project zm-mailbox by Zimbra.

the class FilterUtilTest method init.

@BeforeClass
public static void init() throws Exception {
    MailboxTestUtil.initServer();
    Provisioning prov = Provisioning.getInstance();
    Account acct1 = prov.createAccount("test@zimbra.com", "secret", new HashMap<String, Object>());
    Server server = Provisioning.getInstance().getServer(acct1);
}
Also used : Account(com.zimbra.cs.account.Account) Server(com.zimbra.cs.account.Server) MockProvisioning(com.zimbra.cs.account.MockProvisioning) Provisioning(com.zimbra.cs.account.Provisioning) BeforeClass(org.junit.BeforeClass)

Example 2 with Server

use of com.zimbra.cs.account.Server in project zm-mailbox by Zimbra.

the class RedirectCopyTest method init.

@BeforeClass
public static void init() throws Exception {
    MailboxTestUtil.initServer();
    Provisioning prov = Provisioning.getInstance();
    Map<String, Object> attrs = Maps.newHashMap();
    prov.createDomain("zimbra.com", attrs);
    attrs = Maps.newHashMap();
    attrs.put(Provisioning.A_zimbraId, UUID.randomUUID().toString());
    prov.createAccount("test1@zimbra.com", "secret", attrs);
    attrs = Maps.newHashMap();
    attrs.put(Provisioning.A_zimbraId, UUID.randomUUID().toString());
    Account acct = prov.createAccount("test2@zimbra.com", "secret", attrs);
    attrs = Maps.newHashMap();
    attrs.put(Provisioning.A_zimbraId, UUID.randomUUID().toString());
    prov.createAccount("test3@zimbra.com", "secret", attrs);
    Server server = Provisioning.getInstance().getServer(acct);
    // this MailboxManager does everything except actually send mail
    MailboxManager.setInstance(new DirectInsertionMailboxManager());
}
Also used : Account(com.zimbra.cs.account.Account) Server(com.zimbra.cs.account.Server) Provisioning(com.zimbra.cs.account.Provisioning) DirectInsertionMailboxManager(com.zimbra.cs.service.mail.SendMsgTest.DirectInsertionMailboxManager) BeforeClass(org.junit.BeforeClass)

Example 3 with Server

use of com.zimbra.cs.account.Server in project zm-mailbox by Zimbra.

the class SetVariableTest method init.

@BeforeClass
public static void init() throws Exception {
    MailboxTestUtil.initServer();
    Provisioning prov = Provisioning.getInstance();
    Account acct = prov.createAccount("test1@zimbra.com", "secret", new HashMap<String, Object>());
    Server server = Provisioning.getInstance().getServer(acct);
}
Also used : Account(com.zimbra.cs.account.Account) Server(com.zimbra.cs.account.Server) MockProvisioning(com.zimbra.cs.account.MockProvisioning) Provisioning(com.zimbra.cs.account.Provisioning) BeforeClass(org.junit.BeforeClass)

Example 4 with Server

use of com.zimbra.cs.account.Server in project zm-mailbox by Zimbra.

the class MailSenderTest method sendExternalMessage.

//@Test
public void sendExternalMessage() throws Exception {
    Provisioning prov = Provisioning.getInstance();
    Server server = prov.getLocalServer();
    server.setSmtpHostname(new String[] { "bogusname.test" });
    server.setSmtpPort(25);
    server.setSmtpTimeout(60);
    server.setSmtpSendPartial(true);
    server.setShareNotificationMtaHostname("mta02.zimbra.com");
    server.setShareNotificationMtaPort(25);
    server.setShareNotificationMtaAuthRequired(true);
    server.setShareNotificationMtaConnectionType(ShareNotificationMtaConnectionType.STARTTLS);
    server.setShareNotificationMtaAuthAccount("test-jylee");
    server.setShareNotificationMtaAuthPassword("test123");
    MimeMessage mm = new MimeMessage(JMSession.getSmtpSession());
    InternetAddress address = new JavaMailInternetAddress("test-jylee@zimbra.com");
    mm.setFrom(address);
    address = new JavaMailInternetAddress("test-jylee@zimbra.com");
    mm.setRecipient(javax.mail.Message.RecipientType.TO, address);
    mm.setSubject("test mail");
    mm.setText("hello world");
    mm.saveChanges();
    ZimbraLog.smtp.setLevel(Level.trace);
    MailSender.relayMessage(mm);
}
Also used : InternetAddress(javax.mail.internet.InternetAddress) JavaMailInternetAddress(com.zimbra.common.mime.shim.JavaMailInternetAddress) Server(com.zimbra.cs.account.Server) MimeMessage(javax.mail.internet.MimeMessage) FixedMimeMessage(com.zimbra.cs.mime.Mime.FixedMimeMessage) JavaMailInternetAddress(com.zimbra.common.mime.shim.JavaMailInternetAddress) MockProvisioning(com.zimbra.cs.account.MockProvisioning) Provisioning(com.zimbra.cs.account.Provisioning)

Example 5 with Server

use of com.zimbra.cs.account.Server in project zm-mailbox by Zimbra.

the class CheckPortConflict method checkConfig.

private void checkConfig(Config config, Map<String, Object> configAttrsToModify) throws ServiceException {
    BiMap<String, String> newDefaults = HashBiMap.create();
    /*
         * First, make sure there is no conflict in the Config entry, even
         * if the value on the config entry might not be effective on a server.
         */
    for (String attrName : sPortAttrs) {
        if (!configAttrsToModify.containsKey(attrName))
            newDefaults.put(config.getAttr(attrName), attrName);
    }
    // check conflict for attrs being changed
    for (Map.Entry<String, Object> attrToModify : configAttrsToModify.entrySet()) {
        String attrName = attrToModify.getKey();
        if (!sPortAttrs.contains(attrName))
            continue;
        SingleValueMod mod = singleValueMod(configAttrsToModify, attrName);
        String newValue = null;
        if (mod.setting())
            newValue = mod.value();
        if (conflict(null, newDefaults, newValue, attrName)) {
            throw ServiceException.INVALID_REQUEST("port " + newValue + " conflict between " + attrName + " and " + newDefaults.get(newValue) + " on global config", null);
        } else
            newDefaults.put(newValue, attrName);
    }
    /*
         * Then, iterate through all servers see if this port change on the Config
         * entry has impact on a server.
         */
    List<Server> servers = Provisioning.getInstance().getAllServers();
    for (Server server : servers) {
        checkServerWithNewDefaults(server, newDefaults, configAttrsToModify);
    }
}
Also used : Server(com.zimbra.cs.account.Server) BiMap(com.google.common.collect.BiMap) HashMap(java.util.HashMap) HashBiMap(com.google.common.collect.HashBiMap) Map(java.util.Map)

Aggregations

Server (com.zimbra.cs.account.Server)211 Provisioning (com.zimbra.cs.account.Provisioning)84 ServiceException (com.zimbra.common.service.ServiceException)58 Account (com.zimbra.cs.account.Account)52 Element (com.zimbra.common.soap.Element)49 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)47 Domain (com.zimbra.cs.account.Domain)25 AccountServiceException (com.zimbra.cs.account.AccountServiceException)22 HashMap (java.util.HashMap)22 IOException (java.io.IOException)17 ArrayList (java.util.ArrayList)13 AuthToken (com.zimbra.cs.account.AuthToken)12 Map (java.util.Map)12 Test (org.junit.Test)11 LdapServer (com.zimbra.cs.account.ldap.entry.LdapServer)10 MailServiceException (com.zimbra.cs.mailbox.MailServiceException)10 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)9 Mailbox (com.zimbra.cs.mailbox.Mailbox)9 InMemoryLdapServer (com.zimbra.cs.ldap.unboundid.InMemoryLdapServer)8 List (java.util.List)8