import gr.grnet.aquarium.util.Loggable
import java.util.concurrent.atomic.AtomicReference
import gr.grnet.aquarium.Configurator
-import com.ckkloverdos.maybe.{Failed, NoVal, Maybe, Just}
+import gr.grnet.aquarium.Configurator.Keys
+import com.ckkloverdos.maybe.{Failed, NoVal, Just}
import collection.immutable.{TreeMap, SortedMap}
/**
* Set the configurator to use for loading policy stores. Should only
* used for unit testing.
*/
- /*private[logic] */def withConfigurator(config: Configurator): Unit =
+ def withConfigurator(config: Configurator): Unit =
this.config = config
/**
- * Search default locations for a policy file and provide an
- * arbitrary default if this cannot be found.
- */
- private[logic] def policyFile = {
- BasicResourceContext.getResource(PolicyConfName) match {
- case Just(policyResource) ⇒
- val path = policyResource.url.getPath
- new File(path)
- case _ ⇒
- new File("policy.yaml")
- }
- }
-
- /**
* Check whether the policy definition file (in whichever path) is
* newer than the latest stored policy, reload and set it as current.
* This method has side-effects to this object's state.
//2. Check whether policy file has been updated
val latestPolicyChange = if (pol.isEmpty) 0 else pol.last.validFrom
- val policyf = policyFile
+ val policyf = MasterConfigurator.findConfigFile(PolicyConfName, Keys.aquarium_policy, PolicyConfName)
var updated = false
if (policyf.exists) {
import dsl.DSLAgreement
import gr.grnet.aquarium.util.Loggable
+import gr.grnet.aquarium.Configurator
import gr.grnet.aquarium.Configurator.{MasterConfigurator, Keys}
import io.Source
import java.io.{InputStream, File}
*/
private[logic] def loadMappings = synchronized {
val config = MasterConfigurator.get(Keys.aquarium_role_agreement_map)
- val configFile = new File(config)
+ val configFile = MasterConfigurator.findConfigFile(
+ Configurator.RolesAgreementsName, Keys.aquarium_role_agreement_map,
+ Configurator.RolesAgreementsName)
def loadFromClasspath: Source = {
- getClass.getClassLoader.getResourceAsStream("roles-agreements.map") match {
+ getClass.getClassLoader.getResourceAsStream(Configurator.RolesAgreementsName) match {
case x: InputStream =>
logger.warn("Using default role to agreement mappings, this is " +
"problably not what you want")