From fb2731ff48fb393f24a6f523e84602eeff266fa2 Mon Sep 17 00:00:00 2001
From: David Maus <maus@hab.de>
Date: Mon, 19 Feb 2018 11:51:58 +0100
Subject: [PATCH] =?UTF-8?q?User-Agent=20f=C3=BCr=20Normalisierung=20angebe?=
 =?UTF-8?q?n?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/xproc/publish.xpl | 27 +++++++++++++++++++++------
 src/xslt/mets.xsl     |  7 +++++++
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/src/xproc/publish.xpl b/src/xproc/publish.xpl
index fa74938..0d46c36 100644
--- a/src/xproc/publish.xpl
+++ b/src/xproc/publish.xpl
@@ -1,4 +1,5 @@
 <p:declare-step version="1.0" name="main"
+                xmlns:d="http://dmaus.name/ns/xproc"
                 xmlns:p="http://www.w3.org/ns/xproc">
 
   <p:input  port="source" primary="true" sequence="false"/>
@@ -6,7 +7,20 @@
   <p:option name="objectId"  required="true"/>
   <p:option name="targetUri" required="true"/>
 
-  <p:group name="uuid-source">
+  <p:declare-step type="d:uuid-event">
+    <p:input  port="source"/>
+    <p:output port="result"/>
+    <p:option name="event" required="true"/>
+
+    <p:add-attribute attribute-value="" match="uuid">
+      <p:with-option name="attribute-name" select="$event"/>
+    </p:add-attribute>
+    <p:uuid version="4">
+      <p:with-option name="match" select="concat('@', $event)"/>
+    </p:uuid>
+  </p:declare-step>
+
+  <p:declare-step type="d:uuid-source">
     <p:output port="result"/>
     <p:identity>
       <p:input port="source">
@@ -15,11 +29,11 @@
         </p:inline>
       </p:input>
     </p:identity>
-    <p:add-attribute match="uuid" attribute-name="create" attribute-value=""/>
-    <p:uuid version="4" match="@create"/>
-    <p:add-attribute match="uuid" attribute-name="normalize" attribute-value=""/>
-    <p:uuid version="4" match="@normalize"/>
-  </p:group>
+    <d:uuid-event event="create"/>
+    <d:uuid-event event="normalize"/>
+  </p:declare-step>
+
+  <d:uuid-source name="uuid-source"/>
 
   <p:choose>
     <p:when test="doc-available(resolve-uri($targetUri))">
@@ -52,6 +66,7 @@
         <p:with-param name="eventNormalizeUUID" select="/uuid/@normalize">
           <p:pipe step="uuid-source" port="result"/>
         </p:with-param>
+        <p:with-param name="eventNormalizeAgent" select="concat(p:system-property('p:product-name'), ' ', p:system-property('p:product-version'))"/>
         <p:input port="source">
           <p:pipe step="validate-kitodo" port="result"/>
         </p:input>
diff --git a/src/xslt/mets.xsl b/src/xslt/mets.xsl
index 1e0bd57..3145946 100644
--- a/src/xslt/mets.xsl
+++ b/src/xslt/mets.xsl
@@ -13,6 +13,7 @@
   <xsl:param name="objectId" as="xs:string" required="yes"/>
   <xsl:param name="eventCreateUUID" as="xs:string" required="yes"/>
   <xsl:param name="eventNormalizeUUID" as="xs:string" required="yes"/>
+  <xsl:param name="eventNormalizeAgent" as="xs:string" required="yes"/>
 
   <xsl:key name="files" match="file" use="@ID"/>
 
@@ -57,6 +58,12 @@
               </premis:eventIdentifier>
               <premis:eventType valueURI="http://id.loc.gov/vocabulary/preservation/eventType/normalization">normalization</premis:eventType>
               <premis:eventDataTime><xsl:value-of select="current-dateTime()"/></premis:eventDataTime>
+              <premis:linkingAgentIdentifier>
+                <premis:linkingAgentIdentifierType>Name</premis:linkingAgentIdentifierType>
+                <premis:linkingAgentIdentifierValue><xsl:value-of select="$eventNormalizeAgent"/></premis:linkingAgentIdentifierValue>
+                <premis:linkingAgentRole valueURI="http://id.loc.gov/vocabulary/preservation/eventRelatedAgentRole/exe">executing program</premis:linkingAgentRole>
+              </premis:linkingAgentIdentifier>
+
             </premis:event>
           </xmlData>
         </mdWrap>
-- 
GitLab