Search in sources :

Example 1 with AccountStatus

use of com.zimbra.common.account.ZAttrProvisioning.AccountStatus in project zm-mailbox by Zimbra.

the class DataSourceManager method importData.

/**
     * Executes the data source's {@link MailItemImport} implementation to import data in the current thread.
     */
public static void importData(DataSource ds, List<Integer> folderIds, boolean fullSync) throws ServiceException {
    ZimbraLog.datasource.info("Requested import.");
    AccountStatus status = ds.getAccount().getAccountStatus();
    if (!(status.isActive() || status.isLocked() || status.isLockout())) {
        ZimbraLog.datasource.info("Account is not active. Skipping import.");
        return;
    }
    if (DataSourceManager.getInstance().getMailbox(ds).getMaintenance() != null) {
        ZimbraLog.datasource.info("Mailbox is in maintenance mode. Skipping import.");
        return;
    }
    ImportStatus importStatus = getImportStatus(ds.getAccount(), ds);
    synchronized (importStatus) {
        if (importStatus.isRunning()) {
            ZimbraLog.datasource.info("Attempted to start import while " + " an import process was already running.  Ignoring the second request.");
            return;
        }
        importStatus.mHasRun = true;
        importStatus.mIsRunning = true;
        importStatus.mSuccess = false;
        importStatus.mError = null;
    }
    boolean success = false;
    String error = null;
    addManaged(ds);
    try {
        ZimbraLog.datasource.info("Importing data for data source '%s'", ds.getName());
        getInstance().getDataImport(ds).importData(folderIds, fullSync);
        success = true;
        resetErrorStatus(ds);
    } catch (ServiceException x) {
        error = generateErrorMessage(x);
        setErrorStatus(ds, error);
        throw x;
    } finally {
        ZimbraLog.datasource.info("Import completed for data source '%s'", ds.getName());
        synchronized (importStatus) {
            importStatus.mSuccess = success;
            importStatus.mError = error;
            importStatus.mIsRunning = false;
        }
    }
}
Also used : AccountStatus(com.zimbra.common.account.ZAttrProvisioning.AccountStatus) ServiceException(com.zimbra.common.service.ServiceException)

Example 2 with AccountStatus

use of com.zimbra.common.account.ZAttrProvisioning.AccountStatus in project zm-mailbox by Zimbra.

the class ExternalAccountManagerTask method disableOrDeleteAccount.

private static void disableOrDeleteAccount(Provisioning prov, Account account, Mailbox mbox) throws ServiceException {
    AccountStatus accountStatus = account.getAccountStatus();
    if (accountStatus == AccountStatus.active) {
        account.setExternalAccountDisabledTime(new Date());
        account.setAccountStatus(AccountStatus.closed);
    } else {
        long disabledAcctLifetime = account.getExternalAccountLifetimeAfterDisabled();
        if (accountStatus == AccountStatus.closed && disabledAcctLifetime != 0) {
            Date timeWhenDisabled = account.getExternalAccountDisabledTime();
            if (timeWhenDisabled != null && System.currentTimeMillis() - timeWhenDisabled.getTime() > disabledAcctLifetime) {
                mbox.deleteMailbox();
                prov.deleteAccount(account.getId());
            }
        }
    }
}
Also used : AccountStatus(com.zimbra.common.account.ZAttrProvisioning.AccountStatus) Date(java.util.Date)

Example 3 with AccountStatus

use of com.zimbra.common.account.ZAttrProvisioning.AccountStatus in project zm-mailbox by Zimbra.

the class GetShareInfo method doGetShareInfo.

/**
     * @param zsc
     * @param targetAcct
     * @param request
     * @param response
     */
private void doGetShareInfo(ZimbraSoapContext zsc, Map<String, Object> context, Account targetAcct, Element request, GetShareInfoResponse response) throws ServiceException {
    Provisioning prov = Provisioning.getInstance();
    GetShareInfoRequest req = JaxbUtil.elementToJaxb(request);
    GranteeChooser granteeChooser = req.getGrantee();
    byte granteeType = getGranteeType(granteeChooser);
    String granteeId = granteeChooser == null ? null : granteeChooser.getId();
    String granteeName = granteeChooser == null ? null : granteeChooser.getName();
    Account owner = null;
    AccountSelector ownerSelector = req.getOwner();
    if (ownerSelector != null) {
        owner = prov.get(ownerSelector);
        // when an invalid user name/id is used.
        if ((owner == null) || (owner.isAccountExternal())) {
            return;
        } else {
            AccountStatus status = owner.getAccountStatus();
            if (status != null && status.isClosed()) {
                return;
            }
        }
    }
    OperationContext octxt = getOperationContext(zsc, context);
    ShareInfo.MountedFolders mountedFolders = null;
    if (!Boolean.TRUE.equals(req.getInternal())) {
        // this (new ShareInfo.MountedFolders) should be executed on the requested
        // account's home server.
        // If we get here, we should be proxied to the right server naturally by the framework.
        mountedFolders = new ShareInfo.MountedFolders(octxt, targetAcct);
    }
    ResultFilter resultFilter;
    if (Boolean.FALSE.equals(req.getIncludeSelf())) {
        resultFilter = new ResultFilterByTargetExcludeSelf(granteeId, granteeName, targetAcct);
    } else {
        resultFilter = new ResultFilterByTarget(granteeId, granteeName);
    }
    String filterDomain = null;
    if (LC.PUBLIC_SHARE_VISIBILITY.samePrimaryDomain.equals(LC.getPublicShareAdvertisingScope())) {
        filterDomain = targetAcct.getDomainName();
    }
    ResultFilter resultFilter2 = new ResultFilterForPublicShares(filterDomain);
    ShareInfoVisitor visitor = new ShareInfoVisitor(prov, response, mountedFolders, resultFilter, resultFilter2);
    if (owner == null) {
        // retrieve from published share info
        ShareInfo.Published.get(prov, targetAcct, granteeType, owner, visitor);
    } else {
        if (targetAcct.getId().equals(owner.getId()))
            throw ServiceException.INVALID_REQUEST("cannot discover shares on self", null);
        if (Provisioning.onLocalServer(owner))
            ShareInfo.Discover.discover(octxt, prov, targetAcct, granteeType, owner, visitor);
        else {
            // issue an GetShareInfoRequest to the home server of the owner, and tell it *not*
            // to proxy to the requesting account's mailbox server.
            fetchRemoteShareInfo(context, request, owner.getId(), visitor);
        }
    }
    visitor.finish();
}
Also used : OperationContext(com.zimbra.cs.mailbox.OperationContext) Account(com.zimbra.cs.account.Account) GranteeChooser(com.zimbra.soap.type.GranteeChooser) AccountSelector(com.zimbra.soap.type.AccountSelector) ShareInfo(com.zimbra.cs.account.ShareInfo) Provisioning(com.zimbra.cs.account.Provisioning) AccountStatus(com.zimbra.common.account.ZAttrProvisioning.AccountStatus) GetShareInfoRequest(com.zimbra.soap.account.message.GetShareInfoRequest) PublishedShareInfoVisitor(com.zimbra.cs.account.Provisioning.PublishedShareInfoVisitor)

Aggregations

AccountStatus (com.zimbra.common.account.ZAttrProvisioning.AccountStatus)3 ServiceException (com.zimbra.common.service.ServiceException)1 Account (com.zimbra.cs.account.Account)1 Provisioning (com.zimbra.cs.account.Provisioning)1 PublishedShareInfoVisitor (com.zimbra.cs.account.Provisioning.PublishedShareInfoVisitor)1 ShareInfo (com.zimbra.cs.account.ShareInfo)1 OperationContext (com.zimbra.cs.mailbox.OperationContext)1 GetShareInfoRequest (com.zimbra.soap.account.message.GetShareInfoRequest)1 AccountSelector (com.zimbra.soap.type.AccountSelector)1 GranteeChooser (com.zimbra.soap.type.GranteeChooser)1 Date (java.util.Date)1