Package org.apache.geronimo.system.plugin.model

Examples of org.apache.geronimo.system.plugin.model.PluginType


        }
        return copy;
    }

    public static PluginType toKey(PluginType metadata) {
        PluginType copy = new PluginKey();
        copy.setAuthor(metadata.getAuthor());
        copy.setCategory(metadata.getCategory());
        copy.setName(metadata.getName());
        copy.setUrl(metadata.getUrl());
        copy.getLicense().addAll(metadata.getLicense());
        return copy;
    }
View Full Code Here


     */
    public static PluginType loadPluginMetadata(InputStream in) throws SAXException, MalformedURLException, JAXBException, XMLStreamException {
        XMLStreamReader xmlStream = XMLINPUT_FACTORY.createXMLStreamReader(in);
        Unmarshaller unmarshaller = PLUGIN_CONTEXT.createUnmarshaller();
        JAXBElement<PluginType> element = unmarshaller.unmarshal(xmlStream, PluginType.class);
        PluginType plugin = element.getValue();
        return plugin;
    }
View Full Code Here

     * @param moduleId Identifies the configuration.  This must match a
     *                 configuration currently installed in the local server.
     *                 The configId must be fully resolved (isResolved() == true)
     */
    public PluginType getPluginMetadata(Artifact moduleId) {
        PluginType type = localSourceRepository.extractPluginMetadata(moduleId);
        if (null == type) {
            try {
                type = createDefaultMetadata(moduleId);
            } catch (InvalidConfigException e) {
                log.warn("Unable to generate metadata for " + moduleId, e);
View Full Code Here

     * @param poller                      monitor for reporting progress
     */
    public void install(File carFile, String defaultRepository, boolean restrictToDefaultRepository, String username, String password, DownloadPoller poller) {
        try {
            // 1. Extract the configuration metadata
            PluginType data = GeronimoSourceRepository.extractPluginMetadata(carFile);
            if (data == null) {
                log.error("Invalid Configuration Archive {} no plugin metadata found", carFile.getAbsolutePath());
                throw new IllegalArgumentException(
                        "Invalid Configuration Archive " + carFile.getAbsolutePath() + " no plugin metadata found");
            }

            // 2. Validate that we can install this
            if (!validatePlugin(data)) {
                //already installed
                throw new ConfigurationAlreadyExistsException("Configuration " + toArtifact(data.getPluginArtifact().get(0).getModuleId()) + " is already installed.");
            }

            verifyPrerequisites(data);

            PluginArtifactType instance = data.getPluginArtifact().get(0);
            // 3. Install the CAR into the repository (it shouldn't be re-downloaded)
            if (instance.getModuleId() != null) {
                Artifact pluginArtifact = toArtifact(instance.getModuleId());
                ResultsFileWriteMonitor monitor = new ResultsFileWriteMonitor(poller, log);
                writeableRepo.copyToRepository(carFile, pluginArtifact, monitor);
View Full Code Here

                File tempFile = result.getFile();
                if (tempFile == null) {
                    log.error("Null filehandle was returned for " + configID);
                    throw new IllegalArgumentException("Null filehandle was returned for " + configID);
                }
                PluginType pluginData = metadata.get(configID);
                // Only bother with the hash if we got it from a source other than the download file itself
                HashType hash = pluginData == null ? null : pluginData.getPluginArtifact().get(0).getHash();
                if (hash != null) {
                    String actual = ConfigurationStoreUtil.getActualChecksum(tempFile, hash.getType());
                    if (!actual.equals(hash.getValue())) {
                        log.error("File download incorrect (expected {} hash {} but got {})", new String[]{hash.getType(), hash.getValue(), actual});
                        throw new IOException("File download incorrect (expected " + hash.getType() + " hash " + hash.getValue() + " but got " + actual + ")");
                    }
                }
                // See if the download file has plugin metadata and use it in preference to what is in the catalog.
                try {
                    PluginType realPluginData = GeronimoSourceRepository.extractPluginMetadata(tempFile);
                    if (realPluginData != null) {
                        pluginData = realPluginData;
                    }
                } catch (Exception e) {
                    log.error("Unable to read plugin metadata: {}", e.getMessage());
                    throw (IOException) new IOException("Unable to read plugin metadata: " + e.getMessage()).initCause(e);
                }
                if (pluginData != null) { // it's a plugin, not a plain JAR
                    if (!validatePlugin(pluginData)) {
                        monitor.getResults().addSkippedConfigID(new MissingDependencyException("already installed", configID, (Stack<Artifact>)null));
                        return;
                    }
                    instance = pluginData.getPluginArtifact().get(0);
                }
                monitor.getResults().setCurrentMessage("Copying " + result.getArtifact() + " to the repository");
                result.install(writeableRepo, monitor);
                if (dependency) {
                    monitor.getResults().addDependencyInstalled(configID);
                    configID = result.getArtifact();
                } else {
                    configID = result.getArtifact();
                    monitor.getResults().addInstalledConfigID(configID);
                }
                if (pluginData != null) {
                    log.debug("Installed plugin with moduleId={} and name={}", pluginData.getPluginArtifact().get(0).getModuleId(), pluginData.getName());
                } else {
                    log.debug("Installed artifact={}", configID);
                }
            } finally {
                //todo probably not needede
                result.close();
            }
        } else {
            if (dependency) {
                monitor.getResults().addDependencyPresent(configID);
            } else {
                monitor.getResults().addInstalledConfigID(configID);
            }
        }
        // Download and install the dependencies
        try {
            if (!configID.isResolved()) {
                // See if something's running
                for (int i = matches.length - 1; i >= 0; i--) {
                    Artifact match = matches[i];
                    if (configStore.containsConfiguration(match) && configManager.isRunning(match)) {
                        log.debug("Found required configuration={} and it is running", match);
                        return; // its dependencies must be OK
                    } else {
                        log.debug("Either required configuration={} is not installed or it is not running", match);
                    }
                }
                // Go with something that's installed
                configID = matches[matches.length - 1];
            }
            ConfigurationData data = null;
            if (configStore.containsConfiguration(configID)) {
                if (configManager.isRunning(configID)) {
                    return; // its dependencies must be OK
                }
                log.debug("Loading configuration={}", configID);
                data = configStore.loadConfiguration(configID);
            }
            // Download the dependencies
            parentStack.push(configID);
            if (instance == null) {
                PluginType currentPlugin = getPluginMetadata(configID);
                if (currentPlugin != null) {
                    instance = currentPlugin.getPluginArtifact().get(0);
                }
            }
            if (instance == null) {
                //no plugin metadata, guess with something else
                Dependency[] dependencies = data == null ? getDependencies(writeableRepo, configID) : getDependencies(data);
View Full Code Here

                return null;
            }
        }
        ConfigurationData data = configStore.loadConfiguration(moduleId);

        PluginType meta = new PluginType();
        PluginArtifactType instance = new PluginArtifactType();
        meta.getPluginArtifact().add(instance);
        meta.setName(toArtifactType(moduleId).getArtifactId());
        instance.setModuleId(toArtifactType(moduleId));
        meta.setCategory("Unknown");
        instance.getGeronimoVersion().add(serverInfo.getVersion());
        instance.getObsoletes().add(toArtifactType(new Artifact(moduleId.getGroupId(),
                moduleId.getArtifactId(),
                (Version) null,
                moduleId.getType())));
View Full Code Here

        artifact.setType(id.getType());
        return artifact;
    }

    public static PluginType copy(PluginType metadata, PluginArtifactType instance) {
        PluginType copy = new PluginType();
        copy.setAuthor(metadata.getAuthor());
        copy.setCategory(metadata.getCategory());
        copy.setPluginGroup(metadata.isPluginGroup() == null ? false : metadata.isPluginGroup());
        copy.setDescription(metadata.getDescription());
        copy.setName(metadata.getName());
        copy.setUrl(metadata.getUrl());
        copy.getLicense().addAll(metadata.getLicense());
        if (instance != null) {
            copy.getPluginArtifact().add(instance);
        }
        return copy;
    }
View Full Code Here

       
        // let's add framework plugin group manually so that users can choose it
        for (PluginType metadata : data.getPlugin()) {
            for (PluginArtifactType testInstance : metadata.getPluginArtifact()) {
                if (PluginInstallerGBean.toArtifact(testInstance.getModuleId()).toString().indexOf("plugingroups/framework") > 0) {
                    PluginType plugin = PluginInstallerGBean.copy(metadata, testInstance);
                    appPlugin.getPlugin().add(plugin);
                    break;
                }
            }
        }
View Full Code Here

            Collection<PluginType> items = entry.getValue();
            consoleReader.printString(category);
            consoleReader.printNewline();
            for (PluginType metadata : items) {
                for (PluginArtifactType instance : metadata.getPluginArtifact()) {
                    PluginType copy = PluginInstallerGBean.copy(metadata, instance);
                    available.add(copy);
                    DeployUtils.printTo("  " + available.size() + ":  ", 10, consoleReader);
                    DeployUtils.println(metadata.getName() + " (" + instance.getModuleId().getVersion() + ")", 0, consoleReader);
                }
            }
        }
        if (available.size() == 0) {
            consoleReader.printNewline();
            consoleReader.printString("No plugins from this site are eligible for installation.");
            consoleReader.printNewline();
            return null;
        }
        consoleReader.printNewline();
        consoleReader.flushConsole();
        String answer = consoleReader.readLine("Install Services [enter a comma separated list of numbers or 'q' to quit]: ").trim();
        if (answer.equalsIgnoreCase("q")) {
            return null;
        }
        PluginListType list = new PluginListType();
        for (String instance : answer.split(",")) {
            int selection = Integer.parseInt(instance.trim());
            PluginType target = available.get(selection - 1);
            list.getPlugin().add(target);
        }
       
        if (repo != null) {
            list.getDefaultRepository().add(repo);
View Full Code Here

    }

    private static PluginListType getPluginsFromIds(List<String> configIds, PluginListType list) throws IllegalStateException {
        PluginListType installList = new PluginListType();
        for (String configId : configIds) {
            PluginType plugin = null;
            for (PluginType metadata : list.getPlugin()) {
                for (PluginArtifactType testInstance : metadata.getPluginArtifact()) {
                    if (PluginInstallerGBean.toArtifact(testInstance.getModuleId()).toString().equals(configId)) {
                        plugin = PluginInstallerGBean.copy(metadata, testInstance);
                        installList.getPlugin().add(plugin);
View Full Code Here

TOP

Related Classes of org.apache.geronimo.system.plugin.model.PluginType

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.