Examples of PackageBits


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

        newPackageVersion.setDisplayName(existingPackage.getName());

        newPackageVersion = persistOrMergePackageVersionSafely(newPackageVersion);

        Map<String, String> contentDetails = new HashMap<String, String>();
        PackageBits bits = loadPackageBits(packageBitStream, newPackageVersion.getId(), packageName, version, null,
            contentDetails);

        newPackageVersion.setPackageBits(bits);
        newPackageVersion.setFileSize(Long.valueOf(contentDetails.get(UPLOAD_FILE_SIZE)).longValue());
        newPackageVersion.setSHA256(contentDetails.get(UPLOAD_SHA256));
View Full Code Here

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

            entityManager.persist(packageVersion);
        }

        //get the data
        Map<String, String> contentDetails = new HashMap<String, String>();
        PackageBits bits = loadPackageBits(packageBitStream, packageVersion.getId(), packageName, version, null,
            contentDetails);

        packageVersion.setPackageBits(bits);

        packageVersion.setFileSize(Long.valueOf(contentDetails.get(UPLOAD_FILE_SIZE)).longValue());
View Full Code Here

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

            return loadPackageBitsH2(packageBitStream, packageVersionId, packageName, packageVersion, existingBits,
                contentDetails);
        }

        // use existing or instantiate PackageBits instance.
        PackageBits bits = (null == existingBits) ? initializePackageBits(null) : existingBits;

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

        //associate the two if located.
View Full Code Here

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

    }

    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

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

            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
View Full Code Here

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

        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);

        DataSource mockDataSource = mock(DataSource.class);
        Connection mockConnection = mock(Connection.class);
        when(mockDataSource.getConnection()).thenReturn(mockConnection);
View Full Code Here

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

            Resource resource = new Resource("testPVCSResource", "testPVCSResource", rt);
            resource.setUuid("" + new Random().nextInt());
            Architecture arch = new Architecture("testPVCSInsertArch");
            PackageType pt = new PackageType("testPVCSInsertPT", resource.getResourceType());
            Package pkg = new Package("testPVCSInsertPackage", pt);
            PackageBits bits = createPackageBits(em);
            PackageVersion pv = new PackageVersion(pkg, "version", arch);
            ContentSourceType cst = new ContentSourceType("testPVCSContentSourceType");
            ContentSource cs = new ContentSource("testPVCSContentSource", cst);
            PackageVersionContentSource pvcs = new PackageVersionContentSource(pv, cs, "fooLocation");

            Configuration csConfig = new Configuration();
            csConfig.put(new PropertySimple("csConfig1", "csConfig1Value"));
            cs.setConfiguration(csConfig);

            Configuration pvConfig = new Configuration();
            pvConfig.put(new PropertySimple("pvConfig1", "pvConfig1Value"));
            pv.setExtraProperties(pvConfig);

            bits.getBlob().setBits("testDeleteOrphanedPV".getBytes());
            pv.setPackageBits(bits);

            em.persist(rt);
            em.persist(resource);
            em.persist(arch);
            em.persist(pt);
            em.persist(pkg);
            em.persist(pv);
            em.persist(cst);
            em.persist(cs);
            em.persist(pvcs);
            em.flush();
            em.clear();

            PackageVersionContentSourcePK pk = new PackageVersionContentSourcePK(pv, cs);
            PackageVersionContentSource pvcsDup = em.find(PackageVersionContentSource.class, pk);
            em.clear();

            assert pvcsDup != null;
            assert pvcsDup.equals(pvcs);
            assert pvcsDup.getLocation().equals("fooLocation");

            Query q = em.createNamedQuery(PackageVersionContentSource.DELETE_BY_CONTENT_SOURCE_ID);
            q.setParameter("contentSourceId", cs.getId());
            assert 1 == q.executeUpdate();
            em.clear();

            PackageBits findBits = em.find(PackageBits.class, bits.getId());
            assert findBits != null : "The bits did not cascade-persist for some reason";
            assert findBits.getId() > 0 : "The package bits did not cascade-persist for some reason!";
            assert new String(bits.getBlob().getBits()).equals(new String(findBits.getBlob().getBits()));

            q = em.createNamedQuery(PackageVersion.DELETE_IF_NO_CONTENT_SOURCES_OR_REPOS);
            assert 1 == q.executeUpdate();
            em.clear();
View Full Code Here

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

            getTransactionManager().rollback();
        }
    }

    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
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.