Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[DS-1193] fix problem A #74

Merged
merged 1 commit into from

3 participants

helix84 Tim Donohue João Melo
helix84
Owner

[DS-1193] display bitstream read access permissions on item page

This displays the bitstream READ rights information at the item page
in Mirage, but doesn't indicate whether currently logged in user
has READ access.

Tim Donohue
Owner

Hi Helix84,

A few comments on this work.

First off, the code seems to only work for Mirage / dri2xhtml-alt. It looks like we'd have to replicate that same idea to dri2xhtml and other themes?

Second, I'm actually (very slightly) concerned about hard-coding the name of the "METSRIGHTS" crosswalk into the XSLT. This is potentially "fragile", as it must match exactly the name of the crosswalk in dspace.cfg.

Alternatively, I actually wonder if this should instead be an update to the XMLUI ItemAdapter (which generates the METS in the first place), so that the METSRIGHTS crosswalk is just always called by default (if it's found to exist & be enabled).

This change could be made in the 'renderAdministrativeSection()' function of the ItemAdapter -- and look something like this:

if(amdTypes.size==0) this.setRightsMDTypes("METSRIGHTS");

See: https://github.com/DSpace/DSpace/blob/master/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/objectmanager/ItemAdapter.java#L466

This same sort of concept happens in the 'renderDescriptiveSection()' function, which by default always renders the "DIM" metadata section. See: https://github.com/DSpace/DSpace/blob/master/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/objectmanager/ItemAdapter.java#L222

This is just an idea. There may be reasons why you decided to do this in XSLT that I'm unaware of. I just wanted to note that it may be cleaner to just change the ItemAdapter code directly.

helix84
Owner

First off, the code seems to only work for Mirage / dri2xhtml-alt. It looks like we'd have to replicate that same idea to dri2xhtml and other themes?

Tim, that was intentional at the time I opened the pull request, because I wanted to get feedback if this is fine before doing it for all the themes (actually just dri2xhtml, which would trickle down to Reference). It's just copy-paste.

hard-coding the name of the "METSRIGHTS" crosswalk into the XSLT

This is the default and normal users don't change it, so I'm not worried. If anyone happens to change it, it will just revert to the old behaviour. One solution would be to get the config property name from XSL, but according to mdiggory's comments, it would be good to separate the rights from mets.xml into separate XML document (so that people can enforce access-restrictions on it if needed). I wasn't able to do such change, so he told me to go ahead with the current solution. We can change this at any time, but I think it would be a pity to postpone the whole feature.

tl;dr - METSRIGHTS endpoint will likely change later, no reason to do an intermediate change

Regarding enabling METSRIGHTS crosswalk by default - I intentionally didn't want to do that:
1) it works just fine like this
2) it would change status quo, i.e. rights exposed by default -> someone could have a problem with that
3) as I wrote above, I consider this temporary before METSRIGHTS can generate its own XML document

For reasons why I wanted this in XSL as opposed to Aspect, see Jira. I have another use for this information in XSL.

Thanks Tim for a review. Would you happen to know how create a separate document for METSRIGHTS?

Tim Donohue
Owner

Hi helix84,

Regarding enabling METSRIGHTS crosswalk by default - I intentionally didn't want to do that:

I'm not sure I fully understand this statement. By adding "?rightsMDTypes=METSRIGHTS" into the default XSLT, you actually are causing the METSRIGHTS crosswalk to be "enabled by default" as long as it is defined in the dspace.cfg file. The only way to stop the METSRIGHTS crosswalk from being run in the XMLUI would be to either (a) remove it from the dspace.cfg or (b) modify the XSLT in your theme to override that default "?rightsMDTypes=METSRIGHTS" setting.

After saying that, I can now see the one advantage of enabling METSRIGHTS in the Theme XSLT is that it may be easier to disable in your own custom theme than if it was defined in a Java class (like I had suggested above).

Thanks Tim for a review. Would you happen to know how create a separate document for METSRIGHTS?

Off the top of my head, I'm not sure of an easy way to generate a separate document for METSRIGHTS. It could be something to look into post-3.0 obviously.

João Melo
Owner

(Developer appreciation) +1 Code is fine.

helix84 helix84 [DS-1193] display bitstream read access permissions on item page (squ…
…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.
2499436
helix84
Owner

Tim, both of your concerns have been resolved:
1) all distributed themes now have this feature
2) I'm checking for presence of the METSRIGHTS crosswalk in dspace.cfg and if it's not present, fall back to the old behaviour

helix84 helix84 merged commit 91b4927 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 17, 2012
  1. helix84

    [DS-1193] display bitstream read access permissions on item page (squ…

    helix84 authored
    …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.
This page is out of date. Refresh to see the latest.
BIN  dspace-xmlui/dspace-xmlui-webapp/src/main/webapp/themes/Classic/images/Crystal_Clear_action_lock3_64px.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  dspace-xmlui/dspace-xmlui-webapp/src/main/webapp/themes/Kubrick/images/Crystal_Clear_action_lock3_64px.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  dspace-xmlui/dspace-xmlui-webapp/src/main/webapp/themes/Mirage/images/Crystal_Clear_action_lock3_64px.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 dspace-xmlui/dspace-xmlui-webapp/src/main/webapp/themes/Mirage/lib/xsl/aspect/artifactbrowser/item-view.xsl
View
@@ -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"/>
@@ -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>
BIN  ...ce-xmlui/dspace-xmlui-webapp/src/main/webapp/themes/Reference/images/Crystal_Clear_action_lock3_64px.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 dspace-xmlui/dspace-xmlui-webapp/src/main/webapp/themes/dri2xhtml-alt/aspect/artifactbrowser/common.xsl
View
@@ -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"/>
@@ -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 />
60 dspace-xmlui/dspace-xmlui-webapp/src/main/webapp/themes/dri2xhtml/General-Handler.xsl
View
@@ -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"/>
@@ -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>
@@ -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
11 dspace-xmlui/dspace-xmlui-webapp/src/main/webapp/themes/dri2xhtml/structural.xsl
View
@@ -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"/>
@@ -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"/>
BIN  dspace-xmlui/dspace-xmlui-webapp/src/main/webapp/themes/template/images/Crystal_Clear_action_lock3_64px.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Something went wrong with that request. Please try again.