Package org.rhq.core.domain.content

Examples of org.rhq.core.domain.content.PackageBitsBlob


                    assert packageBits != null;
                    assert packageBits.getBlob().getBits() == null;

                    // now lets store some bits in the DB
                    final String DATA = "testPackageBits data";
                    PackageBitsBlob packageBitsBlob = em.find(PackageBitsBlob.class, packageBits.getId());
                    packageBitsBlob.setBits(DATA.getBytes());
                    em.merge(packageBitsBlob);
                    em.flush();

                    // test that the bits are available and stored in the DB
                    composite = contentUIManager.getLoadedPackageBitsComposite(pkgVer.getId());
View Full Code Here


        });
    }

    private PackageBits createPackageBits() {
        PackageBits bits = null;
        PackageBitsBlob blob = null;

        // We have to work backwards to avoid constraint violations. PackageBits requires a PackageBitsBlob,
        // so create and persist that first, getting the ID
        blob = new PackageBitsBlob();
        em.persist(blob);

        // Now create the PackageBits entity and assign the Id and blob.  Note, do not persist the
        // entity, the row already exists. Just perform and flush the update.
        bits = new PackageBits();
        bits.setId(blob.getId());
        bits.setBlob(blob);
        em.flush();

        // return the new PackageBits and associated PackageBitsBlob
        return bits;
View Full Code Here

     *
     * @return
     */
    private PackageBits createPackageBits(boolean initialize) {
        PackageBits bits = null;
        PackageBitsBlob blob = null;

        // We have to work backwards to avoid constraint violations. PackageBits requires a PackageBitsBlob,
        // so create and persist that first, getting the ID
        blob = new PackageBitsBlob();
        if (initialize) {
            blob.setBits(PackageBits.EMPTY_BLOB.getBytes());
        }
        entityManager.persist(blob);

        // Now create the PackageBits entity and assign the Id and blob.  Note, do not persist the
        // entity, the row already exists. Just perform and flush the update.
        bits = new PackageBits();
        bits.setId(blob.getId());
        bits.setBlob(blob);
        entityManager.flush();

        // return the new PackageBits and associated PackageBitsBlob
        return bits;
View Full Code Here

    private PackageBits loadPackageBitsH2(InputStream packageBitStream, int packageVersionId, String packageName,
        String packageVersion, PackageBits existingBits, Map<String, String> contentDetails) {

        PackageBits bits = null;
        PackageBitsBlob blob = null;

        // The blob cannot be updated, so we'll need to create a whole new row.
        if (null != existingBits) {
            blob = entityManager.find(PackageBitsBlob.class, existingBits.getId());
            entityManager.remove(blob);
            entityManager.flush();
        }

        // We have to work backwards to avoid constraint violations. PackageBits requires a PackageBitsBlob,
        // so create and persist that first, getting the ID
        blob = new PackageBitsBlob();
        // just set the blob now, no streaming. The assumption is that H2 (demo) will not be using large blobs
        byte[] bytes = StreamUtil.slurp(packageBitStream);
        blob.setBits(bytes);
        entityManager.persist(blob);
        entityManager.flush();

        // Now create the PackageBits entity and assign the Id and blob.  Note, do not persist the
        // entity, the row already exists (due to the blob persist above). Just perform and flush the update.
        bits = new PackageBits();
        bits.setId(blob.getId());
        bits.setBlob(blob);
        entityManager.flush();

        //locate related packageVersion
        PackageVersion pv = entityManager.find(PackageVersion.class, packageVersionId);
View Full Code Here

     *
     * @return
     */
    private PackageBits initializePackageBits(PackageBits bits) {
        if (null == bits) {
            PackageBitsBlob blob = null;

            // We have to work backwards to avoid constraint violations. PackageBits requires a PackageBitsBlob,
            // so create and persist that first, getting the ID
            blob = new PackageBitsBlob();
            blob.setBits(PackageBits.EMPTY_BLOB.getBytes());
            entityManager.persist(blob);

            // Now create the PackageBits entity and assign the Id and blob.  Note, do not persist the
            // entity, the row already exists. Just perform and flush the update.
            bits = new PackageBits();
            bits.setId(blob.getId());
            bits.setBlob(blob);
        } else {
            PackageBitsBlob blob = entityManager.find(PackageBitsBlob.class, bits.getId());
            // don't bother testing for null, that may pull a large blob, just make sure it's not null
            blob.setBits(PackageBits.EMPTY_BLOB.getBytes());
        }

        // write to the db and return the new PackageBits and associated PackageBitsBlob
        entityManager.flush();
        return bits;
View Full Code Here

        bits = initializePackageBits(bits);

        //locate the existing PackageBitsBlob instance
        bits = entityManager.find(PackageBits.class, bits.getId());
        PackageBitsBlob blob = bits.getBlob();

        //Create prepared statements to work with Blobs and hibernate.
        Connection conn = null;
        PreparedStatement ps = null;
        PreparedStatement ps2 = null;
View Full Code Here

        when(mockEntityManager.find(eq(PackageVersion.class), anyInt())).thenReturn(mockPackageVersion);
        when(mockPackageVersion.getGeneralPackage()).thenReturn(mockPackage);
        when(mockPackageVersion.getArchitecture()).thenReturn(mockArchitecture);

        PackageBitsBlob mockPackageBitsBlob = mock(PackageBitsBlob.class);
        when(mockEntityManager.find(eq(PackageBitsBlob.class), anyInt())).thenReturn(mockPackageBitsBlob);

        PackageBits mockBits = mock(PackageBits.class);
        when(mockEntityManager.find(eq(PackageBits.class), anyInt())).thenReturn(mockBits);
View Full Code Here

        }
    }

    private PackageBits createPackageBits(EntityManager em) {
        PackageBits bits = null;
        PackageBitsBlob blob = null;

        // We have to work backwards to avoid constraint violations. PackageBits requires a PackageBitsBlob,
        // so create and persist that first, getting the ID
        blob = new PackageBitsBlob();
        em.persist(blob);

        // Now create the PackageBits entity and assign the Id and blob.  Note, do not persist the
        // entity, the row already exists. Just perform and flush the update.
        bits = new PackageBits();
        bits.setId(blob.getId());
        bits.setBlob(blob);
        em.flush();

        // return the new PackageBits and associated PackageBitsBlob
        return bits;
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.content.PackageBitsBlob

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.