Package org.nuxeo.ecm.core.api

Examples of org.nuxeo.ecm.core.api.Blob


        if (!ARTICLE_TYPE.equals(doc.getType())) {
            return;
        }

        Blob image = (Blob) doc.getPropertyValue(CONTENT_PICTURE_PICTURE_PROPERTY);
        if (image == null) {
            return;
        }

        ImagingService service;
        try {
            service = Framework.getService(ImagingService.class);
        } catch (Exception e) {
            throw new ClientException("Failed to get ImagingService", e);
        }

        ImageInfo info = service.getImageInfo(image);
        int width = info.getWidth();
        int height = info.getHeight();
        float wScale = (float) RESIZED_IMAGE_WIDTH / width;
        float hscale = (float) RESIZED_IMAGE_HEIGHT / height;
        float scale = Math.min(wScale, hscale);

        if (scale < 1) {
            image = service.resize(image, "jpg", (int) (width * scale),
                    (int) (height * scale), info.getDepth());
            image.setMimeType("image/jpeg"); // XXX : Should be automatic
            doc.setPropertyValue(CONTENT_PICTURE_PICTURE_PROPERTY,
                    (Serializable) image);
        }
    }
View Full Code Here


    private static final String ERROR_INPUT_FILE_NOT_AN_IMAGE = "error.inputFile.notAnImage";

    @Override
    public void validate(FacesContext context, UIComponent component,
            Object value) throws ValidatorException {
        Blob blob = (Blob) ((InputFileInfo) value).getBlob();
        String mimeType = null;
        if (blob != null) {
            mimeType = blob.getMimeType();
        }
        if (mimeType != null && !mimeType.startsWith(IMAGE_MIME_TYPE_PREFIX)) {
            throw new ValidatorException(MessageFactory.getMessage(
                    ERROR_INPUT_FILE_NOT_AN_IMAGE, FacesMessage.SEVERITY_ERROR));
        }
View Full Code Here

            OperationChain chain = new OperationChain(
                    "testMiniMessageOperation");
            chain.add(AddMiniMessage.ID).set("message",
                    "At the risk of sounding negative, no.");
            Blob result = (Blob) automationService.run(ctx, chain);
            assertNotNull(result);
            String json = result.getString();
            assertNotNull(json);

            List<MiniMessage> messages = miniMessageService.getMiniMessageFor(
                    ActivityHelper.createUserActivityObject("Leela"),
                    CIRCLE_RELATION, 0, 0);
View Full Code Here

            assertNotNull(ctx);

            OperationChain chain = new OperationChain(
                    "testMiniMessageOperation");
            chain.add(GetMiniMessages.ID);
            Blob result = (Blob) automationService.run(ctx, chain);
            assertNotNull(result);
            String json = result.getString();
            assertNotNull(json);

            ObjectMapper mapper = new ObjectMapper();
            Map<String, Object> m = mapper.readValue(json,
                    new TypeReference<Map<String, Object>>() {
View Full Code Here

            assertNotNull(ctx);

            OperationChain chain = new OperationChain(
                    "testMiniMessageOperation");
            chain.add(GetMiniMessages.ID);
            Blob result = (Blob) automationService.run(ctx, chain);
            assertNotNull(result);
            String json = result.getString();
            assertNotNull(json);

            ObjectMapper mapper = new ObjectMapper();
            Map<String, Object> m = mapper.readValue(json,
                    new TypeReference<Map<String, Object>>() {
                    });
            List<Map<String, Object>> miniMessages = (List<Map<String, Object>>) m.get("miniMessages");
            assertEquals(5, miniMessages.size());

            chain = new OperationChain("testMiniMessageOperation");
            chain.add(GetMiniMessages.ID).set("offset", 5);
            result = (Blob) automationService.run(ctx, chain);
            assertNotNull(result);
            json = result.getString();
            assertNotNull(json);

            mapper = new ObjectMapper();
            m = mapper.readValue(json,
                    new TypeReference<Map<String, Object>>() {
                    });
            miniMessages = (List<Map<String, Object>>) m.get("miniMessages");
            assertEquals(5, miniMessages.size());

            chain = new OperationChain("testMiniMessageOperation");
            chain.add(GetMiniMessages.ID).set("offset", 10);
            result = (Blob) automationService.run(ctx, chain);
            assertNotNull(result);
            json = result.getString();
            assertNotNull(json);

            mapper = new ObjectMapper();
            m = mapper.readValue(json,
                    new TypeReference<Map<String, Object>>() {
View Full Code Here

        oParams.set("page", 0);
        oParams.set("pageSize", 5);
        oParams.set("contextPath", "/testSocialWorkspace");
        chain.add(oParams);

        Blob result = (Blob) automationService.run(ctx, chain);
        JSONObject o = JSONObject.fromObject(result.getString());
        JSONArray array = (JSONArray) o.get("users");
        assertEquals(1, array.size());
        assertEquals("testUser_firstName",
                ((JSONObject) array.get(0)).get("firstName"));
        assertEquals("testUser_lastName",
View Full Code Here

            assertNotNull(ctx);

            OperationChain chain = new OperationChain(
                    "testUserActivityStreamOperation");
            chain.add(GetActivityStream.ID);
            Blob result = (Blob) automationService.run(ctx, chain);
            assertNotNull(result);
            String json = result.getString();
            assertNotNull(json);

            ObjectMapper mapper = new ObjectMapper();
            Map<String, Object> m = mapper.readValue(json,
                    new TypeReference<Map<String, Object>>() {
View Full Code Here

TOP

Related Classes of org.nuxeo.ecm.core.api.Blob

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.