WebApplicationDefinitionImpl webApp = new WebApplicationDefinitionImpl();
webApp.setContextRoot("/app1");
webApp.addDescription(Locale.FRENCH, "Description: Le fromage est dans mon pantalon!");
webApp.addDisplayName(Locale.FRENCH, "Display Name: Le fromage est dans mon pantalon!");
PortletDefinitionComposite portlet = new PortletDefinitionImpl();
portlet.setClassName("org.apache.Portlet");
portlet.setName("Portlet 1");
portlet.addDescription(Locale.getDefault(), "POrtlet description.");
portlet.addDisplayName(Locale.getDefault(), "Portlet display Name.");
portlet.addInitParameter("testparam", "test value", "This is a test portlet parameter", Locale.getDefault());
addDublinCore(portlet.getMetadata());
// PreferenceComposite pc = new PrefsPreference();
app.addPortletDefinition(portlet);
PreferenceSetCtrl prefSetCtrl = (PreferenceSetCtrl) portlet.getPreferenceSet();
PreferenceComposite pc = (PreferenceComposite) prefSetCtrl.add("preference 1", Arrays.asList(new String[]
{ "value 1", "value 2" }));
pc.addDescription(JetspeedLocale.getDefaultLocale(), "Preference Description");
assertNotNull(pc.getValueAt(0));
portlet.addLanguage(portletRegistry.createLanguage(Locale.getDefault(), "Portlet 1", "Portlet 1",
"This is Portlet 1", null));
ContentTypeComposite html = new ContentTypeImpl();
html.setContentType("html/text");
ContentTypeComposite wml = new ContentTypeImpl();
html.addPortletMode(new PortletMode(MODE_EDIT));
html.addPortletMode(new PortletMode(MODE_VIEW));
html.addPortletMode(new PortletMode(MODE_HELP));
wml.setContentType("wml");
wml.addPortletMode(new PortletMode(MODE_HELP));
wml.addPortletMode(new PortletMode(MODE_VIEW));
portlet.addContentType(html);
portlet.addContentType(wml);
app.setWebApplicationDefinition(webApp);
portletRegistry.updatePortletApplication(app);
}