當前位置: 首頁>>代碼示例>>Java>>正文


Java PermissionDeniedException.addProxyObject方法代碼示例

本文整理匯總了Java中com.cloud.exception.PermissionDeniedException.addProxyObject方法的典型用法代碼示例。如果您正苦於以下問題:Java PermissionDeniedException.addProxyObject方法的具體用法?Java PermissionDeniedException.addProxyObject怎麽用?Java PermissionDeniedException.addProxyObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.cloud.exception.PermissionDeniedException的用法示例。


在下文中一共展示了PermissionDeniedException.addProxyObject方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getEntityOwnerId

import com.cloud.exception.PermissionDeniedException; //導入方法依賴的package包/類
@Override
public long getEntityOwnerId() {
    Volume volume = _entityMgr.findById(Volume.class, getVolumeId());
    if (volume == null) {
        throw new InvalidParameterValueException("Unable to find volume by id=" + volumeId);
    }

    Account account = _accountService.getAccount(volume.getAccountId());
    //Can create templates for enabled projects/accounts only
    if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
        Project project = _projectService.findByProjectAccountId(volume.getAccountId());
        if (project.getState() != Project.State.Active) {
            PermissionDeniedException ex =
                new PermissionDeniedException("Can't add resources to the specified project id in state=" + project.getState() + " as it's no longer active");
            ex.addProxyObject(project.getUuid(), "projectId");
            throw ex;
        }
    } else if (account.getState() == Account.State.disabled) {
        throw new PermissionDeniedException("The owner of template is disabled: " + account);
    }

    return volume.getAccountId();
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:24,代碼來源:CreateSnapshotPolicyCmd.java

示例2: checkIfDataCenterIsUsable

import com.cloud.exception.PermissionDeniedException; //導入方法依賴的package包/類
public void checkIfDataCenterIsUsable(final DataCenter dataCenter, final Account account) {
    final long dataCenterId = dataCenter.getId();
    logger.debug("Checking if data center " + dataCenterId + " is usable.");
    if (AllocationState.Disabled == dataCenter.getAllocationState() && !accountManager.isRootAdmin(account.getId())) {
        final PermissionDeniedException ex = new PermissionDeniedException("Cannot perform this operation, data center with specified id is currently disabled");
        ex.addProxyObject(dataCenter.getUuid(), "dcId");
        throw ex;
    }
    logger.debug("Data center " + dataCenterId + "is usable");
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:11,代碼來源:ResourceChecker.java

示例3: getEntityOwnerId

import com.cloud.exception.PermissionDeniedException; //導入方法依賴的package包/類
@Override
public long getEntityOwnerId() {
    final Long volumeId = getVolumeId();
    final Long snapshotId = getSnapshotId();
    final Account callingAccount = CallContext.current().getCallingAccount();
    if (volumeId != null) {
        final Volume volume = _entityMgr.findById(Volume.class, volumeId);
        if (volume != null) {
            _accountService.checkAccess(callingAccount, SecurityChecker.AccessType.UseEntry, false, volume);
        } else {
            throw new InvalidParameterValueException("Unable to find volume by id=" + volumeId);
        }
    } else {
        final Snapshot snapshot = _entityMgr.findById(Snapshot.class, snapshotId);
        if (snapshot != null) {
            _accountService.checkAccess(callingAccount, SecurityChecker.AccessType.UseEntry, false, snapshot);
        } else {
            throw new InvalidParameterValueException("Unable to find snapshot by id=" + snapshotId);
        }
    }

    if (projectId != null) {
        final Project project = _projectService.getProject(projectId);
        if (project != null) {
            if (project.getState() == Project.State.Active) {
                final Account projectAccount = _accountService.getAccount(project.getProjectAccountId());
                _accountService.checkAccess(callingAccount, SecurityChecker.AccessType.UseEntry, false, projectAccount);
                return project.getProjectAccountId();
            } else {
                final PermissionDeniedException ex =
                        new PermissionDeniedException("Can't add resources to the project with specified projectId in state=" + project.getState() +
                                " as it's no longer active");
                ex.addProxyObject(project.getUuid(), "projectId");
                throw ex;
            }
        } else {
            throw new InvalidParameterValueException("Unable to find project by id");
        }
    }

    return callingAccount.getId();
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:43,代碼來源:CreateTemplateCmd.java

示例4: finalyzeAccountId

import com.cloud.exception.PermissionDeniedException; //導入方法依賴的package包/類
@Override
public Long finalyzeAccountId(final String accountName, final Long domainId, final Long projectId, final boolean enabledOnly) {
    if (accountName != null) {
        if (domainId == null) {
            throw new InvalidParameterValueException("Account must be specified with domainId parameter");
        }

        final Domain domain = _domainMgr.getDomain(domainId);
        if (domain == null) {
            throw new InvalidParameterValueException("Unable to find domain by id");
        }

        final Account account = getActiveAccountByName(accountName, domainId);
        if (account != null && account.getType() != Account.ACCOUNT_TYPE_PROJECT) {
            if (!enabledOnly || account.getState() == Account.State.enabled) {
                return account.getId();
            } else {
                throw new PermissionDeniedException("Can't add resources to the account id=" + account.getId() + " in state=" + account.getState() +
                        " as it's no longer active");
            }
        } else {
            // idList is not used anywhere, so removed it now
            // List<IdentityProxy> idList = new ArrayList<IdentityProxy>();
            // idList.add(new IdentityProxy("domain", domainId, "domainId"));
            throw new InvalidParameterValueException("Unable to find account by name " + accountName + " in domain with specified id");
        }
    }

    if (projectId != null) {
        final Project project = _projectMgr.getProject(projectId);
        if (project != null) {
            if (!enabledOnly || project.getState() == Project.State.Active) {
                return project.getProjectAccountId();
            } else {
                final PermissionDeniedException ex =
                        new PermissionDeniedException("Can't add resources to the project with specified projectId in state=" + project.getState() +
                                " as it's no longer active");
                ex.addProxyObject(project.getUuid(), "projectId");
                throw ex;
            }
        } else {
            throw new InvalidParameterValueException("Unable to find project by id");
        }
    }
    return null;
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:47,代碼來源:AccountManagerImpl.java

示例5: getEntityOwnerId

import com.cloud.exception.PermissionDeniedException; //導入方法依賴的package包/類
@Override
public long getEntityOwnerId() {
    Long volumeId = getVolumeId();
    Long snapshotId = getSnapshotId();
    Account callingAccount = CallContext.current().getCallingAccount();
    if (volumeId != null) {
        Volume volume = _entityMgr.findById(Volume.class, volumeId);
        if (volume != null) {
            _accountService.checkAccess(callingAccount, SecurityChecker.AccessType.UseEntry, false, volume);
        } else {
            throw new InvalidParameterValueException("Unable to find volume by id=" + volumeId);
        }
    } else {
        Snapshot snapshot = _entityMgr.findById(Snapshot.class, snapshotId);
        if (snapshot != null) {
            _accountService.checkAccess(callingAccount, SecurityChecker.AccessType.UseEntry, false, snapshot);
        } else {
            throw new InvalidParameterValueException("Unable to find snapshot by id=" + snapshotId);
        }
    }

    if(projectId != null){
        final Project project = _projectService.getProject(projectId);
        if (project != null) {
            if (project.getState() == Project.State.Active) {
                Account projectAccount= _accountService.getAccount(project.getProjectAccountId());
                _accountService.checkAccess(callingAccount, SecurityChecker.AccessType.UseEntry, false, projectAccount);
                return project.getProjectAccountId();
            } else {
                final PermissionDeniedException ex =
                        new PermissionDeniedException("Can't add resources to the project with specified projectId in state=" + project.getState() +
                                " as it's no longer active");
                ex.addProxyObject(project.getUuid(), "projectId");
                throw ex;
            }
        } else {
            throw new InvalidParameterValueException("Unable to find project by id");
        }
    }

    return callingAccount.getId();
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:43,代碼來源:CreateTemplateCmd.java

示例6: finalyzeAccountId

import com.cloud.exception.PermissionDeniedException; //導入方法依賴的package包/類
@Override
public Long finalyzeAccountId(final String accountName, final Long domainId, final Long projectId, final boolean enabledOnly) {
    if (accountName != null) {
        if (domainId == null) {
            throw new InvalidParameterValueException("Account must be specified with domainId parameter");
        }

        final Domain domain = _domainMgr.getDomain(domainId);
        if (domain == null) {
            throw new InvalidParameterValueException("Unable to find domain by id");
        }

        final Account account = getActiveAccountByName(accountName, domainId);
        if (account != null && account.getType() != Account.ACCOUNT_TYPE_PROJECT) {
            if (!enabledOnly || account.getState() == Account.State.enabled) {
                return account.getId();
            } else {
                throw new PermissionDeniedException(
                        "Can't add resources to the account id=" + account.getId() + " in state=" + account.getState() + " as it's no longer active");
            }
        } else {
            // idList is not used anywhere, so removed it now
            // List<IdentityProxy> idList = new ArrayList<IdentityProxy>();
            // idList.add(new IdentityProxy("domain", domainId, "domainId"));
            throw new InvalidParameterValueException("Unable to find account by name " + accountName + " in domain with specified id");
        }
    }

    if (projectId != null) {
        final Project project = _projectMgr.getProject(projectId);
        if (project != null) {
            if (!enabledOnly || project.getState() == Project.State.Active) {
                return project.getProjectAccountId();
            } else {
                final PermissionDeniedException ex = new PermissionDeniedException(
                        "Can't add resources to the project with specified projectId in state=" + project.getState() + " as it's no longer active");
                ex.addProxyObject(project.getUuid(), "projectId");
                throw ex;
            }
        } else {
            throw new InvalidParameterValueException("Unable to find project by id");
        }
    }
    return null;
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:46,代碼來源:AccountManagerImpl.java


注:本文中的com.cloud.exception.PermissionDeniedException.addProxyObject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。