Revision bf1fba4c src/main/scala/gr/grnet/aquarium/logic/events/ResourceEvent.scala
b/src/main/scala/gr/grnet/aquarium/logic/events/ResourceEvent.scala | ||
---|---|---|
38 | 38 |
import gr.grnet.aquarium.logic.accounting.Policy |
39 | 39 |
import net.liftweb.json.{JsonAST, Xml} |
40 | 40 |
import gr.grnet.aquarium.util.json.JsonHelpers |
41 |
import gr.grnet.aquarium.logic.accounting.dsl.{DSLResource, DSLComplexResource} |
|
41 |
import gr.grnet.aquarium.logic.accounting.dsl.{OnOffCostPolicy, DSLPolicy, DSLResource, DSLComplexResource}
|
|
42 | 42 |
|
43 | 43 |
/** |
44 | 44 |
* Event sent to Aquarium by clients for resource accounting. |
... | ... | |
60 | 60 |
|
61 | 61 |
def validate() : Boolean = { |
62 | 62 |
|
63 |
if (getInstanceId.isEmpty) |
|
63 |
if (getInstanceId().isEmpty)
|
|
64 | 64 |
return false |
65 | 65 |
|
66 | 66 |
true |
... | ... | |
71 | 71 |
* resource or the instance id field cannot be found, this method returns an |
72 | 72 |
* empty String. |
73 | 73 |
*/ |
74 |
def getInstanceId: String = { |
|
75 |
Policy.policy.findResource(this.resource) match {
|
|
74 |
def getInstanceId(policy: DSLPolicy = Policy.policy): String = {
|
|
75 |
policy.findResource(this.resource) match { |
|
76 | 76 |
case None => "" |
77 | 77 |
case Some(x) => x.isComplex match { |
78 | 78 |
case false => "1" |
... | ... | |
103 | 103 |
def fromXml(xml: String): ResourceEvent = { |
104 | 104 |
fromJValue(Xml.toJson(scala.xml.XML.loadString(xml))) |
105 | 105 |
} |
106 |
|
|
106 |
|
|
107 | 107 |
object JsonNames { |
108 | 108 |
final val _id = "_id" |
109 | 109 |
final val id = "id" |
Also available in: Unified diff