Search in sources :

Example 6 with PortletPublishingDefinition

use of org.apereo.portal.portletpublishing.xml.PortletPublishingDefinition in project uPortal by Jasig.

the class XmlChannelPublishingDefinitionDao method getSharedParameters.

private List<Step> getSharedParameters() {
    if (this.sharedParameters != null) {
        return this.sharedParameters;
    }
    // read and parse the shared CPD
    final Resource paramResource = this.resourceLoader.getResource("classpath:" + SHARED_PARAMETERS_PATH);
    if (!paramResource.exists()) {
        throw new MissingResourceException("Failed to find shared parameters CPD '" + SHARED_PARAMETERS_PATH + "'", this.getClass().getName(), SHARED_PARAMETERS_PATH);
    }
    final InputStream paramStream;
    try {
        paramStream = paramResource.getInputStream();
    } catch (IOException e) {
        throw new MissingResourceException("Failed to load CPD '" + SHARED_PARAMETERS_PATH + "'", this.getClass().getName(), SHARED_PARAMETERS_PATH);
    }
    // parse the shared CPD and add its steps to the end of the type-specific
    try {
        PortletPublishingDefinition config = (PortletPublishingDefinition) unmarshaller.unmarshal(paramStream);
        this.sharedParameters = config.getSteps();
    } catch (JAXBException e) {
        logger.warn("Failed to parse: " + paramResource, e);
    } finally {
        IOUtils.closeQuietly(paramStream);
    }
    return this.sharedParameters;
}
Also used : InputStream(java.io.InputStream) MissingResourceException(java.util.MissingResourceException) JAXBException(javax.xml.bind.JAXBException) Resource(org.springframework.core.io.Resource) PortletPublishingDefinition(org.apereo.portal.portletpublishing.xml.PortletPublishingDefinition) IOException(java.io.IOException)

Example 7 with PortletPublishingDefinition

use of org.apereo.portal.portletpublishing.xml.PortletPublishingDefinition in project uPortal by Jasig.

the class XmlChannelPublishingDefinitionDao method getChannelPublishingDefinitions.

/* (non-Javadoc)
     * @see org.apereo.portal.portlets.portletadmin.xmlsupport.IChannelPublishingDefinitionDao#getChannelPublishingDefinitions()
     */
@Override
public Map<IPortletType, PortletPublishingDefinition> getChannelPublishingDefinitions() {
    final List<IPortletType> channelTypes = this.portletTypeRegistry.getPortletTypes();
    final Map<IPortletType, PortletPublishingDefinition> cpds = new LinkedHashMap<IPortletType, PortletPublishingDefinition>(channelTypes.size());
    for (final IPortletType channelType : channelTypes) {
        final PortletPublishingDefinition cpd = this.getChannelPublishingDefinition(channelType.getId());
        cpds.put(channelType, cpd);
    }
    return cpds;
}
Also used : IPortletType(org.apereo.portal.portlet.om.IPortletType) PortletPublishingDefinition(org.apereo.portal.portletpublishing.xml.PortletPublishingDefinition) LinkedHashMap(java.util.LinkedHashMap)

Example 8 with PortletPublishingDefinition

use of org.apereo.portal.portletpublishing.xml.PortletPublishingDefinition in project uPortal by Jasig.

the class XmlChannelPublishingDefinitionDaoTest method testGetChannelPublishingDefinition.

@Test
public void testGetChannelPublishingDefinition() {
    PortletPublishingDefinition portletPublishingDefinition = xmlChannelPublishingDefinitionDao.getChannelPublishingDefinition(1010);
    assertEquals(portletPublishingDefinition.getPortletDescriptor().getPortletName(), "WebProxyPortlet");
    assertEquals(portletPublishingDefinition.getPortletDescriptor().getWebAppName(), "/WebProxyPortlet");
    assertEquals(portletPublishingDefinition.getSteps().size(), 1);
    List<Step> steps = portletPublishingDefinition.getSteps();
    Step step = steps.get(0);
    assertEquals(step.getName(), "General Configuration");
    assertEquals(step.getDescription(), "Use the configuration options after reviewing the portlet publishing information to configure the portlet.");
}
Also used : PortletPublishingDefinition(org.apereo.portal.portletpublishing.xml.PortletPublishingDefinition) Step(org.apereo.portal.portletpublishing.xml.Step) Test(org.junit.Test)

Example 9 with PortletPublishingDefinition

use of org.apereo.portal.portletpublishing.xml.PortletPublishingDefinition in project uPortal by Jasig.

the class PortletAdministrationHelper method updateFormForSinglePortletType.

/**
 * updates the editPortlet form with the portletType of the first (and only) portletDefinition
 * passed in through the Map of portlet definitions.
 *
 * @param portletDefinitions
 * @param form
 * @return PortletPublishingDefinition of the first portlet definition in the list, null if the
 *     list is empty or has more than one element.
 */
public PortletPublishingDefinition updateFormForSinglePortletType(Map<IPortletType, PortletPublishingDefinition> portletDefinitions, PortletDefinitionForm form) {
    if (portletDefinitions.size() != 1) {
        return null;
    }
    IPortletType portletType = portletDefinitions.keySet().iterator().next();
    form.setTypeId(portletType.getId());
    PortletPublishingDefinition cpd = portletPublishingDefinitionDao.getChannelPublishingDefinition(portletType.getId());
    form.setChannelPublishingDefinition(cpd);
    return cpd;
}
Also used : IPortletType(org.apereo.portal.portlet.om.IPortletType) PortletPublishingDefinition(org.apereo.portal.portletpublishing.xml.PortletPublishingDefinition)

Example 10 with PortletPublishingDefinition

use of org.apereo.portal.portletpublishing.xml.PortletPublishingDefinition in project uPortal by Jasig.

the class PortletAdministrationHelper method getArbitraryPortletPreferenceNames.

/**
 * Get a list of the key names of the currently-set arbitrary portlet preferences.
 *
 * @param form
 * @return
 */
public Set<String> getArbitraryPortletPreferenceNames(PortletDefinitionForm form) {
    // set default values for all portlet parameters
    PortletPublishingDefinition cpd = this.portletPublishingDefinitionDao.getChannelPublishingDefinition(form.getTypeId());
    Set<String> currentPrefs = new HashSet<>();
    currentPrefs.addAll(form.getPortletPreferences().keySet());
    for (Step step : cpd.getSteps()) {
        if (step.getPreferences() != null) {
            for (Preference pref : step.getPreferences()) {
                currentPrefs.remove(pref.getName());
            }
        }
    }
    return currentPrefs;
}
Also used : Preference(org.apereo.portal.portletpublishing.xml.Preference) IPortletPreference(org.apereo.portal.portlet.om.IPortletPreference) PortletPublishingDefinition(org.apereo.portal.portletpublishing.xml.PortletPublishingDefinition) Step(org.apereo.portal.portletpublishing.xml.Step) HashSet(java.util.HashSet)

Aggregations

PortletPublishingDefinition (org.apereo.portal.portletpublishing.xml.PortletPublishingDefinition)12 IPortletType (org.apereo.portal.portlet.om.IPortletType)7 Step (org.apereo.portal.portletpublishing.xml.Step)5 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)3 IPortletPreference (org.apereo.portal.portlet.om.IPortletPreference)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Map (java.util.Map)2 MissingResourceException (java.util.MissingResourceException)2 JAXBException (javax.xml.bind.JAXBException)2 Preference (org.apereo.portal.portletpublishing.xml.Preference)2 BooleanAttribute (org.apereo.portal.portlets.BooleanAttribute)2 PortletDescriptor (org.apereo.portal.xml.PortletDescriptor)2 Test (org.junit.Test)2 Resource (org.springframework.core.io.Resource)2 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Entry (java.util.Map.Entry)1 TreeSet (java.util.TreeSet)1