in pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/JSR362ConfigurationProcessor.java [719:897]
private void handlePortlets(List<PortletType> portlets) {
for (PortletType portlet : portlets) {
// validate portlet name & class
String warning;
if (portlet.getPortletName() == null || portlet.getPortletName().getValue() == null
|| portlet.getPortletName().getValue().length() == 0) {
warning = "Portlet name may not be null";
LOG.warn(warning);
throw new IllegalArgumentException(warning);
}
String pn = portlet.getPortletName().getValue();
String clsName = portlet.getPortletClass();
// set up portlet definition
PortletDefinition pd = pad.getPortlet(pn);
if (pd == null) {
// If no annotated definition, the class name must be present
if (clsName == null || clsName.length() == 0) {
warning = "Portlet class may not be null. Portlet name: " + pn;
LOG.warn(warning);
throw new IllegalArgumentException(warning);
}
pd = new PortletDefinitionImpl(pn, pad);
pd.setPortletClass(portlet.getPortletClass());
} else {
if ((clsName != null) && (clsName.length() > 0)) {
// The portlet class set in the portlet DD overrides the annotated class.
pd.setPortletClass(portlet.getPortletClass());
}
}
if (portlet.getResourceBundle() != null) {
pd.setResourceBundle(portlet.getResourceBundle().getValue());
}
if (portlet.getExpirationCache() != null) {
pd.setExpirationCache(portlet.getExpirationCache().getValue());
}
if (portlet.getCacheScope() != null) {
pd.setCacheScope(portlet.getCacheScope().getValue());
}
for (DisplayName dispName : handleDisplayNames(portlet.getDisplayName())) {
pd.addDisplayName(dispName);
}
for (Description desc : handleDescriptions(portlet.getDescription())) {
pd.addDescription(desc);
}
for (Supports s : handleSupports(portlet.getSupports())) {
pd.addSupports(s);
}
// handle portlet info
PortletInfoType pit = portlet.getPortletInfo();
if (pit != null) {
PortletInfo info = pd.getPortletInfo();
if (info == null) {
info = new PortletInfoImpl();
}
for (TitleType item : pit.getTitle()) {
Locale loc = (item.getLang() == null) ? Locale.ENGLISH : Locale.forLanguageTag(item.getLang());
info.addTitle(new LocaleTextImpl(loc, item.getValue()));
}
for (ShortTitleType item : pit.getShortTitle()) {
Locale loc = (item.getLang() == null) ? Locale.ENGLISH : Locale.forLanguageTag(item.getLang());
info.addShortTitle(new LocaleTextImpl(loc, item.getValue()));
}
for (KeywordsType item : pit.getKeywords()) {
Locale loc = (item.getLang() == null) ? Locale.ENGLISH : Locale.forLanguageTag(item.getLang());
info.addKeywords(new LocaleTextImpl(loc, item.getValue()));
}
pd.setPortletInfo(info);
}
for (SupportedLocaleType slt : portlet.getSupportedLocale()) {
pd.addSupportedLocale(slt.getValue());
}
for (InitParam ip : handleInitParam(portlet.getInitParam())) {
pd.addInitParam(ip);
}
PortletPreferencesType prefs = portlet.getPortletPreferences();
if (prefs != null) {
// merge the new prefs with the old
Preferences newprefs = pd.getPortletPreferences();
clsName = prefs.getPreferencesValidator();
if (clsName != null && clsName.length() > 0) {
if (clsName.equals("null")) {
// marks that an annotated preferences validator should not be
// applied to this portlet
newprefs.setNullValidator(true);
} else {
newprefs.setPreferencesValidator(clsName);
}
}
for (Preference p : handlePreferences(prefs.getPreference())) {
newprefs.addPreference(p);
}
pd.setPortletPreferences(newprefs);
}
for (SecurityRoleRef srr : handleSecRoleRef(portlet.getSecurityRoleRef())) {
pd.addSecurityRoleRef(srr);
}
for (ContainerRuntimeOption cro : handleRTOptions(portlet.getContainerRuntimeOption())) {
pd.addContainerRuntimeOption(cro);
}
for (String prp : portlet.getSupportedPublicRenderParameter()) {
if ((prp == null) || (prp.length() == 0)) {
warning = "Supported public render parameter definition may not be null.";
LOG.warn(warning);
throw new IllegalArgumentException(warning);
}
pd.addSupportedPublicRenderParameter(prp);
}
// Supported processing events
for (EventDefinitionReference edr : handleEventDefRefs(portlet.getSupportedProcessingEvent())) {
pd.addSupportedProcessingEvent(edr);
}
// Supported publishing events
for (EventDefinitionReference edr : handleEventDefRefs(portlet.getSupportedPublishingEvent())) {
pd.addSupportedPublishingEvent(edr);
}
// dependencies
for (DependencyType dt : portlet.getDependency()) {
if (dt.getName() == null || dt.getName().length() == 0) {
String warn = "Dependency name is empty, ignoring Dependency block.";
LOG.warn(warn);
continue;
}
if (dt.getVersion() == null || dt.getVersion().length() == 0) {
String warn = "Dependency version is empty.";
LOG.info(warn);
}
Dependency dep = new DependencyImpl(dt.getName(), dt.getScope(), dt.getVersion());
pd.addDependency(dep);
}
// Async supported
if (portlet.isAsyncSupported() != null) {
pd.setAsyncSupported(portlet.isAsyncSupported());
}
// multipart config
MultipartType muty = portlet.getMultipartConfig();
if (muty != null) {
pd.setMultipartSupported(true);
pd.setLocation(muty.getLocation());
pd.setFileSizeThreshold(muty.getFileSizeThreshold());
pd.setMaxFileSize(muty.getMaxFileSize());
pd.setMaxRequestSize(muty.getMaxRequestSize());
}
pad.addPortlet(pd);
}
}