Package org.rhq.core.domain.content

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


    @RequiredPermission(Permission.MANAGE_REPOSITORIES)
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    @TransactionTimeout(90 * 60)
    public PackageBits downloadPackageBits(Subject subject, PackageVersionContentSource pvcs) {
        PackageVersionContentSourcePK pk = pvcs.getPackageVersionContentSourcePK();
        int contentSourceId = pk.getContentSource().getId();
        int packageVersionId = pk.getPackageVersion().getId();
        String packageVersionLocation = pvcs.getLocation();

        switch (pk.getContentSource().getDownloadMode()) {
        case NEVER: {
            return null; // no-op, our content source was told to never download package bits
        }

        case DATABASE: {
            log.debug("Downloading package bits to DB for package located at [" + packageVersionLocation
                + "] on content source [" + contentSourceId + "]");
            break;
        }

        case FILESYSTEM: {
            log.debug("Downloading package bits to filesystem for package located at [" + packageVersionLocation
                + "] on content source [" + contentSourceId + "]");
            break;
        }

        default: {
            throw new IllegalStateException(" Unknown download mode - this is a bug, please report it: " + pvcs);
        }
        }

        InputStream bitsStream = null;
        PackageBits packageBits = null;

        try {
            ContentServerPluginContainer pc = ContentManagerHelper.getPluginContainer();
            bitsStream = pc.getAdapterManager().loadPackageBits(contentSourceId, packageVersionLocation);

            Connection conn = null;
            PreparedStatement ps = null;
            PreparedStatement ps2 = null;
            try {
                packageBits = createPackageBits(pk.getContentSource().getDownloadMode() == DownloadMode.DATABASE);

                PackageVersion pv = entityManager.find(PackageVersion.class, packageVersionId);
                pv.setPackageBits(packageBits); // associate the entities
                entityManager.flush(); // may not be necessary

                if (pk.getContentSource().getDownloadMode() == DownloadMode.DATABASE) {
                    conn = dataSource.getConnection();
                    // The blob has been initialized to EMPTY_BLOB already by createPackageBits...
                    // we need to lock the row which will be updated so we are using FOR UPDATE
                    ps = conn.prepareStatement("SELECT BITS FROM " + PackageBits.TABLE_NAME
                        + " WHERE ID = ? FOR UPDATE");
View Full Code Here


        // Download the bits for each unloaded package version. Abort the entire download if we
        // fail getting just one package.

        // Note: This can potentially take a very long time.
        for (PackageVersionContentSource item : packageVersionContentSources) {
            PackageVersionContentSourcePK pk = item.getPackageVersionContentSourcePK();

            try {
                log.info("Downloading package version [" + pk.getPackageVersion() + "] located at ["
                    + item.getLocation() + "]" + "] from [" + pk.getContentSource() + "]...");

                tracker.getRepoSyncResults().appendResults(
                    "Downloading package version [" + pk.getPackageVersion() + "] located at [" + item.getLocation()
                        + "]");
                tracker.setRepoSyncResults(repoManager.mergeRepoSyncResults(tracker.getRepoSyncResults()));

                overlord = subjectManager.getOverlord();
                contentSourceManager.downloadPackageBits(overlord, item);

                // Tick off each package as completed work
                tracker.getProgressWatcher().finishWork(sw.getPackageBitsWeight() * 1);
                tracker.getRepoSyncResults().setPercentComplete(
                    new Long(tracker.getProgressWatcher().getPercentComplete()));
                tracker.setRepoSyncResults(repoManager.mergeRepoSyncResults(tracker.getRepoSyncResults()));
            } catch (Exception e) {
                String errorMsg = "Failed to load package bits for package version [" + pk.getPackageVersion()
                    + "] from content source [" + pk.getContentSource() + "] at location [" + item.getLocation() + "]."
                    + "No more packages will be downloaded for this content source.";
                throw new SyncException(errorMsg, e);
            }
        }

View Full Code Here

        // return the new PackageBits and associated PackageBitsBlob
        return bits;
    }

    private InputStream preloadPackageBits(PackageVersionContentSource pvcs) throws Exception {
        PackageVersionContentSourcePK pk = pvcs.getPackageVersionContentSourcePK();
        int contentSourceId = pk.getContentSource().getId();
        int packageVersionId = pk.getPackageVersion().getId();
        String packageVersionLocation = pvcs.getLocation();

        ContentServerPluginContainer pc = ContentManagerHelper.getPluginContainer();
        InputStream bitsStream = pc.getAdapterManager().loadPackageBits(contentSourceId, packageVersionLocation);

        PackageVersion pv = entityManager.find(PackageVersion.class, packageVersionId);

        switch (pk.getContentSource().getDownloadMode()) {
        case NEVER: {
            return null; // no-op, our content source was told to never download package bits
        }

        case DATABASE: {
View Full Code Here

    //       refactored.  Also *** the transactional decls below are not being honored because the method
    //       is not being called through the Local, so not establishing a new transactional context.
    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    @TransactionTimeout(40 * 60)
    private PackageBits preparePackageBits(Subject subject, InputStream bitsStream, PackageVersionContentSource pvcs) {
        PackageVersionContentSourcePK pk = pvcs.getPackageVersionContentSourcePK();
        int contentSourceId = pk.getContentSource().getId();
        int packageVersionId = pk.getPackageVersion().getId();
        String packageVersionLocation = pvcs.getLocation();

        PackageBits packageBits = null;

        try {

            Connection conn = null;
            PreparedStatement ps = null;
            PreparedStatement ps2 = null;
            try {
                packageBits = createPackageBits(pk.getContentSource().getDownloadMode() == DownloadMode.DATABASE);

                PackageVersion pv = entityManager.find(PackageVersion.class, packageVersionId);
                pv.setPackageBits(packageBits); // associate entities
                entityManager.flush(); // not sure this is necessary

                if (pk.getContentSource().getDownloadMode() == DownloadMode.DATABASE) {
                    packageBits = entityManager.find(PackageBits.class, packageBits.getId());

                    conn = dataSource.getConnection();
                    //we are loading the PackageBits saved in the previous step
                    //we need to lock the row which will be updated so we are using FOR UPDATE
View Full Code Here

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

            PackageVersionContentSourcePK pkDup = pvcsDup.getPackageVersionContentSourcePK();
            assert pkDup.getContentSource().getName().equals("testPVCSContentSource");
            assert pkDup.getPackageVersion().getGeneralPackage().getName().equals("testPVCSInsertPackage");

            Query q = em.createNamedQuery(PackageVersionContentSource.QUERY_FIND_BY_CONTENT_SOURCE_ID);
            q.setParameter("id", cs.getId());
            List<PackageVersionContentSource> allPvcs = q.getResultList();
View Full Code Here

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

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

TOP

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

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.