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

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


    }

    @Override
    public List<GroupOperationSchedule> getOperationScheduleList() {
        Subject subject = EnterpriseFacesContextUtility.getSubject();
        ResourceGroup requestGroup = EnterpriseFacesContextUtility.getResourceGroup();

        if (requestGroup == null) {
            requestGroup = group; // request not associated with a resource - use the resource we used before
        } else {
            group = requestGroup; // request switched the resource this UI bean is using
        }

        List<GroupOperationSchedule> results = null;
        try {
            results = manager.findScheduledGroupOperations(subject, requestGroup.getId());
        } catch (Exception e) {
            // throw up all known information to the caller for now
            throw new IllegalStateException(e.getMessage(), e);
        }
View Full Code Here


        if (resourceId != null) {
            Resource res = resourceManager.getResourceById(getSubject(), Integer.parseInt(resourceId));
            visit = new WebUserPreferences.ResourceVisit(Integer.parseInt(resourceId), res.getName(),
                WebUserPreferences.ResourceVisit.Kind.valueOf(res.getResourceType().getCategory().name()));
        } else if (groupId != null) {
            ResourceGroup group = groupManager.getResourceGroupById(getSubject(), Integer.parseInt(groupId), null);
            visit = new WebUserPreferences.ResourceVisit(Integer.parseInt(groupId), group.getName(),
                (group.getResourceType() != null ? WebUserPreferences.ResourceVisit.Kind.COMPATIBLE_GROUP
                    : WebUserPreferences.ResourceVisit.Kind.MIXED_GROUP));
        }

        if (visit != null) {
            prefs.addRecentResource(visit);
View Full Code Here

     * @return resource associated with the request.
     */
    @NotNull
    public static ResourceGroup getResourceGroup() {
        ExternalContext externalContext = FacesContextUtility.getFacesContext().getExternalContext();
        ResourceGroup resourceGroup = (ResourceGroup) externalContext.getRequestMap().get(
            AttrConstants.RESOURCE_GROUP_ATTR);
        if (resourceGroup == null) {
            int resourceGroupId = FacesContextUtility.getRequiredRequestParameter(ParamConstants.GROUP_ID_PARAM,
                Integer.class);

View Full Code Here

        if (schedule instanceof ResourceOperationSchedule) {
            Resource resource = ((ResourceOperationSchedule) schedule).getResource();
            type = resource.getResourceType();
        } else if (schedule instanceof GroupOperationSchedule) {
            ResourceGroup group = ((GroupOperationSchedule) schedule).getGroup();
            type = group.getResourceType();
        } else {
            throw new IllegalArgumentException("OperationParameters does not support objects of type "
                + schedule.getClass().getSimpleName());
        }
View Full Code Here

    public ResourceGroupOperationDefinitionUIBean() {
        super();

        resourceExecutionOption = ResourceGroupExecutionTypeUIBean.Type.CONCURRENT.name();

        ResourceGroup resourceGroup = EnterpriseFacesContextUtility.getResourceGroup();
        this.resourceNameItems = operationManager.getResourceNameOptionItems(resourceGroup.getId());
    }
View Full Code Here

    }

    @Override
    public PageList<OperationDefinition> getOperationDefinitions() {
        Subject subject = EnterpriseFacesContextUtility.getSubject();
        ResourceGroup resourceGroup = EnterpriseFacesContextUtility.getResourceGroup();

        // only name and definition are displayed in the "Supported Operations" section of the Operation>New sub-tab
        List<OperationDefinition> definitions = operationManager.findSupportedGroupOperations(subject, resourceGroup
            .getId(), false);

        return new PageList<OperationDefinition>(definitions, new PageControl(0, definitions.size()));
    }
View Full Code Here

    @EJB
    private SubjectManagerLocal subjectManager;

    public ResourceGroup createAutoClusterBackingGroup(Subject subject, ClusterKey clusterKey, boolean addResources) {
        ResourceGroup autoClusterBackingGroup = null;

        Query query = entityManager.createNamedQuery(ResourceGroup.QUERY_FIND_BY_CLUSTER_KEY);
        query.setParameter("clusterKey", clusterKey.toString());

        ResourceType resourceType = entityManager.find(ResourceType.class, ClusterKey.getResourceType(clusterKey));
        ResourceGroup resourceGroup = entityManager.find(ResourceGroup.class, clusterKey.getClusterGroupId());

        if (!authorizationManager.canViewGroup(subject, clusterKey.getClusterGroupId())) {
            throw new PermissionException("You do not have permission to view child cluster groups of the group ["
                + resourceGroup.getName() + "]");
        }

        // [BZ 817604] In unusual circumstances this clusterKey may be stale. Ensure the cluster group
        // is still a compat group before creating a backing group.
        if (GroupCategory.COMPATIBLE != resourceGroup.getGroupCategory()) {
            throw new IllegalStateException("The root group has changed. Please refresh your group before continuing.");
        }

        List<Resource> resources = null;
        try {
            autoClusterBackingGroup = (ResourceGroup) query.getSingleResult();
        } catch (NoResultException nre) {
            try {
                resources = getAutoClusterResources(subject, clusterKey);
                String name = null;
                if (resources.isEmpty()) {
                    name = "Group of " + resourceType.getName();
                } else {
                    for (Resource res : resources) {
                        if (name == null) {
                            name = res.getName();
                        } else {
                            if (!name.equals(res.getName())) {
                                name = "Group of " + resourceType.getName();
                            }
                        }
                    }
                }

                // Note, group names do not need to be unique for non-visible groups, like autocluster backing groups
                autoClusterBackingGroup = new ResourceGroup(name, resourceType);
                autoClusterBackingGroup.setClusterKey(clusterKey.toString());
                autoClusterBackingGroup.setClusterResourceGroup(resourceGroup);
                autoClusterBackingGroup.setVisible(false);

                // You are allowed to cause the creation of an auto cluster backing group as long as you can
View Full Code Here

        return autoClusterBackingGroup;
    }

    public ResourceGroup getAutoClusterBackingGroup(Subject subject, ClusterKey clusterKey) {
        ResourceGroup result = null;

        Query query = entityManager.createNamedQuery(ResourceGroup.QUERY_FIND_BY_CLUSTER_KEY);
        query.setParameter("clusterKey", clusterKey.toString());
        try {
            result = (ResourceGroup) query.getSingleResult();
View Full Code Here

    @Override
    @SuppressWarnings("unchecked")
    public Set<Permission> getExplicitGroupPermissions(Subject subject, int groupId) {
        Set<Permission> result = new HashSet<Permission>();

        ResourceGroup group = entityManager.find(ResourceGroup.class, groupId);
        Subject owner = group.getSubject();

        if (null == owner) {
            // role-owned group
            Query query = entityManager.createNamedQuery(Subject.QUERY_GET_PERMISSIONS_BY_GROUP_ID);
            query.setParameter("subject", subject);
View Full Code Here

    public boolean hasGroupPermission(Subject subject, Permission permission, int groupId) {
        if (isInventoryManager(subject)) {
            return true;
        }

        ResourceGroup group = entityManager.find(ResourceGroup.class, groupId);
        Subject owner = group.getSubject();

        if (null == owner) {
            // role-owned group
            Query query = entityManager.createNamedQuery(Subject.QUERY_HAS_GROUP_PERMISSION);
            query.setParameter("subject", subject);
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.