Add match on slice HRN
authorAndy Bavier <acb@cs.princeton.edu>
Wed, 28 Oct 2009 21:28:56 +0000 (21:28 +0000)
committerAndy Bavier <acb@cs.princeton.edu>
Wed, 28 Oct 2009 21:28:56 +0000 (21:28 +0000)
sfatables/matches/slice.xml [new file with mode: 0644]
sfatables/processors/slice-hrn.xsl [new file with mode: 0644]

diff --git a/sfatables/matches/slice.xml b/sfatables/matches/slice.xml
new file mode 100644 (file)
index 0000000..e3ee7db
--- /dev/null
@@ -0,0 +1,19 @@
+<!-- 
+"context" specifies the subset of the requestor context that this match needs to see. It is specified as an xpath expression.
+For this simple match, we just need to look at sfa-input. 
+
+"rule" specifies a set of arguments that the match accepts.
+-->
+
+<match name="slice">
+    <!-- Empty context. We _always_ get the hrn of the current user -->
+    <rule element='*'>
+    <context select="//sfa/current/slice@hrn"/>
+        <argument>
+            <name>hrn</name>
+            <help>HRN of the slice requesting resources</help>
+            <operand>HRN</operand>
+        </argument>
+    <processor filename="slice-hrn.xsl"/>
+    </rule>
+</match>
diff --git a/sfatables/processors/slice-hrn.xsl b/sfatables/processors/slice-hrn.xsl
new file mode 100644 (file)
index 0000000..1ba5942
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+    <xsl:variable name="context-hrn" select="//request-context/sfa/slice/hrn"/>
+
+    <!-- Magic sauce -->
+
+    <xsl:template match="@* | node()">
+            <xsl:apply-templates select="@* | node()"/>
+    </xsl:template>
+
+    <xsl:template match="//match-context/argument[name='hrn']">
+                    <xsl:value-of select="hrn"/>
+                    <xsl:choose>
+                    <xsl:when test="starts-with($context-hrn, value)">
+                        <result verdict="True"/> <!--Match -->
+                    </xsl:when>
+                    <xsl:otherwise>
+                        <result verdict="False"/> <!-- No match -->
+                    </xsl:otherwise>
+                </xsl:choose>
+    </xsl:template>
+
+</xsl:stylesheet>