Package org.eurekastreams.server.domain

Examples of org.eurekastreams.server.domain.Image


     */
    public void write(final RenderedImage image, final String identifier) throws Exception
    {
        try
        {
            Image imageInDb = getMapper.execute(identifier);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ImageIO.write(image, "png", baos);

            if (imageInDb == null)
            {
                insertMapper.execute(new PersistenceRequest<Image>(new Image(identifier, baos.toByteArray())));
            }
            else
            {
                imageInDb.setImageBlob(baos.toByteArray());
                updateMapper.execute(new PersistenceRequest<Image>(imageInDb));
            }
        }
        catch (Exception ex)
        {
View Full Code Here


     * @throws Exception
     *             again, the evil.
     */
    public void write(final FileItem fileItem, final String identifier) throws Exception
    {
        Image imageInDb = getMapper.execute(identifier);

        if (imageInDb == null)
        {
            insertMapper.execute(new PersistenceRequest<Image>(new Image(identifier, fileItem.get())));
        }
        else
        {
            imageInDb.setImageBlob(fileItem.get());
            updateMapper.execute(new PersistenceRequest<Image>(imageInDb));
        }

    }
View Full Code Here

     * @param newIdentifier
     *            the path to rename to.
     */
    public void rename(final String orig, final String newIdentifier)
    {
        Image image = getMapper.execute(orig);
        image.setImageIdentifier(newIdentifier);
        updateMapper.execute(new PersistenceRequest<Image>(image));
    }
View Full Code Here

     */
    public RenderedImage read(final String identifier) throws IOException
    {
        try
        {
            Image image = getMapper.execute(identifier);
            ByteArrayInputStream baos = new ByteArrayInputStream(image.getImageBlob());
            return ImageIO.read(baos);
        }
        catch (Exception ex)
        {
            log.error("Error reading file from disk: " + identifier, ex);
View Full Code Here

     * Insert it into the DB. Can't do this in the dataset because of the blob.
     */
    @Before
    public void before()
    {
        Image insertedImage = new Image("myImage", new byte[5]);
        insertMapper.execute(new PersistenceRequest<Image>(insertedImage));
    }
View Full Code Here

     * Get. Delete. Get. Confirm.
     */
    @Test
    public void executeTest()
    {
        Image myImage = getMapper.execute("myImage");
        assertTrue(myImage != null);

        sut.execute("myImage");

        Image myDeletedImage = getMapper.execute("myImage");
        assertTrue(myDeletedImage == null);
    }
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.domain.Image

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.