Package org.rhq.core.domain.resource

Examples of org.rhq.core.domain.resource.Resource


        final DSRequest request) {
        Set<Integer> typesSet = new HashSet<Integer>();
        Set<String> ancestries = new HashSet<String>();
        List<Resource> resources = new ArrayList<Resource>(result.size());
        for (ResourceComposite resourceComposite : result) {
            Resource resource = resourceComposite.getResource();
            resources.add(resource);
            ResourceType type = resource.getResourceType();
            if (type != null) {
                typesSet.add(type.getId());
            }
            ancestries.add(resource.getAncestry());
        }

        // In addition to the types of the result resources, get the types of their ancestry
        // NOTE: this may be too labor intensive in general, but since this is a singleton I couldn't
        //       make it easily optional.
View Full Code Here


    }

    @Override
    public ResourceComposite copyValues(Record from) {
        // not very strong...
        return new ResourceComposite(new Resource(from.getAttributeAsInt("id")), AvailabilityType.DOWN);
    }
View Full Code Here

        return new ResourceComposite(new Resource(from.getAttributeAsInt("id")), AvailabilityType.DOWN);
    }

    @Override
    public ListGridRecord copyValues(ResourceComposite from) {
        Resource res = from.getResource();
        ListGridRecord record = new ListGridRecord();
        record.setAttribute("resourceComposite", from);
        record.setAttribute("resource", res);
        record.setAttribute("id", res.getId());
        record.setAttribute(NAME.propertyName(), res.getName());
        record.setAttribute(KEY.propertyName(), res.getResourceKey());
        record.setAttribute(DESCRIPTION.propertyName(), res.getDescription());
        record.setAttribute(LOCATION.propertyName(), res.getLocation());
        record.setAttribute(TYPE.propertyName(), res.getResourceType().getId());
        record.setAttribute(PLUGIN.propertyName(), res.getResourceType().getPlugin());
        record.setAttribute(VERSION.propertyName(), res.getVersion());
        record.setAttribute(CATEGORY.propertyName(), res.getResourceType().getCategory().name());
        record.setAttribute("icon", ImageManager.getResourceIcon(res.getResourceType().getCategory(), res
            .getCurrentAvailability().getAvailabilityType()));
        record.setAttribute(AVAILABILITY.propertyName(),
            ImageManager.getAvailabilityIconFromAvailType(res.getCurrentAvailability().getAvailabilityType()));
        record.setAttribute(CTIME.propertyName(), res.getCtime());
        record.setAttribute(ITIME.propertyName(), res.getItime());
        record.setAttribute(MTIME.propertyName(), res.getMtime());
        record.setAttribute(MODIFIER.propertyName(), res.getModifiedBy());
        record.setAttribute(INVENTORY_STATUS.propertyName(), res.getInventoryStatus());

        record.setAttribute("resourcePermission", from.getResourcePermission());

        // for ancestry handling      
        record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, res.getAncestry());
        record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, res.getResourceType().getId());

        return record;
    }
View Full Code Here

    @Test(enabled = ENABLE_TESTS)
    public void testNoPermissionCallback() throws Exception {
        Subject superuser = LookupUtil.getSubjectManager().getOverlord();
        Subject noPermSubject = new Subject("userWithNoPermissions", true, false);
        Resource resource = newResource1;

        try {
            noPermSubject = LookupUtil.getSubjectManager().createSubject(superuser, noPermSubject);
            noPermSubject = createSession(noPermSubject);

            try {
                configurationManager.updateResourceConfiguration(noPermSubject, resource.getId(), new Configuration());
                assert false : "Should not have been updated - user didn't have permissions";
            } catch (PermissionException expected) {
                System.out.println("This was expected and OK:\n" + expected);
            }

            try {
                configurationManager.updatePluginConfiguration(noPermSubject, resource.getId(), new Configuration());
                assert false : "Should not have been updated - user didn't have permissions";
            } catch (PermissionException expected) {
                System.out.println("This was expected and OK:\n" + expected);
                expected.printStackTrace();
            }
View Full Code Here

        }
    }

    private Resource createNewResource() throws Exception {
        getTransactionManager().begin();
        Resource resource;

        try {
            try {
                ResourceType resourceType = new ResourceType("plat" + System.currentTimeMillis(), "test",
                    ResourceCategory.PLATFORM, null);
                DriftDefinitionTemplate template = new DriftDefinitionTemplate();
                template.setName("test-template");
                DriftDefinition templateDef = new DriftDefinition(new Configuration());
                templateDef.setName("test-template-def");
                template.setTemplateDefinition(templateDef);
                template.setUserDefined(true);
                resourceType.addDriftDefinitionTemplate(template);
                em.persist(resourceType);

                Agent agent = new Agent("testagent", "testaddress", 1, "", "testtoken");
                em.persist(agent);
                em.flush();

                DriftDefinition test1Def = new DriftDefinition(new Configuration());
                test1Def.setName("test-1");

                DriftDefinition test2Def = new DriftDefinition(new Configuration());
                test2Def.setName("test-2");

                resource = new Resource("reskey" + System.currentTimeMillis(), "resname", resourceType);
                resource.setUuid("" + new Random().nextInt());
                resource.setAgent(agent);
                resource.setInventoryStatus(InventoryStatus.COMMITTED);
                resource.addDriftDefinition(test1Def);
                resource.addDriftDefinition(test2Def);
                em.persist(resource);

            } catch (Exception e) {
                System.out.println("CANNOT PREPARE TEST: " + e);
                getTransactionManager().rollback();
View Full Code Here

            + "toString() value of the collection should be displayed.");
    }

    @Test
    public void idShouldBeFirstResourcePropertyPrinted() {
        Resource resource = createResource();

        writer.print(resource);

        assertLineEquals(1, "\t" + padResourceField("id") + ": " + resource.getId(),
            "Expected Resource.id to be the first property printed.");
    }
View Full Code Here

            "Expected Resource.id to be the first property printed.");
    }

    @Test
    public void nameShouldBeSecondResourcePropertyPrinted() {
        Resource resource = createResource();

        writer.print(resource);

        assertLineEquals(2, "\t" + padResourceField("name") + ": " + resource.getName(),
            "Expected Resource.name to be second property printed");
    }
View Full Code Here

            "Expected Resource.name to be second property printed");
    }

    @Test
    public void versionShouldBeThirdResourcePropertyPrinted() {
        Resource resource = createResource();

        writer.print(resource);

        assertLineEquals(3, "\t" + padResourceField("version") + ": " + resource.getVersion(),
            "Expected Resource.version to be third property printed");
    }
View Full Code Here

            "Expected Resource.version to be third property printed");
    }

    @Test
    public void currentAvailabilityShouldBeFourthResourcePropertyPrinted() {
        Resource resource = createResource();

        writer.print(resource);

        assertLineEquals(4, "\t" + padResourceField("currentAvailability") + ": "
            + resource.getCurrentAvailability().getAvailabilityType(),
            "Expected short version of Resource.currentAvailability to be fourth property printed");
    }
View Full Code Here

            "Expected short version of Resource.currentAvailability to be fourth property printed");
    }

    @Test
    public void handleNullCurrentAvailabilityForResource() {
        Resource resource = createUncommittedResource();

        writer.print(resource);

        assertLineEquals(4, "\t" + padResourceField("currentAvailability") + ": ",
            "Expected to see empty string for Resource.currentAvailability when property is null");
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.resource.Resource

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.