Package org.rhq.enterprise.server.resource

Examples of org.rhq.enterprise.server.resource.ResourceManagerLocal


            counter++;
        }
    }

    private boolean removeDeletedResources(List<Integer> resourceIds) {
        ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
        int[] ids = ArrayUtils.unwrapCollection(resourceIds);
        List<ResourceIdFlyWeight> flyWeights = resourceManager.findFlyWeights(ids);
        boolean removed = false;
        for (int i = resourceIds.size() - 1; i >= 0; i--) {
            Integer resourceIdToVerify = resourceIds.get(i);
            boolean match = false;
            for (int j = 0; j < flyWeights.size(); j++) {
View Full Code Here


        MetricRangePreferences rangePreferences = preferences.getMetricRangePreferences();
        long begin = rangePreferences.begin;
        long end = rangePreferences.end;

        ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();
        ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
        MeasurementDataManagerLocal metricsMgr = LookupUtil.getMeasurementDataManager();

        ResourceGroup group = groupManager.getResourceGroupById(subject, groupId, null);
        PageList<ResourceWithAvailability> resources = resourceManager
            .findImplicitResourceWithAvailabilityByResourceGroup(subject, group, new PageControl());

        Map<Integer, List<MetricDisplaySummary>> meDis = metricsMgr.findNarrowedMetricsDisplaySummariesForCompGroup(
            subject, group, begin, end);
View Full Code Here

        AlertsPortletPreferences alertPrefs = preferences.getAlertsPortletPreferences();
        pForm.setAlertsPortletPreferences(alertPrefs);

        PageControl pageControl = WebUtility.getPageControl(request);

        ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
        PageList<Resource> resources = resourceManager.findResourceByIds(user.getSubject(), alertPrefs.asArray(), false,
            pageControl);

        PageList<DisambiguationReport<Resource>> disambiguatedResources =
            DisambiguatedResourceListUtil.disambiguate(resourceManager, resources, RESOURCE_ID_EXTRACTOR);
       
View Full Code Here

            // get the user's preferences for the alerts portlet
            AlertsPortletPreferences alertPrefs = preferences.getAlertsPortletPreferences();

            PageControl pageControl = new PageControl(0, alertPrefs.count);
            AlertManagerLocal alertManager = LookupUtil.getAlertManager();
            ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();

            AlertCriteria criteria = new AlertCriteria();
            criteria.addFilterPriorities(AlertPriority.getByLegacyIndex(alertPrefs.priority));
            criteria.addFilterStartTime(alertPrefs.timeRange);
            criteria.addFilterResourceIds(("all".equals(alertPrefs.displayAll) ? null : ArrayUtils
View Full Code Here

        HttpServletRequest request, HttpServletResponse response) throws Exception {

        List<DisambiguatedRecentlyAddedResourceComposite> platformList = new ArrayList<DisambiguatedRecentlyAddedResourceComposite>();

        try {
            ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
            WebUser user = SessionUtils.getWebUser(request.getSession());
            if (user == null) {
                // session timed out, return prematurely
                return null;
            }

            WebUserPreferences preferences = user.getWebPreferences();
            RecentlyApprovedPortletPreferences recentlyApprovedPreferences = preferences
                .getRecentlyApprovedPortletPreferences();
            Subject subject = user.getSubject();

            // Based on the user preference, generate a timestamp of the oldest resource to display.
            long range = recentlyApprovedPreferences.hours;
            long ts = 0; // defaults to ANY time in the past
            if (range != -1) {
                // range encoded as hours (UI shows days)
                ts = System.currentTimeMillis() - (range * 60 * 60 * 1000);
            }

            platformList = DisambiguatedRecentlyAddedResourceComposite.fromResolution(resourceManager.disambiguate(
                resourceManager.findRecentlyAddedPlatforms(subject, ts, recentlyApprovedPreferences.range),
                RESOURCE_ID_EXTRACTOR, DefaultDisambiguationUpdateStrategies.getDefault()));

            Map<Integer, DisambiguatedRecentlyAddedResourceComposite> platformMap;
            platformMap = new HashMap<Integer, DisambiguatedRecentlyAddedResourceComposite>();

            for (DisambiguatedRecentlyAddedResourceComposite platform : platformList) {
                platformMap.put(platform.getOriginal().getId(), platform);
            }

            // Set the show servers flag on all expanded platforms.
            // Find the list of expanded platforms for this user and make it available to the jsp.
            List<String> removeExpandedPlatforms = new ArrayList<String>();

            for (String expandedPlatform : recentlyApprovedPreferences.expandedPlatforms) {
                Integer platformId = null;
                try {
                    platformId = Integer.valueOf(expandedPlatform);
                } catch (NumberFormatException nfe) {
                    removeExpandedPlatforms.add(expandedPlatform);
                    continue;
                }
                DisambiguatedRecentlyAddedResourceComposite miniPlatform = platformMap.get(platformId);
                if (miniPlatform != null) {
                    miniPlatform.getOriginal().setShowChildren(true);
                    miniPlatform.setChildren(DisambiguatedRecentlyAddedResourceComposite.fromResolution(
                        resourceManager.disambiguate(resourceManager
                        .findRecentlyAddedServers(subject, ts, platformId.intValue()), RESOURCE_ID_EXTRACTOR,
                        DefaultDisambiguationUpdateStrategies.getDefault())));
                } else {
                    removeExpandedPlatforms.add(expandedPlatform);
                }
View Full Code Here

        Log log = LogFactory.getLog(AddResourcesPrepareAction.class);
        AddResourcesForm addForm = (AddResourcesForm) form;
        HttpSession session = request.getSession();
        WebUser user = RequestUtils.getWebUser(request);
        Subject subject = user.getSubject();
        ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();

        PageControl pcAvail = WebUtility.getPageControl(request, "a");
        PageControl pcPending = WebUtility.getPageControl(request, "p");
        log.trace("available page control: " + pcAvail);
        log.trace("pending page control: " + pcPending);

        // first, get the pending resources (those that have been added to the RHS
        // pending resources are those on the right side of the "add to list" widget that are awaiting association with the group when the form's "ok" button is clicked. */
        log.debug("check session if there are pending resources");
        List<String> pendingResourceList = new ArrayList<String>();

        if (session.getAttribute(Constants.PENDING_RESOURCES_SES_ATTR) == null) {
            // if hitting the page for the first time, load resources already associated with user via preferences
            log.debug("get pending resources from user preferences");
            WebUserPreferences preferences = user.getWebPreferences();
            pendingResourceList = preferences.getPreferenceAsList(addForm.getKey(), DashboardUtils.DASHBOARD_DELIMITER);

            if (pendingResourceList != null) {
                // otherwise, we've been here for a while but the user paged, performed changed LHS<->RHS, etc
                log.debug("put entire list of pending resources in session");
                session.setAttribute(Constants.PENDING_RESOURCES_SES_ATTR, pendingResourceList);
            }
        } else {
            pendingResourceList = SessionUtils.getListAsList(session, Constants.PENDING_RESOURCES_SES_ATTR);
        }

        // get the resources, so we can display name & description in the UI
        log.debug("get page of pending resources selected by user");
        int[] pendingResourceArray = StringUtility.getIntArray(pendingResourceList);
        PageList<Resource> pendingResources = resourceManager.findResourceByIds(subject, pendingResourceArray, false,
            pcPending);

        PageList<DisambiguationReport<Resource>> disambiguatedPendingResources =
            DisambiguatedResourceListUtil.disambiguate(resourceManager, pendingResources, RESOURCE_ID_EXTRACTOR);
       
        // give 'em to the jsp page
        log.debug("put selected page of pending resources in request");
        request.setAttribute(Constants.PENDING_RESOURCES_ATTR, disambiguatedPendingResources);
        request.setAttribute(Constants.NUM_PENDING_RESOURCES_ATTR, disambiguatedPendingResources.getTotalSize());

        // available resources are all resources in the system that are not associated with the user and are not pending
        log.debug("determine if user wants to filter available resources");
        Integer typeIdFilter = ((addForm.getType() == null) || (addForm.getType() == DEFAULT_RESOURCE_TYPE)) ? null
            : addForm.getType();
        ResourceCategory categoryFilter = (addForm.getCategory() != null) ? ResourceCategory.valueOf(addForm
            .getCategory().toUpperCase()) : ResourceCategory.PLATFORM;

        int[] excludeIds = StringUtility.getIntArray(pendingResourceList);
        PageList<Resource> availableResources = null;

        availableResources = resourceManager.findAvailableResourcesForDashboardPortlet(subject, typeIdFilter,
            categoryFilter, excludeIds, pcAvail);

        PageList<DisambiguationReport<Resource>> disambiguatedAvailableResources =
            DisambiguatedResourceListUtil.disambiguate(resourceManager, availableResources, RESOURCE_ID_EXTRACTOR);
               
View Full Code Here

        int[] pendingResourceIds = new int[pendingResourceIdStrings.size()];
        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,
                compatibleTypeFilter, null, nameFilter, pendingResourceIds, pcAvail);
        } else if (resourceGroup.getGroupCategory() == GroupCategory.MIXED) {
            ResourceCategory resourceCategory = getResourceCategory(addForm.getFilterBy());
            availableResources = resourceManager.findAvailableResourcesForResourceGroup(user, groupId, null,
                resourceCategory, nameFilter, pendingResourceIds, pcAvail);
            addForm.setAvailResourceTypes(buildResourceTypes());
        } else {
            throw new IllegalArgumentException("AddGroupResourcesFormPrepareAction " + "does not support '"
                + resourceGroup.getClass().getSimpleName() + " group type");
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) {
                    List<Integer> deletedIds = resourceManager.uninventoryResource(overlord, res.getId());
                    for (Integer deletedResourceId : deletedIds) {
                        resourceManager.uninventoryResourceAsyncWork(overlord, deletedResourceId);
                    }
                }

                // now dispose of other hibernate entities
                getTransactionManager().begin();
View Full Code Here

        log.trace("in ListDefinitionAction");
        Subject subject = RequestUtils.getSubject(request);
        PageControl pc = WebUtility.getPageControl(request);

        AlertDefinitionManagerLocal alertManager = LookupUtil.getAlertDefinitionManager();
        ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();

        int resourceId = RequestUtils.getResourceId(request);

        PageList<AlertDefinition> alertDefinitions = alertManager.findAlertDefinitions(subject, resourceId, pc);

        // TODO GH: Deal with when its by type... i guess for the template setup

        /*PageList uiBeans = new PageList();
         * for (Object alertDefObj : alertDefs) { AlertDefinition alertDef = (AlertDefinition) alertDefObj;
         * AlertDefinitionBean bean = new AlertDefinitionBean(alertDef.getId(),   alertDef.getCtime(),
         * alertDef.getName(), alertDef.getDescription(),   alertDef.getEnabled(), alertDef.getParentId());
         * bean.setAppdefEntityID(appEntId); uiBeans.add(bean);}*/

        context.putAttribute(Constants.HQ_RESOURCE_ATTR, resourceManager.getResourceById(subject, resourceId));
        request.setAttribute(Constants.ALERT_DEFS_ATTR, alertDefinitions);

        /*
         * context.putAttribute(Constants.RESOURCE_OWNER_ATTR, request.getAttribute(Constants.RESOURCE_OWNER_ATTR));
         * context.putAttribute(Constants.RESOURCE_MODIFIER_ATTR,
 
View Full Code Here

                if (children == null)
                    children = new ArrayList<AutoGroupComposite>();
                displaySummary = new ArrayList<AutoGroupCompositeDisplaySummary>(children.size() + 1);

                // get the parent
                ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
                AutoGroupComposite parentComposite = resourceManager.getResourceAutoGroup(subject, parentId);
                if (parentComposite != null) {
                    parentComposite.setMainResource(true);
                    List<MetricDisplaySummary> metricSummaries = null;
                    metricSummaries = chartsManager.getMetricDisplaySummariesForMetrics(subject, parentId,
                        DataType.MEASUREMENT, begin, end, true, true);
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.resource.ResourceManagerLocal

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.