Skip to content

Commit

Permalink
[DS-1193] display bitstream read access permissions on item page (squ…
Browse files Browse the repository at this point in the history
…ashed)

This displays the bitstream READ rights information at the item page
in Mirage, but doesn't indicate whether the currently logged in user
has READ access.
  • Loading branch information
helix84 committed Sep 17, 2012
1 parent 3b1cc06 commit 2499436
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 18 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:encoder="xalan://java.net.URLEncoder"
xmlns:util="org.dspace.app.xmlui.utils.XSLUtils"
exclude-result-prefixes="xalan encoder i18n dri mets dim xlink xsl util">
xmlns:jstring="java.lang.String"
xmlns:rights="http://cosimo.stanford.edu/sdr/metsrights/"
exclude-result-prefixes="xalan encoder i18n dri mets dim xlink xsl util jstring rights">

<xsl:output indent="yes"/>

Expand Down Expand Up @@ -481,16 +483,57 @@
</xsl:if>
</div>
<div class="file-link" style="height: {$thumbnail.maxheight}px;">
<a>
<xsl:attribute name="href">
<xsl:value-of select="mets:FLocat[@LOCTYPE='URL']/@xlink:href"/>
</xsl:attribute>
<i18n:text>xmlui.dri2xhtml.METS-1.0.item-files-viewOpen</i18n:text>
</a>
<xsl:choose>
<xsl:when test="@ADMID">
<xsl:call-template name="display-rights"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="view-open"/>
</xsl:otherwise>
</xsl:choose>
</div>
</div>
</xsl:template>

<xsl:template name="view-open">
<a>
<xsl:attribute name="href">
<xsl:value-of select="mets:FLocat[@LOCTYPE='URL']/@xlink:href"/>
</xsl:attribute>
<i18n:text>xmlui.dri2xhtml.METS-1.0.item-files-viewOpen</i18n:text>
</a>
</xsl:template>

<xsl:template name="display-rights">
<xsl:variable name="file_id" select="jstring:replaceAll(jstring:replaceAll(string(@ADMID), '_METSRIGHTS', ''), 'rightsMD_', '')"/>
<xsl:variable name="rights_declaration" select="../../../mets:amdSec/mets:rightsMD[@ID = concat('rightsMD_', $file_id, '_METSRIGHTS')]/mets:mdWrap/mets:xmlData/rights:RightsDeclarationMD"/>
<xsl:variable name="rights_context" select="$rights_declaration/rights:Context"/>
<xsl:variable name="users">
<xsl:for-each select="$rights_declaration/*">
<xsl:value-of select="rights:UserName"/>
<xsl:choose>
<xsl:when test="rights:UserName/@USERTYPE = 'GROUP'">
<xsl:text> (group)</xsl:text>
</xsl:when>
<xsl:when test="rights:UserName/@USERTYPE = 'INDIVIDUAL'">
<xsl:text> (individual)</xsl:text>
</xsl:when>
</xsl:choose>
<xsl:if test="position() != last()">, </xsl:if>
</xsl:for-each>
</xsl:variable>

<xsl:choose>
<xsl:when test="not ($rights_context/@CONTEXTCLASS = 'GENERAL PUBLIC') and ($rights_context/rights:Permissions/@DISPLAY = 'true')">
<a href="{mets:FLocat[@LOCTYPE='URL']/@xlink:href}">
<img width="64" height="64" src="{concat($theme-path,'/images/Crystal_Clear_action_lock3_64px.png')}" title="Read access available for {$users}"/>
<!-- icon source: http://commons.wikimedia.org/wiki/File:Crystal_Clear_action_lock3.png -->
</a>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="view-open"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:encoder="xalan://java.net.URLEncoder"
exclude-result-prefixes="xalan encoder i18n dri mets dim xlink xsl">
xmlns:confman="org.dspace.core.ConfigurationManager"
exclude-result-prefixes="i18n dri mets dim xlink xsl xalan encoder confman">

<xsl:output indent="yes"/>

Expand Down Expand Up @@ -187,11 +188,19 @@
</xsl:template>

<xsl:template match="dri:reference" mode="summaryView">
<!-- simplified check to verify whether access rights are available in METS -->
<xsl:variable name='METSRIGHTS-enabled' select="contains(confman:getProperty('plugin.named.org.dspace.content.crosswalk.DisseminationCrosswalk'), 'METSRIGHTS')" />
<xsl:variable name="externalMetadataURL">
<xsl:text>cocoon:/</xsl:text>
<xsl:value-of select="@url"/>
<!-- No options selected, render the full METS document -->
<!-- If this is an Item, display the METSRIGHTS section, so we
know which files have access restrictions.
This requires the METSRightsCrosswalk to be enabled! -->
<xsl:if test="@type='DSpace Item' and $METSRIGHTS-enabled">
<xsl:text>?rightsMDTypes=METSRIGHTS</xsl:text>
</xsl:if>
</xsl:variable>
<!-- This comment just displays the full URL in an HTML comment, for easy reference. -->
<xsl:comment> External Metadata URL: <xsl:value-of select="$externalMetadataURL"/> </xsl:comment>
<xsl:apply-templates select="document($externalMetadataURL)" mode="summaryView"/>
<xsl:apply-templates />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
xmlns:xlink="http://www.w3.org/TR/xlink/"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="i18n dri mets xlink xsl">
xmlns:jstring="java.lang.String"
xmlns:rights="http://cosimo.stanford.edu/sdr/metsrights/"
exclude-result-prefixes="i18n dri mets xlink xsl jstring rights">

<xsl:output indent="yes"/>

Expand Down Expand Up @@ -162,12 +164,14 @@
</a>
</xsl:when>
<xsl:otherwise>
<a>
<xsl:attribute name="href">
<xsl:value-of select="mets:FLocat[@LOCTYPE='URL']/@xlink:href"/>
</xsl:attribute>
<i18n:text>xmlui.dri2xhtml.METS-1.0.item-files-viewOpen</i18n:text>
</a>
<xsl:choose>
<xsl:when test="@ADMID">
<xsl:call-template name="display-rights"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="view-open"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</td>
Expand All @@ -181,6 +185,48 @@
</tr>
</xsl:template>

<xsl:template name="view-open">
<a>
<xsl:attribute name="href">
<xsl:value-of select="mets:FLocat[@LOCTYPE='URL']/@xlink:href"/>
</xsl:attribute>
<i18n:text>xmlui.dri2xhtml.METS-1.0.item-files-viewOpen</i18n:text>
</a>
</xsl:template>

<xsl:template name="display-rights">
<xsl:variable name="file_id" select="jstring:replaceAll(jstring:replaceAll(string(@ADMID), '_METSRIGHTS', ''), 'rightsMD_', '')"/>
<xsl:variable name="rights_declaration" select="../../../mets:amdSec/mets:rightsMD[@ID = concat('rightsMD_', $file_id, '_METSRIGHTS')]/mets:mdWrap/mets:xmlData/rights:RightsDeclarationMD"/>
<xsl:variable name="rights_context" select="$rights_declaration/rights:Context"/>
<xsl:variable name="users">
<xsl:for-each select="$rights_declaration/*">
<xsl:value-of select="rights:UserName"/>
<xsl:choose>
<xsl:when test="rights:UserName/@USERTYPE = 'GROUP'">
<xsl:text> (group)</xsl:text>
</xsl:when>
<xsl:when test="rights:UserName/@USERTYPE = 'INDIVIDUAL'">
<xsl:text> (individual)</xsl:text>
</xsl:when>
</xsl:choose>
<xsl:if test="position() != last()">, </xsl:if>
</xsl:for-each>
</xsl:variable>

<xsl:choose>
<xsl:when test="not ($rights_context/@CONTEXTCLASS = 'GENERAL PUBLIC') and ($rights_context/rights:Permissions/@DISPLAY = 'true')">
<a href="{mets:FLocat[@LOCTYPE='URL']/@xlink:href}">
<img width="64" height="64" src="{concat($theme-path,'/images/Crystal_Clear_action_lock3_64px.png')}" title="Read access available for {$users}"/>
<!-- icon source: http://commons.wikimedia.org/wiki/File:Crystal_Clear_action_lock3.png -->
</a>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="view-open"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


<!--
File Type Mapping template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
xmlns:mods="http://www.loc.gov/mods/v3"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="mets xlink xsl dim xhtml mods dc">
xmlns:confman="org.dspace.core.ConfigurationManager"
exclude-result-prefixes="mets xlink xsl dim xhtml mods dc confman">

<xsl:output indent="yes"/>

Expand Down Expand Up @@ -2954,10 +2955,16 @@
</xsl:template>

<xsl:template match="dri:reference" mode="summaryView">
<xsl:variable name='METSRIGHTS-enabled' select="contains(confman:getProperty('plugin.named.org.dspace.content.crosswalk.DisseminationCrosswalk'), 'METSRIGHTS')" />
<xsl:variable name="externalMetadataURL">
<xsl:text>cocoon:/</xsl:text>
<xsl:value-of select="@url"/>
<!-- No options selected, render the full METS document -->
<!-- If this is an Item, display the METSRIGHTS section, so we
know which files have access restrictions.
This requires the METSRightsCrosswalk to be enabled! -->
<xsl:if test="@type='DSpace Item' and $METSRIGHTS-enabled">
<xsl:text>?rightsMDTypes=METSRIGHTS</xsl:text>
</xsl:if>
</xsl:variable>
<xsl:comment> External Metadata URL: <xsl:value-of select="$externalMetadataURL"/> </xsl:comment>
<xsl:apply-templates select="document($externalMetadataURL)" mode="summaryView"/>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2499436

Please sign in to comment.