public PortalLoginModule() {
    if (Validator.isNotNull(PropsValues.PORTAL_JAAS_IMPL)) {
      try {
        _loginModule = (LoginModule) InstanceFactory.newInstance(PropsValues.PORTAL_JAAS_IMPL);
      } catch (Exception e) {
        _log.error(e, e);
      }
    }

    if (_loginModule == null) {
      if (ServerDetector.isJBoss()) {
        _loginModule = new com.liferay.portal.security.jaas.ext.jboss.PortalLoginModule();
      } else if (ServerDetector.isJetty()) {
        _loginModule = new com.liferay.portal.security.jaas.ext.jetty.PortalLoginModule();
      } else if (ServerDetector.isJOnAS()) {
        _loginModule = new com.liferay.portal.security.jaas.ext.jonas.PortalLoginModule();
      } else if (ServerDetector.isResin()) {
        _loginModule = new com.liferay.portal.security.jaas.ext.resin.PortalLoginModule();
      } else if (ServerDetector.isTomcat()) {
        _loginModule = new com.liferay.portal.security.jaas.ext.tomcat.PortalLoginModule();
      } else if (ServerDetector.isWebLogic()) {
        _loginModule = new com.liferay.portal.security.jaas.ext.weblogic.PortalLoginModule();
      }
    }

    if (_log.isDebugEnabled()) {
      _log.debug(_loginModule.getClass().getName());
    }
  }
  protected BackgroundTaskExecutor getBackgroundTaskExecutor(BackgroundTask backgroundTask) {

    BackgroundTaskExecutor backgroundTaskExecutor = null;

    String servletContextNames = backgroundTask.getServletContextNames();

    if (Validator.isNull(servletContextNames)) {
      backgroundTaskExecutor =
          _backgroundTaskExecutorRegistry.getBackgroundTaskExecutor(
              backgroundTask.getTaskExecutorClassName());

      backgroundTaskExecutor = backgroundTaskExecutor.clone();
    } else {
      ClassLoader classLoader = ClassLoaderUtil.getPortalClassLoader();

      if (Validator.isNotNull(servletContextNames)) {
        classLoader =
            ClassLoaderUtil.getAggregatePluginsClassLoader(
                StringUtil.split(servletContextNames), false);
      }

      try {
        backgroundTaskExecutor =
            (BackgroundTaskExecutor)
                InstanceFactory.newInstance(classLoader, backgroundTask.getTaskExecutorClassName());
      } catch (Exception e) {
        if (_log.isDebugEnabled()) {
          _log.debug("Unable to create new background task executor", e);
        }
      }
    }

    return backgroundTaskExecutor;
  }
  /** Initializes the h r office persistence. */
  public void afterPropertiesSet() {
    String[] listenerClassNames =
        StringUtil.split(
            GetterUtil.getString(
                com.liferay.util.service.ServiceProps.get(
                    "value.object.listener.com.liferay.hr.model.HROffice")));

    if (listenerClassNames.length > 0) {
      try {
        List<ModelListener<HROffice>> listenersList = new ArrayList<ModelListener<HROffice>>();

        for (String listenerClassName : listenerClassNames) {
          listenersList.add(
              (ModelListener<HROffice>) InstanceFactory.newInstance(listenerClassName));
        }

        listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
      } catch (Exception e) {
        _log.error(e);
      }
    }

    containsHRHoliday = new ContainsHRHoliday(this);

    addHRHoliday = new AddHRHoliday(this);
    clearHRHolidaies = new ClearHRHolidaies(this);
    removeHRHoliday = new RemoveHRHoliday(this);
  }
Пример #4
0
  @Override
  protected synchronized RequestProcessor getRequestProcessor(ModuleConfig moduleConfig)
      throws ServletException {

    ServletContext servletContext = getServletContext();

    String key = Globals.REQUEST_PROCESSOR_KEY + moduleConfig.getPrefix();

    RequestProcessor requestProcessor = (RequestProcessor) servletContext.getAttribute(key);

    if (requestProcessor == null) {
      ControllerConfig controllerConfig = moduleConfig.getControllerConfig();

      try {
        requestProcessor =
            (RequestProcessor)
                InstanceFactory.newInstance(
                    ClassLoaderUtil.getPortalClassLoader(), controllerConfig.getProcessorClass());
      } catch (Exception e) {
        throw new ServletException(e);
      }

      requestProcessor.init(this, moduleConfig);

      servletContext.setAttribute(key, requestProcessor);
    }

    return requestProcessor;
  }
Пример #5
0
  private MergeScheduler _getMergeScheduler() throws Exception {
    if (PropsValues.LUCENE_MERGE_SCHEDULER.equals(NoMergeScheduler.class.getName())) {

      return NoMergeScheduler.INSTANCE;
    }

    ClassLoader classLoader = ClassLoaderUtil.getPortalClassLoader();

    return (MergeScheduler)
        InstanceFactory.newInstance(classLoader, PropsValues.LUCENE_MERGE_SCHEDULER);
  }
  public void afterPropertiesSet() throws Exception {
    ClassLoader classLoader = ClassLoaderUtil.getPortalClassLoader();

    for (String dlProcessorClassName : _DL_FILE_ENTRY_PROCESSORS) {
      DLProcessor dlProcessor =
          (DLProcessor) InstanceFactory.newInstance(classLoader, dlProcessorClassName);

      dlProcessor.afterPropertiesSet();

      register(dlProcessor);
    }
  }
  public void afterPropertiesSet() throws Exception {
    if (_log.isDebugEnabled()) {
      _log.debug("Instantiate " + PropsValues.USERS_SCREEN_NAME_VALIDATOR);
    }

    ClassLoader classLoader = ClassLoaderUtil.getPortalClassLoader();

    _originalScreenNameValidator =
        (ScreenNameValidator)
            InstanceFactory.newInstance(classLoader, PropsValues.USERS_SCREEN_NAME_VALIDATOR);

    _screenNameValidator = _originalScreenNameValidator;
  }
Пример #8
0
  public void afterPropertiesSet() throws Exception {
    if (_log.isDebugEnabled()) {
      _log.debug("Instantiate " + PropsValues.MEMBERSHIP_POLICY_USER_GROUPS);
    }

    ClassLoader classLoader = ClassLoaderUtil.getPortalClassLoader();

    _originalUserGroupMembershipPolicy =
        (UserGroupMembershipPolicy)
            InstanceFactory.newInstance(classLoader, PropsValues.MEMBERSHIP_POLICY_USER_GROUPS);

    _userGroupMembershipPolicy = _originalUserGroupMembershipPolicy;
  }
Пример #9
0
  private MergePolicy _getMergePolicy() throws Exception {
    if (PropsValues.LUCENE_MERGE_POLICY.equals(NoMergePolicy.class.getName())) {

      return NoMergePolicy.NO_COMPOUND_FILES;
    }

    ClassLoader classLoader = ClassLoaderUtil.getPortalClassLoader();

    MergePolicy mergePolicy =
        (MergePolicy) InstanceFactory.newInstance(classLoader, PropsValues.LUCENE_MERGE_POLICY);

    if (mergePolicy instanceof LogMergePolicy) {
      LogMergePolicy logMergePolicy = (LogMergePolicy) mergePolicy;

      logMergePolicy.setMergeFactor(PropsValues.LUCENE_MERGE_FACTOR);
    }

    return mergePolicy;
  }
  @Override
  public PortalCacheBootstrapLoader create(Properties properties) {
    String className =
        properties.getProperty(EhcacheConstants.BOOTSTRAP_CACHE_LOADER_FACTORY_CLASS_NAME);

    if (Validator.isNull(className)) {
      return null;
    }

    try {
      BootstrapCacheLoaderFactory<?> bootstrapCacheLoaderFactory =
          (BootstrapCacheLoaderFactory<?>) InstanceFactory.newInstance(getClassLoader(), className);

      return new EhcachePortalCacheBootstrapLoaderAdapter(
          bootstrapCacheLoaderFactory.createBootstrapCacheLoader(properties));
    } catch (Exception e) {
      throw new SystemException(
          "Unable to instantiate bootstrap cache loader factory " + className, e);
    }
  }
  /** Initializes the ticket persistence. */
  public void afterPropertiesSet() {
    String[] listenerClassNames =
        StringUtil.split(
            GetterUtil.getString(
                com.liferay.portal.util.PropsUtil.get(
                    "value.object.listener.com.liferay.portal.model.Ticket")));

    if (listenerClassNames.length > 0) {
      try {
        List<ModelListener<Ticket>> listenersList = new ArrayList<ModelListener<Ticket>>();

        for (String listenerClassName : listenerClassNames) {
          listenersList.add((ModelListener<Ticket>) InstanceFactory.newInstance(listenerClassName));
        }

        listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
      } catch (Exception e) {
        _log.error(e);
      }
    }
  }
  /** Initializes the faculty persistence. */
  public void afterPropertiesSet() {
    String[] listenerClassNames =
        StringUtil.split(
            GetterUtil.getString(
                com.liferay.util.service.ServiceProps.get(
                    "value.object.listener.com.asu.poly.teams.manualSelect.slayer.model.Faculty")));

    if (listenerClassNames.length > 0) {
      try {
        List<ModelListener<Faculty>> listenersList = new ArrayList<ModelListener<Faculty>>();

        for (String listenerClassName : listenerClassNames) {
          listenersList.add(
              (ModelListener<Faculty>) InstanceFactory.newInstance(listenerClassName));
        }

        listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
      } catch (Exception e) {
        _log.error(e);
      }
    }
  }
Пример #13
0
  public void setTemplateLoaders(String[] freeMarkerTemplateLoaderClassNames) {

    List<FreeMarkerTemplateLoader> freeMarkerTemplateLoaders =
        new ArrayList<FreeMarkerTemplateLoader>(freeMarkerTemplateLoaderClassNames.length);

    for (String freeMarkerTemplateLoaderClassName : freeMarkerTemplateLoaderClassNames) {

      try {
        FreeMarkerTemplateLoader freeMarkerTemplateLoader =
            (FreeMarkerTemplateLoader)
                InstanceFactory.newInstance(freeMarkerTemplateLoaderClassName);

        freeMarkerTemplateLoaders.add(freeMarkerTemplateLoader);
      } catch (Exception e) {
        _log.error(e, e);
      }
    }

    _freeMarkerTemplateLoaders =
        freeMarkerTemplateLoaders.toArray(
            new FreeMarkerTemplateLoader[freeMarkerTemplateLoaders.size()]);
  }
  /** Initializes the bar persistence. */
  public void afterPropertiesSet() {
    String[] listenerClassNames =
        StringUtil.split(
            GetterUtil.getString(
                com.liferay.util.service.ServiceProps.get(
                    "value.object.listener.com.liferay.testtransaction.model.Bar")));

    if (listenerClassNames.length > 0) {
      try {
        List<ModelListener<Bar>> listenersList = new ArrayList<ModelListener<Bar>>();

        for (String listenerClassName : listenerClassNames) {
          listenersList.add(
              (ModelListener<Bar>)
                  InstanceFactory.newInstance(getClassLoader(), listenerClassName));
        }

        listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
      } catch (Exception e) {
        _log.error(e);
      }
    }
  }
  /** Initializes the j i r a change item persistence. */
  public void afterPropertiesSet() {
    String[] listenerClassNames =
        StringUtil.split(
            GetterUtil.getString(
                com.liferay.util.service.ServiceProps.get(
                    "value.object.listener.com.liferay.socialcoding.model.JIRAChangeItem")));

    if (listenerClassNames.length > 0) {
      try {
        List<ModelListener<JIRAChangeItem>> listenersList =
            new ArrayList<ModelListener<JIRAChangeItem>>();

        for (String listenerClassName : listenerClassNames) {
          listenersList.add(
              (ModelListener<JIRAChangeItem>) InstanceFactory.newInstance(listenerClassName));
        }

        listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
      } catch (Exception e) {
        _log.error(e);
      }
    }
  }
  /** Initializes the threat_subcategories_lkp persistence. */
  public void afterPropertiesSet() {
    String[] listenerClassNames =
        StringUtil.split(
            GetterUtil.getString(
                com.liferay.util.service.ServiceProps.get(
                    "value.object.listener.com.iucn.whp.dbservice.model.threat_subcategories_lkp")));

    if (listenerClassNames.length > 0) {
      try {
        List<ModelListener<threat_subcategories_lkp>> listenersList =
            new ArrayList<ModelListener<threat_subcategories_lkp>>();

        for (String listenerClassName : listenerClassNames) {
          listenersList.add(
              (ModelListener<threat_subcategories_lkp>)
                  InstanceFactory.newInstance(listenerClassName));
        }

        listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
      } catch (Exception e) {
        _log.error(e);
      }
    }
  }
  @Override
  public PortalCacheManagerListener create(
      EhcachePortalCacheManager<?, ?> ehcachePortalCacheManager, Properties properties) {

    String className =
        properties.getProperty(EhcacheConstants.CACHE_MANAGER_LISTENER_FACTORY_CLASS_NAME);

    if (Validator.isNull(className)) {
      return null;
    }

    try {
      CacheManagerEventListenerFactory cacheManagerEventListenerFactory =
          (CacheManagerEventListenerFactory)
              InstanceFactory.newInstance(getClassLoader(), className);

      return new EhcachePortalCacheManagerListenerAdapter(
          cacheManagerEventListenerFactory.createCacheManagerEventListener(
              ehcachePortalCacheManager.getEhcacheManager(), properties));
    } catch (Exception e) {
      throw new SystemException(
          "Unable to instantiate cache manager event listener " + className, e);
    }
  }
  /** Initializes the tra cuu thu tuc hanh chinh persistence. */
  public void afterPropertiesSet() {
    String[] listenerClassNames =
        StringUtil.split(
            GetterUtil.getString(
                com.liferay.util.service.ServiceProps.get(
                    "value.object.listener.org.oep.cmon.dao.touchscreen.model.TraCuuThuTucHanhChinh")));

    if (listenerClassNames.length > 0) {
      try {
        List<ModelListener<TraCuuThuTucHanhChinh>> listenersList =
            new ArrayList<ModelListener<TraCuuThuTucHanhChinh>>();

        for (String listenerClassName : listenerClassNames) {
          listenersList.add(
              (ModelListener<TraCuuThuTucHanhChinh>)
                  InstanceFactory.newInstance(listenerClassName));
        }

        listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
      } catch (Exception e) {
        _log.error(e);
      }
    }
  }
Пример #19
0
  public String transform(
      ThemeDisplay themeDisplay,
      Map<String, String> tokens,
      String viewMode,
      String languageId,
      String xml,
      String script,
      String langType)
      throws Exception {

    // Setup listeners

    if (_log.isDebugEnabled()) {
      _log.debug("Language " + languageId);
    }

    if (Validator.isNull(viewMode)) {
      viewMode = Constants.VIEW;
    }

    if (_logTokens.isDebugEnabled()) {
      String tokensString = PropertiesUtil.list(tokens);

      _logTokens.debug(tokensString);
    }

    if (_logTransformBefore.isDebugEnabled()) {
      _logTransformBefore.debug(xml);
    }

    List<TransformerListener> transformerListeners = new ArrayList<TransformerListener>();

    for (String transformerListenersClassName : _transformerListenerClassNames) {

      TransformerListener transformerListener = null;

      try {
        if (_log.isDebugEnabled()) {
          _log.debug("Instantiate listener " + transformerListenersClassName);
        }

        ClassLoader classLoader = PortalClassLoaderUtil.getClassLoader();

        transformerListener =
            (TransformerListener)
                InstanceFactory.newInstance(classLoader, transformerListenersClassName);

        transformerListeners.add(transformerListener);
      } catch (Exception e) {
        _log.error(e, e);
      }

      // Modify XML

      if (_logXmlBeforeListener.isDebugEnabled()) {
        _logXmlBeforeListener.debug(xml);
      }

      if (transformerListener != null) {
        xml = transformerListener.onXml(xml, languageId, tokens);

        if (_logXmlAfterListener.isDebugEnabled()) {
          _logXmlAfterListener.debug(xml);
        }
      }

      // Modify script

      if (_logScriptBeforeListener.isDebugEnabled()) {
        _logScriptBeforeListener.debug(script);
      }

      if (transformerListener != null) {
        script = transformerListener.onScript(script, xml, languageId, tokens);

        if (_logScriptAfterListener.isDebugEnabled()) {
          _logScriptAfterListener.debug(script);
        }
      }
    }

    // Transform

    String output = null;

    if (Validator.isNull(langType)) {
      output = LocalizationUtil.getLocalization(xml, languageId);
    } else {
      long companyId = 0;
      long companyGroupId = 0;
      long articleGroupId = 0;

      if (tokens != null) {
        companyId = GetterUtil.getLong(tokens.get("company_id"));
        companyGroupId = GetterUtil.getLong(tokens.get("company_group_id"));
        articleGroupId = GetterUtil.getLong(tokens.get("article_group_id"));
      }

      long scopeGroupId = 0;
      long siteGroupId = 0;

      if (themeDisplay != null) {
        companyId = themeDisplay.getCompanyId();
        companyGroupId = themeDisplay.getCompanyGroupId();
        scopeGroupId = themeDisplay.getScopeGroupId();
        siteGroupId = themeDisplay.getSiteGroupId();
      }

      String templateId = tokens.get("template_id");

      templateId = getTemplateId(templateId, companyId, companyGroupId, articleGroupId);

      Template template = getTemplate(templateId, tokens, languageId, xml, script, langType);

      UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter();

      try {
        if (Validator.isNotNull(xml)) {
          Document document = SAXReaderUtil.read(xml);

          Element rootElement = document.getRootElement();

          List<TemplateNode> templateNodes = getTemplateNodes(themeDisplay, rootElement);

          if (templateNodes != null) {
            for (TemplateNode templateNode : templateNodes) {
              template.put(templateNode.getName(), templateNode);
            }
          }

          Element requestElement = rootElement.element("request");

          template.put("request", insertRequestVariables(requestElement));

          template.put("xmlRequest", requestElement.asXML());
        }

        template.put("articleGroupId", articleGroupId);
        template.put("company", getCompany(themeDisplay, companyId));
        template.put("companyId", companyId);
        template.put("device", getDevice(themeDisplay));

        String templatesPath = getTemplatesPath(companyId, articleGroupId);

        template.put("journalTemplatesPath", templatesPath);

        Locale locale = LocaleUtil.fromLanguageId(languageId);

        template.put("locale", locale);

        template.put("permissionChecker", PermissionThreadLocal.getPermissionChecker());
        template.put(
            "randomNamespace",
            PwdGenerator.getPassword(PwdGenerator.KEY3, 4) + StringPool.UNDERLINE);
        template.put("scopeGroupId", scopeGroupId);
        template.put("siteGroupId", siteGroupId);
        template.put("templatesPath", templatesPath);
        template.put("viewMode", viewMode);

        // Deprecated variables

        template.put("groupId", articleGroupId);

        mergeTemplate(template, unsyncStringWriter);
      } catch (Exception e) {
        if (e instanceof DocumentException) {
          throw new TransformException("Unable to read XML document", e);
        } else if (e instanceof IOException) {
          throw new TransformException("Error reading template", e);
        } else if (e instanceof TransformException) {
          throw (TransformException) e;
        } else {
          throw new TransformException("Unhandled exception", e);
        }
      }

      output = unsyncStringWriter.toString();
    }

    // Postprocess output

    for (TransformerListener transformerListener : transformerListeners) {

      // Modify output

      if (_logOutputBeforeListener.isDebugEnabled()) {
        _logOutputBeforeListener.debug(output);
      }

      output = transformerListener.onOutput(output, languageId, tokens);

      if (_logOutputAfterListener.isDebugEnabled()) {
        _logOutputAfterListener.debug(output);
      }
    }

    if (_logTransfromAfter.isDebugEnabled()) {
      _logTransfromAfter.debug(output);
    }

    return output;
  }
  protected void instantiatingListener(String listenerClassName) throws Exception {

    if (_log.isDebugEnabled()) {
      _log.debug("Instantiating " + listenerClassName);
    }

    Object listener = InstanceFactory.newInstance(pluginClassLoader, listenerClassName);

    if (listener instanceof HttpSessionActivationListener) {
      if (_httpSessionActivationListeners == null) {
        _httpSessionActivationListeners = new CopyOnWriteArrayList<HttpSessionActivationListener>();
      }

      _httpSessionActivationListeners.add((HttpSessionActivationListener) listener);
    }

    if (listener instanceof HttpSessionAttributeListener) {
      if (_httpSessionAttributeListeners == null) {
        _httpSessionAttributeListeners = new CopyOnWriteArrayList<HttpSessionAttributeListener>();
      }

      _httpSessionAttributeListeners.add((HttpSessionAttributeListener) listener);
    }

    if (listener instanceof HttpSessionBindingListener) {
      if (_httpSessionBindingListeners == null) {
        _httpSessionBindingListeners = new CopyOnWriteArrayList<HttpSessionBindingListener>();
      }

      _httpSessionBindingListeners.add((HttpSessionBindingListener) listener);
    }

    if (listener instanceof HttpSessionListener) {
      if (_httpSessionListeners == null) {
        _httpSessionListeners = new CopyOnWriteArrayList<HttpSessionListener>();
      }

      _httpSessionListeners.add((HttpSessionListener) listener);
    }

    if (listener instanceof ServletContextListener) {
      if (_servletContextListeners == null) {
        _servletContextListeners = new CopyOnWriteArrayList<ServletContextListener>();
      }

      ServletContextListener servletContextListener = (ServletContextListener) listener;

      _servletContextListeners.add(servletContextListener);

      ServletContextEvent servletContextEvent = new ServletContextEvent(servletContext);

      servletContextListener.contextInitialized(servletContextEvent);
    }

    if (listener instanceof ServletRequestAttributeListener) {
      if (_servletRequestAttributeListeners == null) {
        _servletRequestAttributeListeners =
            new CopyOnWriteArrayList<ServletRequestAttributeListener>();
      }

      _servletRequestAttributeListeners.add((ServletRequestAttributeListener) listener);
    }

    if (listener instanceof ServletRequestListener) {
      if (_servletRequestListeners == null) {
        _servletRequestListeners = new CopyOnWriteArrayList<ServletRequestListener>();
      }

      _servletRequestListeners.add((ServletRequestListener) listener);
    }
  }