Package org.apache.isis.applib.value

Examples of org.apache.isis.applib.value.Blob


    protected Blob getBlobOrClobFrom(final List<FileUpload> fileUploads) {
        final FileUpload fileUpload = fileUploads.get(0);
        final String contentType = fileUpload.getContentType();
        final String clientFileName = fileUpload.getClientFileName();
        final byte[] bytes = fileUpload.getBytes();
        final Blob blob = new Blob(clientFileName, contentType, bytes);
        return blob;
    }
View Full Code Here


                writer.write(propertiesReader.asJson(objectSpec));
                writer.flush();
                zos.closeEntry();
            }
            writer.close();
            return new Blob("layouts.zip", mimeTypeApplicationZip, baos.toByteArray());
        } catch (final IOException ex) {
            throw new FatalException("Unable to create zip of layouts", ex);
        }
    }
View Full Code Here

    private Blob blob;
    private FacetHolder holder;

    @Before
    public void setUpObjects() throws Exception {
        blob = new Blob("myfile1.docx", "application", "vnd.ms-word", new byte[]{1,2,3,4});
        allowMockAdapterToReturn(blob);
        holder = new FacetHolderImpl();

        setValue(value = new BlobValueSemanticsProvider(holder, mockConfiguration, mockContext));
    }
View Full Code Here

    @Test
    public void testEncode_and_decode() {
        String encoded = value.toEncodedString(blob);
        assertEquals("myfile1.docx:application/vnd.ms-word:AQIDBA==", encoded);
        Blob decoded = value.fromEncodedString(encoded);
        assertThat(decoded.getName(), is("myfile1.docx"));
        assertThat(decoded.getMimeType().getPrimaryType(), is("application"));
        assertThat(decoded.getMimeType().getSubType(), is("vnd.ms-word"));
        assertThat(decoded.getBytes().length, is(4));
    }
View Full Code Here

    // EncoderDecoder
    // //////////////////////////////////////////////////////////////////

    @Override
    protected String doEncode(final Object object) {
        Blob blob = (Blob)object;
        return blob.getName() + ":" + blob.getMimeType().getBaseType() + ":" + Base64.encodeBase64String((blob.getBytes()));
    }
View Full Code Here

        final String name  = data.substring(0, colonIdx);
        final int colon2Idx  = data.indexOf(":", colonIdx+1);
        final String mimeTypeBase = data.substring(colonIdx+1, colon2Idx);
        final byte[] bytes = Base64.decodeBase64(data.substring(colon2Idx+1));
        try {
            return new Blob(name, new MimeType(mimeTypeBase), bytes);
        } catch (MimeTypeParseException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

                writer.write(propertiesReader.asJson(objectSpec));
                writer.flush();
                zos.closeEntry();
            }
            writer.close();
            return new Blob("layouts.zip", mimeTypeApplicationZip, baos.toByteArray());
        } catch (final IOException ex) {
            throw new FatalException("Unable to create zip of layouts", ex);
        }
    }
View Full Code Here

                writer.write(propertiesReader.asJson(objectSpec));
                writer.flush();
                zos.closeEntry();
            }
            writer.close();
            return new Blob("layouts.zip", mimeTypeApplicationZip, baos.toByteArray());
        } catch (final IOException ex) {
            throw new FatalException("Unable to create zip of layouts", ex);
        }
    }
View Full Code Here

        if(value instanceof Clob) {
            Clob clob = (Clob)value;
            return handlerFor(resourceStreamFor(clob), clob);
        }
        if(value instanceof Blob) {
            Blob blob = (Blob)value;
            return handlerFor(resourceStreamFor(blob), blob);
        }
        return null;
    }
View Full Code Here

    private Blob blob;
    private FacetHolder holder;

    @Before
    public void setUpObjects() throws Exception {
        blob = new Blob("myfile1.docx", "application", "vnd.ms-word", new byte[]{1,2,3,4});
        allowMockAdapterToReturn(blob);
        holder = new FacetHolderImpl();

        setValue(value = new BlobValueSemanticsProvider(holder, mockConfiguration, mockContext));
    }
View Full Code Here

TOP

Related Classes of org.apache.isis.applib.value.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.