Examples of PluginArtifactType


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

     * @param metadata The data to save.  The contained configId (which must
     *                 be fully resolved) identifies the configuration to save
     *                 this for.
     */
    public void updatePluginMetadata(PluginType metadata) {
        PluginArtifactType instance = metadata.getPluginArtifact().get(0);
        Artifact artifact = toArtifact(instance.getModuleId());
        File dir = writeableRepo.getLocation(artifact);
        if (dir == null) {
            log.error(artifact + " is not installed.");
            throw new IllegalArgumentException(artifact + " is not installed.");
        }
View Full Code Here

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

            for (PluginType metadata : pluginsToInstall.getPlugin()) {
                try {
                    validatePlugin(metadata);
                    verifyPrerequisites(metadata);

                    PluginArtifactType instance = metadata.getPluginArtifact().get(0);

                    if (instance.getModuleId() != null) {
                        metaMap.put(toArtifact(instance.getModuleId()), metadata);
                    }
                    toInstall.add(metadata);
                } catch (MissingDependencyException e) {
                    poller.addSkippedConfigID(e);
                }
            }

            // Step 2: everything is valid, do the installation
            for (PluginType metadata : toInstall) {
                // 2. Unload obsoleted configurations
                PluginArtifactType instance = metadata.getPluginArtifact().get(0);
                List<Artifact> obsoletes = new ArrayList<Artifact>();
                for (ArtifactType obs : instance.getObsoletes()) {
                    Artifact obsolete = toArtifact(obs);
                    Artifact[] list = configManager.getArtifactResolver().queryArtifacts(obsolete);
                    for (Artifact artifact : list) {
                        if (configManager.isLoaded(artifact)) {
                            if (configManager.isRunning(artifact)) {
                                configManager.stopConfiguration(artifact);
                            }
                            configManager.unloadConfiguration(artifact);
                            obsoletes.add(artifact);
                        }
                    }
                }
                // 3. Download the artifact if necessary, and its dependencies
                Set<Artifact> working = new HashSet<Artifact>();
                Stack<Artifact> parentStack = new Stack<Artifact>();
                if (instance.getModuleId() != null) {
                    List<SourceRepository> repos = getRepos(pluginsToInstall, defaultRepository, restrictToDefaultRepository, instance);
                    downloadArtifact(toArtifact(instance.getModuleId()), metaMap, repos,
                            username, password, new ResultsFileWriteMonitor(poller), working, parentStack, false, servers, true);
                } else {
                    List<DependencyType> deps = instance.getDependency();
                    for (DependencyType dep : deps) {
                        Artifact entry = toArtifact(dep);
                        List<SourceRepository> repos = getRepos(pluginsToInstall, defaultRepository, restrictToDefaultRepository, instance);
                        downloadArtifact(entry, metaMap, repos,
                                username, password, new ResultsFileWriteMonitor(poller), working, parentStack, false, servers, dep.isStart());
View Full Code Here

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

                        "Invalid Configuration Archive " + carFile.getAbsolutePath() + " no plugin metadata found");
            }

            // 2. Validate that we can install this
            validatePlugin(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);
                writeableRepo.copyToRepository(carFile, pluginArtifact, monitor);
                installConfigXMLData(pluginArtifact, instance, servers, true);
                if (instance.getCopyFile() != null) {
                    extractPluginFiles(pluginArtifact, data, monitor);
                }
            }

            // 4. Use the standard logic to remove obsoletes, install dependencies, etc.
            //    This will validate all over again (oh, well)
            PluginListType pluginList = new PluginListType();
            pluginList.getPlugin().add(data);
            pluginList.getDefaultRepository().addAll(instance.getSourceRepository());
            install(pluginList, defaultRepository, restrictToDefaultRepository, username, password, poller);
        } catch (Exception e) {
            poller.setFailure(e);
        } finally {
            poller.setFinished();
View Full Code Here

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

     */
    public void validatePlugin(PluginType plugin) throws MissingDependencyException {
        if (plugin.getPluginArtifact().size() != 1) {
            throw new MissingDependencyException("A plugin configuration must include one plugin artifact, not " + plugin.getPluginArtifact().size(), null, (Stack<Artifact>) null);
        }
        PluginArtifactType metadata = plugin.getPluginArtifact().get(0);
        // 1. Check that it's not already installed
        if (metadata.getModuleId() != null) { // that is, it's a real configuration not a plugin list
            Artifact artifact = toArtifact(metadata.getModuleId());
            if (configManager.isInstalled(artifact)) {
                boolean upgrade = false;
                for (ArtifactType obsolete : metadata.getObsoletes()) {
                    Artifact test = toArtifact(obsolete);
                    if (test.matches(artifact)) {
                        upgrade = true;
                        break;
                    }
                }
                if (!upgrade) {
                    log.info("Configuration " + artifact + " is already installed.");
                    throw new MissingDependencyException(
                            "Configuration " + artifact + " is already installed.", toArtifact(metadata.getModuleId()), (Stack<Artifact>) null);
                }
            }
        }

        // 2. Check that we meet the Geronimo, JVM versions
        if (metadata.getGeronimoVersion().size() > 0 && !checkGeronimoVersions(metadata.getGeronimoVersion())) {
            log.error("Cannot install plugin " + toArtifact(metadata.getModuleId()) + " on Geronimo " + serverInfo.getVersion());
            throw new MissingDependencyException(
                    "Cannot install plugin on Geronimo " + serverInfo.getVersion(), toArtifact(metadata.getModuleId()), (Stack<Artifact>) null);
        }
        if (metadata.getJvmVersion().size() > 0 && !checkJVMVersions(metadata.getJvmVersion())) {
            log.error("Cannot install plugin " + toArtifact(metadata.getModuleId()) + " on JVM " + System.getProperty(
                    "java.version"));
            throw new MissingDependencyException(
                    "Cannot install plugin on JVM " + System.getProperty("java.version"), toArtifact(metadata.getModuleId()), (Stack<Artifact>) null);
        }
    }
View Full Code Here

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

    private List<Dependency> getMissingPrerequisites(PluginType plugin) {
        if (plugin.getPluginArtifact().size() != 1) {
            throw new IllegalArgumentException("A plugin configuration must include one plugin artifact, not " + plugin.getPluginArtifact().size());
        }

        PluginArtifactType metadata = plugin.getPluginArtifact().get(0);
        List<PrerequisiteType> prereqs = metadata.getPrerequisite();

        ArrayList<Dependency> missingPrereqs = new ArrayList<Dependency>();
        for (PrerequisiteType prereq : prereqs) {
            Artifact artifact = toArtifact(prereq.getId());
            try {
View Full Code Here

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

    }

    private void verifyPrerequisites(PluginType plugin) throws MissingDependencyException {
        List<Dependency> missingPrereqs = getMissingPrerequisites(plugin);
        if (!missingPrereqs.isEmpty()) {
            PluginArtifactType metadata = plugin.getPluginArtifact().get(0);
            Artifact moduleId = toArtifact(metadata.getModuleId());
            StringBuffer buf = new StringBuffer();
            buf.append(moduleId.toString()).append(" requires ");
            Iterator<Dependency> iter = missingPrereqs.iterator();
            while (iter.hasNext()) {
                buf.append(iter.next().getArtifact().toString());
View Full Code Here

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

            soFar.add(configID);
        }
        // Download and install the main artifact
        boolean pluginWasInstalled = false;
        Artifact[] matches = configManager.getArtifactResolver().queryArtifacts(configID);
        PluginArtifactType instance = null;
        if (matches.length == 0) {
            // not present, needs to be downloaded
            monitor.getResults().setCurrentMessage("Downloading " + configID);
            monitor.getResults().setCurrentFilePercent(-1);
            OpenResult result = null;
            for (SourceRepository repository : repos) {
                result = repository.open(configID, monitor);
                if (result != null) {
                    break;
                }
            }
            if (result == null) {
                throw new IllegalArgumentException("Could not find " + configID + " in any repo");
            }
            // Check if the result is already in server's repository
            if (configManager.getArtifactResolver().queryArtifacts(result.getArtifact()).length > 0) {
                String msg = "Not downloading " + configID + ". Query for " + configID + " resulted in " + result.getArtifact()
                        + " which is already available in server's repository.";
                monitor.getResults().setCurrentMessage(msg);
                log.info(msg);
                result.close();
                return;
            }
            try {
                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.getType() + " hash " + hash.getValue() + " but got " + 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
                    validatePlugin(pluginData);
                    instance = pluginData.getPluginArtifact().get(0);
                }
                monitor.getResults().setCurrentMessage("Copying " + result.getArtifact() + " to the repository");
                result.install(writeableRepo, monitor);
                if (pluginData != null) {
                    installConfigXMLData(result.getArtifact(), instance, servers, loadOverride);
                } else {
                    log.debug("No config XML data to install.");
                }
                if (dependency) {
                    monitor.getResults().addDependencyInstalled(configID);
                    configID = result.getArtifact();
                } else {
                    configID = result.getArtifact();
                    monitor.getResults().addInstalledConfigID(configID);
                }
                pluginWasInstalled = true;
                if (pluginData != null)
                    log.info("Installed plugin with moduleId=" + pluginData.getPluginArtifact().get(0).getModuleId() + " and name=" + pluginData.getName());
                else
                    log.info("Installed artifact=" + configID);
            } catch (InvalidGBeanException e) {
                log.error("Invalid gbean configuration ", e);
                throw new IllegalStateException(
                        "Invalid GBean configuration: " + e.getMessage(), e);

            } 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=" + match + " and it is running.");
                        return; // its dependencies must be OK
                    } else {
                        log.debug("Either required configuration=" + match + " is not installed or it is not running.");
                    }
                }
                // 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) {
                //no plugin metadata, guess with something else
                Dependency[] dependencies = data == null ? getDependencies(writeableRepo, configID) : getDependencies(data);
                for (Dependency dep : dependencies) {
                    Artifact artifact = dep.getArtifact();
                    log.debug("Attempting to download dependency=" + artifact + " for configuration=" + configID);
                    downloadArtifact(artifact, metadata, repos, username, password, monitor, soFar, parentStack, true, servers, loadOverride);
                }
            } else {
                //rely on plugin metadata if present.
                List<DependencyType> deps = instance.getDependency();
                for (DependencyType dep : deps) {
                    Artifact artifact = toArtifact(dep);
                    log.debug("Attempting to download dependency=" + artifact + " for configuration=" + configID);
                    downloadArtifact(artifact, metadata, repos, username, password, monitor, soFar, parentStack, true, servers, loadOverride & dep.isStart());
                }
View Full Code Here

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

            extractPluginFiles(configID, currentPlugin, monitor);
        }
    }

    private void extractPluginFiles(Artifact configID, PluginType currentPlugin, ResultsFileWriteMonitor monitor) throws IOException {
        PluginArtifactType instance = currentPlugin.getPluginArtifact().get(0);
        for (CopyFileType data : instance.getCopyFile()) {
            monitor.getResults().setCurrentFilePercent(-1);
            monitor.getResults().setCurrentFile(data.getValue());
            monitor.getResults().setCurrentMessage("Copying " + data.getValue() + " from plugin to Geronimo installation");
            copyFile(data, configID);
        }
View Full Code Here

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

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

        PluginType meta = new PluginType();
        PluginArtifactType instance = new PluginArtifactType();
        meta.getPluginArtifact().add(instance);
        meta.setName(toArtifactType(moduleId).toString());
        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())));
        List<DependencyType> deps = instance.getDependency();
        addGeronimoDependencies(data, deps, true);
        return meta;
    }
View Full Code Here

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

        assertEquals(1, list.getDefaultRepository().size());
        assertEquals(fakeRepo, list.getDefaultRepository().get(0));
        assertTrue(list.getPlugin().size() > 0);
        int prereqCount = 0;
        for (PluginType metadata: list.getPlugin()) {
            PluginArtifactType instance = metadata.getPluginArtifact().get(0);
            prereqCount += instance.getPrerequisite().size();
//            for (PrerequisiteType prerequisite: instance.getPrerequisite()) {
//                assertFalse(prerequisite.getId());
//            }
        }
        assertTrue(prereqCount > 0);
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.