当前位置: 首页>>代码示例>>Java>>正文


Java User.getRemoved方法代码示例

本文整理汇总了Java中com.cloud.user.User.getRemoved方法的典型用法代码示例。如果您正苦于以下问题:Java User.getRemoved方法的具体用法?Java User.getRemoved怎么用?Java User.getRemoved使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.cloud.user.User的用法示例。


在下文中一共展示了User.getRemoved方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkAccess

import com.cloud.user.User; //导入方法依赖的package包/类
@Override
public boolean checkAccess(final User user, final Domain domain) throws PermissionDeniedException {
    if (user.getRemoved() != null) {
        throw new PermissionDeniedException(user + " is no longer active.");
    }
    final Account account = _accountDao.findById(user.getAccountId());
    return checkAccess(account, domain);
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:9,代码来源:DomainChecker.java

示例2: verifyUser

import com.cloud.user.User; //导入方法依赖的package包/类
public boolean verifyUser(final Long userId) {
    // copy from ApiServer.java, a bit ugly here
    final User user = _accountMgr.getUserIncludingRemoved(userId);
    Account account = null;
    if (user != null) {
        account = _accountMgr.getAccount(user.getAccountId());
    }

    if ((user == null) || (user.getRemoved() != null) || !user.getState().equals(Account.State.enabled) || (account == null) ||
            !account.getState().equals(Account.State.enabled)) {
        s_logger.warn("Deleted/Disabled/Locked user with id=" + userId + " attempting to access public API");
        return false;
    }
    return true;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:16,代码来源:ConsoleProxyServlet.java

示例3: verifyUser

import com.cloud.user.User; //导入方法依赖的package包/类
@Override
public boolean verifyUser(final Long userId) {
    final User user = _accountMgr.getUserIncludingRemoved(userId);
    Account account = null;
    if (user != null) {
        account = _accountMgr.getAccount(user.getAccountId());
    }

    if ((user == null) || (user.getRemoved() != null) || !user.getState().equals(Account.State.enabled) || (account == null) ||
            !account.getState().equals(Account.State.enabled)) {
        s_logger.warn("Deleted/Disabled/Locked user with id=" + userId + " attempting to access public API");
        return false;
    }
    return true;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:16,代码来源:ApiServer.java

示例4: getCloudIdentifierResponse

import com.cloud.user.User; //导入方法依赖的package包/类
@Override
public ArrayList<String> getCloudIdentifierResponse(final long userId) {
    final Account caller = getCaller();

    // verify that user exists
    User user = _accountMgr.getUserIncludingRemoved(userId);
    if (user == null || user.getRemoved() != null) {
        final InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find active user of specified id");
        ex.addProxyObject(String.valueOf(userId), "userId");
        throw ex;
    }

    // check permissions
    _accountMgr.checkAccess(caller, null, true, _accountMgr.getAccount(user.getAccountId()));

    String cloudIdentifier = _configDao.getValue("cloud.identifier");
    if (cloudIdentifier == null) {
        cloudIdentifier = "";
    }

    String signature = "";
    try {
        // get the user obj to get his secret key
        user = _accountMgr.getActiveUser(userId);
        final String secretKey = user.getSecretKey();
        final String input = cloudIdentifier;
        signature = signRequest(input, secretKey);
    } catch (final Exception e) {
        s_logger.warn("Exception whilst creating a signature:" + e);
    }

    final ArrayList<String> cloudParams = new ArrayList<>();
    cloudParams.add(cloudIdentifier);
    cloudParams.add(signature);

    return cloudParams;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:38,代码来源:ManagementServerImpl.java

示例5: deleteDiskOffering

import com.cloud.user.User; //导入方法依赖的package包/类
@Override
@ActionEvent(eventType = EventTypes.EVENT_DISK_OFFERING_DELETE, eventDescription = "deleting disk offering")
public boolean deleteDiskOffering(final DeleteDiskOfferingCmd cmd) {
    final Long diskOfferingId = cmd.getId();

    final DiskOfferingVO offering = _diskOfferingDao.findById(diskOfferingId);

    if (offering == null) {
        throw new InvalidParameterValueException("Unable to find disk offering by id " + diskOfferingId);
    }

    Long userId = CallContext.current().getCallingUserId();
    if (userId == null) {
        userId = Long.valueOf(User.UID_SYSTEM);
    }
    final User user = _userDao.findById(userId);
    if (user == null || user.getRemoved() != null) {
        throw new InvalidParameterValueException("Unable to find active user by id " + userId);
    }
    final Account account = _accountDao.findById(user.getAccountId());
    if (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
        if (offering.getDomainId() == null) {
            throw new InvalidParameterValueException("Unable to delete public disk offering by id " + userId + " because it is domain-admin");
        }
        if (!_domainDao.isChildDomain(account.getDomainId(), offering.getDomainId())) {
            throw new InvalidParameterValueException("Unable to delete disk offering by another domain admin with id " + userId);
        }
    } else if (account.getType() != Account.ACCOUNT_TYPE_ADMIN) {
        throw new InvalidParameterValueException("Unable to delete disk offering by id " + userId + " because it is not root-admin or domain-admin");
    }

    offering.setState(DiskOffering.State.Inactive);
    if (_diskOfferingDao.update(offering.getId(), offering)) {
        CallContext.current().setEventDetails("Disk offering id=" + diskOfferingId);
        return true;
    } else {
        return false;
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:40,代码来源:ConfigurationManagerImpl.java

示例6: updateServiceOffering

import com.cloud.user.User; //导入方法依赖的package包/类
@Override
@ActionEvent(eventType = EventTypes.EVENT_SERVICE_OFFERING_EDIT, eventDescription = "updating service offering")
public ServiceOffering updateServiceOffering(final UpdateServiceOfferingCmd cmd) {
    final String displayText = cmd.getDisplayText();
    final Long id = cmd.getId();
    final String name = cmd.getServiceOfferingName();
    final Integer sortKey = cmd.getSortKey();
    Long userId = CallContext.current().getCallingUserId();

    if (userId == null) {
        userId = Long.valueOf(User.UID_SYSTEM);
    }

    // Verify input parameters
    final ServiceOffering offeringHandle = _entityMgr.findById(ServiceOffering.class, id);

    if (offeringHandle == null) {
        throw new InvalidParameterValueException("unable to find service offering " + id);
    }

    final User user = _userDao.findById(userId);
    if (user == null || user.getRemoved() != null) {
        throw new InvalidParameterValueException("Unable to find active user by id " + userId);
    }
    final Account account = _accountDao.findById(user.getAccountId());
    if (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
        if (offeringHandle.getDomainId() == null) {
            throw new InvalidParameterValueException("Unable to update public service offering by id " + userId + " because it is domain-admin");
        }
        if (!_domainDao.isChildDomain(account.getDomainId(), offeringHandle.getDomainId())) {
            throw new InvalidParameterValueException("Unable to update service offering by another domain admin with id " + userId);
        }
    } else if (account.getType() != Account.ACCOUNT_TYPE_ADMIN) {
        throw new InvalidParameterValueException("Unable to update service offering by id " + userId + " because it is not root-admin or domain-admin");
    }

    final boolean updateNeeded = name != null || displayText != null || sortKey != null;
    if (!updateNeeded) {
        return _serviceOfferingDao.findById(id);
    }

    ServiceOfferingVO offering = _serviceOfferingDao.createForUpdate(id);

    if (name != null) {
        offering.setName(name);
    }

    if (displayText != null) {
        offering.setDisplayText(displayText);
    }

    if (sortKey != null) {
        offering.setSortKey(sortKey);
    }

    if (_serviceOfferingDao.update(id, offering)) {
        offering = _serviceOfferingDao.findById(id);
        CallContext.current().setEventDetails("Service offering id=" + offering.getId());
        return offering;
    } else {
        return null;
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:64,代码来源:ConfigurationManagerImpl.java

示例7: deleteServiceOffering

import com.cloud.user.User; //导入方法依赖的package包/类
@Override
@ActionEvent(eventType = EventTypes.EVENT_SERVICE_OFFERING_DELETE, eventDescription = "deleting service offering")
public boolean deleteServiceOffering(final DeleteServiceOfferingCmd cmd) {

    final Long offeringId = cmd.getId();
    Long userId = CallContext.current().getCallingUserId();

    if (userId == null) {
        userId = Long.valueOf(User.UID_SYSTEM);
    }

    // Verify service offering id
    final ServiceOfferingVO offering = _serviceOfferingDao.findById(offeringId);
    if (offering == null) {
        throw new InvalidParameterValueException("unable to find service offering " + offeringId);
    }

    if (offering.getDefaultUse()) {
        throw new InvalidParameterValueException("Default service offerings cannot be deleted");
    }

    final User user = _userDao.findById(userId);
    if (user == null || user.getRemoved() != null) {
        throw new InvalidParameterValueException("Unable to find active user by id " + userId);
    }
    final Account account = _accountDao.findById(user.getAccountId());
    if (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
        if (offering.getDomainId() == null) {
            throw new InvalidParameterValueException("Unable to delete public service offering by id " + userId + " because it is domain-admin");
        }
        if (!_domainDao.isChildDomain(account.getDomainId(), offering.getDomainId())) {
            throw new InvalidParameterValueException("Unable to delete service offering by another domain admin with id " + userId);
        }
    } else if (account.getType() != Account.ACCOUNT_TYPE_ADMIN) {
        throw new InvalidParameterValueException("Unable to delete service offering by id " + userId + " because it is not root-admin or domain-admin");
    }

    offering.setState(DiskOffering.State.Inactive);
    if (_serviceOfferingDao.update(offeringId, offering)) {
        CallContext.current().setEventDetails("Service offering id=" + offeringId);
        return true;
    } else {
        return false;
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:46,代码来源:ConfigurationManagerImpl.java

示例8: updateDiskOffering

import com.cloud.user.User; //导入方法依赖的package包/类
@Override
@ActionEvent(eventType = EventTypes.EVENT_DISK_OFFERING_EDIT, eventDescription = "updating disk offering")
public DiskOffering updateDiskOffering(final UpdateDiskOfferingCmd cmd) {
    final Long diskOfferingId = cmd.getId();
    final String name = cmd.getDiskOfferingName();
    final String displayText = cmd.getDisplayText();
    final Integer sortKey = cmd.getSortKey();
    final Boolean displayDiskOffering = cmd.getDisplayOffering();

    // Check if diskOffering exists
    final DiskOffering diskOfferingHandle = _entityMgr.findById(DiskOffering.class, diskOfferingId);

    if (diskOfferingHandle == null) {
        throw new InvalidParameterValueException("Unable to find disk offering by id " + diskOfferingId);
    }

    Long userId = CallContext.current().getCallingUserId();
    if (userId == null) {
        userId = Long.valueOf(User.UID_SYSTEM);
    }
    final User user = _userDao.findById(userId);
    if (user == null || user.getRemoved() != null) {
        throw new InvalidParameterValueException("Unable to find active user by id " + userId);
    }
    final Account account = _accountDao.findById(user.getAccountId());
    if (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
        if (diskOfferingHandle.getDomainId() == null) {
            throw new InvalidParameterValueException("Unable to update public disk offering by id " + userId + " because it is domain-admin");
        }
        if (!_domainDao.isChildDomain(account.getDomainId(), diskOfferingHandle.getDomainId())) {
            throw new InvalidParameterValueException("Unable to update disk offering by another domain admin with id " + userId);
        }
    } else if (account.getType() != Account.ACCOUNT_TYPE_ADMIN) {
        throw new InvalidParameterValueException("Unable to update disk offering by id " + userId + " because it is not root-admin or domain-admin");
    }

    final boolean updateNeeded = name != null || displayText != null || sortKey != null || displayDiskOffering != null;
    if (!updateNeeded) {
        return _diskOfferingDao.findById(diskOfferingId);
    }

    final DiskOfferingVO diskOffering = _diskOfferingDao.createForUpdate(diskOfferingId);

    if (name != null) {
        diskOffering.setName(name);
    }

    if (displayText != null) {
        diskOffering.setDisplayText(displayText);
    }

    if (sortKey != null) {
        diskOffering.setSortKey(sortKey);
    }

    if (displayDiskOffering != null) {
        diskOffering.setDisplayOffering(displayDiskOffering);
    }

    if (_diskOfferingDao.update(diskOfferingId, diskOffering)) {
        CallContext.current().setEventDetails("Disk offering id=" + diskOffering.getId());
        return _diskOfferingDao.findById(diskOfferingId);
    } else {
        return null;
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:67,代码来源:ConfigurationManagerImpl.java


注:本文中的com.cloud.user.User.getRemoved方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。