@Override public void init(FilterConfig filterConfig) { super.init(filterConfig); _basicAuthEnabled = GetterUtil.getBoolean(filterConfig.getInitParameter("basic_auth")); _digestAuthEnabled = GetterUtil.getBoolean(filterConfig.getInitParameter("digest_auth")); String propertyPrefix = filterConfig.getInitParameter("portal_property_prefix"); String[] hostsAllowed = null; if (Validator.isNull(propertyPrefix)) { hostsAllowed = StringUtil.split(filterConfig.getInitParameter("hosts.allowed")); _httpsRequired = GetterUtil.getBoolean(filterConfig.getInitParameter("https.required")); } else { hostsAllowed = PropsUtil.getArray(propertyPrefix + "hosts.allowed"); _httpsRequired = GetterUtil.getBoolean(PropsUtil.get(propertyPrefix + "https.required")); } for (String hostAllowed : hostsAllowed) { _hostsAllowed.add(hostAllowed); } _usePermissionChecker = GetterUtil.getBoolean(filterConfig.getInitParameter("use_permission_checker")); }
public boolean isShowParentGroups() { if (_showParentGroups != null) { return _showParentGroups; } String showParentGroupsString = PrefsParamUtil.getString(_portletPreferences, _request, "showParentGroups", null); if (Validator.isNotNull(showParentGroupsString)) { _showParentGroups = GetterUtil.getBoolean(showParentGroupsString); return _showParentGroups; } ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); try { Layout layout = themeDisplay.getLayout(); Group group = layout.getGroup(); _showParentGroups = GetterUtil.getBoolean( group.getTypeSettingsProperty("breadcrumbShowParentGroups"), BreadcrumbConfigurationValues.SHOW_PARENT_GROUPS); } catch (Exception e) { _log.error(e, e); } return _showParentGroups; }
@Override public String[] getAssetTagNames(PortletPreferences portletPreferences, long scopeGroupId) throws Exception { String[] allAssetTagNames = new String[0]; for (int i = 0; true; i++) { String[] queryValues = portletPreferences.getValues("queryValues" + i, null); if ((queryValues == null) || (queryValues.length == 0)) { break; } boolean queryContains = GetterUtil.getBoolean(portletPreferences.getValue("queryContains" + i, StringPool.BLANK)); boolean queryAndOperator = GetterUtil.getBoolean( portletPreferences.getValue("queryAndOperator" + i, StringPool.BLANK)); String queryName = portletPreferences.getValue("queryName" + i, StringPool.BLANK); if (!Validator.equals(queryName, "assetCategories") && queryContains && queryAndOperator) { allAssetTagNames = queryValues; } } return allAssetTagNames; }
@Override public void setModelAttributes(Map<String, Object> attributes) { String uuid = (String) attributes.get("uuid"); if (uuid != null) { setUuid(uuid); } Long gadgetId = (Long) attributes.get("gadgetId"); if (gadgetId != null) { setGadgetId(gadgetId); } Long companyId = (Long) attributes.get("companyId"); if (companyId != null) { setCompanyId(companyId); } Date createDate = (Date) attributes.get("createDate"); if (createDate != null) { setCreateDate(createDate); } Date modifiedDate = (Date) attributes.get("modifiedDate"); if (modifiedDate != null) { setModifiedDate(modifiedDate); } String name = (String) attributes.get("name"); if (name != null) { setName(name); } String url = (String) attributes.get("url"); if (url != null) { setUrl(url); } String portletCategoryNames = (String) attributes.get("portletCategoryNames"); if (portletCategoryNames != null) { setPortletCategoryNames(portletCategoryNames); } Date lastPublishDate = (Date) attributes.get("lastPublishDate"); if (lastPublishDate != null) { setLastPublishDate(lastPublishDate); } _entityCacheEnabled = GetterUtil.getBoolean("entityCacheEnabled"); _finderCacheEnabled = GetterUtil.getBoolean("finderCacheEnabled"); }
public static boolean getEmailPageAddedEnabled(PortletPreferences preferences) { String emailPageAddedEnabled = preferences.getValue("emailPageAddedEnabled", StringPool.BLANK); if (Validator.isNotNull(emailPageAddedEnabled)) { return GetterUtil.getBoolean(emailPageAddedEnabled); } else { return GetterUtil.getBoolean(PropsUtil.get(PropsKeys.WIKI_EMAIL_PAGE_ADDED_ENABLED)); } }
public static boolean getEmailEntryUpdatedEnabled(PortletPreferences preferences) { String emailEntryUpdatedEnabled = preferences.getValue("emailEntryUpdatedEnabled", StringPool.BLANK); if (Validator.isNotNull(emailEntryUpdatedEnabled)) { return GetterUtil.getBoolean(emailEntryUpdatedEnabled); } else { return GetterUtil.getBoolean(PropsUtil.get(PropsKeys.BOOKMARKS_EMAIL_ENTRY_UPDATED_ENABLED)); } }
public static boolean getEmailEventReminderEnabled(PortletPreferences preferences) { String emailEventReminderEnabled = preferences.getValue("emailEventReminderEnabled", StringPool.BLANK); if (Validator.isNotNull(emailEventReminderEnabled)) { return GetterUtil.getBoolean(emailEventReminderEnabled); } else { return GetterUtil.getBoolean(PropsUtil.get(PropsKeys.CALENDAR_EMAIL_EVENT_REMINDER_ENABLED)); } }
public boolean isStagedPortlet(String portletId) { try { if (isLayout()) { Group parentGroup = GroupLocalServiceUtil.getGroup(getParentGroupId()); return parentGroup.isStagedPortlet(portletId); } } catch (Exception e) { } portletId = PortletConstants.getRootPortletId(portletId); String typeSettingsProperty = getTypeSettingsProperty(StagingConstants.STAGED_PORTLET.concat(portletId)); if (Validator.isNotNull(typeSettingsProperty)) { return GetterUtil.getBoolean(typeSettingsProperty); } try { Portlet portlet = PortletLocalServiceUtil.getPortletById(portletId); String portletDataHandlerClass = portlet.getPortletDataHandlerClass(); if (Validator.isNull(portletDataHandlerClass)) { return true; } UnicodeProperties typeSettingsProperties = getTypeSettingsProperties(); for (Map.Entry<String, String> entry : typeSettingsProperties.entrySet()) { String key = entry.getKey(); if (!key.contains(StagingConstants.STAGED_PORTLET)) { continue; } String stagedPortletId = StringUtil.replace(key, StagingConstants.STAGED_PORTLET, StringPool.BLANK); Portlet stagedPortlet = PortletLocalServiceUtil.getPortletById(stagedPortletId); if (portletDataHandlerClass.equals(stagedPortlet.getPortletDataHandlerClass())) { return GetterUtil.getBoolean(entry.getValue()); } } } catch (Exception e) { } return true; }
@Override public void postProcessContextBooleanFilter( BooleanFilter contextBooleanFilter, SearchContext searchContext) throws Exception { Long classNameId = (Long) searchContext.getAttribute(Field.CLASS_NAME_ID); if ((classNameId != null) && (classNameId != 0)) { contextBooleanFilter.addRequiredTerm(Field.CLASS_NAME_ID, classNameId.toString()); } addStatus(contextBooleanFilter, searchContext); addSearchClassTypeIds(contextBooleanFilter, searchContext); String ddmStructureFieldName = (String) searchContext.getAttribute("ddmStructureFieldName"); Serializable ddmStructureFieldValue = searchContext.getAttribute("ddmStructureFieldValue"); if (Validator.isNotNull(ddmStructureFieldName) && Validator.isNotNull(ddmStructureFieldValue)) { QueryFilter queryFilter = _ddmIndexer.createFieldValueQueryFilter( ddmStructureFieldName, ddmStructureFieldValue, searchContext.getLocale()); contextBooleanFilter.add(queryFilter, BooleanClauseOccur.MUST); } String ddmStructureKey = (String) searchContext.getAttribute("ddmStructureKey"); if (Validator.isNotNull(ddmStructureKey)) { contextBooleanFilter.addRequiredTerm("ddmStructureKey", ddmStructureKey); } String ddmTemplateKey = (String) searchContext.getAttribute("ddmTemplateKey"); if (Validator.isNotNull(ddmTemplateKey)) { contextBooleanFilter.addRequiredTerm("ddmTemplateKey", ddmTemplateKey); } boolean head = GetterUtil.getBoolean(searchContext.getAttribute("head"), Boolean.TRUE); boolean relatedClassName = GetterUtil.getBoolean(searchContext.getAttribute("relatedClassName")); boolean showNonindexable = GetterUtil.getBoolean(searchContext.getAttribute("showNonindexable")); if (head && !relatedClassName && !showNonindexable) { contextBooleanFilter.addRequiredTerm("head", Boolean.TRUE); } if (!relatedClassName && showNonindexable) { contextBooleanFilter.addRequiredTerm("headListable", Boolean.TRUE); } }
protected String getDynamicDDMStructureXSD(String fileName, String dynamicDDMStructureName) throws DocumentException { List<Element> structureElements = getDDMStructures(fileName); for (Element structureElement : structureElements) { boolean dynamicStructure = GetterUtil.getBoolean(structureElement.elementText("dynamic-structure")); if (!dynamicStructure) { continue; } String name = structureElement.elementText("name"); if (!name.equals(dynamicDDMStructureName)) { continue; } Element structureElementRootElement = structureElement.element("root"); return structureElementRootElement.asXML(); } return null; }
@Override protected void processTemplates(List<TemplateResource> templateResources, Writer writer) throws Exception { try { String namespace = GetterUtil.getString(get(TemplateConstants.NAMESPACE)); if (Validator.isNull(namespace)) { throw new TemplateException("No namespace specified."); } SoyFileSet soyFileSet = getSoyFileSet(templateResources); SoyTofu soyTofu = soyFileSet.compileToTofu(); Renderer renderer = soyTofu.newRenderer(namespace); renderer.setData(getSoyMapData()); boolean renderStrict = GetterUtil.getBoolean(get(TemplateConstants.RENDER_STRICT), true); if (renderStrict) { SanitizedContent sanitizedContent = renderer.renderStrict(); writer.write(sanitizedContent.stringValue()); } else { writer.write(renderer.render()); } } catch (PrivilegedActionException pae) { throw pae.getException(); } }
@Override public boolean validateReference( PortletDataContext portletDataContext, Element referenceElement) { validateMissingGroupReference(portletDataContext, referenceElement); String uuid = referenceElement.attributeValue("uuid"); Map<Long, Long> groupIds = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(Group.class); long groupId = GetterUtil.getLong(referenceElement.attributeValue("group-id")); groupId = MapUtil.getLong(groupIds, groupId); String fileEntryTypeKey = referenceElement.attributeValue("file-entry-type-key"); boolean preloaded = GetterUtil.getBoolean(referenceElement.attributeValue("preloaded")); DLFileEntryType existingFileEntryType = fetchExistingFileEntryType(uuid, groupId, fileEntryTypeKey, preloaded); if (existingFileEntryType == null) { return false; } return true; }
@Override public boolean isColumnCustomizable(String columnId) { String customizableString = getTypeSettingsProperty(CustomizedPages.namespaceColumnId(columnId)); boolean customizable = GetterUtil.getBoolean(customizableString); if (customizable) { if (isLayoutSetPrototype()) { return false; } return true; } if (hasUserPreferences()) { String columnValue = _portalPreferences.getValue( CustomizedPages.namespacePlid(getPlid()), columnId, StringPool.NULL); if (!Objects.equals(columnValue, StringPool.NULL)) { setUserPreference(columnId, null); } } return false; }
public boolean isEnableRSS() { if (_enableRSS == null) { _enableRSS = GetterUtil.getBoolean(_portletPreferences.getValue("enableRss", null)); } return _enableRSS; }
public boolean isEnablePrint() { if (_enablePrint == null) { _enablePrint = GetterUtil.getBoolean(_portletPreferences.getValue("enablePrint", null)); } return _enablePrint; }
@Override public boolean validateReference( PortletDataContext portletDataContext, Element referenceElement) { String uuid = referenceElement.attributeValue("uuid"); long classNameId = PortalUtil.getClassNameId(referenceElement.attributeValue("referenced-class-name")); String structureKey = referenceElement.attributeValue("structure-key"); boolean preloaded = GetterUtil.getBoolean(referenceElement.attributeValue("preloaded")); try { DDMStructure existingStructure = fetchExistingStructure( uuid, portletDataContext.getScopeGroupId(), classNameId, structureKey, preloaded); if (existingStructure == null) { existingStructure = fetchExistingStructure( uuid, portletDataContext.getCompanyGroupId(), classNameId, structureKey, preloaded); } if (existingStructure == null) { return false; } return true; } catch (Exception e) { return false; } }
private PropsUtil() { try { SystemProperties.set(PropsKeys.DEFAULT_LIFERAY_HOME, _getDefaultLiferayHome()); _configuration = new ConfigurationImpl(PropsUtil.class.getClassLoader(), PropsFiles.PORTAL); String liferayHome = _get(PropsKeys.LIFERAY_HOME); if (_log.isDebugEnabled()) { _log.debug("Configured Liferay home " + liferayHome); } SystemProperties.set(PropsKeys.LIFERAY_HOME, liferayHome); SystemProperties.set("ehcache.disk.store.dir", liferayHome + "/data/ehcache"); if (GetterUtil.getBoolean(SystemProperties.get("company-id-properties"))) { _configurations = new HashMap<Long, Configuration>(); } } catch (Exception e) { if (_log.isErrorEnabled()) { _log.error("Unable to initialize PropsUtil", e); } } }
protected void parseTransition(Definition definition, Element nodeElement) { String sourceName = nodeElement.elementText("name"); Node sourceNode = definition.getNode(sourceName); Element transitionsElement = nodeElement.element("transitions"); if (transitionsElement == null) { return; } List<Element> transitionElements = transitionsElement.elements("transition"); for (Element transitionElement : transitionElements) { String transitionName = transitionElement.elementText("name"); String targetName = transitionElement.elementText("target"); Node targetNode = definition.getNode(targetName); boolean defaultValue = GetterUtil.getBoolean(transitionElement.elementText("default"), true); Transition transition = new Transition(transitionName, sourceNode, targetNode, defaultValue); Element timerElement = transitionElement.element("timer"); if (timerElement != null) { Timer timer = parseTimerElement(timerElement, false); transition.setTimers(timer); } sourceNode.addTransition(transition); } }
protected Timer parseTimerElement(Element timerElement, boolean isTaskTimer) { String name = timerElement.elementText("name"); String description = timerElement.elementText("description"); boolean blocking = GetterUtil.getBoolean(timerElement.elementText("blocking"), !isTaskTimer); Timer timer = new Timer(name, description, blocking); Element delayElement = timerElement.element("delay"); DelayDuration delayDuration = parseDelay(delayElement); timer.setDelayDuration(delayDuration); if (!blocking) { Element recurrenceElement = timerElement.element("recurrence"); DelayDuration recurrence = parseDelay(recurrenceElement); timer.setRecurrence(recurrence); } Element timerActions = timerElement.element("timer-actions"); parseTimerActions(timerActions, timer); return timer; }
public static void init() { if (!_LOG_SANITIZER_ENABLED) { return; } _LOG_SANITIZER_ESCAPE_HTML_ENABLED = GetterUtil.getBoolean(SystemProperties.get(PropsKeys.LOG_SANITIZER_ESCAPE_HTML_ENABLED)); _LOG_SANITIZER_REPLACEMENT_CHARACTER = (char) GetterUtil.getInteger( SystemProperties.get(PropsKeys.LOG_SANITIZER_REPLACEMENT_CHARACTER)); int[] whitelistCharacters = GetterUtil.getIntegerValues( SystemProperties.getArray(PropsKeys.LOG_SANITIZER_WHITELIST_CHARACTERS)); for (int whitelistCharacter : whitelistCharacters) { if ((whitelistCharacter >= 0) && (whitelistCharacter < _whitelistCharacters.length)) { _whitelistCharacters[whitelistCharacter] = 1; } else { System.err.println("Unable to register log whitelist character " + whitelistCharacter); } } }
@Override protected void doVerify() throws Exception { List<String> pendingModels = new ArrayList<String>(); for (String[] model : _MODELS) { pendingModels.add(model[0]); } while (!pendingModels.isEmpty()) { int count = pendingModels.size(); for (String[] model : _MODELS) { if (pendingModels.contains(model[3]) || !pendingModels.contains(model[0])) { continue; } verifyModel( model[0], model[1], model[2], model[3], model[4], GetterUtil.getBoolean(model[5])); pendingModels.remove(model[0]); } if (pendingModels.size() == count) { throw new VerifyException("Circular dependency detected " + pendingModels); } } }
@Override public boolean validateReference( PortletDataContext portletDataContext, Element referenceElement) { String uuid = referenceElement.attributeValue("uuid"); String fileEntryTypeKey = referenceElement.attributeValue("file-entry-type-key"); boolean preloaded = GetterUtil.getBoolean(referenceElement.attributeValue("preloaded")); try { DLFileEntryType existingFileEntryType = fetchExistingFileEntryType( uuid, portletDataContext.getScopeGroupId(), fileEntryTypeKey, preloaded); if (existingFileEntryType == null) { existingFileEntryType = fetchExistingFileEntryType( uuid, portletDataContext.getCompanyGroupId(), fileEntryTypeKey, preloaded); } if (existingFileEntryType == null) { return false; } return true; } catch (Exception e) { return false; } }
@Override public boolean validateReference( PortletDataContext portletDataContext, Element referenceElement) { validateMissingGroupReference(portletDataContext, referenceElement); String uuid = referenceElement.attributeValue("uuid"); Map<Long, Long> groupIds = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(Group.class); long groupId = GetterUtil.getLong(referenceElement.attributeValue("group-id")); groupId = MapUtil.getLong(groupIds, groupId); boolean privateLayout = GetterUtil.getBoolean(referenceElement.attributeValue("private-layout")); Layout existingLayout = fetchMissingReference(uuid, groupId, privateLayout); if (existingLayout == null) { return false; } return true; }
protected void updateLDAPUser(User ldapUser, Contact ldapContact, User user) throws PortalException, SystemException { Contact contact = user.getContact(); ldapContact.setAimSn(GetterUtil.getString(contact.getAimSn())); ldapContact.setFacebookSn(GetterUtil.getString(contact.getFacebookSn())); ldapContact.setIcqSn(GetterUtil.getString(contact.getIcqSn())); ldapContact.setJabberSn(GetterUtil.getString(contact.getJabberSn())); ldapContact.setMale(GetterUtil.getBoolean(contact.getMale())); ldapContact.setMsnSn(GetterUtil.getString(contact.getMsnSn())); ldapContact.setMySpaceSn(GetterUtil.getString(contact.getMySpaceSn())); ldapContact.setPrefixId(GetterUtil.getInteger(contact.getPrefixId())); ldapContact.setSkypeSn(GetterUtil.getString(contact.getSkypeSn())); ldapContact.setSmsSn(GetterUtil.getString(contact.getSmsSn())); ldapContact.setSuffixId(GetterUtil.getInteger(contact.getSuffixId())); ldapContact.setTwitterSn(GetterUtil.getString(contact.getTwitterSn())); ldapContact.setYmSn(GetterUtil.getString(contact.getYmSn())); ldapUser.setComments(GetterUtil.getString(user.getComments())); ldapUser.setGreeting(GetterUtil.getString(user.getGreeting())); ldapUser.setJobTitle(GetterUtil.getString(user.getJobTitle())); ldapUser.setLanguageId(GetterUtil.getString(user.getLanguageId())); ldapUser.setMiddleName(GetterUtil.getString(user.getMiddleName())); ldapUser.setOpenId(GetterUtil.getString(user.getOpenId())); ldapUser.setTimeZoneId(GetterUtil.getString(user.getTimeZoneId())); }
public Boolean isEnablePermissions() { if (_enablePermissions != null) { return _enablePermissions; } String portletName = getPortletName(); if (!portletName.equals(AssetPublisherPortletKeys.HIGHEST_RATED_ASSETS) && !portletName.equals(AssetPublisherPortletKeys.MOST_VIEWED_ASSETS) && AssetPublisherWebConfigurationValues.SEARCH_WITH_INDEX) { _enablePermissions = true; return _enablePermissions; } if (!AssetPublisherWebConfigurationValues.PERMISSION_CHECKING_CONFIGURABLE) { _enablePermissions = true; return _enablePermissions; } _enablePermissions = GetterUtil.getBoolean(_portletPreferences.getValue("enablePermissions", null), true); return _enablePermissions; }
@Override public boolean hasLock() { if (!isCheckedOut()) { return false; } AllowableActions allowableActions = _document.getAllowableActions(); Set<Action> allowableActionsSet = allowableActions.getAllowableActions(); if (allowableActionsSet.contains(Action.CAN_CHECK_IN)) { return true; } List<CmisExtensionElement> cmisExtensionElements = allowableActions.getExtensions(); for (CmisExtensionElement cmisExtensionElement : cmisExtensionElements) { String name = cmisExtensionElement.getName(); if (name.equals("canCheckInSpecified")) { return GetterUtil.getBoolean(cmisExtensionElement.getValue()); } } return false; }
public boolean isEnableRatings() { if (_enableRatings == null) { _enableRatings = GetterUtil.getBoolean(_portletPreferences.getValue("enableRatings", null)); } return _enableRatings; }
@Override public void importMissingReference( PortletDataContext portletDataContext, Element referenceElement) throws PortletDataException { importMissingGroupReference(portletDataContext, referenceElement); String uuid = referenceElement.attributeValue("uuid"); Map<Long, Long> groupIds = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(Group.class); long groupId = GetterUtil.getLong(referenceElement.attributeValue("group-id")); groupId = MapUtil.getLong(groupIds, groupId); String fileEntryTypeKey = referenceElement.attributeValue("file-entry-type-key"); boolean preloaded = GetterUtil.getBoolean(referenceElement.attributeValue("preloaded")); DLFileEntryType existingFileEntryType = null; existingFileEntryType = fetchExistingFileEntryType(uuid, groupId, fileEntryTypeKey, preloaded); Map<Long, Long> fileEntryTypeIds = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(DLFileEntryType.class); long fileEntryTypeId = GetterUtil.getLong(referenceElement.attributeValue("class-pk")); fileEntryTypeIds.put(fileEntryTypeId, existingFileEntryType.getFileEntryTypeId()); }
@Override public void importCompanyStagedModel(PortletDataContext portletDataContext, Element element) throws PortletDataException { String uuid = element.attributeValue("uuid"); long classNameId = PortalUtil.getClassNameId(element.attributeValue("referenced-class-name")); String structureKey = element.attributeValue("structure-key"); boolean preloaded = GetterUtil.getBoolean(element.attributeValue("preloaded")); DDMStructure existingStructure = null; try { existingStructure = fetchExistingStructure( uuid, portletDataContext.getCompanyGroupId(), classNameId, structureKey, preloaded); } catch (Exception e) { throw new PortletDataException(e); } Map<Long, Long> structureIds = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(DDMStructure.class); long structureId = GetterUtil.getLong(element.attributeValue("class-pk")); structureIds.put(structureId, existingStructure.getStructureId()); Map<String, String> structureKeys = (Map<String, String>) portletDataContext.getNewPrimaryKeysMap(DDMStructure.class + ".ddmStructureKey"); structureKeys.put(structureKey, existingStructure.getStructureKey()); }
@Override public void importCompanyStagedModel(PortletDataContext portletDataContext, Element element) throws PortletDataException { String uuid = element.attributeValue("uuid"); String fileEntryTypeKey = element.attributeValue("file-entry-type-key"); boolean preloaded = GetterUtil.getBoolean(element.attributeValue("preloaded")); DLFileEntryType existingFileEntryType = null; try { existingFileEntryType = fetchExistingFileEntryType( uuid, portletDataContext.getCompanyGroupId(), fileEntryTypeKey, preloaded); } catch (Exception e) { throw new PortletDataException(e); } Map<Long, Long> fileEntryTypeIds = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(DLFileEntryType.class); long fileEntryTypeId = GetterUtil.getLong(element.attributeValue("class-pk")); fileEntryTypeIds.put(fileEntryTypeId, existingFileEntryType.getFileEntryTypeId()); }