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

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


    public Integer calculateGroupMembership_helper(Subject overlord, int groupDefinitionId,
        ExpressionEvaluator.Result result) throws ResourceGroupDeleteException, GroupDefinitionNotFoundException,
        GroupDefinitionNotFoundException {
        long startTime = System.currentTimeMillis();

        GroupDefinition groupDefinition = getById(groupDefinitionId);

        String groupByClause = result.getGroupByClause();
        ResourceGroup resourceGroup = resourceGroupManager.getByGroupDefinitionAndGroupByClause(
            groupDefinition.getId(), groupByClause);
        int resourceGroupId = 0;
        if (resourceGroup == null) {
            String newDynamicGroupName = getDynamicGroupName(groupDefinition.getName(), groupByClause);

            resourceGroup = new ResourceGroup(newDynamicGroupName);
            resourceGroupId = resourceGroupManager.createResourceGroup(overlord, resourceGroup).getId();

            resourceGroup.setRecursive(groupDefinition.isRecursive());
            resourceGroup.setGroupByClause(groupByClause);
            groupDefinition.addResourceGroup(resourceGroup);
        } else {
            resourceGroupId = resourceGroup.getId();
        }

        /*
 
View Full Code Here


        Subject overlord = subjectManager.getOverlord();
        for (Integer managedGroupId : managedGroupIds) {
            removeManagedResource_helper(overlord, groupDefinitionId, managedGroupId);
        }

        GroupDefinition groupDefinition = getById(groupDefinitionId);
        try {
            entityManager.remove(groupDefinition);
        } catch (Exception e) {
            throw new GroupDefinitionDeleteException("Error deleting groupDefinition '" + groupDefinition.getName()
                + "': ", e);
        }
    }
View Full Code Here

    @RequiredPermission(Permission.MANAGE_INVENTORY)
    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    public void removeManagedResource_helper(Subject overlord, int groupDefinitionId, Integer doomedGroupId)
        throws GroupDefinitionDeleteException, GroupDefinitionNotFoundException {
        GroupDefinition groupDefinition = getById(groupDefinitionId);
        ResourceGroup doomedGroup = entityManager.getReference(ResourceGroup.class, doomedGroupId);
        groupDefinition.removeResourceGroup(doomedGroup);

        try {
            /*
             * using the group manager's delete method ensures that auditing data,
             * such as completed operations, is correctly removed
             */
            resourceGroupManager.deleteResourceGroup(subjectManager.getOverlord(), doomedGroupId);
        } catch (Exception e) {
            throw new GroupDefinitionDeleteException("Error removing managedGroup '" + doomedGroup.getName() + "' "
                + "from groupDefinition '" + groupDefinition.getName() + "': ", e);
        }
    }
View Full Code Here

    private GroupDefinition getByName(String name) {
        Query query = entityManager.createNamedQuery(GroupDefinition.QUERY_FIND_BY_NAME);
        query.setParameter("name", name);

        try {
            GroupDefinition found = (GroupDefinition) query.getSingleResult();
            return found;
        } catch (NoResultException e) {
            return null;
        }
    }
View Full Code Here

        @SuppressWarnings("unchecked")
        List<GroupDefinition> result = query.getResultList();
        if (cge.isCreateByDefault()) {
            // let's deploy dyna-group
            if (result.isEmpty()) {
                GroupDefinition sameName = getByName(cge.getName());
                if (sameName != null) {
                    log.info("Not creating DynaGroup based on ["+cge.getPlugin()+"] "+cge+" DynaGroup with same name already exists");
                    return;
                }
                log.info("Creating dynaGroup based on ["+cge.getPlugin()+"] "+cge);
                GroupDefinition gd = new GroupDefinition(cge.getName());
                updateGroupProperties(gd, cge);
                try {
                    createGroupDefinition(subjectManager.getOverlord(), gd);
                } catch (Exception ex) {
                   log.error(ex);
                }
            }
            else {
                log.info("Updating dynaGroup based on ["+cge.getPlugin()+"] "+cge);
                GroupDefinition gd = result.get(0);
                updateGroupProperties(gd, cge);
                try {
                    updateGroupDefinition(subjectManager.getOverlord(), gd, false);
                } catch (Exception ex) {
                   log.error(ex);
View Full Code Here

    private String expression;

    private GroupDefinitionManagerLocal groupDefinitionManager = LookupUtil.getGroupDefinitionManager();

    public EditGroupDefinitionGeneralPropertiesUIBean() {
        GroupDefinition groupDefinition = null;
        try {
            groupDefinition = GroupDefinitionUIBean.lookupGroupDefinition();
        } catch (GroupDefinitionException gde) {
            FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Problem looking up group definition: "
                + gde.getMessage());
            return;
        }

        HttpSession session = FacesContextUtility.getRequest().getSession();

        String marker = (String) session.getAttribute(TEMPORARY_EDIT_MARKER);
        String previousExpression = (String) session.getAttribute(TEMPORARY_EXPRESSION_ATTRIBUTE);
        String previousName = (String) session.getAttribute(TEMPORARY_NAME_ATTRIBUTE);
        String previousDescription = (String) session.getAttribute(TEMPORARY_DESCRIPTION_ATTRIBUTE);
        String previousRecursive = (String) session.getAttribute(TEMPORARY_RECURSIVE_ATTRIBUTE);
        String previousInterval = (String) session.getAttribute(TEMPORARY_RECALCULATION_INTERVAL);

        if (marker == null) {
            this.expression = groupDefinition.getExpression();
            this.name = groupDefinition.getName();
            this.description = groupDefinition.getDescription();
            this.recursive = groupDefinition.isRecursive();
            this.recalculationInterval = (int) (groupDefinition.getRecalculationInterval() / 60000L);
        } else {
            this.expression = previousExpression;
            this.name = previousName;
            this.description = previousDescription;
            this.recursive = previousRecursive.equals("TRUE");
View Full Code Here

    public String update() {
        HttpSession session = FacesContextUtility.getRequest().getSession();

        try {
            GroupDefinition groupDefinition = GroupDefinitionUIBean.lookupGroupDefinition();

            groupDefinition.setName(this.name);
            groupDefinition.setDescription(this.description);
            groupDefinition.setRecursive(this.recursive);
            groupDefinition.setRecalculationInterval(this.recalculationInterval * 60000L);

            /*
             * cleanse expression of system-dependent new line chars
             *
             * unified everything as a single '\n' character by replacing singular instances of '\f' and '\r' with '\n',
             * and then replacing all adjacent '\n' characters with a single character of the same
             */
            groupDefinition.setExpression(expression.replaceAll("\\r", "\n").replaceAll("\\f", "\n").replaceAll("\\n+",
                "\n"));

            session.setAttribute(TEMPORARY_EDIT_MARKER, "marker");
            session.setAttribute(TEMPORARY_EXPRESSION_ATTRIBUTE, expression);
            session.setAttribute(TEMPORARY_NAME_ATTRIBUTE, name);
View Full Code Here

        return OUTCOME_FAILURE;
    }

    public String createGroups() {
        try {
            GroupDefinition groupDefinition = GroupDefinitionUIBean.lookupGroupDefinition();
            Subject subject = EnterpriseFacesContextUtility.getSubject();

            this.groupDefinitionManager.calculateGroupMembership(subject, groupDefinition.getId());
        } catch (GroupDefinitionException gde) {
            FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Problem updating group definition: "
                + gde.getMessage());
            log.error("Problem updating group definition: ", gde);
            return OUTCOME_FAILURE;
View Full Code Here

    public String create() {
        HttpSession session = FacesContextUtility.getRequest().getSession();

        try {
            GroupDefinition groupDefinition = new GroupDefinition(this.name);

            groupDefinition.setDescription(this.description);
            groupDefinition.setRecursive(this.recursive);

            session.setAttribute(TEMPORARY_CREATE_MARKER, "marker");
            session.setAttribute(TEMPORARY_NAME_ATTRIBUTE, name);
            session.setAttribute(TEMPORARY_DESCRIPTION_ATTRIBUTE, description);
            session.setAttribute(TEMPORARY_RECURSIVE_ATTRIBUTE, (recursive ? "TRUE" : "FALSE"));

            GroupDefinition newGroupdefinition = this.groupDefinitionManager.createGroupDefinition(
                EnterpriseFacesContextUtility.getSubject(), groupDefinition);
            id = newGroupdefinition.getId();
        } catch (GroupDefinitionException gde) {
            FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Problem creating group definition: "
                + gde.getMessage());
            return OUTCOME_FAILURE;
        } catch (Exception e) {
View Full Code Here

        formItems.add(lastModifiedByItem);

        if (isDynaGroup) {
            StaticTextItem groupDefinitionItem = new StaticTextItem("groupDefinition",
                MSG.view_group_summary_groupDefinition());
            GroupDefinition groupDefinition = group.getGroupDefinition();
            String groupDefinitionUrl = LinkManager.getGroupDefinitionLink(groupDefinition.getId());
            String groupDefinitionName = StringUtility.escapeHtml(groupDefinition.getName());
            groupDefinitionItem.setValue("<a href=\"" + groupDefinitionUrl + "\">" + groupDefinitionName + "</a>");
            formItems.add(groupDefinitionItem);
        }

        generalPropsForm.setItems(formItems.toArray(new FormItem[formItems.size()]));
View Full Code Here

TOP

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

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.