Package org.rhq.core.domain.resource.group

Examples of org.rhq.core.domain.resource.group.ResourceGroup


    public void setResourceTypeInNewTx(int resourceGroupId) throws ResourceGroupDeleteException {
        Query query = entityManager.createNamedQuery(ResourceType.QUERY_GET_EXPLICIT_RESOURCE_TYPE_COUNTS_BY_GROUP);
        query.setParameter("groupId", resourceGroupId);

        Subject overlord = subjectManager.getOverlord();
        ResourceGroup resourceGroup = getResourceGroupById(overlord, resourceGroupId, null);

        @SuppressWarnings("unchecked")
        List<Object> results = query.getResultList();
        if (results.size() == 1) {
            Object[] info = (Object[]) results.get(0);
            int resourceTypeId = (Integer) info[0];

            ResourceType flyWeightType = new ResourceType();
            flyWeightType.setId(resourceTypeId);
            resourceGroup.setResourceType(flyWeightType);
        } else {
            if (resourceGroup.getResourceType() != null) {
                // converting compatible group to mixed group, remove all corresponding compatible constructs
                removeCompatibleGroupConstructs(overlord, resourceGroup);
            }
            resourceGroup.setResourceType(null);
        }
    }
View Full Code Here


            long explicitDisabled = (Long) row[3];
            long implicitCount = (Long) row[4];
            long implicitDown = (Long) row[5];
            long implicitUnknown = (Long) row[6];
            long implicitDisabled = (Long) row[7];
            ResourceGroup group = groupMap.get(groupIds.get(i++));
            ResourceType type = group.getResourceType();
            ResourceFacets facets;
            if (type == null) {
                // mixed group
                facets = ResourceFacets.NONE;
            } else {
                // compatible group
                facets = resourceTypeManager.getResourceFacets(type.getId());
            }
            ResourceGroupComposite composite = new ResourceGroupComposite(explicitCount, explicitDown, explicitUnknown,
                explicitDisabled, implicitCount, implicitDown, implicitUnknown, implicitDisabled, group, facets);
            Set<Permission> perms = authorizationManager.getImplicitGroupPermissions(subject, group.getId());
            composite.setResourcePermission(new ResourcePermission(perms));
            results.add(composite);
        }

        return new PageList<ResourceGroupComposite>(results, (int) count, pc);
View Full Code Here

    }

    public void setAssignedResources(Subject subject, int groupId, int[] resourceIds, boolean setType)
        throws ResourceGroupDeleteException {

        ResourceGroup group = entityManager.find(ResourceGroup.class, groupId);
        if (group.isPrivateGroup()) {
            List<Integer> ids = new ArrayList<Integer>(resourceIds.length);
            for (int id : resourceIds) {
                ids.add(id);
            }
            if (!authorizationManager.canViewResources(subject, ids)) {
View Full Code Here

            throw new ResourceGroupNotFoundException(groupId);
        }

        Object[] data = results.get(0);

        ResourceGroup group = (ResourceGroup) data[8];
        ResourceType type = group.getResourceType();
        ResourceFacets facets;
        if (type == null) {
            // mixed group
            facets = ResourceFacets.NONE;
        } else {
            // compatible group
            facets = resourceTypeManager.getResourceFacets(group.getResourceType().getId());
        }

        ResourceGroupComposite composite = null;
        if (((Number) data[4]).longValue() > 0) {
            long explicitCount = ((Number) data[0]).longValue();
View Full Code Here

    @RequiredPermission(Permission.MANAGE_INVENTORY)
    public void setRecursive( //
        Subject subject, //
        int groupId, //
        boolean isRecursive) {
        ResourceGroup group = entityManager.find(ResourceGroup.class, groupId);
        if (group == null) {
            throw new ResourceGroupNotFoundException(groupId);
        }
        updateResourceGroup(subject, group, isRecursive ? RecursivityChangeType.AddedRecursion
            : RecursivityChangeType.RemovedRecursion);
View Full Code Here

        PageList<ResourceGroupComposite> results = queryRunner.execute();

        results = getAuthorizedGroupComposites(subject, authzType, results);

        for (ResourceGroupComposite composite : results) {
            ResourceGroup group = composite.getResourceGroup();
            ResourceType type = group.getResourceType();
            ResourceFacets facets = (type != null) ? resourceTypeManager.getResourceFacets(type.getId())
                : ResourceFacets.NONE;

            queryRunner.initFetchFields(group); // manual field fetch for composite-wrapped entity
            composite.setResourceFacets(facets);
View Full Code Here

            break;
        case SUBJECT_OWNED:
            Iterator<ResourceGroupComposite> iterator = groupComposites.iterator();
            while (iterator.hasNext()) {
                ResourceGroupComposite groupComposite = iterator.next();
                ResourceGroup group = groupComposite.getResourceGroup();
                Subject groupOwner = group.getSubject();
                if (null != groupOwner) {
                    // private group, we need to set the group resource permissions since we couldn't do it in
                    // the projection.
                    groupComposite.setResourcePermission(new ResourcePermission(authorizationManager
                        .getExplicitGroupPermissions(groupOwner, group.getId())));
                } else {
                    throw new IllegalStateException("Unexpected group, not subject owned: " + groupComposite);
                }
            }
            break;
View Full Code Here

    public void updateResourceGroupName(Subject subject, int groupId, String name) {
        if (name == null) {
            throw new IllegalArgumentException("Group name cannot be null.");
        }
        ResourceGroup group = getResourceGroupToBeModified(subject, groupId);
        group.setName(name);
        group.setMtime(System.currentTimeMillis());
    }
View Full Code Here

        group.setName(name);
        group.setMtime(System.currentTimeMillis());
    }

    public void updateResourceGroupDescription(Subject subject, int groupId, String description) {
        ResourceGroup group = getResourceGroupToBeModified(subject, groupId);
        group.setDescription(description);
        group.setMtime(System.currentTimeMillis());
    }
View Full Code Here

        group.setDescription(description);
        group.setMtime(System.currentTimeMillis());
    }

    public void updateResourceGroupLocation(Subject subject, int groupId, String location) {
        ResourceGroup group = getResourceGroupToBeModified(subject, groupId);
        group.setDescription(location);
        group.setMtime(System.currentTimeMillis());
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.resource.group.ResourceGroup

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.