Search in sources :

Example 56 with Account

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

the class BUG_72007 method upgrdeAcount.

private void upgrdeAcount(String name) throws ServiceException {
    if (name != null) {
        Account acct = prov.get(AccountBy.name, name);
        if (acct != null) {
            Map<String, Object> attrs = new HashMap<String, Object>();
            if (!acct.isIsSystemResource()) {
                attrs.put(Provisioning.A_zimbraIsSystemResource, ProvisioningConstants.TRUE);
            }
            if (!acct.isIsSystemAccount()) {
                attrs.put(Provisioning.A_zimbraIsSystemAccount, ProvisioningConstants.TRUE);
            }
            modifyAttrs(acct, attrs);
        }
    }
}
Also used : Account(com.zimbra.cs.account.Account) HashMap(java.util.HashMap)

Example 57 with Account

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

the class SoapProvisioning method getAllAdminAccounts.

// SoapProvisioning only, for zmprov
public List<Account> getAllAdminAccounts(boolean applyDefault) throws ServiceException {
    ArrayList<Account> result = new ArrayList<Account>();
    GetAllAdminAccountsResponse resp = invokeJaxb(new GetAllAdminAccountsRequest(applyDefault));
    for (AccountInfo acct : resp.getAccountList()) {
        result.add(new SoapAccount(acct, this));
    }
    return result;
}
Also used : Account(com.zimbra.cs.account.Account) ArrayList(java.util.ArrayList) AccountInfo(com.zimbra.soap.admin.type.AccountInfo)

Example 58 with Account

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

the class DataSourceTask method call.

@Override
public Void call() {
    ZimbraLog.clearContext();
    ZimbraLog.addMboxToContext(getMailboxId());
    ZimbraLog.datasource.debug("Running scheduled import for DataSource %s", getDataSourceId());
    Mailbox mbox = null;
    try {
        // Look up mailbox, account and data source
        mbox = MailboxManager.getInstance().getMailboxById(getMailboxId());
        Account account = mbox.getAccount();
        ZimbraLog.addAccountNameToContext(account.getName());
        Provisioning prov = Provisioning.getInstance();
        DataSource ds = prov.get(account, Key.DataSourceBy.id, getDataSourceId());
        if (ds != null) {
            ZimbraLog.addDataSourceNameToContext(ds.getName());
            if (!ds.isEnabled()) {
                ZimbraLog.datasource.info("DataSource is disabled.  Cancelling future tasks.");
                DataSourceManager.cancelTask(mbox, getDataSourceId());
                return null;
            }
            // Do the work
            DataSourceManager.importData(ds);
        } else {
            ZimbraLog.datasource.info("DataSource %s was deleted.  Cancelling future tasks.", getDataSourceId());
            DataSourceManager.cancelTask(mbox, getDataSourceId());
        }
    } catch (ServiceException e) {
        ZimbraLog.datasource.warn("Scheduled DataSource import failed.", e);
        return null;
    }
    ZimbraLog.clearContext();
    return null;
}
Also used : Account(com.zimbra.cs.account.Account) Mailbox(com.zimbra.cs.mailbox.Mailbox) ServiceException(com.zimbra.common.service.ServiceException) Provisioning(com.zimbra.cs.account.Provisioning) DataSource(com.zimbra.cs.account.DataSource)

Example 59 with Account

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

the class AutoScheduler method getAutoScheduler.

public static AutoScheduler getAutoScheduler(Mailbox userMailbox, Mailbox calendarMailbox, Invite[] origInvites, int calendarMailItemId, int flags, String[] tags, SetCalendarItemData scidDefault, SetCalendarItemData[] scidExceptions, List<ReplyInfo> replies, DavContext context) {
    if (!DavResource.isCalendarAutoSchedulingEnabled()) {
        return null;
    }
    if (calendarMailbox == null) {
        // We don't know who to act as
        return null;
    }
    ZOrganizer organizer = null;
    Account organizerAcct = null;
    try {
        if (scidDefault == null || scidDefault.invite == null) {
            if (isEmpty(origInvites)) {
                // No new or old invites!
                return null;
            }
            organizer = origInvites[0].getOrganizer();
            organizerAcct = origInvites[0].getOrganizerAccount();
        } else {
            organizer = scidDefault.invite.getOrganizer();
            organizerAcct = scidDefault.invite.getOrganizerAccount();
        }
        if (organizer == null) {
            // no organizer means no scheduling
            return null;
        }
        // TODO:  Does the auth user have scheduling capability for the calendar
        if (calendarMailbox.getAccount().sameAccount(organizerAcct)) {
            return new OrganizerAutoScheduler(userMailbox, calendarMailbox, origInvites, calendarMailItemId, flags, tags, scidDefault, scidExceptions, replies, context);
        } else {
            return new AttendeeAutoScheduler(userMailbox, calendarMailbox, origInvites, calendarMailItemId, flags, tags, scidDefault, scidExceptions, replies, context);
        }
    } catch (ServiceException e) {
        ZimbraLog.dav.debug("Hit this whilst getting AutoScheduler", e);
    }
    return null;
}
Also used : Account(com.zimbra.cs.account.Account) ServiceException(com.zimbra.common.service.ServiceException) MailServiceException(com.zimbra.cs.mailbox.MailServiceException) ZOrganizer(com.zimbra.cs.mailbox.calendar.ZOrganizer)

Example 60 with Account

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

the class CalDavUtils method removeAttendeeForOrganizer.

// Fixup for ATTENDEE properties set by Apple iCal
// Don't let the organizer to be also listed as an attendee.
public static void removeAttendeeForOrganizer(ZComponent comp) {
    if (!DebugConfig.caldavAllowAttendeeForOrganizer && (ICalTok.VEVENT.equals(comp.getTok()) || ICalTok.VTODO.equals(comp.getTok()))) {
        String organizer = comp.getPropVal(ICalTok.ORGANIZER, null);
        if (organizer != null) {
            organizer = organizer.trim();
            AccountAddressMatcher acctMatcher = null;
            String address = stripMailto(organizer);
            if (address != null) {
                try {
                    Account acct = Provisioning.getInstance().get(AccountBy.name, address);
                    if (acct != null) {
                        acctMatcher = new AccountAddressMatcher(acct);
                    }
                } catch (ServiceException e) {
                    // ignore
                    ZimbraLog.dav.warn("could not get the account matcher for " + address, e);
                }
            }
            for (Iterator<ZProperty> propIter = comp.getPropertyIterator(); propIter.hasNext(); ) {
                ZProperty prop = propIter.next();
                if (ICalTok.ATTENDEE.equals(prop.getToken())) {
                    String att = prop.getValue();
                    if (att != null) {
                        att = att.trim();
                        try {
                            // iCal has a habit of listing the organizer as an ATTENDEE.  Undo it.
                            if (att.equalsIgnoreCase(organizer) || (acctMatcher != null && acctMatcher.matches(stripMailto(att)))) {
                                propIter.remove();
                            }
                        } catch (ServiceException e) {
                            // ignore
                            ZimbraLog.dav.warn("exception while matching the attendee address " + att, e);
                        }
                    } else {
                        // We haven't seen this case occur, but just in case.
                        propIter.remove();
                    }
                }
            }
        }
    }
}
Also used : Account(com.zimbra.cs.account.Account) ServiceException(com.zimbra.common.service.ServiceException) AccountAddressMatcher(com.zimbra.cs.util.AccountUtil.AccountAddressMatcher) ZProperty(com.zimbra.common.calendar.ZCalendar.ZProperty)

Aggregations

Account (com.zimbra.cs.account.Account)1244 Test (org.junit.Test)520 Mailbox (com.zimbra.cs.mailbox.Mailbox)389 OperationContext (com.zimbra.cs.mailbox.OperationContext)292 ParsedMessage (com.zimbra.cs.mime.ParsedMessage)274 Message (com.zimbra.cs.mailbox.Message)255 DeliveryContext (com.zimbra.cs.mailbox.DeliveryContext)242 Provisioning (com.zimbra.cs.account.Provisioning)222 Element (com.zimbra.common.soap.Element)220 ItemId (com.zimbra.cs.service.util.ItemId)219 ServiceException (com.zimbra.common.service.ServiceException)201 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)158 HashMap (java.util.HashMap)154 Domain (com.zimbra.cs.account.Domain)145 MimeMessage (javax.mail.internet.MimeMessage)104 GuestAccount (com.zimbra.cs.account.GuestAccount)98 MailServiceException (com.zimbra.cs.mailbox.MailServiceException)92 AccountServiceException (com.zimbra.cs.account.AccountServiceException)77 ZMailbox (com.zimbra.client.ZMailbox)72 Header (javax.mail.Header)67