Package com.streamreduce.core.service

Examples of com.streamreduce.core.service.InventoryService


        } catch (ConnectionNotFoundException e) {
            return error(e.getMessage(), Response.status(Response.Status.NOT_FOUND));
        }

        InventoryService inventoryService = applicationManager.getInventoryService();
        List<InventoryItem> inventoryItems = inventoryService.getInventoryItems(connection, currentUser);

        if (inventoryItems == null || inventoryItems.size() == 0) {
            return Response.noContent().build();
        } else if (count) {
            return Response.ok(inventoryItems.size()).build();
View Full Code Here


     * @response.representation.400.doc Returned when the client attempts to reboot a non-cloud inventory item or an inventory item it does not own.
     */
    @PUT
    @Path("{itemId}/reboot")
    public Response reboot(@PathParam("itemId") ObjectId itemId) {
        InventoryService inventoryService = applicationManager.getInventoryService();
        InventoryItem inventoryItem;

        try {
            inventoryItem = inventoryService.getInventoryItem(itemId);
        } catch (InventoryItemNotFoundException e) {
            return error(e.getMessage(), Response.status(Response.Status.NOT_FOUND));
        }

        if (!(inventoryItem.getType().equals(Constants.COMPUTE_INSTANCE_TYPE))) {
            return error("You can only reboot cloud inventory items.", Response.status(Response.Status.BAD_REQUEST));
        }

        try {
            // only the owner can do this...
            if (!isOwner(inventoryItem.getConnection().getUser())) {
                return error(ErrorMessages.APPLICATION_ACCESS_DENIED, Response.status(Response.Status.BAD_REQUEST));
            }

            inventoryService.rebootComputeInstance(inventoryItem);
        } catch (CommandNotAllowedException cnae) {
            return error(cnae.getMessage(), Response.status(Response.Status.BAD_REQUEST));
        } catch (InvalidCredentialsException icce) {
            return error(icce.getMessage(), Response.status(Response.Status.BAD_REQUEST));
        }
View Full Code Here

     * @response.representation.404.doc Returned when the client attempts to delete an inventory item that does not exist
     */
    @DELETE
    @Path("{itemId}")
    public Response deleteInventoryItem(@PathParam("itemId") ObjectId itemId) {
        InventoryService inventoryService = applicationManager.getInventoryService();
        InventoryItem inventoryItem;

        try {
            inventoryItem = inventoryService.getInventoryItem(itemId);
        } catch (InventoryItemNotFoundException e) {
            return error(e.getMessage(), Response.status(Response.Status.NOT_FOUND));
        }

        // only the owner can do this...
        if (!isOwner(inventoryItem.getConnection().getUser())) {
            return error(ErrorMessages.APPLICATION_ACCESS_DENIED, Response.status(Response.Status.BAD_REQUEST));
        }

        inventoryService.deleteInventoryItem(inventoryItem);

        return Response.ok().build();
    }
View Full Code Here

TOP

Related Classes of com.streamreduce.core.service.InventoryService

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.