Permalink
Browse files

Issue #2399: add reason for event log as parameter of relevant methods

  • Loading branch information...
1 parent b944192 commit eb8504820367f1b160e0613480b160737795a394 @fanf fanf committed May 3, 2012
View
5 src/main/scala/com/normation/cfclerk/services/TechniqueLibraryUpdateNotification.scala
@@ -55,7 +55,10 @@ trait TechniquesLibraryUpdateNotification {
/**
* That method will be called when techniques are updated.
* TODO: perhaps we want something more useful as a return type.
+ *
+ * Description is a log description to explain why techniques should be updated
+ * (user action, commit, etc).
*/
- def updatedTechniques(TechniqueIds:Seq[TechniqueId], actor: EventActor) : Unit
+ def updatedTechniques(TechniqueIds:Seq[TechniqueId], actor: EventActor, reason: Option[String]) : Unit
}
View
2 src/main/scala/com/normation/cfclerk/services/UpdateTechniqueLibrary.scala
@@ -48,7 +48,7 @@ trait UpdateTechniqueLibrary {
* Update the lib, and return the list of
* actually updated policy templates.
*/
- def update(actor:EventActor) : Box[Seq[TechniqueId]]
+ def update(actor:EventActor, reason: Option[String]) : Box[Seq[TechniqueId]]
/**
* Allows callbacks to be called on a Policy Template library update.
View
9 src/main/scala/com/normation/cfclerk/services/impl/TechniqueRepositoryImpl.scala
@@ -72,8 +72,9 @@ class TechniqueRepositoryImpl(
techniqueReader.readTechniques
} catch {
case e:Exception =>
- logger.error("Error when loading the previously saved policy template library. Trying to update to last library available to overcome the error")
- this.update(CfclerkEventActor)
+ val msg = "Error when loading the previously saved policy template library. Trying to update to last library available to overcome the error"
+ logger.error(msg)
+ this.update(CfclerkEventActor, Some(msg))
techniqueReader.readTechniques
}
}
@@ -88,7 +89,7 @@ class TechniqueRepositoryImpl(
callbacks.append(callback)
}
- override def update(actor:EventActor) : Box[Seq[TechniqueId]] = {
+ override def update(actor:EventActor, reason: Option[String]) : Box[Seq[TechniqueId]] = {
try {
val modifiedPackages = techniqueReader.getModifiedTechniques
if (modifiedPackages.nonEmpty || /* first time init */ null == techniqueInfosCache) {
@@ -100,7 +101,7 @@ class TechniqueRepositoryImpl(
callbacks.foreach { callback =>
try {
- callback.updatedTechniques(modifiedPackages, actor)
+ callback.updatedTechniques(modifiedPackages, actor, reason)
} catch {
case e: Exception => logger.error("Error when executing callback '%s' with updated technique: '%s'".format(callback.name, modifiedPackages.mkString(", ")), e)
}

0 comments on commit eb85048

Please sign in to comment.