use of org.apereo.portal.portlet.om.IPortletPreference in project uPortal by Jasig.
the class MarketplacePortletDefinition method initPortletReleaseNotes.
private void initPortletReleaseNotes() {
PortletReleaseNotes temp = new PortletReleaseNotes();
for (IPortletPreference portletPreference : this.portletDefinition.getPortletPreferences()) {
if (MarketplacePortletDefinition.RELEASE_DATE_PREFERENCE_NAME.equalsIgnoreCase(portletPreference.getName())) {
try {
DateTime dt = releaseDateFormatter.parseDateTime(portletPreference.getValues()[0]);
temp.setReleaseDate(dt);
} catch (Exception e) {
logger.warn("Issue with parsing " + RELEASE_DATE_PREFERENCE_NAME + ". Should be in format " + RELEASE_DATE_FORMAT, e);
}
continue;
}
if (MarketplacePortletDefinition.RELEASE_NOTE_PREFERENCE_NAME.equalsIgnoreCase(portletPreference.getName())) {
temp.setReleaseNotes(Arrays.asList(portletPreference.getValues()));
continue;
}
if (MarketplacePortletDefinition.INITIAL_RELEASE_DATE_PREFERENCE_NAME.equalsIgnoreCase(portletPreference.getName())) {
try {
DateTime dt = releaseDateFormatter.parseDateTime(portletPreference.getValues()[0]);
temp.setInitialReleaseDate(dt);
} catch (Exception e) {
logger.warn("Issue with parsing " + INITIAL_RELEASE_DATE_PREFERENCE_NAME + ". Should be in format " + RELEASE_DATE_FORMAT, e);
}
continue;
}
}
this.setPortletReleaseNotes(temp);
}
use of org.apereo.portal.portlet.om.IPortletPreference in project uPortal by Jasig.
the class PortletDefinitionBeanTest method testFromMarketplacePortletDefinitionNoKeywords.
@Test
public void testFromMarketplacePortletDefinitionNoKeywords() {
Long id = 345L;
String name = "testName";
// Create a non-keyword list
String[] nonKeywords = new String[] { "val1", "val2" };
List<IPortletPreference> prefs = new ArrayList<>();
prefs.add(portletPref);
Mockito.when(portletPref.getName()).thenReturn("non-keywords");
Mockito.when(portletPref.getValues()).thenReturn(nonKeywords);
MarketplacePortletDefinition mpd = buildMarketplacePortletDefinition(id, name, prefs, null);
PortletDefinitionBean pdb = PortletDefinitionBean.fromMarketplacePortletDefinition(mpd, Locale.ENGLISH, false);
assertEquals(Collections.EMPTY_LIST, pdb.getKeywords());
}
use of org.apereo.portal.portlet.om.IPortletPreference in project uPortal by Jasig.
the class AbstractPortletPreferencesImpl method setValues.
@Override
public final void setValues(String key, String[] values) throws ReadOnlyException {
Assert.notNull(key, "Preference Key cannot be null");
final Map<String, IPortletPreference> targetPortletPreferences = this.getTargetPortletPreferences();
// Check if there is a base preference for the key
final Map<String, IPortletPreference> basePortletPreferences = this.getBasePortletPreferences();
final IPortletPreference basePreference = basePortletPreferences.get(key);
if (basePreference != null) {
if (this.isReadOnly(basePreference)) {
throw new ReadOnlyException("Preference '" + key + "' is read only");
}
// if the set value matches base value, delete any target pref
if (Arrays.equals(values, basePreference.getValues())) {
this.reset(key);
return;
}
}
IPortletPreference portletPreference = targetPortletPreferences.get(key);
// No target preference exists yet, create it and then update the composite map
if (portletPreference == null) {
portletPreference = new PortletPreferenceImpl(key, false, values != null ? values.clone() : null);
targetPortletPreferences.put(key, portletPreference);
final Map<String, IPortletPreference> compositePortletPreferences = this.getCompositePortletPreferences();
compositePortletPreferences.put(key, portletPreference);
this.modified = true;
} else // Update the existing preference if the values array is different
if (!Arrays.equals(values, portletPreference.getValues())) {
portletPreference.setValues(values != null ? values.clone() : null);
this.modified = true;
}
}
use of org.apereo.portal.portlet.om.IPortletPreference in project uPortal by Jasig.
the class AbstractPortletPreferencesImpl method reset.
@Override
public final void reset(String key) throws ReadOnlyException {
final Map<String, IPortletPreference> basePortletPreferences = this.getBasePortletPreferences();
final IPortletPreference basePreference = basePortletPreferences.get(key);
if (this.isReadOnly(basePreference)) {
throw new ReadOnlyException("Preference '" + key + "' is read only");
}
final Map<String, IPortletPreference> targetPortletPreferences = this.getTargetPortletPreferences();
final IPortletPreference removed = targetPortletPreferences.remove(key);
// There was a target preference with that key, update the composite preferences map
if (removed != null) {
final Map<String, IPortletPreference> compositePortletPreferences = this.getCompositePortletPreferences();
if (basePreference != null) {
compositePortletPreferences.put(key, basePreference);
} else {
compositePortletPreferences.remove(key);
}
this.modified = true;
}
}
use of org.apereo.portal.portlet.om.IPortletPreference in project uPortal by Jasig.
the class GuestPortletEntityPreferencesImpl method storeInternal.
@Override
protected boolean storeInternal() throws IOException, ValidatorException {
final Map<String, IPortletPreference> targetPortletPreferences = this.getTargetPortletPreferences();
if (targetPortletPreferences.isEmpty()) {
return false;
}
final HttpServletRequest containerRequest = portletRequestContext.getContainerRequest();
this.storeSessionPreferences(portletEntityId, containerRequest, targetPortletPreferences);
return true;
}
Aggregations