private static boolean getMetaDataBooleanValue(GenericMetadata metaData, String fieldName, boolean defaultValue ) { String value = null; if ( metaData != null ) { Collection<LocalizedField> fields = metaData.getFields(fieldName); if ( fields != null && !fields.isEmpty() ) { value = fields.iterator().next().getValue(); } } if ( value != null ) { return Boolean.valueOf(value).booleanValue(); } return defaultValue; }
protected boolean enforceSecurityConstraint(PortletDefinition portlet) { Collection c = portlet.getMetadata().getFields("render-time.security-constraints"); if (c != null) { Iterator it = c.iterator(); if (it.hasNext()) { LocalizedField field = (LocalizedField) it.next(); return Boolean.parseBoolean(field.getValue()); } } return false; }
protected String getRefreshFunction(PortletDefinition portletDefinition) { String refreshFunction = null; Collection<LocalizedField> refreshFields = null; if (portletDefinition != null) { refreshFields = portletDefinition.getMetadata().getFields(PortalReservedParameters.PORTLET_EXTENDED_DESCRIPTOR_REFRESH_FUNCTION); } if (refreshFields != null && !refreshFields.isEmpty()) { refreshFunction = refreshFields.iterator().next().getValue(); } return refreshFunction; }
public LocalizedFieldBean(final LocalizedField localizedField) { name = localizedField.getName(); value = localizedField.getValue(); Locale locale = localizedField.getLocale(); if (locale != null) { localeString = locale.toString(); } }
protected String getVersion(PortletApplication pa) { String version = ""; Collection versionList = pa.getMetadata().getFields("pa-version"); if (versionList != null) { Iterator it = versionList.iterator(); if (it.hasNext()) { LocalizedField field = (LocalizedField)it.next(); version = field.getValue(); } } return version; }
protected long getTimeoutOnJob(PortletDefinition portletDefinition) { long timeoutMetadata = 0; Collection<LocalizedField> timeoutFields = null; if (portletDefinition != null) { timeoutFields = portletDefinition.getMetadata().getFields(PortalReservedParameters.PORTLET_EXTENDED_DESCRIPTOR_RENDER_TIMEOUT); } if (timeoutFields != null && !timeoutFields.isEmpty()) { try { timeoutMetadata = Long.parseLong(timeoutFields.iterator().next().getValue()); } catch (NumberFormatException nfe) { log.warn("Invalid timeout metadata: " + nfe.getMessage()); } } return timeoutMetadata; }
protected long getRefreshRate(PortletDefinition portletDefinition) { long refreshRate = -1; Collection<LocalizedField> refreshFields = null; if (portletDefinition != null) { refreshFields = portletDefinition.getMetadata().getFields(PortalReservedParameters.PORTLET_EXTENDED_DESCRIPTOR_REFRESH_RATE); } if (refreshFields != null && !refreshFields.isEmpty()) { try { refreshRate = Long.parseLong(refreshFields.iterator().next().getValue()); } catch (NumberFormatException nfe) { log.warn("Invalid refreshRate metadata: " + nfe.getMessage()); } } return refreshRate; }
private boolean isFilteredOutByRole(PortletDefinition pd, HttpServletRequest servletRequest) { boolean filteredOut = false; Collection<LocalizedField> fields = pd.getMetadata().getFields("selector.conditional.role"); if (fields != null && !fields.isEmpty()) { LocalizedField field = fields.iterator().next(); String role = field.getValue(); if (!StringUtils.isBlank(role)) { if (role.equals("*")) { filteredOut = true; } else { filteredOut = (!servletRequest.isUserInRole(role)); } } } return filteredOut; }
static protected String retrieveField(Folder folder, Locale locale, String name) { GenericMetadata metadata = folder.getMetadata(); Collection<LocalizedField> fields = metadata.getFields(); if (fields != null) { Iterator<LocalizedField> it = fields.iterator(); while (it.hasNext()) { LocalizedField field = it.next(); if (locale == null || field.getLocale().equals(locale)) { if (field.getName().equals(name)) { return field.getValue(); } } } } return null; }
if (!this.fields.contains(field)) addField(field.getLocale(), field.getName(), field.getValue());
if (BooleanUtils.toBoolean(fields.iterator().next().getValue()))
contentPageImpl.getMetadata().getFields().add(new ContentLocalizedFieldImpl(fieldLocale, fieldName, field.getValue()));
fieldMap.put(field.getName(), field.getValue());
fieldMap.put(field.getName(), field.getValue());
copy.getMetadata().addField(field.getLocale(), field.getName(), field.getValue());