Revision 00df2d57
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.{OnOffCostPolicy, DSLPolicy, DSLResource, DSLComplexResource}
|
|
41 |
import gr.grnet.aquarium.logic.accounting.dsl._
|
|
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(Policy.policy).isEmpty)
|
|
64 | 64 |
return false |
65 | 65 |
|
66 | 66 |
true |
... | ... | |
70 | 70 |
* Return the instance id affected by this resource event. If either the |
71 | 71 |
* resource or the instance id field cannot be found, this method returns an |
72 | 72 |
* empty String. |
73 |
* |
|
74 |
* If no policy is given, then a default policy is loaded. |
|
73 | 75 |
*/ |
74 |
def getInstanceId(policy: DSLPolicy = Policy.policy): String = {
|
|
76 |
def getInstanceId(policy: DSLPolicy): String = { |
|
75 | 77 |
policy.findResource(this.resource) match { |
78 |
case Some(DSLComplexResource(_, _, _, descriminatorField)) ⇒ |
|
79 |
details.getOrElse(descriminatorField, "") |
|
80 |
case Some(DSLSimpleResource(_, _, _)) ⇒ |
|
81 |
"1" // TODO: put this constant somewhere centrally... |
|
76 | 82 |
case None => "" |
77 | 83 |
case Some(x) => x.isComplex match { |
78 | 84 |
case false => "1" |
Also available in: Unified diff