private boolean updateArtifactInfo()

in indexer-core/src/main/java/org/apache/maven/index/creator/OsgiArtifactIndexCreator.java [415:558]


    private boolean updateArtifactInfo(ArtifactInfo ai, File f) throws IOException {
        boolean updated = false;

        try (ZipFile zipFile = new ZipFile(f)) {
            final Enumeration<? extends ZipEntry> entries = zipFile.entries();

            while (entries.hasMoreElements()) {
                ZipEntry zipEntry = entries.nextElement();

                if (zipEntry.getName().equals("META-INF/MANIFEST.MF")) {
                    Manifest manifest = new Manifest(zipFile.getInputStream(zipEntry));

                    Attributes mainAttributes = manifest.getMainAttributes();

                    if (mainAttributes != null) {
                        String attValue = mainAttributes.getValue(BSN);
                        if (StringUtils.isNotBlank(attValue)) {
                            ai.setBundleSymbolicName(attValue);
                            updated = true;
                        } else {
                            ai.setBundleSymbolicName(null);
                        }

                        attValue = mainAttributes.getValue(BV);
                        if (StringUtils.isNotBlank(attValue)) {
                            ai.setBundleVersion(attValue);
                            updated = true;
                        } else {
                            ai.setBundleVersion(null);
                        }

                        attValue = mainAttributes.getValue(BEP);
                        if (StringUtils.isNotBlank(attValue)) {
                            ai.setBundleExportPackage(attValue);
                            updated = true;
                        } else {
                            ai.setBundleExportPackage(null);
                        }

                        attValue = mainAttributes.getValue(BES);
                        if (StringUtils.isNotBlank(attValue)) {
                            ai.setBundleExportService(attValue);
                            updated = true;
                        } else {
                            ai.setBundleExportService(null);
                        }

                        attValue = mainAttributes.getValue(BD);
                        if (StringUtils.isNotBlank(attValue)) {
                            ai.setBundleDescription(attValue);
                            updated = true;
                        } else {
                            ai.setBundleDescription(null);
                        }

                        attValue = mainAttributes.getValue(BN);
                        if (StringUtils.isNotBlank(attValue)) {
                            ai.setBundleName(attValue);
                            updated = true;
                        } else {
                            ai.setBundleName(null);
                        }

                        attValue = mainAttributes.getValue(BL);
                        if (StringUtils.isNotBlank(attValue)) {
                            ai.setBundleLicense(attValue);
                            updated = true;
                        } else {
                            ai.setBundleLicense(null);
                        }

                        attValue = mainAttributes.getValue(BDU);
                        if (StringUtils.isNotBlank(attValue)) {
                            ai.setBundleDocUrl(attValue);
                            updated = true;
                        } else {
                            ai.setBundleDocUrl(null);
                        }

                        attValue = mainAttributes.getValue(BIP);
                        if (StringUtils.isNotBlank(attValue)) {
                            ai.setBundleImportPackage(attValue);
                            updated = true;
                        } else {
                            ai.setBundleImportPackage(null);
                        }

                        attValue = mainAttributes.getValue(BRB);
                        if (StringUtils.isNotBlank(attValue)) {
                            ai.setBundleRequireBundle(attValue);
                            updated = true;
                        } else {
                            ai.setBundleRequireBundle(null);
                        }

                        attValue = mainAttributes.getValue(PROVIDE_CAPABILITY);
                        if (StringUtils.isNotBlank(attValue)) {
                            ai.setBundleProvideCapability(attValue);
                            updated = true;
                        } else {
                            ai.setBundleProvideCapability(null);
                        }

                        attValue = mainAttributes.getValue(REQUIRE_CAPABILITY);
                        if (StringUtils.isNotBlank(attValue)) {
                            ai.setBundleRequireCapability(attValue);
                            updated = true;
                        } else {
                            ai.setBundleRequireCapability(null);
                        }

                        attValue = mainAttributes.getValue(FRAGMENT_HOST);
                        if (StringUtils.isNotBlank(attValue)) {
                            ai.setBundleFragmentHost(attValue);
                            updated = true;
                        } else {
                            ai.setBundleFragmentHost(null);
                        }

                        attValue = mainAttributes.getValue(BUNDLE_REQUIRED_EXECUTION_ENVIRONMENT);
                        if (StringUtils.isNotBlank(attValue)) {
                            ai.setBundleRequiredExecutionEnvironment(attValue);
                            updated = true;
                        } else {
                            ai.setBundleRequiredExecutionEnvironment(null);
                        }
                    }
                }
            }
        }

        // only calculate sha256 digest for if we are indexing a bundle.
        if (ai.getBundleSymbolicName() != null) {
            String sha256 = computeSha256(f);
            if (sha256 != null) {
                ai.setSha256(sha256);
                updated = true;
            } else {
                ai.setSha256(null);
            }
        }

        return updated;
    }