Package org.rhq.core.domain.drift

Examples of org.rhq.core.domain.drift.DriftDefinitionTemplate


    }

    @RequiredPermission(Permission.MANAGE_SETTINGS)
    @Override
    public void deleteTemplate(Subject subject, int templateId) {
        DriftDefinitionTemplate template = entityMgr.find(DriftDefinitionTemplate.class, templateId);
        if (!template.isUserDefined()) {
            throw new IllegalArgumentException(template.getName() + " is a plugin defined template. Plugin defined " +
                "templates cannot be deleted.");
        }
        for (DriftDefinition defintion : template.getDriftDefinitions()) {
            if (defintion.isAttached()) {
                driftMgr.deleteDriftDefinition(subject, forResource(defintion.getResource().getId()), defintion
                    .getName());
            } else {
                defintion.setTemplate(null);
View Full Code Here


    @RequiredPermission(Permission.MANAGE_SETTINGS)
    @Override
    public void updateTemplate(Subject subject, DriftDefinitionTemplate updatedTemplate) {

        DriftDefinitionTemplate template = entityMgr.find(DriftDefinitionTemplate.class, updatedTemplate.getId());

        if (null == template) {
            throw new IllegalArgumentException("Template with id [" + updatedTemplate.getId() + "] not found");
        }
        if (!template.isUserDefined()) {
            throw new IllegalArgumentException("Plugin-defined templates cannot be be modified");
        }
        if (!template.getName().equals(updatedTemplate.getName())) {
            throw new IllegalArgumentException("The template's name cannot be modified");
        }
        DriftDefinitionComparator comparator = new DriftDefinitionComparator(
            DriftDefinitionComparator.CompareMode.ONLY_DIRECTORY_SPECIFICATIONS);
        if (comparator.compare(template.getTemplateDefinition(), updatedTemplate.getTemplateDefinition()) != 0) {
            throw new IllegalArgumentException("The template's base directory and filters cannot be modified");
        }

        template.setTemplateDefinition(updatedTemplate.getTemplateDefinition());
        template = entityMgr.merge(template);
        DriftDefinition templateDef = template.getTemplateDefinition();

        for (DriftDefinition resourceDef : template.getDriftDefinitions()) {
            DriftDefinition driftDef = entityMgr.find(DriftDefinition.class, resourceDef.getId());
            if (driftDef.isAttached()) {
                driftDef.setInterval(templateDef.getInterval());
                driftDef.setDriftHandlingMode(templateDef.getDriftHandlingMode());
                driftDef.setEnabled(templateDef.isEnabled());
View Full Code Here

        Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
        PluginMetadataParser parser = new PluginMetadataParser(descriptor, parsersByPlugin);
        ResourceType resourceType = findResourceType(parser, resourceTypeName);
        Set<DriftDefinitionTemplate> driftTemplates = resourceType.getDriftDefinitionTemplates();
        DriftDefinitionTemplate driftTemplate = null;
        for (DriftDefinitionTemplate template : driftTemplates) {
            if (template.getName().equals(driftDefName)) {
                driftTemplate = template;
                break;
            }
        }
        assertNotNull(driftTemplate, "Failed to find drift definition template [" + driftDefName
            + "]. The name attribute may not have been parsed correctly.");

        PropertySimple name = driftTemplate.getConfiguration().getSimple(DriftConfigurationDefinition.PROP_NAME);
        PropertySimple enabled = driftTemplate.getConfiguration().getSimple(DriftConfigurationDefinition.PROP_ENABLED);

        assertNotNull(name, "Expected to find a simple property <name> for the drift definition name");
        assertEquals(name.getStringValue(), driftDefName,
            "The value is wrong for the <name> property that represents the drift definition name");
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.drift.DriftDefinitionTemplate

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.