use of org.apereo.portal.portlet.dao.jpa.PortletDefinitionParameterImpl in project uPortal by Jasig.
the class ExternalPortletDefinitionUnmarshaller method unmarshall.
/* package-private */
IPortletDefinition unmarshall(ExternalPortletDefinition epd) {
final PortletDescriptor portletDescriptor = epd.getPortletDescriptor();
final Boolean isFramework = portletDescriptor.isIsFramework();
if (isFramework != null && isFramework && "UPGRADED_CHANNEL_IS_NOT_A_PORTLET".equals(portletDescriptor.getPortletName())) {
if (errorOnChannel) {
throw new IllegalArgumentException(epd.getFname() + " is not a portlet. It was likely an IChannel from a previous version of uPortal and cannot be imported.");
}
logger.warn(epd.getFname() + " is not a portlet. It was likely an IChannel from a previous version of uPortal and will not be imported.");
return null;
}
// get the portlet type
final IPortletType portletType = portletTypeRegistry.getPortletType(epd.getType());
if (portletType == null) {
throw new IllegalArgumentException("No portlet type registered for: " + epd.getType());
}
final String fname = epd.getFname();
IPortletDefinition rslt = portletDefinitionDao.getPortletDefinitionByFname(fname);
if (rslt == null) {
rslt = new PortletDefinitionImpl(portletType, fname, epd.getName(), epd.getTitle(), portletDescriptor.getWebAppName(), portletDescriptor.getPortletName(), isFramework != null ? isFramework : false);
} else {
final IPortletDescriptorKey portletDescriptorKey = rslt.getPortletDescriptorKey();
portletDescriptorKey.setPortletName(portletDescriptor.getPortletName());
if (isFramework != null && isFramework) {
portletDescriptorKey.setFrameworkPortlet(true);
portletDescriptorKey.setWebAppName(null);
} else {
portletDescriptorKey.setFrameworkPortlet(false);
portletDescriptorKey.setWebAppName(portletDescriptor.getWebAppName());
}
rslt.setName(epd.getName());
rslt.setTitle(epd.getTitle());
rslt.setType(portletType);
}
rslt.setDescription(epd.getDesc());
final BigInteger timeout = epd.getTimeout();
if (timeout != null) {
rslt.setTimeout(timeout.intValue());
}
final BigInteger actionTimeout = epd.getActionTimeout();
if (actionTimeout != null) {
rslt.setActionTimeout(actionTimeout.intValue());
}
final BigInteger eventTimeout = epd.getEventTimeout();
if (eventTimeout != null) {
rslt.setEventTimeout(eventTimeout.intValue());
}
final BigInteger renderTimeout = epd.getRenderTimeout();
if (renderTimeout != null) {
rslt.setRenderTimeout(renderTimeout.intValue());
}
final BigInteger resourceTimeout = epd.getResourceTimeout();
if (resourceTimeout != null) {
rslt.setResourceTimeout(resourceTimeout.intValue());
}
unmarshallLifecycle(epd.getLifecycle(), rslt);
final Set<IPortletDefinitionParameter> parameters = new LinkedHashSet<>();
for (ExternalPortletParameter param : epd.getParameters()) {
parameters.add(new PortletDefinitionParameterImpl(param.getName(), param.getValue()));
}
rslt.setParameters(parameters);
final ArrayList<IPortletPreference> preferenceList = new ArrayList<>();
for (ExternalPortletPreference pref : epd.getPortletPreferences()) {
final List<String> valueList = pref.getValues();
final String[] values = valueList.toArray(new String[valueList.size()]);
final Boolean readOnly = pref.isReadOnly();
preferenceList.add(new PortletPreferenceImpl(pref.getName(), readOnly != null ? readOnly : false, values));
}
rslt.setPortletPreferences(preferenceList);
return rslt;
}
Aggregations