<commit_before>package global

/**
 * Original work: SecureSocial (https://github.com/jaliss/securesocial)
 * Copyright 2014 <NAME> (jaliss at gmail dot com) - twitter: @jaliss
 *
 * Derivative work: Physalis (https://github.com/danbeck/physalis)
 * Modifications Copyright 2014-2015 <NAME> (d.danielbeck at googlemail dot com)- twitter:  @ddanieltwitt
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

import java.lang.reflect.Constructor

import controllers.CustomRoutesService
import models.{ PhysalisProfile, User }
import play.Play
import play.api.Logger
import play.api.Application
import play.api.data.Form
import play.api.i18n.Lang
import play.api.mvc.RequestHeader
import securesocial.views.html.Registration
import play.twirl.api.Html
import securesocial.controllers.{ ChangeInfo, RegistrationInfo, ViewTemplates }
import securesocial.core.RuntimeEnvironment
import securesocial.core.providers.GitHubProvider
import securesocial.core.services.UserService
import service.{ PhysalisBuildService, InMemoryUserService, SecureSocialEventListener }
import service.simpledb.{ UserService => SimpleDBUserService }

import scala.collection.immutable.ListMap

object Global extends play.api.GlobalSettings {

  val logger: Logger = Logger.apply(this.getClass)
  var application: Application = null

  def platforms: Option[List[String]] = {
    val platformsToBuildFor: Option[String] = application.configuration.getString("PLATFORMS_TO_BUILD_FOR")
    platformsToBuildFor.map(string => string.split(",").toList)
  }

  override def onStart(app: Application) = {
    application = app
    logger.info(s"Starting services. Configured build platforms ${platforms}")
    PhysalisBuildService.start(platforms)
  }

  override def onStop(app: Application) = {
    logger.info("stopping Physalis")
    PhysalisBuildService.stop()
  }

  /**
   * An implementation that checks if the controller expects a RuntimeEnvironment and
   * passes the instance to it if required.
   *
   * This can be replaced by any DI framework to inject it differently.
   *
   * @param controllerClass
   * @tparam A
   * @return
   */
  override def getControllerInstance[A](controllerClass: Class[A]): A = {
    val instance = controllerClass.getConstructors.find { c =>
      val params = c.getParameterTypes
      params.length == 1 && params(0) == classOf[RuntimeEnvironment[User]]
    }.map {
      _.asInstanceOf[Constructor[A]].newInstance(MyRuntimeEnvironment)
    }
    instance.getOrElse(super.getControllerInstance(controllerClass))
  }

  object MyViewTemplates {

    /**
     * The default views.
     */
    class Default(env: RuntimeEnvironment[_]) extends ViewTemplates {
      implicit val implicitEnv = env

      override def getLoginPage(form: Form[(String, String)],
                                msg: Option[String] = None)(implicit request: RequestHeader, lang: Lang): Html =
        views.html.login(null)

      override def getSignUpPage(form: Form[RegistrationInfo], token: String)(implicit request: RequestHeader, lang: Lang): Html =
        Registration.signUp(form, token)

      override def getStartSignUpPage(form: Form[String])(implicit request: RequestHeader, lang: Lang): Html =
        Registration.startSignUp(form)

      override def getStartResetPasswordPage(form: Form[String])(implicit request: RequestHeader, lang: Lang): Html =
        Registration.startResetPassword(form)

      override def getResetPasswordPage(form: Form[(String, String)], token: String)(implicit request: RequestHeader, lang: Lang): Html =
        Registration.resetPasswordPage(form, token)

      override def getPasswordChangePage(form: Form[ChangeInfo])(implicit request: RequestHeader, lang: Lang): Html =
        securesocial.views.html.passwordChange(form)
<commit_msg>Login Page raised a NullPointerException.<commit_after>package global

/**
 * Original work: SecureSocial (https://github.com/jaliss/securesocial)
 * Copyright 2014 <NAME> (jaliss at gmail dot com) - twitter: @jaliss
 *
 * Derivative work: Physalis (https://github.com/danbeck/physalis)
 * Modifications Copyright 2014-2015 <NAME> (d.danielbeck at googlemail dot com)- twitter:  @ddanieltwitt
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

import java.lang.reflect.Constructor

import controllers.CustomRoutesService
import models.{ PhysalisProfile, User }
import play.Play
import play.api.Logger
import play.api.Application
import play.api.data.Form
import play.api.i18n.Lang
import play.api.mvc.RequestHeader
import securesocial.views.html.Registration
import play.twirl.api.Html
import securesocial.controllers.{ ChangeInfo, RegistrationInfo, ViewTemplates }
import securesocial.core.RuntimeEnvironment
import securesocial.core.providers.GitHubProvider
import securesocial.core.services.UserService
import service.{ PhysalisBuildService, InMemoryUserService, SecureSocialEventListener }
import service.simpledb.{ UserService => SimpleDBUserService }

import scala.collection.immutable.ListMap

object Global extends play.api.GlobalSettings {

  val logger: Logger = Logger.apply(this.getClass)
  var application: Application = null

  def platforms: Option[List[String]] = {
    val platformsToBuildFor: Option[String] = application.configuration.getString("PLATFORMS_TO_BUILD_FOR")
    platformsToBuildFor.map(string => string.split(",").toList)
  }

  override def onStart(app: Application) = {
    application = app
    logger.info(s"Starting services. Configured build platforms ${platforms}")
    PhysalisBuildService.start(platforms)
  }

  override def onStop(app: Application) = {
    logger.info("stopping Physalis")
    PhysalisBuildService.stop()
  }

  /**
   * An implementation that checks if the controller expects a RuntimeEnvironment and
   * passes the instance to it if required.
   *
   * This can be replaced by any DI framework to inject it differently.
   *
   * @param controllerClass
   * @tparam A
   * @return
   */
  override def getControllerInstance[A](controllerClass: Class[A]): A = {
    val instance = controllerClass.getConstructors.find { c =>
      val params = c.getParameterTypes
      params.length == 1 && params(0) == classOf[RuntimeEnvironment[User]]
    }.map {
      _.asInstanceOf[Constructor[A]].newInstance(MyRuntimeEnvironment)
    }
    instance.getOrElse(super.getControllerInstance(controllerClass))
  }

  object MyViewTemplates {

    /**
     * The default views.
     */
    class Default(env: RuntimeEnvironment[_]) extends ViewTemplates {
      implicit val implicitEnv = env

      override def getLoginPage(form: Form[(String, String)],
                                msg: Option[String] = None)(implicit request: RequestHeader, lang: Lang): Html =
        views.html.login(None)

      override def getSignUpPage(form: Form[RegistrationInfo], token: String)(implicit request: RequestHeader, lang: Lang): Html =
        Registration.signUp(form, token)

      override def getStartSignUpPage(form: Form[String])(implicit request: RequestHeader, lang: Lang): Html =
        Registration.startSignUp(form)

      override def getStartResetPasswordPage(form: Form[String])(implicit request: RequestHeader, lang: Lang): Html =
        Registration.startResetPassword(form)

      override def getResetPasswordPage(form: Form[(String, String)], token: String)(implicit request: RequestHeader, lang: Lang): Html =
        Registration.resetPasswordPage(form, token)

      override def getPasswordChangePage(form: Form[ChangeInfo])(implicit request: RequestHeader, lang: Lang): Html =
        securesocial.views.html.passwordChange(form)

{'fraction_non_alphanumeric': 0.09483360484058645, 'fraction_numerical': 0.004654410053525715, 'mean_word_length': 4.285977859778598, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6054698', 'n_tokens_mistral': 2391, 'n_tokens_neox': 2314, 'n_words': 674}