Package com.streamreduce.rest.dto.response

Examples of com.streamreduce.rest.dto.response.InventoryItemResponseDTO


        return baseResponseDTO;
    }

    protected InventoryItemResponseDTO toFullDTO(InventoryItem inventoryItem) {
        InventoryItemResponseDTO dto = new InventoryItemResponseDTO();
        Connection connection = inventoryItem.getConnection();
        BasicDBObject payload = applicationManager.getInventoryService().getInventoryItemPayload(inventoryItem);

        super.toBaseDTO(inventoryItem, dto);

        dto.setOwner(inventoryItem.getUser().getId().equals(securityService.getCurrentUser().getId()));

        dto.setConnectionAlias(connection.getAlias());
        dto.setConnectionId(connection.getId());
        dto.setConnectionType(connection.getType());
        dto.setConnectionProviderId(connection.getProviderId());

        dto.setExternalId(inventoryItem.getExternalId());
        dto.setType(inventoryItem.getType());

        // Prune any sensitive information from the payload
        if (!dto.isOwner()) {
            if (payload.containsField("adminPassword")) {
                payload.removeField("adminPassword");
            }
            if (payload.containsField("credentials")) {
                payload.removeField("credentials");
            }
        }

        dto.setPayload(payload);

        return dto;
    }
View Full Code Here


        String cloudInventoryUrl = connectionsBaseUrl + "/" + cloud.getId() + "/inventory";
        ConnectionInventoryResponseDTO cloudInventory =
                jsonToObject(makeRequest(cloudInventoryUrl, "GET", null, authnToken),
                TypeFactory.defaultInstance().constructType(ConnectionInventoryResponseDTO.class));

        InventoryItemResponseDTO originalDTO = null;

        for (InventoryItemResponseDTO inventoryItem : cloudInventory.getInventoryItems()) {
            if (inventoryItem.getExternalId().equals(newNode.getProviderId())) {
                originalDTO = inventoryItem;
                // Default name for nodes without name is the node id
                assertEquals(inventoryItem.getExternalId(), inventoryItem.getAlias());
                break;
            }
        }

        assertNotNull(originalDTO);

        // Change the name of the inventory item
        JSONObject json = new JSONObject();

        json.put("alias", "Inventory Item Name");

        InventoryItemResponseDTO responseDTO =
                jsonToObject(makeRequest(inventoryItemBaseUrl + "/" + originalDTO.getId(), "PUT", json, authnToken),
                TypeFactory.defaultInstance().constructType(InventoryItemResponseDTO.class));

        assertEquals(json.getString("alias"), responseDTO.getAlias());
    }
View Full Code Here

        String cloudInventoryUrl = connectionsBaseUrl + "/" + cloud.getId() + "/inventory";
        ConnectionInventoryResponseDTO cloudInventory =
                jsonToObject(makeRequest(cloudInventoryUrl, "GET", null, authnToken),
                TypeFactory.defaultInstance().constructType(ConnectionInventoryResponseDTO.class));

        InventoryItemResponseDTO iiDTO = null;

        for (InventoryItemResponseDTO inventoryItem : cloudInventory.getInventoryItems()) {
            if (inventoryItem.getExternalId().equals(newNode.getProviderId())) {
                iiDTO = inventoryItem;
                break;
            }
        }

        assertNotNull(iiDTO);

        String currentState =  iiDTO.getPayload().getString("state");

        assertEquals(NodeState.RUNNING.toString(), currentState);

        assertEquals("200",
                makeRequest(inventoryItemBaseUrl + "/" +  iiDTO.getId() + "/reboot", "PUT", null, authnToken));

        cloudInventory = jsonToObject(makeRequest(cloudInventoryUrl, "GET", null, authnToken),
                TypeFactory.defaultInstance().constructType(InventoryItemResponseDTO.class));


        for (InventoryItemResponseDTO inventoryItem : cloudInventory.getInventoryItems()) {
            if (inventoryItem.getExternalId().equals(newNode.getProviderId())) {
                iiDTO = inventoryItem;
                break;
            }
        }

        // There is no good way to test a reboot since it seems that these node reboots are too fast to see a state
        // change so just ensure they are running after reboot.
        currentState =  iiDTO.getPayload().getString("state");

        assertEquals(NodeState.RUNNING.toString(), currentState);

        // Destroy the node
        makeRequest(inventoryItemBaseUrl + "/" +  iiDTO.getId(), "DELETE", null, authnToken);

        cloudInventory = jsonToObject(makeRequest(cloudInventoryUrl, "GET", null, authnToken),
                TypeFactory.defaultInstance().constructType(ConnectionInventoryResponseDTO.class));

View Full Code Here

        String cloudInventoryUrl = connectionsBaseUrl + "/" + cloud.getId() + "/inventory";
        ConnectionInventoryResponseDTO cloudInventory =
                jsonToObject(makeRequest(cloudInventoryUrl, "GET", null, authnToken),
                TypeFactory.defaultInstance().constructType(ConnectionInventoryResponseDTO.class));

        InventoryItemResponseDTO inventoryItemDTO = null;

        for (InventoryItemResponseDTO inventoryItem : cloudInventory.getInventoryItems()) {
            if (inventoryItem.getExternalId().equals(newNode.getProviderId())) {
                inventoryItemDTO = inventoryItem;
                break;
            }
        }

        assertNotNull(inventoryItemDTO);

        // Make sure the zone and region is accurate
        Location location = newNode.getLocation();
        boolean zoneMatches = false;
        boolean regionMatches = false;

        while (location != null) {
            JSONObject payload = JSONObject.fromObject(inventoryItemDTO.getPayload().toString());
            String region = inventoryService.getLocationByScope(payload, LocationScope.REGION).getId();
            String zone = inventoryService.getLocationByScope(payload, LocationScope.ZONE).getId();

            if (location.getScope() == LocationScope.REGION) {
                if (location.getId().equals(region)) {
View Full Code Here

TOP

Related Classes of com.streamreduce.rest.dto.response.InventoryItemResponseDTO

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.