Refine search
private static ManifestElement[] parseManifestHeader(String header, Map<String, String> manifest, String bundleLocation) { try { return ManifestElement.parseHeader(header, manifest.get(header)); } catch (BundleException e) { String message = NLS.bind(Messages.exception_errorReadingManifest, bundleLocation, e.getMessage()); LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message, e)); return null; } }
private static void checkExtensionBundle(String headerKey, ManifestElement[] elements) throws BundleException { if (elements.length == 0 || elements[0].getDirective(Constants.EXTENSION_DIRECTIVE) == null) return; String hostName = elements[0].getValue(); // XXX: The extension bundle check is done against system.bundle and org.eclipse.osgi if (!hostName.equals(Constants.SYSTEM_BUNDLE_SYMBOLICNAME) && !hostName.equals(EquinoxContainer.NAME)) { String message = NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, headerKey, elements[0].toString()); throw new BundleException(message + " : " + NLS.bind(StateMsg.HEADER_EXTENSION_ERROR, hostName), BundleException.MANIFEST_ERROR); //$NON-NLS-1$ } }
private void init(ManifestElement manifestElement) { setValueComponents(manifestElement.getValueComponents()); Enumeration attKeys = manifestElement.getKeys(); if (attKeys != null) { while (attKeys.hasMoreElements()) { String attKey = (String)attKeys.nextElement(); String[] values = ManifestElement.getArrayFromList(manifestElement.getAttribute(attKey)); for (int i = 0; i < values.length; i++) addAttribute(attKey, values[i]); } } Enumeration dirKeys = manifestElement.getDirectiveKeys(); if (dirKeys != null) { while (dirKeys.hasMoreElements()) { String dirKey = (String)dirKeys.nextElement(); String[] values = ManifestElement.getArrayFromList(manifestElement.getDirective(dirKey)); for (int i = 0; i < values.length; i++) addDirective(dirKey, values[i]); } } }
private static String getInstallationDirective(String requirementId, ManifestElement[] correspondingBundleHeader) { for (ManifestElement manifestElement : correspondingBundleHeader) { String[] packages = manifestElement.getValueComponents(); for (String pckg : packages) { if (requirementId.equals(pckg)) { return manifestElement.getDirective(INSTALLATION_DIRECTIVE); } } } // TODO this case indicates an internal error -> return assertion error status return null; }
public String getLabel() { String version = underlyingElement.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE); String value = underlyingElement.getValue(); if (version == null) return value; if (Character.isDigit(version.charAt(0))) version = '(' + version + ')'; return value + ' ' + version; } }
private void validateBundleVersionAttribute(IHeader header, ManifestElement element) { String versionRange = element.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE); if (versionRange != null && !VersionUtil.validateVersionRange(versionRange).isOK()) { report(NLS.bind(PDECoreMessages.BundleErrorReporter_InvalidFormatInBundleVersion, element.getValue()), getPackageLine(header, element), CompilerFlags.ERROR, PDEMarkerFactory.CAT_FATAL); } }
private void validateOptionalAttribute(IHeader header, ManifestElement element) { String rexport = element.getAttribute(ICoreConstants.OPTIONAL_ATTRIBUTE); if (rexport != null) { validateBooleanAttributeValue(header, element, ICoreConstants.OPTIONAL_ATTRIBUTE); if (fOsgiR4 && isCheckDeprecated()) { report(NLS.bind(PDECoreMessages.BundleErrorReporter_deprecated_attribute_optional, ICoreConstants.OPTIONAL_ATTRIBUTE), getLine(header, ICoreConstants.OPTIONAL_ATTRIBUTE + "="), //$NON-NLS-1$ CompilerFlags.P_DEPRECATED, PDEMarkerFactory.CAT_DEPRECATION); } } }
private void validateX_FriendsDirective(IHeader header, ManifestElement element) { String friends = element.getDirective(ICoreConstants.FRIENDS_DIRECTIVE); String internal = element.getDirective(ICoreConstants.INTERNAL_DIRECTIVE); if (friends != null && internal != null) { String message = NLS.bind(PDECoreMessages.BundleErrorReporter_directive_hasNoEffectWith_, new String[] {ICoreConstants.FRIENDS_DIRECTIVE, ICoreConstants.INTERNAL_DIRECTIVE}); IMarker marker = report(message, getPackageLine(header, element), CompilerFlags.WARNING, PDEMarkerFactory.M_DIRECTIVE_HAS_NO_EFFECT, PDEMarkerFactory.CAT_OTHER); addMarkerAttribute(marker, "packageName", element.getValue()); //$NON-NLS-1$ } }
private void validateFragmentHost(IHeader requireBundleHeader, ManifestElement element) { IHeader header = getHeader(Constants.FRAGMENT_HOST); if (header == null) return; ManifestElement[] elements = header.getElements(); if (elements[0] != null && elements[0].getValue().equals(element.getValue())) { IMarker marker = report(NLS.bind(PDECoreMessages.BundleErrorReporter_unecessaryDependencyDueToFragmentHost, element.getValue()), getPackageLine(requireBundleHeader, element), CompilerFlags.WARNING, PDEMarkerFactory.M_UNECESSARY_DEP, PDEMarkerFactory.CAT_OTHER); addMarkerAttribute(marker, "bundleId", element.getValue()); //$NON-NLS-1$ } }
private void validateX_InternalDirective(IHeader header, ManifestElement element) { String internal = element.getDirective(ICoreConstants.INTERNAL_DIRECTIVE); if (internal == null) return; for (int i = 0; i < BOOLEAN_VALUES.length; i++) { if (BOOLEAN_VALUES[i].equals(internal)) return; } String message = NLS.bind(PDECoreMessages.BundleErrorReporter_dir_value, (new String[] {internal, ICoreConstants.INTERNAL_DIRECTIVE})); report(message, getPackageLine(header, element), CompilerFlags.ERROR, PDEMarkerFactory.CAT_FATAL); }
public static Headers<String, String> parseManifest(InputStream in) throws BundleException { Headers<String, String> headers = new Headers<String, String>(10); try { ManifestElement.parseBundleManifest(in, headers); } catch (IOException e) { throw new BundleException(Msg.MANIFEST_IOEXCEPTION, BundleException.MANIFEST_ERROR, e); } headers.setReadOnly(); return headers; }
private static BundleSpecification createRequiredBundle(ManifestElement spec) { BundleSpecificationImpl result = new BundleSpecificationImpl(); result.setName(spec.getValue()); result.setVersionRange(getVersionRange(spec.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE))); result.setExported(Constants.VISIBILITY_REEXPORT.equals(spec.getDirective(Constants.VISIBILITY_DIRECTIVE)) || "true".equals(spec.getAttribute(Constants.REPROVIDE_ATTRIBUTE))); //$NON-NLS-1$ result.setOptional(Constants.RESOLUTION_OPTIONAL.equals(spec.getDirective(Constants.RESOLUTION_DIRECTIVE)) || "true".equals(spec.getAttribute(Constants.OPTIONAL_ATTRIBUTE))); //$NON-NLS-1$ result.setAttributes(getAttributes(spec, DEFINED_BSN_MATCHING_ATTRS)); return result; }
private void addSystemCapabilities(List<GenericDescription> capabilities) { for (int i = 0; i < platformProperties.length; i++) try { addSystemCapabilities(capabilities, ManifestElement.parseHeader(Constants.PROVIDE_CAPABILITY, (String) platformProperties[i].get(Constants.FRAMEWORK_SYSTEMCAPABILITIES))); addSystemCapabilities(capabilities, ManifestElement.parseHeader(Constants.PROVIDE_CAPABILITY, (String) platformProperties[i].get(Constants.FRAMEWORK_SYSTEMCAPABILITIES_EXTRA))); } catch (BundleException e) { // TODO consider throwing this... } }
private static Map<String, String> getDirectives(ManifestElement element) { Map<String, String> directives = new HashMap<String, String>(); Enumeration<String> keys = element.getDirectiveKeys(); if (keys == null) return directives; while (keys.hasMoreElements()) { String key = keys.nextElement(); directives.put(key, element.getDirective(key)); } return directives; }
public String toString() { Enumeration<String> attrKeys = getKeys(); Enumeration<String> directiveKeys = getDirectiveKeys(); if (attrKeys == null && directiveKeys == null) return mainValue; StringBuffer result = new StringBuffer(mainValue); if (attrKeys != null) { while (attrKeys.hasMoreElements()) { String key = attrKeys.nextElement(); addValues(false, key, getAttributes(key), result); } } if (directiveKeys != null) { while (directiveKeys.hasMoreElements()) { String key = directiveKeys.nextElement(); addValues(true, key, getDirectives(key), result); } } return result.toString(); }
static void parseSystemCapabilities(String systemCapabilities, MultiStatus parsingStatus, List<IProvidedCapability> parsingResult) { if (systemCapabilities == null || (systemCapabilities.trim().length() == 0)) { return; } try { ManifestElement[] eeEntries = ManifestElement.parseHeader(Constants.FRAMEWORK_SYSTEMCAPABILITIES, systemCapabilities); parseSystemCapabilities(eeEntries, parsingStatus, parsingResult); } catch (BundleException e) { parsingStatus.add(newErrorStatus(e.getLocalizedMessage(), e)); } }
protected int getPackageLine(IHeader header, ManifestElement element) { String packageName = element.getValue(); if (element.getDirectiveKeys() != null || element.getKeys() != null) return getLine(header, packageName + ";"); //$NON-NLS-1$ // check for this exact package on the last line try { IRegion lineRegion = fTextDocument.getLineInformation(header.getLineNumber() + header.getLinesSpan() - 1); String lineStr = fTextDocument.get(lineRegion.getOffset(), lineRegion.getLength()); if (lineStr.endsWith(packageName)) { return header.getLineNumber() + header.getLinesSpan(); } } catch (BadLocationException ble) { PDECore.logException(ble); } // search all except last line return getLine(header, packageName + ","); //$NON-NLS-1$ }
private static void getRequireCapabilities(ModuleRevisionBuilder builder, ManifestElement[] requireElements) { if (requireElements == null) return; for (ManifestElement requireElement : requireElements) { String[] namespaces = requireElement.getValueComponents(); Map<String, Object> attributes = getAttributes(requireElement); Map<String, String> directives = getDirectives(requireElement); for (String namespace : namespaces) { builder.addRequirement(namespace, directives, attributes); } } }
protected void validateHeaderValue(IHeader header, String[] allowedValues) { ManifestElement[] elements = header.getElements(); if (elements.length > 0) { for (int i = 0; i < allowedValues.length; i++) { if (allowedValues[i].equals(elements[0].getValue())) { return; } } reportIllegalValue(header, elements[0].getValue()); } }
/** * Returns the result of converting a list of comma-separated tokens into an array * * @return the array of string tokens * @param prop the initial comma-separated string */ private static String[] getArrayFromList(String prop, String separator) { return ManifestElement.getArrayFromList(prop, separator); }