use of org.apereo.portal.portlets.StringListAttribute in project uPortal by Jasig.
the class PortletDefinitionForm method setChannelPublishingDefinition.
/**
* Sets the Java class name and parameter defaults based on the PortletPublishingDefinition.
*/
public void setChannelPublishingDefinition(PortletPublishingDefinition cpd) {
// portlet, the applicationId is /uPortal.
if (cpd.getPortletDescriptor() != null) {
final PortletDescriptor pDesc = cpd.getPortletDescriptor();
// PortletDescriptor is a class generated from XSD. The value of
// isIsFramework() will commonly be null.
final boolean isFramework = pDesc.isIsFramework() != null ? pDesc.isIsFramework() : false;
applicationId = isFramework ? FRAMEWORK_PORTLET_URL : pDesc.getWebAppName();
portletName = pDesc.getPortletName();
}
// set default values for all portlet parameters
for (Step step : cpd.getSteps()) {
if (step.getParameters() != null) {
for (Parameter param : step.getParameters()) {
// if this parameter doesn't currently have a value, check
// for a default in the CPD
Attribute attribute = parameters.get(param.getName());
if (attribute == null || attribute.getValue() == null || attribute.getValue().trim().equals("")) {
// use the default value if one exists
ParameterInputType input = param.getParameterInput().getValue();
if (input != null) {
parameters.put(param.getName(), new Attribute(input.getDefault()));
}
}
}
}
if (step.getPreferences() != null) {
for (Preference pref : step.getPreferences()) {
// for a default in the CPD
if (!portletPreferences.containsKey(pref.getName()) || portletPreferences.get(pref.getName()).getValue().size() == 0 || (portletPreferences.get(pref.getName()).getValue().size() == 1 && portletPreferences.get(pref.getName()).getValue().get(0).trim().equals(""))) {
if (!portletPreferences.containsKey(pref.getName())) {
portletPreferences.put(pref.getName(), new StringListAttribute());
}
// use the default value if one exists
PreferenceInputType input = pref.getPreferenceInput().getValue();
if (input instanceof SingleValuedPreferenceInputType) {
SingleValuedPreferenceInputType singleValued = (SingleValuedPreferenceInputType) input;
if (singleValued.getDefault() != null) {
portletPreferences.get(pref.getName()).getValue().add(singleValued.getDefault());
}
} else if (input instanceof MultiValuedPreferenceInputType) {
MultiValuedPreferenceInputType multiValued = (MultiValuedPreferenceInputType) input;
if (multiValued.getDefaults() != null) {
portletPreferences.get(pref.getName()).getValue().addAll(multiValued.getDefaults());
}
}
}
}
}
}
}
Aggregations