use of org.apache.pluto.container.om.portlet.Supports in project uPortal by Jasig.
the class PortletAdministrationHelper method supportsConfigMode.
/**
* If the portlet is a portlet and if one of the supported portlet modes is {@link
* IPortletRenderer#CONFIG}
*/
public boolean supportsConfigMode(PortletDefinitionForm form) {
final Tuple<String, String> portletDescriptorKeys = this.getPortletDescriptorKeys(form);
if (portletDescriptorKeys == null) {
return false;
}
final String portletAppId = portletDescriptorKeys.first;
final String portletName = portletDescriptorKeys.second;
final PortletRegistryService portletRegistryService = this.portalDriverContainerServices.getPortletRegistryService();
final PortletDefinition portletDescriptor;
try {
portletDescriptor = portletRegistryService.getPortlet(portletAppId, portletName);
} catch (PortletContainerException e) {
this.logger.warn("Failed to load portlet descriptor for appId='" + portletAppId + "', portletName='" + portletName + "'", e);
return false;
}
if (portletDescriptor == null) {
return false;
}
//Iterate over supported portlet modes, this ignores the content types for now
final List<? extends Supports> supports = portletDescriptor.getSupports();
for (final Supports support : supports) {
final List<String> portletModes = support.getPortletModes();
for (final String portletMode : portletModes) {
if (IPortletRenderer.CONFIG.equals(PortletUtils.getPortletMode(portletMode))) {
return true;
}
}
}
return false;
}
use of org.apache.pluto.container.om.portlet.Supports in project uPortal by Jasig.
the class PortletAdministrationHelper method loadDefaultsFromPortletDefinitionIfNew.
/**
* Pre-populate a new {@link PortletDefinitionForm} with information from the {@link
* PortletDefinition}.
*
* @param form
*/
public void loadDefaultsFromPortletDefinitionIfNew(PortletDefinitionForm form) {
if (!form.isNew()) {
// Get out; we only prepopulate new portlets
return;
}
// appName/portletName must be set at this point
Validate.notBlank(form.getApplicationId(), "ApplicationId not set");
Validate.notBlank(form.getPortletName(), "PortletName not set");
final PortletRegistryService portletRegistryService = portalDriverContainerServices.getPortletRegistryService();
final PortletDefinition portletDef;
try {
portletDef = portletRegistryService.getPortlet(form.getApplicationId(), form.getPortletName());
} catch (PortletContainerException e) {
this.logger.warn("Failed to load portlet descriptor for appId='" + form.getApplicationId() + "', portletName='" + form.getPortletName() + "'", e);
return;
}
form.setTitle(portletDef.getPortletName());
form.setName(portletDef.getPortletName());
for (Supports supports : portletDef.getSupports()) {
for (String mode : supports.getPortletModes()) {
if ("edit".equalsIgnoreCase(mode)) {
form.setEditable(true);
} else if ("help".equalsIgnoreCase(mode)) {
form.setHasHelp(true);
} else if ("config".equalsIgnoreCase(mode)) {
form.setConfigurable(true);
}
}
}
}
Aggregations