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

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


    public Response updateGroup(@ApiParam(value = "Id of the group to update") @PathParam("id") int id,
                                @ApiParam(value = "New version of the group") GroupRest in,
                                @Context HttpHeaders headers,
                                @Context UriInfo uriInfo) {

        ResourceGroup resourceGroup = fetchGroup(id, false);
        resourceGroup.setName(in.getName());
        Response.ResponseBuilder builder;

        try {
            resourceGroup = resourceGroupManager.updateResourceGroup(caller,resourceGroup);
            builder=Response.ok(fillGroup(resourceGroup,uriInfo));
            putToCache(resourceGroup.getId(),ResourceGroup.class,resourceGroup);
        }
        catch (Exception e) {
            builder = Response.status(Response.Status.NOT_ACCEPTABLE);
        }
View Full Code Here


    @ApiError(code = 404, reason = "Group with passed id does not exist")
    public Response getResources(@ApiParam("Id of the group to retrieve the resources for") @PathParam("id") int id,
                                 @Context HttpHeaders headers,
                                 @Context UriInfo uriInfo) {

        ResourceGroup resourceGroup = fetchGroup(id, false);

        Set<Resource> resources = resourceGroup.getExplicitResources();
        List<ResourceWithType> rwtList = new ArrayList<ResourceWithType>(resources.size());
        for (Resource res: resources) {
            rwtList.add(fillRWT(res,uriInfo));
        }
        MediaType mediaType = headers.getAcceptableMediaTypes().get(0);
View Full Code Here

                                @ApiParam("Id of the resource to add") @PathParam("resourceId") int resourceId,
                                @Context HttpHeaders headers, @Context UriInfo uriInfo) {

        MediaType mediaType = headers.getAcceptableMediaTypes().get(0);

        ResourceGroup resourceGroup = fetchGroup(id, false);
        Resource res = resourceManager.getResource(caller,resourceId);
        if (res==null)
            throw new StuffNotFoundException("Resource with id " + resourceId);

        // A resource type is set for the group, so only allow to add resources with the same type.
        if (resourceGroup.getResourceType()!=null) {
            if (!res.getResourceType().equals(resourceGroup.getResourceType())) {
                Response.ResponseBuilder status = Response.status(Response.Status.CONFLICT);
                status.type(mediaType);
                return status.build();
            }
        }
View Full Code Here

    public Response removeResource(@ApiParam("Id of the existing group") @PathParam("id") int id,
                                   @ApiParam("Id of the resource to remove") @PathParam("resourceId") int resourceId,
                                   @ApiParam("Validate if the resource exists in the group") @QueryParam(
                                       "validate") @DefaultValue("false") boolean validate) {

        ResourceGroup resourceGroup = fetchGroup(id, false);
        Resource res = resourceManager.getResource(caller, resourceId);
        if (res==null)
            throw new StuffNotFoundException("Resource with id " + resourceId);

        boolean removed = resourceGroup.removeExplicitResource(res);
        if (!removed && validate) {
            throw new StuffNotFoundException("Resource " + resourceId + " in group " + id);
        }

        return Response.noContent().build();
View Full Code Here

    @ApiOperation(value = "Get the metric definitions for the compatible group with the passed id")
    @ApiError(code = 404, reason = "Group with the passed id does not exist")
    public Response getMetricDefinitionsForGroup(@ApiParam(value = "Id of the group") @PathParam("id") int id,
                                                 @Context HttpHeaders headers,
                                                 @Context UriInfo uriInfo) {
        ResourceGroup group = fetchGroup(id, true);

        Set<MeasurementDefinition> definitions = group.getResourceType().getMetricDefinitions();
        List<MetricSchedule> schedules = new ArrayList<MetricSchedule>(definitions.size());
        for (MeasurementDefinition def : definitions) {
            MetricSchedule schedule = new MetricSchedule(def.getId(),def.getName(),def.getDisplayName(),false,def.getDefaultInterval(),
                    def.getUnits().getName(),def.getDataType().toString());
            schedule.setDefinitionId(def.getId());
View Full Code Here

        leftPane.setPadding(5);
        leftPane.setMembersMargin(5);
        leftPane.setAutoHeight();

        Resource resource = null;
        ResourceGroup group = null;
        GroupCategory groupCategory = null;
        Set<ResourceTypeFacet> facets = null;
        Set<ResourceTypeFacet> resourceFacets = null;
        if ((groupComposite != null) && (groupComposite.getResourceGroup() != null)) {
            group = groupComposite.getResourceGroup();
View Full Code Here

            GWTServiceLookup.getResourceGroupService().findResourceGroupsByCriteria(criteria,
                new AsyncCallback<PageList<ResourceGroup>>() {
                    @Override
                    public void onSuccess(PageList<ResourceGroup> results) {
                        if (!results.isEmpty()) {
                            ResourceGroup gp = results.get(0);
                            Set<Resource> explicitMembers = gp.getExplicitResources();
                            Resource[] currentResources = new Resource[explicitMembers.size()];
                            explicitMembers.toArray(currentResources);
                            if (group.getGroupCategory().equals(GroupCategory.COMPATIBLE)) {
                                if (currentResources[0].getResourceType().getCategory()
                                    .equals(ResourceCategory.PLATFORM)) {
View Full Code Here

        try {
            getTransactionManager().begin();

            try {
                ResourceGroup group = em.find(ResourceGroup.class, compatibleGroup.getId());
                em.remove(group);

                getTransactionManager().commit();
            } catch (Exception e) {
                try {
View Full Code Here

        Integer idAttrib = from.getAttributeAsInt("id");
        String nameAttrib = from.getAttribute(NAME.propertyName());
        String descriptionAttrib = from.getAttribute(DESCRIPTION.propertyName());
        String typeNameAttrib = from.getAttribute(TYPE.propertyName());

        ResourceGroup rg = new ResourceGroup(nameAttrib);
        rg.setId(idAttrib);
        rg.setDescription(descriptionAttrib);
        if (typeNameAttrib != null) {
            ResourceType rt = new ResourceType();
            rt.setName(typeNameAttrib);
            String pluginNameAttrib = from.getAttribute(PLUGIN.propertyName());
            rt.setPlugin(pluginNameAttrib);
            rg.setResourceType(rt);
        }

        Long explicitCount = Long.valueOf(from.getAttribute("explicitCount"));
        Long explicitDown = Long.valueOf(from.getAttribute("explicitDown"));
        Long explicitUnknown = Long.valueOf(from.getAttribute("explicitUnknown"));
View Full Code Here

        schedule3 = new MeasurementSchedule(definitionCt3, resource2);
        em.persist(schedule3);
        definitionCt3.addSchedule(schedule3);
        resource2.addSchedule(schedule3);

        group = new ResourceGroup("test-group", theResourceType);
        em.persist(group);

        // prepare return values and expected values
        long time1 = System.currentTimeMillis();
        long time2 = time1 + 1;
View Full Code Here

TOP

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

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.