@Override public Object put(String key, Object value) { if (key == null) { throw new ManifestException("The key of a manifest attribute must not be null."); } if (value == null) { throw new ManifestException(String.format("The value of a manifest attribute must not be null (Key=%s).", key)); } try { new java.util.jar.Attributes.Name(key); } catch (IllegalArgumentException e) { throw new ManifestException(String.format("The Key=%s violates the Manifest spec!", key)); } return attributes.put(key, value); }
public Object put(String key, Object value) { if (key == null) { throw new ManifestException("The key of a manifest attribute must not be null."); } if (value == null) { throw new ManifestException("The value of a manifest attribute must not be null."); } try { new java.util.jar.Attributes.Name(key); } catch(IllegalArgumentException e) { throw new ManifestException(String.format("The Key=%s violates the Manifest spec!", key)); } return attributes.put(key, value); }
private static final String generateUpdateVersion(Attributes attributes) { try { String manifestDate = (String)attributes.get("keycounter"); if (manifestDate==null) { throw new ManifestException("keycounter not found in SAP_MANIFEST attributes"); } Date date = new SimpleDateFormat(SAPManifest.MANIFEST_DATE_FORMAT).parse(manifestDate); return "LB-" + (new SimpleDateFormat(UPDATEVERSION_DATE_FORMAT)).format(date); } catch (ParseException e) { throw new ManifestException(e.getMessage(), e); } }
@Override public DefaultManifest getEffectiveManifest() { Attributes attributes = getAttributes(); String keyname = (String)attributes.get("keyname"); if (keyname==null || keyname.isEmpty()) { throw new ManifestException("keyname needs to be set before getting effective manifest"); } attributes.put("componentelement", ComponentElementHelper.generate(attributes)); // System.out.println("SAPManifest.getEffectiveManifest~includeDependencies:" +includeDependencies); // System.out.println("SAPManifest.getEffectiveManifest~applicationJ2eeEngineFile:" +applicationJ2eeEngineFile); boolean hasDependencies = false; if (includeDependencies && applicationJ2eeEngineFile!=null) { //deferred application-j2ee-engine.xml parse final ApplicationJ2eeEngineHelper applicationJ2eeEngineHelper = new ApplicationJ2eeEngineHelper(); applicationJ2eeEngineHelper.setSourceFile(applicationJ2eeEngineFile).parse(); hasDependencies = applicationJ2eeEngineHelper.hasReferences(); if (hasDependencies) { String dependencies = applicationJ2eeEngineHelper.toDependencies().toString(); attributes.put("dependencies", ManifestStringSplitter.splitIt(dependencies)); //System.out.println(ManifestStringSplitter.splitIt(dependencies)); String dependencyList = applicationJ2eeEngineHelper.toDependencyList().toString(); attributes.put("dependencyList", ManifestStringSplitter.splitIt(dependencyList)); //System.out.println(ManifestStringSplitter.splitIt(dependencyList)); } } if (!hasDependencies) { attributes.remove("dependencies"); attributes.remove("dependencyList"); } //System.out.println("SAPManifest.getEffectiveManifest() - attributes.get("componentelement")); return super.getEffectiveManifest(); }
@Test(expected=ManifestException.class) public void testWithDefaults() { StringWriter writer = new StringWriter(); //ManifestException: keyname needs to be set before getting effective manifest createSAPManifest().writeTo(writer); }