Package org.apache.cloudstack.iam.api

Examples of org.apache.cloudstack.iam.api.IAMGroup


    @DB
    @Override
    public boolean deleteIAMGroup(final Long iamGroupId) {
        // get the Acl Group entity
        final IAMGroup grp = _aclGroupDao.findById(iamGroupId);
        if (grp == null) {
            throw new InvalidParameterValueException("Unable to find acl group: " + iamGroupId
                    + "; failed to delete acl group.");
        }

        Transaction.execute(new TransactionCallbackNoReturn() {
            @Override
            public void doInTransactionWithoutResult(TransactionStatus status) {
                // remove this group related entry in acl_group_policy_map
                List<IAMGroupPolicyMapVO> groupPolicyMap = _aclGroupPolicyMapDao.listByGroupId(grp.getId());
                if (groupPolicyMap != null) {
                    for (IAMGroupPolicyMapVO gr : groupPolicyMap) {
                        _aclGroupPolicyMapDao.remove(gr.getId());
                    }
                }

                // remove this group related entry in acl_group_account table
                List<IAMGroupAccountMapVO> groupAcctMap = _aclGroupAccountMapDao.listByGroupId(grp.getId());
                if (groupAcctMap != null) {
                    for (IAMGroupAccountMapVO grpAcct : groupAcctMap) {
                        _aclGroupAccountMapDao.remove(grpAcct.getId());
                    }
                }
View Full Code Here


    @DB
    @Override
    public IAMGroup addAccountsToGroup(final List<Long> acctIds, final Long groupId) {
        // get the Acl Group entity
        IAMGroup group = _aclGroupDao.findById(groupId);
        if (group == null) {
            throw new InvalidParameterValueException("Unable to find acl group: " + groupId
                    + "; failed to add accounts to acl group.");
        }
View Full Code Here

    @DB
    @Override
    public IAMGroup removeAccountsFromGroup(final List<Long> acctIds, final Long groupId) {
        // get the Acl Group entity
        IAMGroup group = _aclGroupDao.findById(groupId);
        if (group == null) {
            throw new InvalidParameterValueException("Unable to find acl group: " + groupId
                    + "; failed to remove accounts from acl group.");
        }
View Full Code Here

    }

    @Override
    public Pair<List<IAMGroup>, Integer> listIAMGroups(Long iamGroupId, String iamGroupName, String path, Long startIndex, Long pageSize) {
        if (iamGroupId != null) {
            IAMGroup group = _aclGroupDao.findById(iamGroupId);
            if (group == null) {
                throw new InvalidParameterValueException("Unable to find acl group by id " + iamGroupId);
            }
        }
View Full Code Here

        return new Pair<List<IAMGroup>, Integer>(new ArrayList<IAMGroup>(groups.first()), groups.second());
    }

    @Override
    public List<IAMGroup> listParentIAMGroups(long groupId) {
        IAMGroup group = _aclGroupDao.findById(groupId);
        if (group == null) {
            throw new InvalidParameterValueException("Unable to find acl group by id " + groupId);
        }

        String path = group.getPath();
        List<String> pathList = new ArrayList<String>();

        String[] parts = path.split("/");

        for (String part : parts) {
View Full Code Here

    @DB
    @Override
    public IAMGroup attachIAMPoliciesToGroup(final List<Long> policyIds, final Long groupId) {
        // get the Acl Group entity
        IAMGroup group = _aclGroupDao.findById(groupId);
        if (group == null) {
            throw new InvalidParameterValueException("Unable to find acl group: " + groupId
                    + "; failed to add roles to acl group.");
        }
View Full Code Here

    @DB
    @Override
    public IAMGroup removeIAMPoliciesFromGroup(final List<Long> policyIds, final Long groupId) {
        // get the Acl Group entity
        IAMGroup group = _aclGroupDao.findById(groupId);
        if (group == null) {
            throw new InvalidParameterValueException("Unable to find acl group: " + groupId
                    + "; failed to remove roles from acl group.");
        }
View Full Code Here

        doNothing().when(_accountMgr).checkAccess(caller, callerDomain);
    }

    @Test
    public void createIAMGroupTest() {
        IAMGroup group = new IAMGroupVO("group1", "tester group1");
        List<IAMGroup> groups = new ArrayList<IAMGroup>();
        groups.add(group);
        Pair<List<IAMGroup>, Integer> grpList = new Pair<List<IAMGroup>, Integer>(groups, 1);
        when(_iamSrv.createIAMGroup("group1", "tester group1", callerDomainPath)).thenReturn(group);
        when(_iamSrv.listIAMGroups(null, null, callerDomainPath, 0L, 20L)).thenReturn(grpList);

        IAMGroup createdGrp = _aclSrv.createIAMGroup(caller, "group1", "tester group1");
        assertNotNull("IAM group 'group1' failed to create ", createdGrp);
        ListResponse<IAMGroupResponse> grpResp = _aclSrv.listIAMGroups(null, null, callerDomainId, 0L, 20L);
        assertTrue("No. of response items should be one", grpResp.getCount() == 1);
        IAMGroupResponse resp = grpResp.getResponses().get(0);
        assertEquals("Error in created group name", "group1", resp.getName());
View Full Code Here

        assertTrue("failed to delete acl group 1", _aclSrv.deleteIAMGroup(1L));
    }

    @Test
    public void listIAMGroupTest() {
        IAMGroup group = new IAMGroupVO("group1", "tester group1");
        List<IAMGroup> groups = new ArrayList<IAMGroup>();
        groups.add(group);
        when(_iamSrv.listIAMGroups(callerId)).thenReturn(groups);
        List<IAMGroup> grps = _aclSrv.listIAMGroups(callerId);
        assertTrue(grps != null && grps.size() == 1);
        IAMGroup grp = grps.get(0);
        assertEquals("Error to retrieve group", "group1", grp.getName());
    }
View Full Code Here

        assertEquals("Error to retrieve group", "group1", grp.getName());
    }

    @Test
    public void addRemoveAccountToGroupTest() {
        IAMGroup group = new IAMGroupVO("group1", "tester group1");
        List<IAMGroup> groups = new ArrayList<IAMGroup>();
        groups.add(group);
        Long groupId = group.getId();
        List<Long> acctIds = new ArrayList<Long>();
        AccountVO acct1 = new AccountVO(100L);
        acct1.setAccountName("account1");
        AccountVO acct2 = new AccountVO(200L);
        acct2.setAccountName("account2");
View Full Code Here

TOP

Related Classes of org.apache.cloudstack.iam.api.IAMGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.