Package io.fathom.cloud.protobuf.ImageModel

Examples of io.fathom.cloud.protobuf.ImageModel.ImageData


        return listImages(project, filter);
    }

    @Override
    public ImageImpl findImage(Project project, long imageId) throws CloudException {
        ImageData image = imageRepository.getImages().find(imageId);
        if (image != null) {
            if (!isVisible(project, image)) {
                image = null;
            }
        }
View Full Code Here


        ImageImpl i = findImage(project, id);
        if (i == null) {
            throw new WebApplicationException(Status.NOT_FOUND);
        }

        ImageData changes;

        {
            ImageData.Builder b = ImageData.newBuilder();
            mapHeadersToBuilder(metadata, b);
            changes = b.buildPartial();
        }

        Set<String> allowed = Sets.newHashSet("is_public", "name", "attributes", "is_protected");

        for (Entry<FieldDescriptor, Object> entry : changes.getAllFields().entrySet()) {
            FieldDescriptor field = entry.getKey();
            String key = field.getName();

            if (!allowed.contains(key)) {
                Object existing = i.getData().getField(field);
View Full Code Here

    // }

    @Override
    public BlobData getImageBlob(Image i) throws IOException {
        ImageImpl image = (ImageImpl) i;
        ImageData data = image.getData();

        Project project = new Project(data.getOwnerProject());
        BlobData imageData = findImageData(project, data);
        return imageData;
    }
View Full Code Here

        if (projectId != 0) {
            b.setOwnerProject(projectId);
        }

        ImageData created = imageRepository.getImages().create(b);
        return new ImageImpl(created);
    }
View Full Code Here

            throw new IllegalArgumentException();
        }

        long size = src.size();

        ImageData existing = imageRepository.getImages().find(image.data.getId());
        if (existing == null) {
            throw new WebApplicationException(Status.NOT_FOUND);
        }
        ImageData.Builder b = ImageData.newBuilder(existing);

        if (b.hasImageSize()) {
            if (b.getImageSize() != size) {
                throw new IllegalArgumentException();
            }
        }

        b.setUpdatedAt(Clock.getTimestamp());
        b.setImageSize(size);
        b.setImageState(ImageState.ACTIVE);

        {
            String stored = imageDataService.storeImageFile(src);

            ImageLocation.Builder loc = b.getLocationBuilder();
            loc.setStored(stored);

            b.setImageChecksum(src.getHash());
        }

        ImageData updated = imageRepository.getImages().update(b);

        return new ImageImpl(updated);
    }
View Full Code Here

    }

    @DELETE
    @Path("{id}")
    public Response deleteImage(@PathParam("id") String id) throws CloudException, IOException {
        ImageData image = findImage(id);
        if (image == null) {
            throw new WebApplicationException(Status.NOT_FOUND);
        }

        imageService.deleteImage(getProject(), image.getId());

        return Response.status(Status.NO_CONTENT).build();
    }
View Full Code Here

    public Response updateImage(@PathParam("id") String id, File content) throws CloudException, IOException {
        if (content != null && content.length() != 0) {
            throw new UnsupportedOperationException();
        }

        ImageData image = findImage(id);
        if (image == null) {
            throw new WebApplicationException(Status.NOT_FOUND);
        }

        // TODO: Some
        // -H 'x-image-meta-protected: True'
        // -H 'x-glance-registry-purge-props: false'

        Map<String, String> metadata = extractHeaders();

        image = imageService.updateImage(getProject(), image.getId(), metadata);

        // ResponseBuilder response = Response.ok();
        // setHttpHeaders(image, response);
        // return response.build();
View Full Code Here

    }

    @HEAD
    @Path("{id}")
    public Response getImageInfo(@PathParam("id") String id) throws CloudException, IOException {
        ImageData image = findImage(id);
        if (image == null) {
            throw new WebApplicationException(Status.NOT_FOUND);
        }

        ResponseBuilder response = Response.ok();
View Full Code Here

    }

    @GET
    @Path("{id}")
    public Response getImage(@PathParam("id") String id) throws CloudException, IOException {
        ImageData image = findImage(id);
        if (image == null) {
            throw new WebApplicationException(Status.NOT_FOUND);
        }

        ResponseBuilder response;
        ImageLocation imageLocation = image.getLocation();
        if (imageLocation.hasStored()) {
            String cookie = imageLocation.getStored();

            BlobData blob = imageDataService.getImageFile(cookie);
View Full Code Here

TOP

Related Classes of io.fathom.cloud.protobuf.ImageModel.ImageData

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.