public void removeAttribute( String attributeName ) { backingAttributes.remove( new Attributes.Name( attributeName ) ); }
@Override public Object remove(Object name) { linkedHashMap.remove(name); return super.remove(name); }
private Manifest buildManifest(JarFile archive) throws IOException { Manifest manifest = archive.getManifest(); // The repackager looks for this attribute and bails out if it finds it manifest.getMainAttributes().remove(new Attributes.Name(BOOT_VERSION_ATTRIBUTE)); // We also want to replace this with the default one from the repackager manifest.getMainAttributes().remove(Attributes.Name.MAIN_CLASS); if (this.mainClass != null) { manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, this.mainClass); } return manifest; }
public void removeEntryAttribute(String entryName, Object key) { Attributes attr = getAttributes(entryName); if (attr != null) attr.remove(key); }
private void doHeader(Attributes main, String header) { String value = annotationHeaders.getHeader(header); if (value != null && main.getValue(header) == null) { if (value.trim().length() == 0) main.remove(header); else if (value.trim().equals(EMPTY_HEADER)) main.putValue(header, ""); else main.putValue(header, value); } }
private void doHeader(Attributes main, String header) { String value = annotationHeaders.getHeader(header); if (value != null && main.getValue(header) == null) { if (value.trim().length() == 0) main.remove(header); else if (value.trim().equals(EMPTY_HEADER)) main.putValue(header, ""); else main.putValue(header, value); } }
private void writeManifestOverride(final TransformContext context, final Manifest mf) throws IOException { // Removing this field makes the generated manifest deterministic final Attributes.Name lastModifiedKey = new Attributes.Name("Bnd-LastModified"); mf.getMainAttributes().remove(lastModifiedKey); final ByteArrayOutputStream bout = new ByteArrayOutputStream(); mf.write(bout); context.getFileOverrides().put("META-INF/MANIFEST.MF", bout.toByteArray()); }
private static byte[] buildExtensionBundle(Manifest manifest) throws IOException { Attributes atts = manifest.getMainAttributes(); //the following properties are invalid in extension bundles atts.remove(new Attributes.Name(Constants.IMPORT_PACKAGE)); atts.remove(new Attributes.Name(Constants.REQUIRE_BUNDLE)); atts.remove(new Attributes.Name(Constants.BUNDLE_NATIVECODE)); atts.remove(new Attributes.Name(Constants.DYNAMICIMPORT_PACKAGE)); atts.remove(new Attributes.Name(Constants.BUNDLE_ACTIVATOR)); //mark as extension bundle atts.putValue(Constants.FRAGMENT_HOST, "system.bundle; extension:=framework"); //create the jar containing the manifest ByteArrayOutputStream jar = new ByteArrayOutputStream(); JarOutputStream out = new JarOutputStream(jar, manifest); out.close(); return jar.toByteArray(); }
private void doHeader(Attributes main, String header) { String value = annotationHeaders.getHeader(header); if (value == null) return; Name name = new Name(header); if (main.getValue(name) != null) return; String trimmed = value.trim(); if (trimmed.isEmpty()) main.remove(name); else if (EMPTY_HEADER.equals(trimmed)) main.put(name, ""); else main.put(name, value); }
private void doHeader(Attributes main, String header) { String value = annotationHeaders.getHeader(header); if (value == null) return; Name name = new Name(header); if (main.getValue(name) != null) return; String trimmed = value.trim(); if (trimmed.isEmpty()) main.remove(name); else if (EMPTY_HEADER.equals(trimmed)) main.put(name, ""); else main.put(name, value); }
/** * @see com.ibm.etools.archive.ArchiveManifest */ public void setClassPath(java.lang.String aSpaceDelimitedPath) { Attributes attributes = getMainAttributes(); if (aSpaceDelimitedPath == null) attributes.remove(Attributes.Name.CLASS_PATH); else attributes.putValue(Attributes.Name.CLASS_PATH.toString(), aSpaceDelimitedPath); }
/** * @see com.ibm.etools.archive.ArchiveManifest */ public void setMainClass(java.lang.String className) { Attributes attributes = getMainAttributes(); if (className == null) attributes.remove(Attributes.Name.MAIN_CLASS); else attributes.putValue(Attributes.Name.MAIN_CLASS.toString(), className); }
protected void resetClassPath(List cp) { ArchiveManifest mf = outgoingArchive.getManifest(); if (cp.isEmpty()) mf.getMainAttributes().remove(Attributes.Name.CLASS_PATH); else { mf.setClassPath("");//$NON-NLS-1$ for (int i = 0; i < cp.size(); i++) { mf.appendClassPath((String) cp.get(i)); } } }
@Override public Manifest cleanRepeatedImports( Manifest manifest, Collection<Archive<?>> auxiliaryArchives) throws IOException { List<String> auxiliaryArchivesPackages = getAuxiliaryArchivesPackages( auxiliaryArchives); Attributes mainAttributes = manifest.getMainAttributes(); String importPackages = mainAttributes.getValue(IMPORT_PACKAGE); mainAttributes.remove(new Attributes.Name(IMPORT_PACKAGE)); Map<String, Set<String>> importsWithDirectivesMap = toImportsWithDirectivesMap(importPackages); List<String> resultImports = new ArrayList<>(); for (String importValue : importsWithDirectivesMap.keySet()) { if (auxiliaryArchivesPackages.contains(importValue)) { continue; } StringBuilder sb = new StringBuilder(); sb.append(importValue); for (String directive : importsWithDirectivesMap.get(importValue)) { sb.append(";"); sb.append(directive); } resultImports.add(sb.toString()); } ManifestManager manifestManager = _manifestManagerInstance.get(); manifest = manifestManager.putAttributeValue( manifest, IMPORT_PACKAGE, resultImports.toArray(new String[resultImports.size()])); return manifest; }
Manifest resultManifest = Utils.readManifest(manifestFile); resultManifest.getMainAttributes().remove(new Name(Constants.DEPLOYMENTPACKAGE_FIXPACK)); String path = (String) iter.next(); Attributes sourceAttribute = (Attributes) resultManifest.getEntries().get(path); if ("true".equals(sourceAttribute.remove(new Name(Constants.DEPLOYMENTPACKAGE_MISSING)))) { targetFiles.remove(path);
public byte[] getTimelessDigest() throws Exception { check(); MessageDigest md = MessageDigest.getInstance("SHA1"); OutputStream dout = new DigestOutputStream(IO.nullStream, md); // dout = System.out; Manifest m = getManifest(); if (m != null) { Manifest m2 = new Manifest(m); Attributes main = m2.getMainAttributes(); String lastmodified = (String) main.remove(new Attributes.Name(Constants.BND_LASTMODIFIED)); String version = main.getValue(new Attributes.Name(Constants.BUNDLE_VERSION)); if (version != null && Verifier.isVersion(version)) { Version v = new Version(version); main.putValue(Constants.BUNDLE_VERSION, v.toStringWithoutQualifier()); } writeManifest(m2, dout); for (Map.Entry<String, Resource> entry : getResources().entrySet()) { String path = entry.getKey(); if (path.equals(manifestName)) continue; Resource resource = entry.getValue(); dout.write(path.getBytes(UTF_8)); resource.write(dout); } } return md.digest(); }
public byte[] getTimelessDigest() throws Exception { check(); MessageDigest md = MessageDigest.getInstance("SHA1"); OutputStream dout = new DigestOutputStream(IO.nullStream, md); // dout = System.out; Manifest m = getManifest(); if (m != null) { Manifest m2 = new Manifest(m); Attributes main = m2.getMainAttributes(); String lastmodified = (String) main.remove(new Attributes.Name(Constants.BND_LASTMODIFIED)); String version = main.getValue(new Attributes.Name(Constants.BUNDLE_VERSION)); if (version != null && Verifier.isVersion(version)) { Version v = new Version(version); main.putValue(Constants.BUNDLE_VERSION, v.toStringWithoutQualifier()); } writeManifest(m2, dout); for (Map.Entry<String, Resource> entry : getResources().entrySet()) { String path = entry.getKey(); if (path.equals(manifestName)) continue; Resource resource = entry.getValue(); dout.write(path.getBytes(UTF_8)); resource.write(dout); } } return md.digest(); }
Manifest m2 = new Manifest(m); Attributes main = m2.getMainAttributes(); String lastmodified = (String) main.remove(new Attributes.Name(Constants.BND_LASTMODIFIED)); String version = main.getValue(new Attributes.Name(Constants.BUNDLE_VERSION)); if ( version != null && Verifier.isVersion(version)) {
Manifest m2 = new Manifest(m); Attributes main = m2.getMainAttributes(); String lastmodified = (String) main.remove(new Attributes.Name(Constants.BND_LASTMODIFIED)); String version = main.getValue(new Attributes.Name(Constants.BUNDLE_VERSION)); if ( version != null && Verifier.isVersion(version)) {