Package org.rhq.enterprise.server.bundle

Examples of org.rhq.enterprise.server.bundle.RecipeParseResults


            throw new IllegalArgumentException("distributionFile == null");
        }

        String fileName = null;
        String recipe = null;
        RecipeParseResults parseResults = null;

        FileInputStream in = new FileInputStream(distributionFile);
        try {
            PatchInfo patchInfo = PatchParser.parse(in, true);

            if (patchInfo == null) {
                throw new UnknownRecipeException();
            }

            if (patchInfo.is(Patch.class)) {
                Patch patch = patchInfo.as(Patch.class);

                String version = patch.getType() == Patch.Type.ONE_OFF ? patch.getTargetVersion() + "+" + patch.getId()
                    : patch.getTargetVersion();

                DeploymentProperties props = new DeploymentProperties(0, patch.getIdentityName(),
                    version, patch.getDescription(), DestinationComplianceMode.full);

                ConfigurationDefinition config = new ConfigurationDefinition("wildfly-patch", null);
                PropertyDefinitionSimple patchIdProp = new PropertyDefinitionSimple("patchId", "The ID of the patch",
                    true,
                    PropertySimpleType.STRING);
                patchIdProp.setDefaultValue(patch.getId());
                patchIdProp.setReadOnly(true);
                PropertyDefinitionSimple patchTypeProp = new PropertyDefinitionSimple("patchType",
                    "The type of the patch",
                    true, PropertySimpleType.STRING);
                patchTypeProp.setDefaultValue(patch.getType().toString());
                patchTypeProp.setReadOnly(true);

                config.put(patchIdProp);
                config.put(patchTypeProp);
                addCommonProperties(config);

                parseResults = new RecipeParseResults(props, config, null);
                fileName = patch.getId();
                recipe = patch.getContents();
            } else if (patchInfo.is(PatchBundle.class)) {
                PatchBundle patchBundle = patchInfo.as(PatchBundle.class);

                Patch lastPatch = null;
                StringBuilder allPatchIds = new StringBuilder();

                for (PatchBundle.Element p : patchBundle) {
                    lastPatch = p.getPatch();
                    allPatchIds.append(p.getPatch().getId()).append("#");
                }
                allPatchIds.replace(allPatchIds.length() - 1, allPatchIds.length(), "");

                if (lastPatch == null) {
                    throw new UnknownRecipeException("Not a Wildfly patch");
                }

                DeploymentProperties props = new DeploymentProperties(0, lastPatch.getIdentityName(),
                    lastPatch.getTargetVersion(), lastPatch.getDescription(), DestinationComplianceMode.full);

                ConfigurationDefinition config = new ConfigurationDefinition("wildfly-patch", null);
                PropertyDefinitionSimple allPatchIdsProp = new PropertyDefinitionSimple("allPatchIds",
                    "Hash-separated list of all individual patches the patch bundle is composed of.", true,
                    PropertySimpleType.STRING);
                allPatchIdsProp.setDefaultValue(allPatchIds.toString());
                allPatchIdsProp.setReadOnly(true);
                PropertyDefinitionSimple patchTypeProp = new PropertyDefinitionSimple("patchType",
                    "The type of the patch", true, PropertySimpleType.STRING);
                patchTypeProp.setDefaultValue("patch-bundle");
                patchTypeProp.setReadOnly(true);

                config.put(allPatchIdsProp);
                config.put(patchTypeProp);
                addCommonProperties(config);

                parseResults = new RecipeParseResults(props, config, null);
                fileName = allPatchIds.toString();
                recipe = patchBundle.getContents();
            }
        } finally {
            in.close();
View Full Code Here


        BundleServerPluginFacet facet = (BundleServerPluginFacet) component; // we know this cast will work because our loadPlugin ensured so
        getLog().debug("Bundle server plugin [" + pluginName + "] is parsing a bundle recipe");
        ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(pluginEnv.getPluginClassLoader());
            RecipeParseResults results = facet.parseRecipe(recipe);
            ensureDisplayNameIsSet(results);
            return results;
        } finally {
            Thread.currentThread().setContextClassLoader(originalContextClassLoader);
        }
View Full Code Here

            getLog().debug("Bundle server plugin [" + pluginName + "] is parsing a recipe");
            ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader();
            try {
                Thread.currentThread().setContextClassLoader(env.getPluginClassLoader());
                try {
                    RecipeParseResults results = facet.parseRecipe(recipe);
                    info = new BundleDistributionInfo(recipe, results, null);
                    info.setBundleTypeName(descriptor.getBundle().getType());
                    break;
                } catch (UnknownRecipeException ure) {
                    // the recipe is not a type that the plugin can handle, go on to the next
View Full Code Here

                prop.setDefaultValue(recipeContext.getReplacementVariableDefaultValues().get(replacementVar));
                configDef.put(prop);
            }
        }

        RecipeParseResults results = new RecipeParseResults(bundleMetadata, configDef, bundleFileNames);
        return results;

    }
View Full Code Here

            throw new IllegalArgumentException("distributionFile == null");
        }

        BundleDistributionInfo info = null;
        String recipe = null;
        RecipeParseResults recipeParseResults = null;
        Map<String, File> bundleFiles = null;

        // try and parse the recipe, if successful then process the distributionFile completely
        RecipeVisitor recipeVisitor = new RecipeVisitor(this, "deploy.txt");
        ZipUtil.walkZipFile(distributionFile, recipeVisitor);
        recipe = recipeVisitor.getRecipe();
        recipeParseResults = recipeVisitor.getResults();

        if (null == recipeParseResults) {
            // we also want to support the ability to provide just a file template recipe as the distro file
            // so see if we can parse it, but note that we don't even bother if its a really big file since
            // that's probably not a recipe file and we don't want to risk loading in a huge file in memory
            if (distributionFile.length() < 50000L) {
                byte[] content = StreamUtil.slurp(new FileInputStream(distributionFile));
                recipe = new String(content);
                content = null;
                recipeParseResults = parseRecipe(recipe); // if it isn't a recipe either, this will throw UnknownRecipeException
            } else {
                throw new UnknownRecipeException("Not a File Template Bundle");
            }
        } else {
            // if we parsed the recipe, then this is a distribution zip we can deal with, get the bundle file Map                
            BundleFileVisitor bundleFileVisitor = new BundleFileVisitor(recipeParseResults.getBundleMetadata()
                .getBundleName(), recipeParseResults.getBundleFileNames());
            ZipUtil.walkZipFile(distributionFile, bundleFileVisitor);
            bundleFiles = bundleFileVisitor.getBundleFiles();
        }

        info = new BundleDistributionInfo(recipe, recipeParseResults, bundleFiles);
View Full Code Here

        DeploymentProperties deploymentProps;
        Set<String> bundleFiles;
        ConfigurationDefinition configDef;

        RecipeParseResults results;

        File recipeFile = File.createTempFile("ant-bundle-recipe", ".xml", this.tmpDirectory);
        File logFile = File.createTempFile("ant-bundle-recipe", ".log", this.tmpDirectory);
        try {
            // store the recipe in the tmp recipe file
            ByteArrayInputStream in = new ByteArrayInputStream(recipe.getBytes());
            FileOutputStream out = new FileOutputStream(recipeFile);
            StreamUtil.copy(in, out);

            // parse, but do not execute, the Ant script
            AntLauncher antLauncher = new AntLauncher(true);
            BundleAntProject project = antLauncher.parseBundleDeployFile(recipeFile, null);

            // obtain the parse results
            deploymentProps = new DeploymentProperties(0, project.getBundleName(), project.getBundleVersion(),
                project.getBundleDescription(), project.getDestinationCompliance());

            bundleFiles = project.getBundleFileNames();
            configDef = project.getConfigurationDefinition();
        } catch (Throwable t) {
            if (LOG.isDebugEnabled()) {
                try {
                    LOG.debug(new String(StreamUtil.slurp(new FileInputStream(logFile))));
                } catch (Exception ignore) {
                }
            }
            throw new Exception("Failed to parse the bundle Ant script.", t);
        } finally {
            recipeFile.delete();
            logFile.delete();
        }

        results = new RecipeParseResults(deploymentProps, configDef, bundleFiles);
        return results;
    }
View Full Code Here

        // try and parse the recipe, if successful then process the distributionFile completely
        RecipeVisitor recipeVisitor = new RecipeVisitor(this, "deploy.xml");
        ZipUtil.walkZipFile(distributionFile, recipeVisitor);
        String recipe = recipeVisitor.getRecipe();
        RecipeParseResults recipeParseResults = recipeVisitor.getResults();

        if (null == recipeParseResults) {
            throw new UnknownRecipeException("Not an Ant Bundle");
        }

        // if we parsed the recipe then this is a distribution we can deal with, get the bundle file Map                
        BundleFileVisitor bundleFileVisitor = new BundleFileVisitor(recipeParseResults.getBundleFileNames());
        ZipUtil.walkZipFile(distributionFile, bundleFileVisitor);

        return new BundleDistributionInfo(recipe, recipeParseResults, bundleFileVisitor.getBundleFiles());
    }
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.bundle.RecipeParseResults

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.