private long _initCompany(ServletContext servletContext, String webId) { // Begin initializing company if (_log.isDebugEnabled()) { _log.debug("Begin initializing company with web id " + webId); } long companyId = 0; try { Company company = CompanyLocalServiceUtil.checkCompany(webId); companyId = company.getCompanyId(); } catch (Exception e) { _log.error(e, e); } CompanyThreadLocal.setCompanyId(companyId); // Lucene LuceneHelperUtil.startup(companyId); // Initialize display if (_log.isDebugEnabled()) { _log.debug("Initialize display"); } try { String xml = HttpUtil.URLtoString(servletContext.getResource("/WEB-INF/liferay-display.xml")); PortletCategory portletCategory = (PortletCategory) WebAppPool.get(companyId, WebKeys.PORTLET_CATEGORY); if (portletCategory == null) { portletCategory = new PortletCategory(); } PortletCategory newPortletCategory = PortletLocalServiceUtil.getEARDisplay(xml); portletCategory.merge(newPortletCategory); for (int i = 0; i < _companyIds.length; i++) { long currentCompanyId = _companyIds[i]; PortletCategory currentPortletCategory = (PortletCategory) WebAppPool.get(currentCompanyId, WebKeys.PORTLET_CATEGORY); if (currentPortletCategory != null) { portletCategory.merge(currentPortletCategory); } } WebAppPool.put(companyId, WebKeys.PORTLET_CATEGORY, portletCategory); } catch (Exception e) { _log.error(e, e); } // Check journal content search if (_log.isDebugEnabled()) { _log.debug("Check journal content search"); } if (GetterUtil.getBoolean(PropsUtil.get(PropsKeys.JOURNAL_SYNC_CONTENT_SEARCH_ON_STARTUP))) { try { JournalContentSearchLocalServiceUtil.checkContentSearches(companyId); } catch (Exception e) { _log.error(e, e); } } // Process application startup events if (_log.isDebugEnabled()) { _log.debug("Process application startup events"); } try { EventsProcessorUtil.process( PropsKeys.APPLICATION_STARTUP_EVENTS, PropsValues.APPLICATION_STARTUP_EVENTS, new String[] {String.valueOf(companyId)}); } catch (Exception e) { _log.error(e, e); } // End initializing company if (_log.isDebugEnabled()) { _log.debug("End initializing company with web id " + webId + " and company id " + companyId); } addCompanyId(companyId); return companyId; }