From 8682b0408ad2d05870b6f95b84f09542515a57d9 Mon Sep 17 00:00:00 2001 From: Elaad Date: Thu, 26 Sep 2019 15:21:38 +0200 Subject: [PATCH] Work in progress --- .../rudder/rest/internal/EventLogAPI.scala | 75 +- .../rudder/web/services/DiffDisplayer.scala | 9 - .../web/services/EventLogDetailsService.scala | 187 +- .../web/services/RudderProperties.scala | 51 - .../bootstrap/liftweb/RudderConfig.scala | 2 +- .../web/services/EventListDisplayer.scala | 1743 +++++++++-------- .../javascript/rudder/rudder-datatable.js | 48 + .../webapp/secure/utilities/eventLogs.html | 27 + 8 files changed, 1123 insertions(+), 1019 deletions(-) delete mode 100644 webapp/sources/rudder/rudder-rest/src/main/scala/com/normation/rudder/web/services/RudderProperties.scala diff --git a/webapp/sources/rudder/rudder-rest/src/main/scala/com/normation/rudder/rest/internal/EventLogAPI.scala b/webapp/sources/rudder/rudder-rest/src/main/scala/com/normation/rudder/rest/internal/EventLogAPI.scala index 492641e31c3..3be00c4c46d 100644 --- a/webapp/sources/rudder/rudder-rest/src/main/scala/com/normation/rudder/rest/internal/EventLogAPI.scala +++ b/webapp/sources/rudder/rudder-rest/src/main/scala/com/normation/rudder/rest/internal/EventLogAPI.scala @@ -42,6 +42,7 @@ import com.normation.rudder.db.Doobie import com.normation.rudder.repository.EventLogRepository import com.normation.rudder.rest.RestExtractorService import com.normation.rudder.rest.RestUtils._ +import com.normation.rudder.services.user.PersonIdentService import com.normation.rudder.web.components.DateFormaterService import com.normation.rudder.web.services._ import net.liftweb.common._ @@ -50,11 +51,14 @@ import net.liftweb.http.{JsonResponse, LiftResponse, Req, S} import net.liftweb.json.JValue import net.liftweb.json.JsonDSL._ +import scala.xml.NodeSeq + class EventLogAPI ( repos: EventLogRepository , restExtractor : RestExtractorService , eventLogDetail : EventListDisplayer , doobie : Doobie + , personIdentService : PersonIdentService ) extends RestHelper with Loggable { def serialize(event: EventLog): JValue = { @@ -96,7 +100,7 @@ class EventLogAPI ( def requestDispatch: PartialFunction[Req, () => Box[LiftResponse]] = { case Get(Nil, req) => - + println("NORMAL") val draw = req.params.get("draw") match { case Some(value :: Nil) => Full(value.toInt) case None => Failure("Missing 'draw' field from datatable's request") @@ -141,6 +145,7 @@ class EventLogAPI ( JsonResponse(response, Nil, Nil, 200) case Get(id :: "details" :: Nil, _) => + println("DETAILS") repos.getEventLogByCriteria(Some(s"id = $id")).toBox match { case Full(e) => e.headOption match { @@ -150,6 +155,7 @@ class EventLogAPI ( case _ => None }) val htmlDetails = eventLogDetail.displayDetails(eventLog, crid) + println(htmlDetails.toString()) toJsonResponse(None, "content" -> htmlDetails.toString())("eventdetails", prettify = false) case None => toJsonError(None, s"EventLog $id not found")("eventdetails", prettify = false) @@ -158,6 +164,71 @@ class EventLogAPI ( val e = eb ?~! s"Error when trying to retrieve eventlog : $id" toJsonError(None, e.messageChain)("eventdetails", prettify = false) } - } + + case Get(id :: "details" :: "rollback" :: Nil, req) => + println("ROLLBACK ACTION") + val logId = id.toInt + + val mode = req.params.get("mode") match { + case Some(value :: Nil) if(value.toLowerCase() == "cancel" || value.toLowerCase() == "confirm") => Full(value.toLowerCase()) + case Some(value :: Nil) => Failure(s"Unknow '${value}' mode") + case None => Failure(s"Missing 'mode' field in request : ${req}") + } + val action = req.params.get("action") match { + case Some(value :: Nil) if(value.toLowerCase() == "after") => Full(eventLogDetail.RollbackTo) + case Some(value :: Nil) if(value.toLowerCase() == "before") => Full(eventLogDetail.RollbackBefore) + case Some(value :: Nil) => Failure(s"Unknow '${value}' action") + case None => Failure(s"Missing 'action' field in request : ${req}") + } + + mode match { + case Full(v) => v match { + case "cancel" => + toJsonResponse(None, "action" -> "cancel")("eventdetails", prettify = false) + + case "confirm" => + action match { + case Full(a) => + val select = a.selectRollbackedEventsRequest(logId) + repos.getEventLogByCriteria(Some(select)).toBox match { + case Full(events) => + val rollbackedEvents = events.filter(_.canRollBack) + repos.getEventLogByCriteria((Some(s"id = $id"))).toBox match { + case Full(e) => + e.headOption match { + case Some(event) => + personIdentService.getPersonIdentOrDefault(CurrentUserService.actor.name).toBox match { + case Full(commiter) => + a.action(event, commiter, rollbackedEvents, event) +// S.redirectTo("eventLogs") + toJsonResponse(None, "content" -> "confirm")("eventdetails", prettify = false) + case eb:EmptyBox => + val e = eb ?~! "this should not happen, as person identifier service always return a working value" + toJsonError(None, e.messageChain)("eventdetails", prettify = false) + } + + case None => + toJsonError(None, s"EventLog $id not found")("eventdetails", prettify = false) + } + case eb: EmptyBox => + val e = eb ?~! "Problem while performing a rollback" + toJsonError(None, e.messageChain)("eventdetails", prettify = false) + } + case eb: EmptyBox => + val e = eb ?~! "Problem while performing a rollback" + toJsonError(None, e.messageChain)("eventdetails", prettify = false) + } + case eb: EmptyBox => + val e = eb ?~! "Problem while performing a rollback" + toJsonError(None, e.messageChain)("eventdetails", prettify = false) + } + } + case eb: EmptyBox => + val e = eb ?~! s"Error when trying to use eventlog's Rollback feature : $id" + toJsonError(None, e.messageChain)("eventdetails", prettify = false) + // empty confirm[ID] and show rollback[ID] + // dialog in confirm[ID] and hide rollback[ID] + } + } serve("secure" / "api" / "eventlog" prefix requestDispatch) } diff --git a/webapp/sources/rudder/rudder-rest/src/main/scala/com/normation/rudder/web/services/DiffDisplayer.scala b/webapp/sources/rudder/rudder-rest/src/main/scala/com/normation/rudder/web/services/DiffDisplayer.scala index 646f285fb44..0224f619cf1 100644 --- a/webapp/sources/rudder/rudder-rest/src/main/scala/com/normation/rudder/web/services/DiffDisplayer.scala +++ b/webapp/sources/rudder/rudder-rest/src/main/scala/com/normation/rudder/web/services/DiffDisplayer.scala @@ -47,16 +47,7 @@ import net.liftweb.common.Full import net.liftweb.common.EmptyBox import net.liftweb.common.Loggable import com.normation.rudder.domain.policies._ -import com.normation.rudder.repository.ldap.{LDAPEntityMapper, RoLDAPNodeGroupRepository, RoLDAPRuleRepository, ScalaLock} import com.normation.rudder.web.model.LinkUtil -import RudderProperties._ -import com.normation.inventory.ldap.core.{InventoryDit, InventoryDitService, InventoryDitServiceImpl, InventoryMapper} -import com.normation.ldap.sdk.ROPooledSimpleAuthConnectionProvider -import com.normation.rudder.domain.logger.ApplicationLogger -import com.normation.rudder.domain.queries.{DitQueryData, ObjectCriterion, SubGroupChoice} -import com.normation.rudder.services.queries.{CmdbQueryParser, DefaultStringQueryParser, JsonQueryLexer} -import com.typesafe.config.ConfigException - import scala.language.implicitConversions trait DiffItem[T] { diff --git a/webapp/sources/rudder/rudder-rest/src/main/scala/com/normation/rudder/web/services/EventLogDetailsService.scala b/webapp/sources/rudder/rudder-rest/src/main/scala/com/normation/rudder/web/services/EventLogDetailsService.scala index 295dfa74aee..861538fbb47 100644 --- a/webapp/sources/rudder/rudder-rest/src/main/scala/com/normation/rudder/web/services/EventLogDetailsService.scala +++ b/webapp/sources/rudder/rudder-rest/src/main/scala/com/normation/rudder/web/services/EventLogDetailsService.scala @@ -382,104 +382,105 @@ class EventListDisplayer( } def showConfirmationDialog(action : RollBackAction, commiter:PersonIdent) : JsCmd = { - val cancel : JsCmd = { - SetHtml("confirm%d".format(event.id.getOrElse(0)), NodeSeq.Empty) & - JsRaw(""" $('#rollback%d').show();""".format(event.id.getOrElse(0))) - } - - val dialog = -

- - {"Are you sure you want to restore configuration policy %s this change".format(action.name)} -

- { - SHtml.ajaxButton( - "Cancel" - , () => cancel - , ("class","btn btn-default") - ) - } - { - SHtml.ajaxButton( - "Confirm" - , () => { - event.id match { - case Some(id) => val select = action.selectRollbackedEventsRequest(id) - repos.getEventLogByCriteria(Some(select)).toBox match { - case Full(events) => - val rollbackedEvents = events.filter(_.canRollBack) - action.action(event,commiter,rollbackedEvents,event) - S.redirectTo("eventLogs") - case eb => S.error("Problem while performing a rollback") - logger.error("Problem while performing a rollback : ",eb) - cancel - } - case None => val failure = "Problem while performing a rollback, could not find event id" - S.error(failure) - logger.error(failure) - cancel - } - } - ,("class" ,"btn btn-danger") - ) - } - - def showDialog : JsCmd = { - SetHtml("confirm%d".format(event.id.getOrElse(0)), dialog) & - JsRaw(""" $('#rollback%d').hide(); - $('#confirm%d').stop(true, true).slideDown(1000); """.format(event.id.getOrElse(0),event.id.getOrElse(0))) - } - - showDialog +// val cancel : JsCmd = { +// SetHtml("confirm%d".format(event.id.getOrElse(0)), NodeSeq.Empty) & +// JsRaw(""" $('#rollback%d').show();""".format(event.id.getOrElse(0))) +// } +// +// val dialog = +//

+// +// {"Are you sure you want to restore configuration policy %s this change".format(action.name)} +//

+// { +// SHtml.ajaxButton( +// "Cancel" +// , () => cancel +// , ("class","btn btn-default") +// ) +// } +// { +// SHtml.ajaxButton( +// "Confirm" +// , () => { +// event.id match { +// case Some(id) => val select = action.selectRollbackedEventsRequest(id) +// repos.getEventLogByCriteria(Some(select)).toBox match { +// case Full(events) => +// val rollbackedEvents = events.filter(_.canRollBack) +// action.action(event,commiter,rollbackedEvents,event) +// S.redirectTo("eventLogs") +// case eb => S.error("Problem while performing a rollback") +// logger.error("Problem while performing a rollback : ",eb) +// cancel +// } +// case None => val failure = "Problem while performing a rollback, could not find event id" +// S.error(failure) +// logger.error(failure) +// cancel +// } +// } +// ,("class" ,"btn btn-danger") +// ) +// } +// +// def showDialog : JsCmd = { +// SetHtml("confirm%d".format(event.id.getOrElse(0)), dialog) & +// JsRaw(""" $('#rollback%d').hide(); +// $('#confirm%d').stop(true, true).slideDown(1000); """.format(event.id.getOrElse(0),event.id.getOrElse(0))) +// } +// +// showDialog } def addRestoreAction() = personIdentService.getPersonIdentOrDefault(CurrentUserService.actor.name).toBox match { case Full(commiter) => - var rollbackAction : RollBackAction = null - - if (event.canRollBack) - modificationService.getCommitsfromEventLog(event).map{ commit => -
-
Rollback -
- Restore configuration policy to -
    { - SHtml.radio( - Seq("before","after") - , Full("before") - , {value:String => - rollbackAction = value match { - case "after" => RollbackTo - case "before" => RollbackBefore - } - } - , ("class", "radio") - ).flatMap(e => -
  • - -
  • - ) - } -
- this change - - { SHtml.ajaxSubmit( - "Restore" - , () => showConfirmationDialog(rollbackAction,commiter) - , ("style","vertical-align:50%;") - , ("class","btn btn-default btn-sm") - ) - } - -
- -
-
- }.getOrElse(NodeSeq.Empty) - else +// var rollbackAction : RollBackAction = null +// +// if (event.canRollBack) +// modificationService.getCommitsfromEventLog(event).map{ commit => +//
+//
Rollback +//
+// Restore configuration policy to +//
    { +// SHtml.radio( +// Seq("before","after") +// , Full("before") +// , {value:String => +// rollbackAction = value match { +// case "after" => RollbackTo +// case "before" => RollbackBefore +// } +// } +// , ("class", "radio") +// ).flatMap(e => +//
  • +// +//
  • +// ) +// } +//
+// this change +// +// { SHtml.ajaxSubmit( +// "Restore" +// , () => showConfirmationDialog(rollbackAction,commiter) +// , ("style","vertical-align:50%;") +// , ("class","btn btn-default btn-sm") +// ) +// } +// +//
+// +//
+//
+// }.getOrElse(NodeSeq.Empty) + // NodeSeq.Empty + // else NodeSeq.Empty case eb:EmptyBox => logger.error("this should not happen, as person identifier service always return a working value") NodeSeq.Empty diff --git a/webapp/sources/rudder/rudder-rest/src/main/scala/com/normation/rudder/web/services/RudderProperties.scala b/webapp/sources/rudder/rudder-rest/src/main/scala/com/normation/rudder/web/services/RudderProperties.scala deleted file mode 100644 index 083bad1faf6..00000000000 --- a/webapp/sources/rudder/rudder-rest/src/main/scala/com/normation/rudder/web/services/RudderProperties.scala +++ /dev/null @@ -1,51 +0,0 @@ -package com.normation.rudder.web.services - -import java.io.File - -import com.normation.rudder.domain.logger.ApplicationLogger -import com.typesafe.config.{Config, ConfigFactory} -import org.springframework.core.io.ClassPathResource -/** - * Define a resource for configuration. - * For now, config properties can only be loaded from either - * a file in the classpath, or a file in the file system. - */ -sealed trait ConfigResource -final case class ClassPathResource(name: String) extends ConfigResource -final case class FileSystemResource(file: File) extends ConfigResource - -object RudderProperties { - - val JVM_CONFIG_FILE_KEY = "rudder.configFile" - val DEFAULT_CONFIG_FILE_NAME = "configuration.properties" - - /** - * Where to go to look for properties - */ - val configResource = System.getProperty(JVM_CONFIG_FILE_KEY) match { - case null | "" => //use default location in classpath - ApplicationLogger.info("JVM property -D%s is not defined, use configuration file in classpath".format(JVM_CONFIG_FILE_KEY)) - ClassPathResource(DEFAULT_CONFIG_FILE_NAME) - case x => //so, it should be a full path, check it - val config = new File(x) - if(config.exists && config.canRead) { - ApplicationLogger.info("Use configuration file defined by JVM property -D%s : %s".format(JVM_CONFIG_FILE_KEY, config.getPath)) - FileSystemResource(config) - } else { - ApplicationLogger.error("Can not find configuration file specified by JVM property %s: %s ; abort".format(JVM_CONFIG_FILE_KEY, config.getPath)) - throw new javax.servlet.UnavailableException("Configuration file not found: %s".format(config.getPath)) - } - } - - // some value used as defaults for migration - val migrationConfig = - s"""rudder.batch.reportscleaner.compliancelevels.delete.TTL=15 - """ - - val config : Config = { - (configResource match { - case ClassPathResource(name) => ConfigFactory.load(name) - case FileSystemResource(file) => ConfigFactory.load(ConfigFactory.parseFile(file)) - }).withFallback(ConfigFactory.parseString(migrationConfig)) - } -} \ No newline at end of file diff --git a/webapp/sources/rudder/rudder-web/src/main/scala/bootstrap/liftweb/RudderConfig.scala b/webapp/sources/rudder/rudder-web/src/main/scala/bootstrap/liftweb/RudderConfig.scala index 01112241f17..dba26c172bc 100644 --- a/webapp/sources/rudder/rudder-web/src/main/scala/bootstrap/liftweb/RudderConfig.scala +++ b/webapp/sources/rudder/rudder-web/src/main/scala/bootstrap/liftweb/RudderConfig.scala @@ -809,7 +809,7 @@ object RudderConfig extends Loggable { // Internal APIs val sharedFileApi = new SharedFilesAPI(restExtractorService,RUDDER_DIR_SHARED_FILES_FOLDER) - val eventLogApi= new EventLogAPI(eventLogRepository, restExtractorService, eventListDisplayerImpl, doobie) + val eventLogApi= new EventLogAPI(eventLogRepository, restExtractorService, eventListDisplayerImpl, doobie, personIdentService) lazy val asyncWorkflowInfo = new AsyncWorkflowInfo lazy val configService: ReadConfigService with UpdateConfigService = { diff --git a/webapp/sources/rudder/rudder-web/src/main/scala/com/normation/rudder/web/services/EventListDisplayer.scala b/webapp/sources/rudder/rudder-web/src/main/scala/com/normation/rudder/web/services/EventListDisplayer.scala index b2a0ddbc23e..b0225608485 100644 --- a/webapp/sources/rudder/rudder-web/src/main/scala/com/normation/rudder/web/services/EventListDisplayer.scala +++ b/webapp/sources/rudder/rudder-web/src/main/scala/com/normation/rudder/web/services/EventListDisplayer.scala @@ -88,15 +88,15 @@ import com.normation.box._ * or in the administration EventLogsViewer */ class EventListDisplayer( - logDetailsService : EventLogDetailsService - , repos : EventLogRepository - , nodeGroupRepository : RoNodeGroupRepository - , directiveRepository : RoDirectiveRepository - , nodeInfoService : NodeInfoService - , ruleCatRepository : RoRuleCategoryRepository - , modificationService : ModificationService - , personIdentService : PersonIdentService - , linkUtil : LinkUtil + logDetailsService : EventLogDetailsService + , repos : EventLogRepository + , nodeGroupRepository : RoNodeGroupRepository + , directiveRepository : RoDirectiveRepository + , nodeInfoService : NodeInfoService + , ruleCatRepository : RoRuleCategoryRepository + , modificationService : ModificationService + , personIdentService : PersonIdentService + , linkUtil : LinkUtil ) extends Loggable { private[this] val xmlPretty = new scala.xml.PrettyPrinter(80, 2) @@ -136,25 +136,25 @@ class EventListDisplayer( displayEvents(for { parsed <- tryo(parse(jsonInterval)) ?~! s"Error when trying to parse '${jsonInterval}' as a JSON datastructure with fields 'start' and 'end'" startStr <- parsed \ "start" match { - case JString(startStr) if startStr.nonEmpty => - val date = tryo(DateTime.parse(startStr, format)) ?~! s"Error when trying to parse start date '${startStr}" - date match { - case Full(d) => Full(Some(new Timestamp(d.getMillis))) - case eb: EmptyBox => - eb ?~! s"Invalid start date" - } - case _ => Full(None) - } + case JString(startStr) if startStr.nonEmpty => + val date = tryo(DateTime.parse(startStr, format)) ?~! s"Error when trying to parse start date '${startStr}" + date match { + case Full(d) => Full(Some(new Timestamp(d.getMillis))) + case eb: EmptyBox => + eb ?~! s"Invalid start date" + } + case _ => Full(None) + } endStr <- parsed \ "end" match { - case JString(endStr) if endStr.nonEmpty => - val date = tryo(DateTime.parse(endStr, format)) ?~! s"Error when trying to parse end date '${endStr}" - date match { - case Full(d) => Full(Some(new Timestamp(d.getMillis))) - case eb: EmptyBox => - eb ?~! s"Invalid end date" - } - case _ => Full(None) - } + case JString(endStr) if endStr.nonEmpty => + val date = tryo(DateTime.parse(endStr, format)) ?~! s"Error when trying to parse end date '${endStr}" + date match { + case Full(d) => Full(Some(new Timestamp(d.getMillis))) + case eb: EmptyBox => + eb ?~! s"Invalid end date" + } + case _ => Full(None) + } whereStatement = (startStr, endStr) match { case (None, None) => None case (Some(start), None) => Some(s" creationdate > '$start'") @@ -173,8 +173,8 @@ class EventListDisplayer( Script(OnLoad(JsRaw(s""" var pickEventLogsInInterval = ${AnonFunc(SHtml.ajaxCall(JsRaw( - """'{"start":"'+$(".pickStartInput").val()+'", "end":"'+$(".pickEndInput").val()+'"}'""" - ), getEventsInterval)._2).toJsCmd} + """'{"start":"'+$(".pickStartInput").val()+'", "end":"'+$(".pickEndInput").val()+'"}'""" + ), getEventsInterval)._2).toJsCmd} var refreshEventLogs = ${refresh.toJsCmd}; createEventLogTable('${gridName}',[], '${S.contextPath}', refreshEventLogs, pickEventLogsInInterval) refreshEventLogs(); @@ -194,76 +194,76 @@ class EventListDisplayer( * } */ case class EventLogLine(event : EventLog) extends JsTableLine { - val detailsCallback = { - AnonFunc("details",SHtml.ajaxCall(JsVar("details"), {(abc) => - val crId = event.id.flatMap(repos.getEventLogWithChangeRequest(_).toBox match { - case Full(Some((_,crId))) => crId - case _ => None - }) - SetHtml(abc,displayDetails(event,crId)) - } - ) - ) - } + // val detailsCallback = { + // AnonFunc("details",SHtml.ajaxCall(JsVar("details"), {(abc) => + // val crId = event.id.flatMap(repos.getEventLogWithChangeRequest(_).toBox match { + // case Full(Some((_,crId))) => crId + // case _ => None + // }) + // SetHtml(abc,displayDetails(event,crId)) + // } + // ) + // ) + // } val json = { JsObj( - "id" -> (event.id.map(_.toString).getOrElse("Unknown"): String) + "id" -> (event.id.map(_.toString).getOrElse("Unknown"): String) , "date" -> DateFormaterService.getFormatedDate(event.creationDate) , "actor" -> event.principal.name , "type" -> S.?("rudder.log.eventType.names." + event.eventType.serialize) , "description" -> displayDescription(event).toString - , "details" -> detailsCallback + // , "details" -> detailsCallback , "hasDetails" -> boolToJsExp(event.details != ) ) } } - //////////////////// Display description/details of //////////////////// + //////////////////// Display description/details of //////////////////// //convention: "X" means "ignore" def displayDescription(event:EventLog) = { import linkUtil._ def crDesc(x:EventLog, actionName: NodeSeq) = { - val id = (x.details \ "rule" \ "id").text - val name = (x.details \ "rule" \ "displayName").text - Text("Rule ") ++ { - if(id.size < 1) Text(name) - else {name} ++ actionName - } + val id = (x.details \ "rule" \ "id").text + val name = (x.details \ "rule" \ "displayName").text + Text("Rule ") ++ { + if(id.size < 1) Text(name) + else {name} ++ actionName + } } def piDesc(x:EventLog, actionName: NodeSeq) = { - val id = (x.details \ "directive" \ "id").text - val name = (x.details \ "directive" \ "displayName").text - Text("Directive ") ++ { - if(id.size < 1) Text(name) - else {name} ++ actionName - } + val id = (x.details \ "directive" \ "id").text + val name = (x.details \ "directive" \ "displayName").text + Text("Directive ") ++ { + if(id.size < 1) Text(name) + else {name} ++ actionName + } } def groupDesc(x:EventLog, actionName: NodeSeq) = { - val id = (x.details \ "nodeGroup" \ "id").text - val name = (x.details \ "nodeGroup" \ "displayName").text - Text("Group ") ++ { - if(id.size < 1) Text(name) - else {name} ++ actionName - } + val id = (x.details \ "nodeGroup" \ "id").text + val name = (x.details \ "nodeGroup" \ "displayName").text + Text("Group ") ++ { + if(id.size < 1) Text(name) + else {name} ++ actionName + } } def nodeDesc(x:EventLog, actionName: NodeSeq) = { - val id = (x.details \\ "node" \ "id").text - val name = (x.details \\ "node" \ "hostname").text - Text("Node ") ++ { - if ((id.size < 1)||(actionName==Text(" deleted"))) Text(name) - else {name} ++ actionName - } + val id = (x.details \\ "node" \ "id").text + val name = (x.details \\ "node" \ "hostname").text + Text("Node ") ++ { + if ((id.size < 1)||(actionName==Text(" deleted"))) Text(name) + else {name} ++ actionName + } } def techniqueDesc(x:EventLog, actionName: NodeSeq) = { - val name = (x.details \ "activeTechnique" \ "techniqueName").text - Text("Technique %s".format(name)) ++ actionName + val name = (x.details \ "activeTechnique" \ "techniqueName").text + Text("Technique %s".format(name)) ++ actionName } def globalParamDesc(x:EventLog, actionName: NodeSeq) = { @@ -284,7 +284,7 @@ class EventListDisplayer( case Catch(e) => logger.error(s"could not translate ${idNode} to a correct chage request identifier: ${e.getMessage()}") Text(name) - } + } Text("Change request ") ++ xml ++ actionName } @@ -292,8 +292,8 @@ class EventListDisplayer( logDetailsService.getWorkflotStepChange(x.details) match { case Full(WorkflowStepChange(crId,from,to)) => Text("Change request #") ++ - {crId} ++ - Text(s" status modified from ${from} to ${to}") + {crId} ++ + Text(s" status modified from ${from} to ${to}") case eb:EmptyBox => val fail = eb ?~! "could not display workflow step event log" logger.error(fail.msg) @@ -368,10 +368,11 @@ class EventListDisplayer( val generatedByChangeRequest = changeRequestId match { - case None => NodeSeq.Empty - case Some(id) => -// val htmlCR =

This change was introduced by change request {SHtml.a(() => S.redirectTo(linkUtil.changeRequestLink(id)),Text(s"#${id}"))}

- NodeSeq.Empty + case None => NodeSeq.Empty + case Some(id) => + // val htmlCR =

This change was introduced by change request {SHtml.a(() => S.redirectTo(linkUtil.changeRequestLink(id)),Text(s"#${id}"))}

+ NodeSeq.Empty + // htmlCR } def xmlParameters(eventId: Option[Int]) = { eventId match { @@ -380,116 +381,132 @@ class EventListDisplayer( - + } } - def showConfirmationDialog(action : RollBackAction, commiter:PersonIdent) : JsCmd = { - val cancel : JsCmd = { - SetHtml("confirm%d".format(event.id.getOrElse(0)), NodeSeq.Empty) & - JsRaw(""" $('#rollback%d').show();""".format(event.id.getOrElse(0))) - } - - val dialog = -

- - {"Are you sure you want to restore configuration policy %s this change".format(action.name)} -

- { - SHtml.ajaxButton( - "Cancel" - , () => cancel - , ("class","btn btn-default") - ) - } - { - SHtml.ajaxButton( - "Confirm" - , () => { - event.id match { - case Some(id) => val select = action.selectRollbackedEventsRequest(id) - repos.getEventLogByCriteria(Some(select)).toBox match { - case Full(events) => - val rollbackedEvents = events.filter(_.canRollBack) - action.action(event,commiter,rollbackedEvents,event) - S.redirectTo("eventLogs") - case eb => S.error("Problem while performing a rollback") - logger.error("Problem while performing a rollback : ",eb) - cancel - } - case None => val failure = "Problem while performing a rollback, could not find event id" - S.error(failure) - logger.error(failure) - cancel - } - } - ,("class" ,"btn btn-danger") - ) - } - - def showDialog : JsCmd = { - SetHtml("confirm%d".format(event.id.getOrElse(0)), dialog) & - JsRaw(""" $('#rollback%d').hide(); - $('#confirm%d').stop(true, true).slideDown(1000); """.format(event.id.getOrElse(0),event.id.getOrElse(0))) - } - - showDialog - } +// def showConfirmationDialog(action : RollBackAction, commiter:PersonIdent) : JsCmd = { + // val cancel : JsCmd = { + // SetHtml("confirm%d".format(event.id.getOrElse(0)), NodeSeq.Empty) & + // JsRaw(""" $('#rollback%d').show();""".format(event.id.getOrElse(0))) + // } + + // val dialog = + //

+ // + // {"Are you sure you want to restore configuration policy %s this change".format(action.name)} + //

+ // + // + // + // + // + // + // + + // def showDialog : JsCmd = { + // SetHtml("confirm%d".format(event.id.getOrElse(0)), dialog) & + // JsRaw(""" $('#rollback%d').hide(); + // $('#confirm%d').stop(true, true).slideDown(1000); """.format(event.id.getOrElse(0),event.id.getOrElse(0))) + // } + // + // showDialog +// } def addRestoreAction() = personIdentService.getPersonIdentOrDefault(CurrentUserService.actor.name).toBox match { - case Full(commiter) => - var rollbackAction : RollBackAction = null - - if (event.canRollBack) { -// val rollDisplay = modificationService.getCommitsfromEventLog(event).map { commit => -//
-//
-// Rollback -//
-// Restore configuration policy to -//
    -// {SHtml.radio( -// Seq("before", "after") -// , Full("before") -// , { value: String => -// rollbackAction = value match { -// case "after" => RollbackTo -// case "before" => RollbackBefore -// } -// } -// , ("class", "radio") -// ).flatMap(e => -//
  • -// -//
  • -// )} -//
-// this change -// -// {SHtml.ajaxSubmit( -// "Restore" -// , () => showConfirmationDialog(rollbackAction, commiter) -// , ("style", "vertical-align:50%;") -// , ("class", "btn btn-default btn-sm") -// )} -// -//
-// -//
-//
-// }.getOrElse(NodeSeq.Empty) + case Full(commiter) => + var rollbackAction : RollBackAction = null + + if (event.canRollBack) { + // val rollDisplay = modificationService.getCommitsfromEventLog(event).map { commit => + //
+ //
+ // Rollback + //
+ // Restore configuration policy to + //
    + // + // + // + // + + + //
+ // this change + // + // + // + // + //
+ // + //
+ //
+ // }.getOrElse(NodeSeq.Empty) + NodeSeq.Empty + // rollDisplay + } + else + NodeSeq.Empty + case eb:EmptyBox => logger.error("this should not happen, as person identifier service always return a working value") NodeSeq.Empty - } - else - NodeSeq.Empty - case eb:EmptyBox => logger.error("this should not happen, as person identifier service always return a working value") - NodeSeq.Empty - } + } val reasonHtml = { val r = event.eventDetails.reason.getOrElse("") @@ -508,350 +525,350 @@ class EventListDisplayer( } { - (event match { - /* - * bug in scalac : https://issues.scala-lang.org/browse/SI-6897 - * A workaround is to type with a Nodeseq - */ - case add:AddRule => - "*" #> { val xml : NodeSeq = logDetailsService.getRuleAddDetails(add.details) match { - case Full(addDiff) => -
- { generatedByChangeRequest } - { addRestoreAction } - { ruleDetails(crDetailsXML, addDiff.rule, groupLib, rootRuleCategory)} - { reasonHtml } - { xmlParameters(event.id) } -
- case Failure(m,_,_) =>

{m}

- case e:EmptyBox => errorMessage(e) - } - xml - } + (event match { + /* + * bug in scalac : https://issues.scala-lang.org/browse/SI-6897 + * A workaround is to type with a Nodeseq + */ + case add:AddRule => + "*" #> { val xml : NodeSeq = logDetailsService.getRuleAddDetails(add.details) match { + case Full(addDiff) => +
+ { generatedByChangeRequest } + { addRestoreAction } + { ruleDetails(crDetailsXML, addDiff.rule, groupLib, rootRuleCategory)} + { reasonHtml } + { xmlParameters(event.id) } +
+ case Failure(m,_,_) =>

{m}

+ case e:EmptyBox => errorMessage(e) + } + xml + } - case del:DeleteRule => - "*" #> { val xml : NodeSeq = logDetailsService.getRuleDeleteDetails(del.details) match { - case Full(delDiff) => -
- { addRestoreAction } - { generatedByChangeRequest } - { ruleDetails(crDetailsXML, delDiff.rule, groupLib, rootRuleCategory) } - { reasonHtml } - { xmlParameters(event.id) } -
- case e:EmptyBox => errorMessage(e) - } - xml } + case del:DeleteRule => + "*" #> { val xml : NodeSeq = logDetailsService.getRuleDeleteDetails(del.details) match { + case Full(delDiff) => +
+ { addRestoreAction } + { generatedByChangeRequest } + { ruleDetails(crDetailsXML, delDiff.rule, groupLib, rootRuleCategory) } + { reasonHtml } + { xmlParameters(event.id) } +
+ case e:EmptyBox => errorMessage(e) + } + xml } - case mod:ModifyRule => - "*" #> { val xml : NodeSeq = logDetailsService.getRuleModifyDetails(mod.details) match { - case Full(modDiff) => -
- { addRestoreAction } - { generatedByChangeRequest } -

Rule overview:

- - { + case mod:ModifyRule => + "*" #> { val xml : NodeSeq = logDetailsService.getRuleModifyDetails(mod.details) match { + case Full(modDiff) => +
+ { addRestoreAction } + { generatedByChangeRequest } +

Rule overview:

+
    +
  • Rule ID: { modDiff.id.value }
  • +
  • Name: { + modDiff.modName.map(diff => diff.newValue).getOrElse(modDiff.name) + }
  • +
+ { val modCategory = modDiff.modCategory.map { case SimpleDiff(oldOne,newOne) => -
  • Rule category changed:
  • ++ +
  • Rule category changed:
  • ++ DiffDisplayer.displayRuleCategory(rootRuleCategory, oldOne, Some(newOne)) - } - ( - "#name" #> mapSimpleDiff(modDiff.modName) & - "#category" #> modCategory & - "#isEnabled *" #> mapSimpleDiff(modDiff.modIsActivatedStatus) & - "#isSystem *" #> mapSimpleDiff(modDiff.modIsSystem) & - "#shortDescription *" #> mapSimpleDiff(modDiff.modShortDescription) & - "#longDescription *" #> mapSimpleDiff(modDiff.modLongDescription) & - "#target" #> ( - modDiff.modTarget.map{ - case SimpleDiff(oldOnes,newOnes) => -
  • Group Targets changed:
  • ++ - DiffDisplayer.displayRuleTargets(oldOnes.toSeq,newOnes.toSeq, groupLib) - } ) & - "#policies" #> ( - modDiff.modDirectiveIds.map{ - case SimpleDiff(oldOnes,newOnes) => -
  • Directives changed:
  • ++ - DiffDisplayer.displayDirectiveChangeList(oldOnes.toSeq,newOnes.toSeq) - } ) - )(crModDetailsXML) - } - { reasonHtml } - { xmlParameters(event.id) } -
    - case e:EmptyBox => errorMessage(e) - } - xml } + } + ( + "#name" #> mapSimpleDiff(modDiff.modName) & + "#category" #> modCategory & + "#isEnabled *" #> mapSimpleDiff(modDiff.modIsActivatedStatus) & + "#isSystem *" #> mapSimpleDiff(modDiff.modIsSystem) & + "#shortDescription *" #> mapSimpleDiff(modDiff.modShortDescription) & + "#longDescription *" #> mapSimpleDiff(modDiff.modLongDescription) & + "#target" #> ( + modDiff.modTarget.map{ + case SimpleDiff(oldOnes,newOnes) => +
  • Group Targets changed:
  • ++ + DiffDisplayer.displayRuleTargets(oldOnes.toSeq,newOnes.toSeq, groupLib) + } ) & + "#policies" #> ( + modDiff.modDirectiveIds.map{ + case SimpleDiff(oldOnes,newOnes) => +
  • Directives changed:
  • ++ + DiffDisplayer.displayDirectiveChangeList(oldOnes.toSeq,newOnes.toSeq) + } ) + )(crModDetailsXML) + } + { reasonHtml } + { xmlParameters(event.id) } +
    + case e:EmptyBox => errorMessage(e) + } + xml } - ///////// Directive ///////// + ///////// Directive ///////// - case x:ModifyDirective => - "*" #> { val xml : NodeSeq = logDetailsService.getDirectiveModifyDetails(x.details) match { - case Full(modDiff) => -
    - { addRestoreAction } - { generatedByChangeRequest } -

    Directive overview:

    - - {( + case x:ModifyDirective => + "*" #> { val xml : NodeSeq = logDetailsService.getDirectiveModifyDetails(x.details) match { + case Full(modDiff) => +
    + { addRestoreAction } + { generatedByChangeRequest } +

    Directive overview:

    +
      +
    • Directive ID: { modDiff.id.value }
    • +
    • Name: { + modDiff.modName.map(diff => diff.newValue.toString).getOrElse(modDiff.name) + }
    • +
    + {( "#name" #> mapSimpleDiff(modDiff.modName, modDiff.id) & - "#priority *" #> mapSimpleDiff(modDiff.modPriority) & - "#isEnabled *" #> mapSimpleDiff(modDiff.modIsActivated) & - "#isSystem *" #> mapSimpleDiff(modDiff.modIsSystem) & - "#shortDescription *" #> mapSimpleDiff(modDiff.modShortDescription) & - "#longDescription *" #> mapSimpleDiff(modDiff.modLongDescription) & - "#ptVersion *" #> mapSimpleDiff(modDiff.modTechniqueVersion) & - "#parameters" #> ( - modDiff.modParameters.map { diff => - "#diff" #> displaydirectiveInnerFormDiff(diff, event.id) - } - ) - )(piModDirectiveDetailsXML)} - { reasonHtml } - { xmlParameters(event.id) } -
    - case Failure(m, _, _) =>

    {m}

    - case e:EmptyBox => errorMessage(e) - } - xml } + "#priority *" #> mapSimpleDiff(modDiff.modPriority) & + "#isEnabled *" #> mapSimpleDiff(modDiff.modIsActivated) & + "#isSystem *" #> mapSimpleDiff(modDiff.modIsSystem) & + "#shortDescription *" #> mapSimpleDiff(modDiff.modShortDescription) & + "#longDescription *" #> mapSimpleDiff(modDiff.modLongDescription) & + "#ptVersion *" #> mapSimpleDiff(modDiff.modTechniqueVersion) & + "#parameters" #> ( + modDiff.modParameters.map { diff => + "#diff" #> displaydirectiveInnerFormDiff(diff, event.id) + } + ) + )(piModDirectiveDetailsXML)} + { reasonHtml } + { xmlParameters(event.id) } +
    + case Failure(m, _, _) =>

    {m}

    + case e:EmptyBox => errorMessage(e) + } + xml } - case x:AddDirective => - "*" #> { val xml : NodeSeq = logDetailsService.getDirectiveAddDetails(x.details) match { - case Full((diff,sectionVal)) => -
    - { addRestoreAction } - { generatedByChangeRequest } - { directiveDetails(piDetailsXML, diff.techniqueName, - diff.directive, sectionVal) } - { reasonHtml } - { xmlParameters(event.id) } -
    - case e:EmptyBox => errorMessage(e) - } - xml} + case x:AddDirective => + "*" #> { val xml : NodeSeq = logDetailsService.getDirectiveAddDetails(x.details) match { + case Full((diff,sectionVal)) => +
    + { addRestoreAction } + { generatedByChangeRequest } + { directiveDetails(piDetailsXML, diff.techniqueName, + diff.directive, sectionVal) } + { reasonHtml } + { xmlParameters(event.id) } +
    + case e:EmptyBox => errorMessage(e) + } + xml} - case x:DeleteDirective => - "*" #> { val xml : NodeSeq = logDetailsService.getDirectiveDeleteDetails(x.details) match { - case Full((diff,sectionVal)) => -
    - { addRestoreAction } - { generatedByChangeRequest } - { directiveDetails(piDetailsXML, diff.techniqueName, - diff.directive, sectionVal) } - { reasonHtml } - { xmlParameters(event.id) } -
    - case e:EmptyBox => errorMessage(e) - } - xml } + case x:DeleteDirective => + "*" #> { val xml : NodeSeq = logDetailsService.getDirectiveDeleteDetails(x.details) match { + case Full((diff,sectionVal)) => +
    + { addRestoreAction } + { generatedByChangeRequest } + { directiveDetails(piDetailsXML, diff.techniqueName, + diff.directive, sectionVal) } + { reasonHtml } + { xmlParameters(event.id) } +
    + case e:EmptyBox => errorMessage(e) + } + xml } - ///////// Node Group ///////// + ///////// Node Group ///////// - case x:ModifyNodeGroup => - "*" #> { val xml : NodeSeq = logDetailsService.getNodeGroupModifyDetails(x.details) match { - case Full(modDiff) => -
    - { addRestoreAction } - { generatedByChangeRequest } -

    Group overview:

    - - {( + case x:ModifyNodeGroup => + "*" #> { val xml : NodeSeq = logDetailsService.getNodeGroupModifyDetails(x.details) match { + case Full(modDiff) => +
    + { addRestoreAction } + { generatedByChangeRequest } +

    Group overview:

    +
      +
    • Node Group ID: { modDiff.id.value }
    • +
    • Name: { + modDiff.modName.map(diff => diff.newValue.toString).getOrElse(modDiff.name) + }
    • +
    + {( "#name" #> mapSimpleDiff(modDiff.modName) & - "#isEnabled *" #> mapSimpleDiff(modDiff.modIsActivated) & - "#isSystem *" #> mapSimpleDiff(modDiff.modIsSystem) & - "#isDynamic *" #> mapSimpleDiff(modDiff.modIsDynamic) & - "#shortDescription *" #> mapSimpleDiff(modDiff.modDescription) & - "#query" #> ( + "#isEnabled *" #> mapSimpleDiff(modDiff.modIsActivated) & + "#isSystem *" #> mapSimpleDiff(modDiff.modIsSystem) & + "#isDynamic *" #> mapSimpleDiff(modDiff.modIsDynamic) & + "#shortDescription *" #> mapSimpleDiff(modDiff.modDescription) & + "#query" #> ( modDiff.modQuery.map { diff => - val mapOptionQuery = (opt:Option[Query]) => - opt match { - case None => Text("None") - case Some(q) => Text(q.toJSONString) - } + val mapOptionQuery = (opt:Option[Query]) => + opt match { + case None => Text("None") + case Some(q) => Text(q.toJSONString) + } - ".diffOldValue *" #> mapOptionQuery(diff.oldValue) & - ".diffNewValue *" #> mapOptionQuery(diff.newValue) + ".diffOldValue *" #> mapOptionQuery(diff.oldValue) & + ".diffNewValue *" #> mapOptionQuery(diff.newValue) } - ) & - "#nodes" #> ( - modDiff.modNodeList.map { diff => - ".diffOldValue *" #> nodeGroupDetails(diff.oldValue) & - ".diffNewValue *" #> nodeGroupDetails(diff.newValue) - } - ) - )(groupModDetailsXML)} - { reasonHtml } - { xmlParameters(event.id) } -
    - case e:EmptyBox => errorMessage(e) - } - xml } + ) & + "#nodes" #> ( + modDiff.modNodeList.map { diff => + ".diffOldValue *" #> nodeGroupDetails(diff.oldValue) & + ".diffNewValue *" #> nodeGroupDetails(diff.newValue) + } + ) + )(groupModDetailsXML)} + { reasonHtml } + { xmlParameters(event.id) } +
    + case e:EmptyBox => errorMessage(e) + } + xml } - case x:AddNodeGroup => - "*" #> { val xml : NodeSeq = logDetailsService.getNodeGroupAddDetails(x.details) match { - case Full(diff) => -
    - { addRestoreAction } - { generatedByChangeRequest } - { groupDetails(groupDetailsXML, diff.group) } - { reasonHtml } - { xmlParameters(event.id) } -
    - case e:EmptyBox => errorMessage(e) - } - xml } + case x:AddNodeGroup => + "*" #> { val xml : NodeSeq = logDetailsService.getNodeGroupAddDetails(x.details) match { + case Full(diff) => +
    + { addRestoreAction } + { generatedByChangeRequest } + { groupDetails(groupDetailsXML, diff.group) } + { reasonHtml } + { xmlParameters(event.id) } +
    + case e:EmptyBox => errorMessage(e) + } + xml } - case x:DeleteNodeGroup => - "*" #> { val xml : NodeSeq = logDetailsService.getNodeGroupDeleteDetails(x.details) match { - case Full(diff) => -
    - { addRestoreAction } - { generatedByChangeRequest } - { groupDetails(groupDetailsXML, diff.group) } - { reasonHtml } - { xmlParameters(event.id) } -
    - case e:EmptyBox => errorMessage(e) - } - xml } + case x:DeleteNodeGroup => + "*" #> { val xml : NodeSeq = logDetailsService.getNodeGroupDeleteDetails(x.details) match { + case Full(diff) => +
    + { addRestoreAction } + { generatedByChangeRequest } + { groupDetails(groupDetailsXML, diff.group) } + { reasonHtml } + { xmlParameters(event.id) } +
    + case e:EmptyBox => errorMessage(e) + } + xml } - ///////// Node Group ///////// + ///////// Node Group ///////// - case x:AcceptNodeEventLog => - "*" #> { val xml : NodeSeq = logDetailsService.getAcceptNodeLogDetails(x.details) match { - case Full(details) => -
    - { addRestoreAction } -

    Node accepted overview:

    - { nodeDetails(details) } - { reasonHtml } - { xmlParameters(event.id) } -
    - case e:EmptyBox => errorMessage(e) - } - xml } + case x:AcceptNodeEventLog => + "*" #> { val xml : NodeSeq = logDetailsService.getAcceptNodeLogDetails(x.details) match { + case Full(details) => +
    + { addRestoreAction } +

    Node accepted overview:

    + { nodeDetails(details) } + { reasonHtml } + { xmlParameters(event.id) } +
    + case e:EmptyBox => errorMessage(e) + } + xml } - case x:RefuseNodeEventLog => - "*" #> { val xml : NodeSeq = logDetailsService.getRefuseNodeLogDetails(x.details) match { - case Full(details) => -
    - { addRestoreAction } -

    Node refused overview:

    - { nodeDetails(details) } - { reasonHtml } - { xmlParameters(event.id) } -
    - case e:EmptyBox => errorMessage(e) - } - xml } + case x:RefuseNodeEventLog => + "*" #> { val xml : NodeSeq = logDetailsService.getRefuseNodeLogDetails(x.details) match { + case Full(details) => +
    + { addRestoreAction } +

    Node refused overview:

    + { nodeDetails(details) } + { reasonHtml } + { xmlParameters(event.id) } +
    + case e:EmptyBox => errorMessage(e) + } + xml } - case x:DeleteNodeEventLog => - "*" #> { val xml : NodeSeq = logDetailsService.getDeleteNodeLogDetails(x.details) match { - case Full(details) => -
    - { addRestoreAction } -

    Node deleted overview:

    - { nodeDetails(details) } - { reasonHtml } - { xmlParameters(event.id) } -
    - case e:EmptyBox => errorMessage(e) - } - xml } + case x:DeleteNodeEventLog => + "*" #> { val xml : NodeSeq = logDetailsService.getDeleteNodeLogDetails(x.details) match { + case Full(details) => +
    + { addRestoreAction } +

    Node deleted overview:

    + { nodeDetails(details) } + { reasonHtml } + { xmlParameters(event.id) } +
    + case e:EmptyBox => errorMessage(e) + } + xml } - ////////// deployment ////////// - case x:SuccessfulDeployment => - "*" #> { val xml : NodeSeq = logDetailsService.getDeploymentStatusDetails(x.details) match { - case Full(SuccessStatus(id,started,ended,_)) => -
    - { addRestoreAction } -

    Successful policy update:

    - - { reasonHtml } - { xmlParameters(event.id) } -
    - case Full(_) => errorMessage(Failure("Unconsistant policy update status")) - case e:EmptyBox => errorMessage(e) - } - xml } + ////////// deployment ////////// + case x:SuccessfulDeployment => + "*" #> { val xml : NodeSeq = logDetailsService.getDeploymentStatusDetails(x.details) match { + case Full(SuccessStatus(id,started,ended,_)) => +
    + { addRestoreAction } +

    Successful policy update:

    + + { reasonHtml } + { xmlParameters(event.id) } +
    + case Full(_) => errorMessage(Failure("Unconsistant policy update status")) + case e:EmptyBox => errorMessage(e) + } + xml } - case x:FailedDeployment => - "*" #> { val xml : NodeSeq = logDetailsService.getDeploymentStatusDetails(x.details) match { - case Full(ErrorStatus(id,started,ended,failure)) => -
    - { addRestoreAction } -

    Failed policy update:

    - - { reasonHtml } - { xmlParameters(event.id) } -
    - case Full(_) => errorMessage(Failure("Unconsistant policy update status")) - case e:EmptyBox => errorMessage(e) - } - xml } + case x:FailedDeployment => + "*" #> { val xml : NodeSeq = logDetailsService.getDeploymentStatusDetails(x.details) match { + case Full(ErrorStatus(id,started,ended,failure)) => +
    + { addRestoreAction } +

    Failed policy update:

    + + { reasonHtml } + { xmlParameters(event.id) } +
    + case Full(_) => errorMessage(Failure("Unconsistant policy update status")) + case e:EmptyBox => errorMessage(e) + } + xml } - case x:AutomaticStartDeployement => - "*" #> + case x:AutomaticStartDeployement => + "*" #>
    { addRestoreAction } { xmlParameters(event.id) }
    - ////////// change authorized networks ////////// + ////////// change authorized networks ////////// - case x:UpdatePolicyServer => - "*" #> { val xml : NodeSeq = logDetailsService.getUpdatePolicyServerDetails(x.details) match { - case Full(details) => + case x:UpdatePolicyServer => + "*" #> { val xml : NodeSeq = logDetailsService.getUpdatePolicyServerDetails(x.details) match { + case Full(details) => - def networksToXML(nets:Seq[String]) = { - - } + def networksToXML(nets:Seq[String]) = { + + } -
    - { addRestoreAction }{ - ( +
    + { addRestoreAction }{ + ( ".diffOldValue *" #> networksToXML(details.oldNetworks) & - ".diffNewValue *" #> networksToXML(details.newNetworks) - )(authorizedNetworksXML) - } - { reasonHtml } - { xmlParameters(event.id) } -
    - case e:EmptyBox => errorMessage(e) - } - xml } + ".diffNewValue *" #> networksToXML(details.newNetworks) + )(authorizedNetworksXML) + } + { reasonHtml } + { xmlParameters(event.id) } +
    + case e:EmptyBox => errorMessage(e) + } + xml } - // Technique library reloaded + // Technique library reloaded - case x:ReloadTechniqueLibrary => - "*" #> { val xml : NodeSeq = logDetailsService.getTechniqueLibraryReloadDetails(x.details) match { - case Full(details) => + case x:ReloadTechniqueLibrary => + "*" #> { val xml : NodeSeq = logDetailsService.getTechniqueLibraryReloadDetails(x.details) match { + case Full(details) =>
    { addRestoreAction } The Technique library was reloaded and following Techniques were updated: @@ -859,220 +876,220 @@ class EventListDisplayer(
  • { "%s (version %s)".format(technique.name.value, technique.version.toString)}
  • } } { reasonHtml } - { xmlParameters(event.id) } + { xmlParameters(event.id) }
    - case e:EmptyBox => errorMessage(e) - } - xml } + case e:EmptyBox => errorMessage(e) + } + xml } - // Technique modified - case x:ModifyTechnique => - "*" #> { val xml : NodeSeq = logDetailsService.getTechniqueModifyDetails(x.details) match { - case Full(modDiff) => -
    - { addRestoreAction } -

    Technique overview:

    - - {( + // Technique modified + case x:ModifyTechnique => + "*" #> { val xml : NodeSeq = logDetailsService.getTechniqueModifyDetails(x.details) match { + case Full(modDiff) => +
    + { addRestoreAction } +

    Technique overview:

    +
      +
    • Technique ID: { modDiff.id.value }
    • +
    • Name: { modDiff.name }
    • +
    + {( "#isEnabled *" #> mapSimpleDiff(modDiff.modIsEnabled) - ).apply(liModDetailsXML("isEnabled", "Activation status")) - } - { reasonHtml } - { xmlParameters(event.id) } -
    - case e:EmptyBox => errorMessage(e) - } - xml } + ).apply(liModDetailsXML("isEnabled", "Activation status")) + } + { reasonHtml } + { xmlParameters(event.id) } +
    + case e:EmptyBox => errorMessage(e) + } + xml } - // Technique modified - case x:DeleteTechnique => - "*" #> { val xml : NodeSeq = logDetailsService.getTechniqueDeleteDetails(x.details) match { - case Full(techDiff) => -
    - { addRestoreAction } - { techniqueDetails(techniqueDetailsXML, techDiff.technique) } - { reasonHtml } - { xmlParameters(event.id) } -
    - case e:EmptyBox => errorMessage(e) - } - xml } + // Technique modified + case x:DeleteTechnique => + "*" #> { val xml : NodeSeq = logDetailsService.getTechniqueDeleteDetails(x.details) match { + case Full(techDiff) => +
    + { addRestoreAction } + { techniqueDetails(techniqueDetailsXML, techDiff.technique) } + { reasonHtml } + { xmlParameters(event.id) } +
    + case e:EmptyBox => errorMessage(e) + } + xml } - // archiving & restoring + // archiving & restoring - case x:ExportEventLog => - "*" #> { val xml : NodeSeq = logDetailsService.getNewArchiveDetails(x.details, x) match { - case Full(gitArchiveId) => + case x:ExportEventLog => + "*" #> { val xml : NodeSeq = logDetailsService.getNewArchiveDetails(x.details, x) match { + case Full(gitArchiveId) => addRestoreAction ++ - displayExportArchiveDetails(gitArchiveId, xmlParameters(event.id)) - case e:EmptyBox => errorMessage(e) - } - xml } - - case x:Rollback => - "*" #> { val xml : NodeSeq = logDetailsService.getRollbackDetails(x.details) match { - case Full(eventLogs) => -// addRestoreAction ++ -// displayRollbackDetails(eventLogs,event.id.get) - NodeSeq.Empty // To prevent a stateful error - case e:EmptyBox => logger.warn(e) - errorMessage(e) - } - xml } - - case x:ImportEventLog => - "*" #> { val xml : NodeSeq = logDetailsService.getRestoreArchiveDetails(x.details, x) match { - case Full(gitArchiveId) => - addRestoreAction ++ - displayImportArchiveDetails(gitArchiveId, xmlParameters(event.id)) - case e:EmptyBox => errorMessage(e) - } - xml } - - case x:ChangeRequestEventLog => - "*" #> { logDetailsService.getChangeRequestDetails(x.details) match { - case Full(diff) => - val (name,desc) = x.id match { - case None => (Text(diff.changeRequest.info.name),Text(diff.changeRequest.info.description)) - case Some(id) => - val modName = displaySimpleDiff(diff.diffName, s"name${id}", diff.changeRequest.info.name) - val modDesc = displaySimpleDiff(diff.diffDescription, s"description${id}", diff.changeRequest.info.description) - (modName,modDesc) - } -
    -

    Change request details:

    - -
    - case e:EmptyBox => logger.warn(e) - errorMessage(e) - } - } + displayExportArchiveDetails(gitArchiveId, xmlParameters(event.id)) + case e:EmptyBox => errorMessage(e) + } + xml } - case x:WorkflowStepChanged => - "*" #> { logDetailsService.getWorkflotStepChange(x.details) match { - case Full(step) => -
    -

    Change request status modified:

    - -
    - case e:EmptyBox => logger.warn(e) - errorMessage(e) - } - } + case x:Rollback => + "*" #> { val xml : NodeSeq = logDetailsService.getRollbackDetails(x.details) match { + case Full(eventLogs) => + addRestoreAction ++ + displayRollbackDetails(eventLogs,event.id.get) + // NodeSeq.Empty // To prevent a stateful error + case e:EmptyBox => logger.warn(e) + errorMessage(e) + } + xml } - // Global parameters + case x:ImportEventLog => + "*" #> { val xml : NodeSeq = logDetailsService.getRestoreArchiveDetails(x.details, x) match { + case Full(gitArchiveId) => + addRestoreAction ++ + displayImportArchiveDetails(gitArchiveId, xmlParameters(event.id)) + case e:EmptyBox => errorMessage(e) + } + xml } + + case x:ChangeRequestEventLog => + "*" #> { logDetailsService.getChangeRequestDetails(x.details) match { + case Full(diff) => + val (name,desc) = x.id match { + case None => (Text(diff.changeRequest.info.name),Text(diff.changeRequest.info.description)) + case Some(id) => + val modName = displaySimpleDiff(diff.diffName, s"name${id}", diff.changeRequest.info.name) + val modDesc = displaySimpleDiff(diff.diffDescription, s"description${id}", diff.changeRequest.info.description) + (modName,modDesc) + } +
    +

    Change request details:

    + +
    + case e:EmptyBox => logger.warn(e) + errorMessage(e) + } + } - case x:AddGlobalParameter => - "*" #> { logDetailsService.getGlobalParameterAddDetails(x.details) match { - case Full(globalParamDiff) => -
    - { addRestoreAction } - { generatedByChangeRequest } - { globalParameterDetails(globalParamDetailsXML, globalParamDiff.parameter)} - { reasonHtml } - { xmlParameters(event.id) } -
    - case e:EmptyBox => logger.warn(e) - errorMessage(e) - } - } + case x:WorkflowStepChanged => + "*" #> { logDetailsService.getWorkflotStepChange(x.details) match { + case Full(step) => +
    +

    Change request status modified:

    + +
    + case e:EmptyBox => logger.warn(e) + errorMessage(e) + } + } - case x:DeleteGlobalParameter => - "*" #> { logDetailsService.getGlobalParameterDeleteDetails(x.details) match { - case Full(globalParamDiff) => -
    - { addRestoreAction } - { generatedByChangeRequest } - { globalParameterDetails(globalParamDetailsXML, globalParamDiff.parameter)} - { reasonHtml } - { xmlParameters(event.id) } -
    - case e:EmptyBox => logger.warn(e) - errorMessage(e) - } - } + // Global parameters - case mod:ModifyGlobalParameter => - "*" #> { logDetailsService.getGlobalParameterModifyDetails(mod.details) match { - case Full(modDiff) => -
    - { addRestoreAction } - { generatedByChangeRequest } -

    Global Parameter overview:

    - - {( + case x:AddGlobalParameter => + "*" #> { logDetailsService.getGlobalParameterAddDetails(x.details) match { + case Full(globalParamDiff) => +
    + { addRestoreAction } + { generatedByChangeRequest } + { globalParameterDetails(globalParamDetailsXML, globalParamDiff.parameter)} + { reasonHtml } + { xmlParameters(event.id) } +
    + case e:EmptyBox => logger.warn(e) + errorMessage(e) + } + } + + case x:DeleteGlobalParameter => + "*" #> { logDetailsService.getGlobalParameterDeleteDetails(x.details) match { + case Full(globalParamDiff) => +
    + { addRestoreAction } + { generatedByChangeRequest } + { globalParameterDetails(globalParamDetailsXML, globalParamDiff.parameter)} + { reasonHtml } + { xmlParameters(event.id) } +
    + case e:EmptyBox => logger.warn(e) + errorMessage(e) + } + } + + case mod:ModifyGlobalParameter => + "*" #> { logDetailsService.getGlobalParameterModifyDetails(mod.details) match { + case Full(modDiff) => +
    + { addRestoreAction } + { generatedByChangeRequest } +

    Global Parameter overview:

    +
      +
    • Global Parameter name: { modDiff.name.value }
    • +
    + {( "#name" #> modDiff.name.value & - "#value" #> mapSimpleDiff(modDiff.modValue) & - "#description *" #> mapSimpleDiff(modDiff.modDescription) & - "#overridable *" #> mapSimpleDiff(modDiff.modOverridable) - )(globalParamModDetailsXML) - } - { reasonHtml } - { xmlParameters(event.id) } -
    - case e:EmptyBox => logger.warn(e) - errorMessage(e) - } - } + "#value" #> mapSimpleDiff(modDiff.modValue) & + "#description *" #> mapSimpleDiff(modDiff.modDescription) & + "#overridable *" #> mapSimpleDiff(modDiff.modOverridable) + )(globalParamModDetailsXML) + } + { reasonHtml } + { xmlParameters(event.id) } +
    + case e:EmptyBox => logger.warn(e) + errorMessage(e) + } + } - case x:CreateAPIAccountEventLog => - "*" #> { logDetailsService.getApiAccountAddDetails(x.details) match { + case x:CreateAPIAccountEventLog => + "*" #> { logDetailsService.getApiAccountAddDetails(x.details) match { case Full(apiAccountDiff) => -
    - { addRestoreAction } - { generatedByChangeRequest } - { apiAccountDetails(apiAccountDetailsXML, apiAccountDiff.apiAccount)} - { reasonHtml } - { xmlParameters(event.id) } -
    +
    + { addRestoreAction } + { generatedByChangeRequest } + { apiAccountDetails(apiAccountDetailsXML, apiAccountDiff.apiAccount)} + { reasonHtml } + { xmlParameters(event.id) } +
    case e:EmptyBox => logger.warn(e) errorMessage(e) } - } + } - case x:DeleteAPIAccountEventLog => - "*" #> { logDetailsService.getApiAccountDeleteDetails(x.details) match { + case x:DeleteAPIAccountEventLog => + "*" #> { logDetailsService.getApiAccountDeleteDetails(x.details) match { case Full(apiAccountDiff) => -
    - { addRestoreAction } - { generatedByChangeRequest } - { apiAccountDetails(apiAccountDetailsXML, apiAccountDiff.apiAccount)} - { reasonHtml } - { xmlParameters(event.id) } -
    +
    + { addRestoreAction } + { generatedByChangeRequest } + { apiAccountDetails(apiAccountDetailsXML, apiAccountDiff.apiAccount)} + { reasonHtml } + { xmlParameters(event.id) } +
    case e:EmptyBox => logger.warn(e) errorMessage(e) } - } + } - case mod:ModifyAPIAccountEventLog => - "*" #> { logDetailsService.getApiAccountModifyDetails(mod.details) match { - case Full(apiAccountDiff) => + case mod:ModifyAPIAccountEventLog => + "*" #> { logDetailsService.getApiAccountModifyDetails(mod.details) match { + case Full(apiAccountDiff) =>
    - { addRestoreAction } - { generatedByChangeRequest } -

    API account overview:

    - - {( - "#name" #> mapSimpleDiff(apiAccountDiff.modName) & + { addRestoreAction } + { generatedByChangeRequest } +

    API account overview:

    + + {( + "#name" #> mapSimpleDiff(apiAccountDiff.modName) & "#token" #> mapSimpleDiff(apiAccountDiff.modToken) & "#description *" #> mapSimpleDiff(apiAccountDiff.modDescription) & "#isEnabled *" #> mapSimpleDiff(apiAccountDiff.modIsEnabled) & @@ -1082,101 +1099,101 @@ class EventListDisplayer( "#accountKind *" #> mapSimpleDiff(apiAccountDiff.modAccountKind) & //make list of ACL unsderstandable "#acls *" #> mapSimpleDiff(apiAccountDiff.modAccountAcl.map(o => { - val f = (l: List[ApiAclElement]) => l.sortBy(_.path.value).map(x => s"[${x.actions.map(_.name.toUpperCase()).mkString(",")}] ${x.path.value}").mkString(" | ") - SimpleDiff(f(o.oldValue), f(o.newValue)) - })) + val f = (l: List[ApiAclElement]) => l.sortBy(_.path.value).map(x => s"[${x.actions.map(_.name.toUpperCase()).mkString(",")}] ${x.path.value}").mkString(" | ") + SimpleDiff(f(o.oldValue), f(o.newValue)) + })) )(apiAccountModDetailsXML) } - { reasonHtml } - { xmlParameters(event.id) } -
    - case e:EmptyBox => logger.warn(e) - errorMessage(e) + { reasonHtml } + { xmlParameters(event.id) } + + case e:EmptyBox => logger.warn(e) + errorMessage(e) + } } - } - case mod:ModifyGlobalProperty => - "*" #> { logDetailsService.getModifyGlobalPropertyDetails(mod.details) match { - case Full((oldProp,newProp)) => + case mod:ModifyGlobalProperty => + "*" #> { logDetailsService.getModifyGlobalPropertyDetails(mod.details) match { + case Full((oldProp,newProp)) =>
    -

    Global property overview:

    - - { reasonHtml } - { xmlParameters(event.id) } -
    - case e:EmptyBox => logger.warn(e) - errorMessage(e) +

    Global property overview:

    + + { reasonHtml } + { xmlParameters(event.id) } + + case e:EmptyBox => logger.warn(e) + errorMessage(e) + } } - } - // Node modifiction - case mod:ModifyNode => - "*" #> { logDetailsService.getModifyNodeDetails(mod.details) match { - case Full(modDiff) => - logger.info(modDiff.modAgentRun) -
    - { addRestoreAction } - { generatedByChangeRequest } -

    Node '{modDiff.id.value}' modified:

    - - { + // Node modifiction + case mod:ModifyNode => + "*" #> { logDetailsService.getModifyNodeDetails(mod.details) match { + case Full(modDiff) => + logger.info(modDiff.modAgentRun) +
    + { addRestoreAction } + { generatedByChangeRequest } +

    Node '{modDiff.id.value}' modified:

    +
      +
    • Node ID:{modDiff.id.value}
    • +
    + { mapComplexDiff(modDiff.modAgentRun){ (optAr:Option[AgentRunInterval]) => optAr match { case None => No value case Some(ar) => agentRunDetails(ar) } } - } - { + } + { mapComplexDiff(modDiff.modHeartbeat){ (optHb:Option[HeartbeatConfiguration]) => optHb match { case None => No value case Some(hb) => heartbeatDetails(hb) } } - } - { + } + { mapComplexDiff(modDiff.modProperties){ (props:Seq[NodeProperty]) => nodePropertiesDetails(props) } - } - { + } + { mapComplexDiff(modDiff.modPolicyMode){ (optMode:Option[PolicyMode]) => optMode match { case None => Use global policy mode case Some(mode) => {mode.name} } } - } - { reasonHtml } - { xmlParameters(event.id) } -
    - case e:EmptyBox => logger.warn(e) - errorMessage(e) - } - } + } + { reasonHtml } + { xmlParameters(event.id) } +
    + case e:EmptyBox => logger.warn(e) + errorMessage(e) + } + } - // other case: do not display details at all - case _ => "*" #> "" + // other case: do not display details at all + case _ => "*" #> "" - })(event.details)} + })(event.details)} } private[this] def agentRunDetails(ar: AgentRunInterval): NodeSeq = { ( "#override" #> ar.overrides.map(_.toString()).getOrElse("false") - & "#interval" #> ar.interval - & "#startMinute" #> ar.startMinute - & "#startHour" #> ar.startHour - & "#splaytime" #> ar.splaytime - ).apply( + & "#interval" #> ar.interval + & "#startMinute" #> ar.startMinute + & "#startHour" #> ar.startHour + & "#splaytime" #> ar.splaytime + ).apply(