Search in sources :

Example 1 with PortletDefinitionParameterImpl

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IPortletPreference(org.apereo.portal.portlet.om.IPortletPreference) ArrayList(java.util.ArrayList) IPortletDescriptorKey(org.apereo.portal.portlet.om.IPortletDescriptorKey) PortletDescriptor(org.apereo.portal.xml.PortletDescriptor) IPortletType(org.apereo.portal.portlet.om.IPortletType) IPortletDefinitionParameter(org.apereo.portal.portlet.om.IPortletDefinitionParameter) BigInteger(java.math.BigInteger) PortletDefinitionImpl(org.apereo.portal.portlet.dao.jpa.PortletDefinitionImpl) PortletPreferenceImpl(org.apereo.portal.portlet.dao.jpa.PortletPreferenceImpl) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletDefinitionParameterImpl(org.apereo.portal.portlet.dao.jpa.PortletDefinitionParameterImpl)

Aggregations

BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 PortletDefinitionImpl (org.apereo.portal.portlet.dao.jpa.PortletDefinitionImpl)1 PortletDefinitionParameterImpl (org.apereo.portal.portlet.dao.jpa.PortletDefinitionParameterImpl)1 PortletPreferenceImpl (org.apereo.portal.portlet.dao.jpa.PortletPreferenceImpl)1 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)1 IPortletDefinitionParameter (org.apereo.portal.portlet.om.IPortletDefinitionParameter)1 IPortletDescriptorKey (org.apereo.portal.portlet.om.IPortletDescriptorKey)1 IPortletPreference (org.apereo.portal.portlet.om.IPortletPreference)1 IPortletType (org.apereo.portal.portlet.om.IPortletType)1 PortletDescriptor (org.apereo.portal.xml.PortletDescriptor)1