### Eclipse Workspace Patch 1.0 #P org.eclipse.equinox.p2.tests Index: src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java =================================================================== RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java,v retrieving revision 1.4 diff -u -r1.4 ProductFileTest.java --- src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java 9 Mar 2009 22:37:19 -0000 1.4 +++ src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java 23 Apr 2009 22:00:41 -0000 @@ -196,4 +196,16 @@ assertEquals("1.1", "programArg", programArguments); } + public void testGetLicenseURL() throws Exception { + String productWithLicense = TestData.getFile("ProductActionTest", "productWithLicense.product").toString(); + ProductFile product = new ProductFile(productWithLicense); + assertEquals("1.0", "http://www.example.com", product.getLicenseURL()); + } + + public void testGetLicenseText() throws Exception { + String productWithLicense = TestData.getFile("ProductActionTest", "productWithLicense.product").toString(); + ProductFile product = new ProductFile(productWithLicense); + assertEquals("1.0", "This is the liCenSE.", product.getLicenseText().trim()); + } + } Index: testData/ProductActionTest/productWithLicense.product =================================================================== RCS file: testData/ProductActionTest/productWithLicense.product diff -N testData/ProductActionTest/productWithLicense.product --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testData/ProductActionTest/productWithLicense.product 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,34 @@ + + + + + + + + + + -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts + + + + + + + + + + + + + + http://www.example.com + + This is the liCenSE. + + + + + + + + #P org.eclipse.equinox.p2.publisher Index: src/org/eclipse/equinox/internal/p2/publisher/eclipse/IProductDescriptor.java =================================================================== RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/eclipse/IProductDescriptor.java,v retrieving revision 1.3 diff -u -r1.3 IProductDescriptor.java --- src/org/eclipse/equinox/internal/p2/publisher/eclipse/IProductDescriptor.java 9 Mar 2009 22:37:22 -0000 1.3 +++ src/org/eclipse/equinox/internal/p2/publisher/eclipse/IProductDescriptor.java 23 Apr 2009 22:00:42 -0000 @@ -116,4 +116,14 @@ */ public File getLocation(); + /** + * Returns the license URL for this product + */ + public String getLicenseURL(); + + /** + * Returns the license text for this product + */ + public String getLicenseText(); + } \ No newline at end of file Index: src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java =================================================================== RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java,v retrieving revision 1.8 diff -u -r1.8 ProductFile.java --- src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java 9 Mar 2009 22:37:22 -0000 1.8 +++ src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java 23 Apr 2009 22:00:43 -0000 @@ -85,6 +85,9 @@ private static final String EL_LAUNCHER_ARGS = "launcherArgs"; //$NON-NLS-1$ private static final String EL_SPLASH = "splash"; //$NON-NLS-1$ private static final String EL_CONFIGURATIONS = "configurations"; //$NON-NLS-1$ + private static final String EL_LICENSE = "license"; //$NON-NLS-1$ + private static final String EL_URL = "url"; //$NON-NLS-1$ + private static final String EL_TEXT = "text"; //$NON-NLS-1$ //These constants form a small state machine to parse the .product file private static final int STATE_START = 0; @@ -105,6 +108,9 @@ private static final int STATE_VM_ARGS_WIN = 15; private static final int STATE_CONFIG_INI = 16; private static final int STATE_CONFIGURATIONS = 17; + private static final int STATE_LICENSE = 18; + private static final int STATE_LICENSE_URL = 19; + private static final int STATE_LICENSE_TEXT = 20; private int state = STATE_START; @@ -130,6 +136,8 @@ private File location; private List bundleInfos; private Properties properties; + private String licenseURL; + private String licenseText = null; private static String normalize(String text) { if (text == null || text.trim().length() == 0) @@ -370,6 +378,14 @@ return normalize(args); } + public String getLicenseText() { + return licenseText; + } + + public String getLicenseURL() { + return licenseURL; + } + public void startElement(String uri, String localName, String qName, Attributes attributes) { switch (state) { case STATE_START : @@ -396,6 +412,8 @@ splashLocation = attributes.getValue(ATTRIBUTE_LOCATION); } else if (EL_CONFIGURATIONS.equals(localName)) { state = STATE_CONFIGURATIONS; + } else if (EL_LICENSE.equals(localName)) { + state = STATE_LICENSE; } break; @@ -450,6 +468,15 @@ } break; + case STATE_LICENSE : + if (EL_URL.equals(localName)) { + state = STATE_LICENSE_URL; + } else if (EL_TEXT.equals(localName)) { + licenseText = ""; //$NON-NLS-1$ + state = STATE_LICENSE_TEXT; + } + break; + case STATE_FEATURES : if (EL_FEATURE.equals(localName)) { processFeature(attributes); @@ -519,6 +546,10 @@ if (EL_CONFIGURATIONS.equals(localName)) state = STATE_PRODUCT; break; + case STATE_LICENSE : + if (EL_LICENSE.equals(localName)) + state = STATE_PRODUCT; + break; case STATE_PROGRAM_ARGS : case STATE_PROGRAM_ARGS_LINUX : @@ -532,6 +563,10 @@ case STATE_VM_ARGS_WIN : state = STATE_LAUNCHER_ARGS; break; + case STATE_LICENSE_URL : + case STATE_LICENSE_TEXT : + state = STATE_LICENSE; + break; case STATE_CONFIG_INI : if (EL_CONFIG_INI.equals(localName)) @@ -578,6 +613,14 @@ if (platformConfigPath != null) platformConfigPath += String.valueOf(ch, start, length); break; + case STATE_LICENSE_URL : + licenseURL = String.valueOf(ch, start, length); + break; + case STATE_LICENSE_TEXT : + if (licenseText != null) + licenseText += String.valueOf(ch, start, length); + break; + } } @@ -698,4 +741,5 @@ private void processMac(Attributes attributes) { addIcon(OS_MACOSX, attributes.getValue(ATTRIBUTE_ICON)); } + }