Package org.springframework.roo.addon.roobot.client.model

Examples of org.springframework.roo.addon.roobot.client.model.Bundle


            final String optionContext, final MethodTarget target) {
        final Map<String, Bundle> bundles = addonManagerOperations
                .getAddOnCache(false);
        for (final Entry<String, Bundle> entry : bundles.entrySet()) {
            final String bsn = entry.getKey();
            final Bundle bundle = entry.getValue();
            if (bundle.getVersions().size() > 1) {
                for (final BundleVersion bundleVersion : bundle.getVersions()) {
                    completions.add(new Completion(bsn + ";"
                            + bundleVersion.getVersion()));
                }
            }
            completions.add(new Completion(bsn));
View Full Code Here


        synchronized (mutex) {
            String bsnString = bsn.getKey();
            if (bsnString.contains(";")) {
                bsnString = bsnString.split(";")[0];
            }
            final Bundle bundle = bundleCache.get(bsnString);
            if (bundle == null) {
                LOGGER.warning("Unable to find specified bundle with symbolic name: "
                        + bsn.getKey());
                return;
            }
            addOnInfo(bundle, bundle.getBundleVersion(bsn.getKey()));
        }
    }
View Full Code Here

    }

    public void addOnInfo(final String bundleKey) {
        Validate.notBlank(bundleKey, "A valid bundle ID is required");
        synchronized (mutex) {
            Bundle bundle = null;
            if (searchResultCache != null) {
                bundle = searchResultCache.get(String.format("%02d",
                        Integer.parseInt(bundleKey)));
            }
            if (bundle == null) {
                LOGGER.warning("A valid bundle ID is required");
                return;
            }
            addOnInfo(bundle, bundle.getBundleVersion(bundleKey));
        }
    }
View Full Code Here

            return bundles;
        }
        final BundleContext bundleContext = context.getBundleContext();
        for (final org.osgi.framework.Bundle bundle : bundleContext
                .getBundles()) {
            final Bundle b = bundleCache.get(bundle.getSymbolicName());
            if (b == null) {
                continue;
            }
            final BundleVersion bundleVersion = b.getLatestVersion();
            final String rooBotBundleVersion = bundleVersion.getVersion();
            final Object ebv = bundle.getHeaders().get("Bundle-Version");
            if (ebv == null) {
                continue;
            }
            final String exisingBundleVersion = ebv.toString().trim();
            if (isCompatible(b.getLatestVersion().getRooVersion())
                    && rooBotBundleVersion
                            .compareToIgnoreCase(exisingBundleVersion) > 0
                    && asl.getLevel() > AddOnStabilityLevel
                            .getAddOnStabilityLevel(exisingBundleVersion)) {

                bundles.put(b.getSymbolicName() + ";" + exisingBundleVersion, b);
            }
        }
        return bundles;
    }
View Full Code Here

                    "A valid add-on bundle symbolic name is required");
            String bsnString = bsn.getKey();
            if (bsnString.contains(";")) {
                bsnString = bsnString.split(";")[0];
            }
            final Bundle bundle = bundleCache.get(bsnString);
            if (bundle == null) {
                LOGGER.warning("Could not find specified bundle with symbolic name: "
                        + bsn.getKey());
                return InstallOrUpgradeStatus.FAILED;
            }
            return installAddon(bundle.getBundleVersion(bsn.getKey()),
                    bsn.getKey());
        }
    }
View Full Code Here

    }

    public InstallOrUpgradeStatus installAddOn(final String bundleKey) {
        synchronized (mutex) {
            Validate.notBlank(bundleKey, "A valid bundle ID is required");
            Bundle bundle = null;
            if (searchResultCache != null) {
                bundle = searchResultCache.get(String.format("%02d",
                        Integer.parseInt(bundleKey)));
            }
            if (bundle == null) {
                LOGGER.warning("To install an addon a valid bundle ID is required");
                return InstallOrUpgradeStatus.FAILED;
            }
            return installAddon(bundle.getBundleVersion(bundleKey),
                    bundle.getSymbolicName());
        }
    }
View Full Code Here

                comments.add(new Comment(Rating.fromInt(new Integer(
                        commentElement.getAttribute("rating"))), commentElement
                        .getAttribute("comment"), dateFormat
                        .parse(commentElement.getAttribute("date"))));
            }
            final Bundle bundle = new Bundle(bundleElement.getAttribute("bsn"),
                    new Float(bundleElement.getAttribute("uaa-ranking")),
                    comments);
            for (final Element versionElement : XmlUtils.findElements(
                    "versions/version", bundleElement)) {
                if (bsn != null && bsn.length() > 0 && versionElement != null) {
                    String signedBy = "";
                    final String pgpKey = versionElement
                            .getAttribute("pgp-key-id");
                    if (pgpKey != null && pgpKey.length() > 0) {
                        final Element pgpSigned = XmlUtils.findFirstElement(
                                "/roobot/pgp-keys/pgp-key[@id='" + pgpKey
                                        + "']/pgp-key-description",
                                roobotXml.getDocumentElement());
                        if (pgpSigned != null) {
                            signedBy = pgpSigned.getAttribute("text");
                        }
                    }

                    final Map<String, String> commands = new HashMap<String, String>();
                    for (final Element shell : XmlUtils.findElements(
                            "shell-commands/shell-command", versionElement)) {
                        commands.put(shell.getAttribute("command"),
                                shell.getAttribute("help"));
                    }

                    final StringBuilder versionBuilder = new StringBuilder();
                    versionBuilder.append(versionElement.getAttribute("major"))
                            .append(".")
                            .append(versionElement.getAttribute("minor"));
                    final String versionMicro = versionElement
                            .getAttribute("micro");
                    if (versionMicro != null && versionMicro.length() > 0) {
                        versionBuilder.append(".").append(versionMicro);
                    }
                    final String versionQualifier = versionElement
                            .getAttribute("qualifier");
                    if (versionQualifier != null
                            && versionQualifier.length() > 0) {
                        versionBuilder.append(".").append(versionQualifier);
                    }

                    String rooVersion = versionElement
                            .getAttribute("roo-version");
                    if (rooVersion.equals("*") || rooVersion.length() == 0) {
                        rooVersion = getVersionForCompatibility();
                    }
                    else {
                        final String[] split = rooVersion.split("\\.");
                        if (split.length > 2) {
                            // Only interested in major.minor
                            rooVersion = split[0] + "." + split[1];
                        }
                    }
                    final BundleVersion version = new BundleVersion(
                            versionElement.getAttribute("url"),
                            versionElement.getAttribute("obr-url"),
                            versionBuilder.toString(),
                            versionElement.getAttribute("name"),
                            new Long(versionElement.getAttribute("size"))
                                    .longValue(),
                            versionElement.getAttribute("description"), pgpKey,
                            signedBy, rooVersion, commands);
                    // For security reasons we ONLY accept httppgp://
                    // add-on versions
                    if (!version.getUri().startsWith("httppgp://")) {
                        continue;
                    }
                    bundle.addVersion(version);
                }
                bundleCache.put(bsn, bundle);
            }
        }
    }
View Full Code Here

                    "A valid add-on bundle symbolic name is required");
            String bsnString = bsn.getKey();
            if (bsnString.contains(";")) {
                bsnString = bsnString.split(";")[0];
            }
            final Bundle bundle = bundleCache.get(bsnString);
            if (bundle == null) {
                LOGGER.warning("Could not find specified bundle with symbolic name: "
                        + bsn.getKey());
                return InstallOrUpgradeStatus.FAILED;
            }
            final BundleVersion bundleVersion = bundle.getBundleVersion(bsn
                    .getKey());
            final InstallOrUpgradeStatus status = installOrUpgradeAddOn(
                    bundleVersion, bsn.getKey(), false);
            if (status.equals(InstallOrUpgradeStatus.SUCCESS)) {
                LOGGER.info("Successfully upgraded: "
                        + bundle.getSymbolicName() + " [version: "
                        + bundleVersion.getVersion() + "]");
                LOGGER.warning("Please restart the Roo shell to complete the upgrade");
            }
            else if (status.equals(InstallOrUpgradeStatus.FAILED)) {
                LOGGER.warning("Unable to upgrade: " + bundle.getSymbolicName()
                        + " [version: " + bundleVersion.getVersion() + "]");
            }
            return status;
        }
    }
View Full Code Here

    }

    public InstallOrUpgradeStatus upgradeAddOn(final String bundleId) {
        synchronized (mutex) {
            Validate.notBlank(bundleId, "A valid bundle ID is required");
            Bundle bundle = null;
            if (searchResultCache != null) {
                bundle = searchResultCache.get(String.format("%02d",
                        Integer.parseInt(bundleId)));
            }
            if (bundle == null) {
                LOGGER.warning("A valid bundle ID is required");
                return InstallOrUpgradeStatus.FAILED;
            }
            final BundleVersion bundleVersion = bundle
                    .getBundleVersion(bundleId);
            final InstallOrUpgradeStatus status = installOrUpgradeAddOn(
                    bundleVersion, bundle.getSymbolicName(), false);
            if (status.equals(InstallOrUpgradeStatus.SUCCESS)) {
                LOGGER.info("Successfully upgraded: "
                        + bundle.getSymbolicName() + " [version: "
                        + bundleVersion.getVersion() + "]");
                LOGGER.warning("Please restart the Roo shell to complete the upgrade");
            }
            else if (status.equals(InstallOrUpgradeStatus.FAILED)) {
                LOGGER.warning("Unable to upgrade: " + bundle.getSymbolicName()
                        + " [version: " + bundleVersion.getVersion() + "]");
            }
            return status;
        }
    }
View Full Code Here

  }
 
  public InstallOrUpgradeStatus installOrUpgradeAddOn(PluginVersion pluginVersion, boolean install) {
    synchronized (mutex) {
    BundleVersion bundleVersion = ((RooAddOnVersion)pluginVersion).getBundleVersion();
    Bundle bundle = ((RooAddOnVersion)pluginVersion).getBundle();
    if (!verifyRepository(bundleVersion.getObrUrl())) {
      return InstallOrUpgradeStatus.INVALID_REPOSITORY_URL;
    }
    boolean success = true
    int count = countBundles();
    boolean requiresWrappedCoreDep = bundleVersion.getDescription().contains("#wrappedCoreDependency");
    if (requiresWrappedCoreDep && !shell.executeCommand("osgi obr url add --url http://spring-roo-repository.springsource.org/repository.xml")) {
      success = false;
    }
    if (!shell.executeCommand("osgi obr url add --url " + bundleVersion.getObrUrl())) {
      success = false;
    }
    if (!shell.executeCommand("osgi obr start --bundleSymbolicName " + bundle.getSymbolicName())) {
      success = false;
    }
    if (!shell.executeCommand("osgi obr url remove --url " + bundleVersion.getObrUrl())) {
      success = false;
    }
View Full Code Here

TOP

Related Classes of org.springframework.roo.addon.roobot.client.model.Bundle

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.