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


        final Object object = adapter.getObject();
        if(!(object instanceof Blob)) {
            return null;
        }
       
        final Blob blob = (Blob)object;
        final MimeType mimeType = blob.getMimeType();
        if(mimeType == null || !mimeType.getPrimaryType().equals("image")) {
            return null;
        }
       
        final BufferedImage image = asBufferedImage(blob);
View Full Code Here

        ByteArrayOutputStream baos = null;
        try {
            fis = new FileInputStream(file);
            baos = new ByteArrayOutputStream();
            IOUtils.copy(fis, baos);
            return new Blob(name, xslxMimeType, baos.toByteArray());
        } catch (IOException ex) {
            throw new ExcelService.Exception(ex);
        } finally {
            IOUtils.closeQuietly(fis);
            IOUtils.closeQuietly(baos);
View Full Code Here

                new ResourceStreamRequestHandler(new StringResourceStream(clob.getChars(), clob.getMimeType().toString()), clob.getName());
            handler.setContentDisposition(ContentDisposition.ATTACHMENT);
            getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
            label = "Downloading: " + clob.getName();
        } else if(value instanceof Blob) {
            final Blob blob = (Blob) value;
            ResourceRequestHandler handler =
                    new ResourceRequestHandler(new ByteArrayResource(blob.getMimeType().toString(), blob.getBytes(), blob.getName()), null);
            getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
            label = "Downloading: " + blob.getName();
        } else {
            label = objectAdapter.titleString(null);
        }
        add(new Label(ID_STANDALONE_VALUE, label));
    }
View Full Code Here

        addColumns(ClassNameConstants.BYTE_ARRAY); // bytes
    }

    public Object getValueForDatastoreMapping(NucleusContext nucleusCtx, int index, Object value)
    {
        Blob blob = ((Blob)value);
        switch (index) {
            case 0: return blob.getName();
            case 1: return blob.getMimeType().getBaseType();
            case 2: return blob.getBytes();
        }
        throw new IndexOutOfBoundsException();
    }
View Full Code Here

        throw new IndexOutOfBoundsException();
    }

    public void setObject(ExecutionContext ec, PreparedStatement preparedStmt, int[] exprIndex, Object value)
    {
        Blob blob = ((Blob)value);
        if (blob == null) {
            getDatastoreMapping(0).setObject(preparedStmt, exprIndex[0], null);
            getDatastoreMapping(1).setObject(preparedStmt, exprIndex[1], null);
            getDatastoreMapping(2).setObject(preparedStmt, exprIndex[2], null);
        } else {
            getDatastoreMapping(0).setString(preparedStmt, exprIndex[0], blob.getName());
            getDatastoreMapping(1).setString(preparedStmt, exprIndex[1], blob.getMimeType().getBaseType());
            getDatastoreMapping(2).setObject(preparedStmt, exprIndex[2], blob.getBytes());
        }
    }
View Full Code Here

        final String mimeTypeBase = getDatastoreMapping(1).getString(resultSet, exprIndex[1]);
        final byte[] bytes = (byte[]) getDatastoreMapping(2).getObject(resultSet, exprIndex[2]);
        if(name == null || mimeTypeBase == null || bytes == null) {
            return null;
        }
        return new Blob(name, mimeTypeBase, bytes);
    }
View Full Code Here

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

        addColumns(ClassNameConstants.JAVA_LANG_BYTE_ARRAY); // bytes
    }

    public Object getValueForDatastoreMapping(NucleusContext nucleusCtx, int index, Object value)
    {
        Blob blob = ((Blob)value);
        switch (index) {
            case 0: return blob.getName();
            case 1: return blob.getMimeType().getBaseType();
            case 2: return blob.getBytes();
        }
        throw new IndexOutOfBoundsException();
    }
View Full Code Here

        throw new IndexOutOfBoundsException();
    }

    public void setObject(ExecutionContext ec, PreparedStatement preparedStmt, int[] exprIndex, Object value)
    {
        Blob blob = ((Blob)value);
        if (blob == null) {
            getDatastoreMapping(0).setObject(preparedStmt, exprIndex[0], null);
            getDatastoreMapping(1).setObject(preparedStmt, exprIndex[1], null);
            getDatastoreMapping(2).setObject(preparedStmt, exprIndex[2], null);
        } else {
            getDatastoreMapping(0).setString(preparedStmt, exprIndex[0], blob.getName());
            getDatastoreMapping(1).setString(preparedStmt, exprIndex[1], blob.getMimeType().getBaseType());
            getDatastoreMapping(2).setObject(preparedStmt, exprIndex[2], blob.getBytes());
        }
    }
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.