当前位置: 首页>>代码示例>>Scala>>正文


Scala DateTimeUtils类代码示例

本文整理汇总了Scala中uk.gov.hmrc.time.DateTimeUtils的典型用法代码示例。如果您正苦于以下问题:Scala DateTimeUtils类的具体用法?Scala DateTimeUtils怎么用?Scala DateTimeUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DateTimeUtils类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。

示例1: TagNames

//设置package包名称以及导入依赖的类
package uk.gov.hmrc.audit.model

import java.util.UUID

import org.joda.time.DateTime
import uk.gov.hmrc.http.{HeaderCarrier, HeaderNames}
import uk.gov.hmrc.play.audit.model.DataCall
import uk.gov.hmrc.time.DateTimeUtils

object TagNames {
  val path = "path"
  val clientIP = "clientIP"
  val clientPort = "clientPort"
  val transactionName = "transactionName"
  val requestID: String = HeaderNames.xRequestId
  val sessionID: String = HeaderNames.xSessionId
  val authorisation: String = HeaderNames.authorisation

  val excludedFromDetail = Seq(path, clientIP, clientPort, transactionName, requestID, sessionID, authorisation)
}

object LegacyDetailNames {
  val method = "method"
  val statusCode = "method"
  val requestBody = "requestBody"
  val responseMessage = "responseMessage"
  val akamaiReputation = "Akamai-Reputation"
}


@deprecated("Use class uk.gov.hmrc.audit.model.AuditEvent")
object DataEvent {
  def apply(auditSource: String,
    auditType: String,
    eventId: String = UUID.randomUUID().toString,
    tags: Map[String, String] = Map.empty,
    detail: Map[String, String] = Map.empty,
    generatedAt: DateTime = DateTimeUtils.now)(implicit hc: HeaderCarrier = HeaderCarrier()): AuditEvent = {

    val sessionId = if (tags.contains(TagNames.sessionID)) Some(tags(TagNames.sessionID)) else None
    val authorisationToken = if (tags.contains(TagNames.authorisation)) Some(tags(TagNames.authorisation)) else None
    val requestId = Some(tags.getOrElse(TagNames.requestID, ""))
    val clientIP = if (tags.contains(TagNames.clientIP)) Some(tags(TagNames.clientIP)) else None
    val clientPort = if (tags.contains(TagNames.clientPort)) Some(tags(TagNames.clientPort).toInt) else None

    AuditEvent(auditSource,
      auditType,
      "method",
      tags.getOrElse("path", ""),
      generatedAt,
      detail,
      eventID = eventId,
      requestID = requestId,
      sessionID = sessionId,
      authorisationToken = authorisationToken,
      clientIP = clientIP,
      clientPort = clientPort
    ).withTags(tags.filterNot(tag => TagNames.excludedFromDetail.contains(tag._1)).toArray:_*)
  }
} 
开发者ID:hmrc,项目名称:auditing,代码行数:61,代码来源:LegacyEventCompanions.scala


注:本文中的uk.gov.hmrc.time.DateTimeUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。