Examples of JPADriftFileBits


Examples of org.rhq.core.domain.drift.JPADriftFileBits

    @Override
    @TransactionAttribute(REQUIRES_NEW)
    public void persistDriftFileData(JPADriftFile driftFile, InputStream data, long numBytes) throws Exception {

        JPADriftFileBits df = entityManager.find(JPADriftFileBits.class, driftFile.getHashId());
        if (null == df) {
            throw new IllegalArgumentException("JPADriftFile not found [" + driftFile.getHashId() + "]");
        }
        Session session = (Session)entityManager.getDelegate();
        df.setDataSize(numBytes);
        df.setData(session.getLobHelper().createBlob(new BufferedInputStream(data), numBytes));
        df.setStatus(LOADED);
    }
View Full Code Here

Examples of org.rhq.core.domain.drift.JPADriftFileBits

    @Override
    public String getDriftFileBits(String hash) {
        // TODO add security
        try {
            JPADriftFileBits content = (JPADriftFileBits) entityManager.createNamedQuery(
                JPADriftFileBits.QUERY_FIND_BY_ID).setParameter("hashId", hash).getSingleResult();
            if (content.getDataSize() == null || content.getDataSize() < 1) {
                return null;
            }
            return IOUtils.toString(content.getBlob().getBinaryStream(), Charset.defaultCharset().name());
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
View Full Code Here

Examples of org.rhq.core.domain.drift.JPADriftFileBits

    }

    @Override
    public byte[] getDriftFileAsByteArray(String hash) {
        try {
            JPADriftFileBits content = (JPADriftFileBits) entityManager.createNamedQuery(
                JPADriftFileBits.QUERY_FIND_BY_ID).setParameter("hashId", hash).getSingleResult();
            if (content.getDataSize() == null || content.getDataSize() < 1) {
                return new byte[] {};
            }
            return StreamUtil.slurp(content.getBlob().getBinaryStream());
        } catch (SQLException e) {
            e.printStackTrace();
            return null;
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.