Package org.rhq.enterprise.server.resource.group

Examples of org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal


            int[] resourceIds = new int[resourceIdStrings.length];
            for (int i = 0; i < resourceIds.length; i++) {
                resourceIds[i] = Integer.parseInt(resourceIdStrings[i]);
            }

            ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();
            groupManager.removeResourcesFromGroup(subject, groupId, resourceIds);

            return returnSuccess(request, mapping, forwardParams);
        } catch (ResourceGroupUpdateException rgue) {
            log.debug("group update failed:", rgue);
            RequestUtils.setError(request, "resource.group.inventory.error.GroupUpdateError", rgue.getMessage());
View Full Code Here


        for (int i = 0, sz = pendingResourceIdStrings.size(); i < sz; i++) {
            pendingResourceIds[i] = Integer.parseInt(pendingResourceIdStrings.get(i));
        }

        ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
        ResourceGroupManagerLocal resourceGroupManager = LookupUtil.getResourceGroupManager();

        log.trace("getting pending resources for group [" + groupId + "]");
        // pass true so that the parent is each resource is connected
        PageList<Resource> pendingResources = resourceManager.findResourceByIds(user, pendingResourceIds, true,
            pcPending);

        PageList<DisambiguationReport<Resource>> disambiguatedpeningResources =
            DisambiguatedResourceListUtil.disambiguate(resourceManager, pendingResources, RESOURCE_ID_EXTRACTOR);
       
        request.setAttribute(Constants.PENDING_RESOURCES_ATTR, disambiguatedpeningResources);
        request.setAttribute(Constants.NUM_PENDING_RESOURCES_ATTR, disambiguatedpeningResources.size());

        /*
         * available resources are all resources in the system that are not associated with the user and are not pending
         */
        log.trace("getting available resources for group [" + groupId + "]");

        String nameFilter = RequestUtils.getStringParameter(request, "nameFilter", null);
        ResourceGroup resourceGroup = resourceGroupManager.getResourceGroupById(user, groupId, null);

        PageList<Resource> availableResources = null;
        if (resourceGroup.getGroupCategory() == GroupCategory.COMPATIBLE) {
            ResourceType compatibleTypeFilter = resourceGroup.getResourceType();
            availableResources = resourceManager.findAvailableResourcesForResourceGroup(user, groupId,
View Full Code Here

            RequestUtils.setError(request, "resource.group.inventory.error.GroupTypeIsRequired");
            return returnFailure(request, mapping);
        }

        ResourceTypeManagerLocal resourceTypeManager = LookupUtil.getResourceTypeManager();
        ResourceGroupManagerLocal resourceGroupManager = LookupUtil.getResourceGroupManager();

        ResourceGroup newGroup = new ResourceGroup(newGroupName);
        try {
            if (category == GroupCategory.COMPATIBLE) {
                ResourceType groupResourceType = resourceTypeManager.getResourceTypeById(subject, resourceTypeId);
                newGroup.setResourceType(groupResourceType);
            }
        } catch (ResourceTypeNotFoundException ex) {
            log.debug("group created failed: ", ex);
            RequestUtils.setError(request, "resource.group.inventory.error.ResourceTypeIdNotFound");
            return returnFailure(request, mapping);
        }

        String location = newForm.getLocation();
        String description = newForm.getDescription();
        boolean recursive = newForm.isRecursive();

        try {
            newGroup.setDescription(description);
            //newGroup.setLocation(location);
            newGroup.setRecursive(recursive);

            log.trace("creating group [" + newForm.getName() + "]" + " with attributes " + newForm);

            // ctime, mtime, and modifiedBy should all be persistence hooks
            resourceGroupManager.createResourceGroup(subject, newGroup);
        } catch (Throwable t) {
            log.debug("group creation failed: ", t);
            RequestUtils.setError(request, "resource.group.inventory.error.GroupCreateError", t.getMessage());
            return returnFailure(request, mapping);
        }

        // Check for resources
        int groupId = newGroup.getId();
        Integer[] newResourceIds = newForm.getResourceIds();
        if ((newResourceIds != null) && (newResourceIds.length > 0)) {
            // Clean up after ourselves first
            HttpSession session = request.getSession();
            session.removeAttribute(Constants.RESOURCE_IDS_ATTR);
            session.removeAttribute(Constants.RESOURCE_TYPE_ATTR);

            // Now add the new entities to group
            resourceGroupManager.addResourcesToGroup(subject, groupId, ArrayUtils.unwrapArray(newResourceIds));
        }

        RequestUtils.setConfirmation(request, "resource.group.inventory.confirm.CreateGroup", newGroupName);

        HashMap<String, Object> forwardParams = new HashMap<String, Object>(2);
View Full Code Here

                return group;
            }

            String groupId = request.getParameter(Constants.GROUP_ID_PARAM);
            Subject subject = RequestUtils.getSubject(request);
            ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();

            group = groupManager.getResourceGroup(subject, Integer.valueOf(groupId));

            request.setAttribute(Constants.RESOURCE_GROUP_ATTR, group);

            return group;
        } catch (Exception e) {
View Full Code Here

    private void deleteNewResource(Resource resource) throws Exception {
        if (null != resource) {

            try {
                ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
                ResourceGroupManagerLocal resourceGroupManager = LookupUtil.getResourceGroupManager();

                // first, get entity for group removal
                getTransactionManager().begin();
                em = getEntityManager();

                ResourceGroup group = null;
                Resource res = em.find(Resource.class, resource.getId());
                if (null != res) {
                    if (res.getExplicitGroups().iterator().hasNext()) {
                        group = res.getExplicitGroups().iterator().next();
                    }
                }
                getTransactionManager().commit();

                Subject overlord = overlord();

                // delete the group if necessary
                if (null != group) {
                    resourceGroupManager.deleteResourceGroup(overlord, group.getId());
                }

                // invoke bulk delete on the resource to remove any dependencies not defined in the hibernate entity model
                // perform in-band and out-of-band work in quick succession
                if (null != res) {
View Full Code Here

        List<MetricDisplaySummary> metricSummaries = null;

        //  GH: Why are we only getting the first one? --> single resource case
        if (myGroupId > 0) {
            ResourceGroupManagerLocal resGrpMgr = LookupUtil.getResourceGroupManager();
            int[] definitionIds = resGrpMgr.findDefinitionsForCompatibleGroup(subject, myGroupId, false);
            metricSummaries = chartsManager.getMetricDisplaySummariesForCompatibleGroup(subject,
                EntityContext.forGroup(myGroupId),
                definitionIds, begin, end, false);
        } else if ((parent > 0) && (type > 0)) {
            ResourceGroupManagerLocal resGrpMgr = LookupUtil.getResourceGroupManager();
            int[] definitionIds = resGrpMgr.findDefinitionsForAutoGroup(subject, parent, type, false);
            metricSummaries = chartsManager.getMetricDisplaySummariesForAutoGroup(subject, parent, type, definitionIds,
                begin, end, false);
        } else if ((resourceIds != null) && (resourceIds.length > 0)) {
            int resourceId = resourceIds[0];
View Full Code Here

        WebUser user = SessionUtils.getWebUser(request.getSession());

        int[] resourceIds;
        groupId = WebUtility.getOptionalIntRequestParameter(request, ParamConstants.GROUP_ID_PARAM, -1);
        if (groupId > 0) {
            ResourceGroupManagerLocal resGrpMgr = LookupUtil.getResourceGroupManager();
            List<Resource> resources = resGrpMgr.findResourcesForResourceGroup(user.getSubject(), groupId,
                GroupCategory.COMPATIBLE);

            // Can we put the ResourceType in the Request so we don't need another EJB call in MetricsControlFormPrepareAction.java
            if (resources.size() > 0) {
                ResourceType resourceType = resources.get(0).getResourceType();
View Full Code Here

                        EntityContext.forGroup(groupId), pageControl);
                    request.setAttribute(AttrConstants.GROUP_ID, groupId);
                }

                //adding the groupName into the request to display on config page.
                ResourceGroupManagerLocal resourceGroupManager = LookupUtil.getResourceGroupManager();
                String groupName = resourceGroupManager
                    .getResourceGroupById(subject, groupId, GroupCategory.COMPATIBLE).getName();
                request.setAttribute(AttrConstants.GROUP_NAME, groupName);
            }
        }
View Full Code Here

    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
        GroupHubForm hubForm = (GroupHubForm) form;

        Subject subject = RequestUtils.getSubject(request);
        ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();

        String[] resources = hubForm.getResources();
        int remaining = resources.length;

        String invalidGroupIds = "";
        String invalidIntegers = "";
        String errorGroupIds = "";

        for (String item : resources) {
            try {
                groupManager.deleteResourceGroup(subject, new Integer(item));
                remaining--;
            } catch (ResourceGroupNotFoundException e) {
                invalidGroupIds = add(invalidGroupIds, item);
            } catch (NumberFormatException nfe) {
                invalidIntegers = add(invalidIntegers, item);
View Full Code Here

                }

                return forward;
            }

            ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();

            Subject user = RequestUtils.getSubject(request);

            log.trace("getting pending resource list");
            List<String> pendingResourceIdStrings = SessionUtils.getListAsListStr(request.getSession(),
                Constants.PENDING_RESOURCES_SES_ATTR);

            // Bug#7258; don't do anything if the user does not add any
            // members to the group.
            if (pendingResourceIdStrings.size() == 0) {
                return returnSuccess(request, mapping, forwardParams);
            }

            int[] pendingResourceIds = new int[pendingResourceIdStrings.size()];
            for (int i = 0; i < pendingResourceIds.length; i++) {
                pendingResourceIds[i] = Integer.parseInt(pendingResourceIdStrings.get(i));
            }

            groupManager.addResourcesToGroup(user, groupId, pendingResourceIds);

            // but how does this get removed when the user
            // navigates away instead of concluding this workflow
            log.trace("removing pending user list");
            SessionUtils.removeList(session, Constants.PENDING_RESOURCES_SES_ATTR);
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal

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.