<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div>Hi John / Fran,</div>
<div><br>
</div>
<div>I believe I have made the appropriate tweaks needed in EPrints 3.4's perl_lib/EPrints/Apache/CRUD.pm and this seems to fix the issue from my testing. &nbsp;You will need to set an extra role for the user that is going to submit &quot;on behalf of&quot; other users. &nbsp;This
 permission is:</div>
<div><br>
</div>
<div>&#43;user/mediate</div>
<div><br>
</div>
<div>I will endeavour to post the updated version to GitHub soon, assuming it is not too different to the version I was working against. &nbsp;However, if you want to make the changes yourself, there are only three places in CRUD.pm that need fixed (see below).
 &nbsp;I am assuming this is on a development instance you are working on, as I would not be 100% confident this will not have any side effects. &nbsp;John thoughts?</div>
<div><br>
</div>
<div>Regards</div>
<div><br>
</div>
<div>David Newman</div>
<div><br>
</div>
<div># 1.&nbsp;sub&nbsp;handler</div>
<div><b></b>-<span class="Apple-tab-span" style="white-space: pre;"> </span>my( $rc, $owner ) = on_behalf_of( $repo, $r, $user );</div>
<div>&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>my( $rc, $owner ) = $self-&gt;on_behalf_of( $user );</div>
<div><br>
</div>
<div><br>
</div>
<div># 2. sub on_behalf_of</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>my( $repo, $r, $user ) = @_;</div>
<div>&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>my( $self, $user ) = @_;</div>
<div>&nbsp;</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>my $err = {</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>status =&gt; HTTP_FORBIDDEN,</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>href =&gt; &quot;<a href="https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpurl.org%2Fnet%2Fsword%2Ferror%2FTargetOwnerUnknown&amp;data=01%7C01%7C%7C1b45f7ce28ec4c60989908d674c6a2c9%7C4a5378f929f44d3ebe89669d03ada9d8%7C1&amp;sdata=4wK422ITPxTP9cGx9CuZ%2B2psPYUx6TjdxrbGdq6DiV8%3D&amp;reserved=0" originalsrc="http://purl.org/net/sword/error/TargetOwnerUnknown" shash="DHyr78mKjtinPvNU&#43;7qC2o2e8AUtU73rnE6RGBL8YU843&#43;tNZJdDyM3tymjdfXcLoNeBjpqLVhyQ49bdVNajDjjPWLylchW42pldDTd1wMh4FPvkEY8nvnp5Xrpq&#43;AwApcZ9kHkDeJFvI1txd&#43;BfwrIOeSCqJ4fqEGf/Z89uw&#43;4=">http://purl.org/net/sword/error/TargetOwnerUnknown</a>&quot;,</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>summary =&gt; &quot;Target user unknown or no permission to act on-behalf-of&quot;,</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>};</div>
<div>&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>my $r = $self-&gt;request;</div>
<div>&#43; &nbsp; &nbsp; &nbsp; my $repo = $self-&gt;repository;</div>
<div>&nbsp;</div>
<div>&nbsp;<span class="Apple-tab-span" style="white-space:pre"> </span>my $on_behalf_of =</div>
<div>&nbsp;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>$r-&gt;headers_in-&gt;{'On-Behalf-Of'} || # SWORD 2.0</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>$r-&gt;headers_in-&gt;{'X-On-Behalf-Of'}; # SWORD 1.3</div>
<div>&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<b></b>return( OK, $user ) if !$on_behalf_of;</div>
<div><br>
</div>
<div>&nbsp;<span class="Apple-tab-span" style="white-space:pre"> </span>my $owner = $repo-&gt;user_by_username( $on_behalf_of );</div>
<div>&nbsp;</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>return sword_error($repo, $r, %$err )</div>
<div>&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>return ( HTTP_FORBIDDEN, undef )</div>
<div>&nbsp;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>if !defined $owner;</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>return sword_error($repo, $r, %$err )&nbsp;</div>
<div>&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>return ( HTTP_FORBIDDEN, undef )</div>
<div>&nbsp;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>if !$user-&gt;allow( &quot;user/mediate&quot;, $owner );</div>
<div>&nbsp;</div>
<div>&nbsp;<span class="Apple-tab-span" style="white-space:pre"> </span>return( OK, $owner );</div>
<div><br>
</div>
<div><br>
</div>
<div># 3. sub servicedocument</div>
<div>&nbsp;<span class="Apple-tab-span" style="white-space:pre"> </span>my $user = $repo-&gt;current_user;</div>
<div>&nbsp;<span class="Apple-tab-span" style="white-space:pre"> </span>EPrints-&gt;abort( &quot;unprotected&quot; ) if !defined $user; # Rewrite foobar</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>my $on_behalf_of = on_behalf_of( $repo, $r, $user );</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>if( $on_behalf_of-&gt;{status} != OK )</div>
<div>&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>my ( $status, $on_behalf_of ) = $self-&gt;on_behalf_of( $user );</div>
<div>&#43;<span class="Apple-tab-span" style="white-space:pre"> </span>if( $status != OK )</div>
<div>&nbsp;<span class="Apple-tab-span" style="white-space:pre"> </span>{</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>return sword_error( $repo, $r, %$on_behalf_of );</div>
<div>&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>return $self-&gt;sword_error(&nbsp;</div>
<div>&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>status =&gt; HTTP_FORBIDDEN,</div>
<div>&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span><span class="Apple-tab-span" style="white-space:pre"></span>href =&gt; &quot;<a href="https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpurl.org%2Fnet%2Fsword%2Ferror%2FTargetOwnerUnknown&amp;data=01%7C01%7C%7C1b45f7ce28ec4c60989908d674c6a2c9%7C4a5378f929f44d3ebe89669d03ada9d8%7C1&amp;sdata=4wK422ITPxTP9cGx9CuZ%2B2psPYUx6TjdxrbGdq6DiV8%3D&amp;reserved=0" originalsrc="http://purl.org/net/sword/error/TargetOwnerUnknown" shash="DHyr78mKjtinPvNU&#43;7qC2o2e8AUtU73rnE6RGBL8YU843&#43;tNZJdDyM3tymjdfXcLoNeBjpqLVhyQ49bdVNajDjjPWLylchW42pldDTd1wMh4FPvkEY8nvnp5Xrpq&#43;AwApcZ9kHkDeJFvI1txd&#43;BfwrIOeSCqJ4fqEGf/Z89uw&#43;4=">http://purl.org/net/sword/error/TargetOwnerUnknown</a>&quot;,</div>
<div>&#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;summary =&gt; &quot;Target user unknown or no permission to act on-behalf-of&quot;,</div>
<div>&#43;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"></span>);</div>
<div>&nbsp;<span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>$on_behalf_of = $on_behalf_of-&gt;{on_behalf_of};</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>On Mon, 2019-01-07 at 16:30 &#43;0000, John Salter via Eprints-tech wrote:</div>
<blockquote type="cite">
<div>Hi Fran,</div>
<div>It would depend on the CRIS system, and local policy: is knowing who the depositing author is from within EPrints important?</div>
<div>&nbsp;</div>
<div>You could create a 'CRIS' account - and all deposits would be made by this account (if the CRIS system allows this).</div>
<div>&nbsp;</div>
<div>I think both the Pure and the Symplectic connectors can do something similar to this - so it might be worth pursuing.</div>
<div>&nbsp;</div>
<div>If I get a chance I'll take a look at the module tonight.</div>
<div>Would you be in a position to test a proposed update to the file this week?</div>
<div>&nbsp;</div>
<div>Cheers,</div>
<div>John</div>
<div>From: <a href="mailto:eprints-tech-bounces@ecs.soton.ac.uk">eprints-tech-bounces@ecs.soton.ac.uk</a> [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Fran Callaghan via Eprints-tech</div>
<div>Sent: 07 January 2019 16:08</div>
<div>To: <a href="mailto:eprints-tech@ecs.soton.ac.uk">eprints-tech@ecs.soton.ac.uk</a></div>
<div>Subject: Re: [EP-tech] Error whilst depositing via SWORD</div>
<div>&nbsp;</div>
<div>Hi John,</div>
<div>&nbsp;</div>
<div>The depositing system is our CRIS. Would this make sense in so far as it would be making deposits &quot;on behalf of&quot; genuine researchers? Does the depositing system need to make this explicit in the first place? Can't it just deposit with a different author
 name?</div>
<div>&nbsp;</div>
<div>Thanks all,</div>
<div><br>
</div>
<div>Fran Callaghan</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>On Mon, 7 Jan 2019 at 15:38, John Salter &lt;<a href="mailto:J.Salter@leeds.ac.uk">J.Salter@leeds.ac.uk</a>&gt; wrote:</div>
<div>Hi Fran,</div>
<div>Taking a quick look at the code, I think the issue is that in the CRUD module, there are a couple of instances where the 'sword_error' is called as a raw function , rather than an object method e.g.:</div>
<div>Normal working:</div>
<div>https://github.com/eprints/eprints/blob/3.3/perl_lib/EPrints/Apache/CRUD.pm#L432-L436</div>
<div>&nbsp;</div>
<div>Function call in servicedocument function:</div>
<div>https://github.com/eprints/eprints/blob/3.3/perl_lib/EPrints/Apache/CRUD.pm#L1742-L1745</div>
<div>and 'on_behalf_of' function:</div>
<div>https://github.com/eprints/eprints/blob/3.3/perl_lib/EPrints/Apache/CRUD.pm#L1838-L1862</div>
<div>&nbsp;</div>
<div>This issue will only become apparent when you're doing a SWORD deposit using the 'on-behalf-of' header.</div>
<div>I think it may have been present for ~7 years, when the first line of the sword_error function was changed from</div>
<div>my( $repo, $r, %opts ) = @_;</div>
<div>to</div>
<div>my( $self, %opts ) = @_;</div>
<div>&nbsp;</div>
<div>I think it's more than a 5-minute job to fix properly - I need to get into the code a bit more to understand what was changed - and how to resolve it.</div>
<div>&nbsp;</div>
<div>I'll log it in GitHub and let you know try and come up with a solution - unless anyone else fancies having a&nbsp; go..?</div>
<div>&nbsp;</div>
<div>Cheers,</div>
<div>John</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>From: <a href="mailto:eprints-tech-bounces@ecs.soton.ac.uk">eprints-tech-bounces@ecs.soton.ac.uk</a> [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Fran Callaghan via Eprints-tech</div>
<div>Sent: 07 January 2019 14:50</div>
<div>To: <a href="mailto:eprints-tech@ecs.soton.ac.uk">eprints-tech@ecs.soton.ac.uk</a></div>
<div>Subject: [EP-tech] Error whilst depositing via SWORD</div>
<div>&nbsp;</div>
<div>Hi All,</div>
<div>&nbsp;</div>
<div>We have a third party depositing via SWORD. They're getting a generic 500 message back but when I lookup the error_log corresponding to the time of the test I can see this message...</div>
<div>&nbsp;</div>
<div>[Mon Jan 07 13:46:18.179171 2019] [perl:error] [pid 10713] [client X.X.X.X] Can't locate object method &quot;repository&quot; via package &quot;EPrints::Repository&quot; at /opt/eprints3/perl_lib/EPrints/Apache/CRUD.pm line 1977.\n</div>
<div>&nbsp;</div>
<div>Any ideas what's wrong with CRUD.pm? Or is it a problem with the syntax of the deposit? I had expected SWORD to be pretty much plug and play (actually not even 'plug' since the documentation says it is configured by default).</div>
<div>&nbsp;</div>
<div>**NOTE: I have X'd out the client IP address, it's a genuine IP in the original message</div>
<div>&nbsp;</div>
<div>Thanks all,</div>
<div>Fran Callaghan</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>Séanadh Ríomhphoist/Email Disclaimer</div>
<div>Tá an ríomhphost seo agus aon chomhad a sheoltar leis faoi rún agus is lena úsáid ag an seolaí agus sin amháin é. Is féidir tuilleadh a léamh anseo.&nbsp;</div>
<div>This e-mail and any files transmitted with it are confidential and are intended solely for use by the addressee. Read more here.</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>&nbsp;</div>
<div>Séanadh Ríomhphoist/Email Disclaimer</div>
<div>Tá an ríomhphost seo agus aon chomhad a sheoltar leis faoi rún agus is lena úsáid ag an seolaí agus sin amháin é. Is féidir tuilleadh a léamh anseo.&nbsp;</div>
<div>This e-mail and any files transmitted with it are confidential and are intended solely for use by the addressee. Read more here.</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</div>
<div>*** Archive: <a href="https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.eprints.org%2Ftech.php%2F&amp;data=01%7C01%7C%7C1b45f7ce28ec4c60989908d674c6a2c9%7C4a5378f929f44d3ebe89669d03ada9d8%7C1&amp;sdata=wIi50DheYKsmVCJVD%2F81q%2BcPWQjqRt3u3ugiKW23Bmk%3D&amp;reserved=0" originalsrc="http://www.eprints.org/tech.php/" shash="kCTY4fA89FYX4V97sQCllnmioz1&#43;HWZZ616q5vgpnQy8XlWKv/HnCMA/ejH2jcCRaxP7BnpvKAG9NQfXMSd9w&#43;X3SN3zTUra1Un7wDm8rEJWylOZQ3/1RqCvHnMCr73KFHqgtDYbgpxpVzbDWu96/ZeC&#43;FZMXUdP7/FoFNAz97w=">
http://www.eprints.org/tech.php/</a></div>
<div>*** EPrints community wiki: <a href="https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.eprints.org%2F&amp;data=01%7C01%7C%7C1b45f7ce28ec4c60989908d674c6a2c9%7C4a5378f929f44d3ebe89669d03ada9d8%7C1&amp;sdata=x12p%2B1GNIPT1DUnTbRLOcovfplPn3BnP9F7Q0rRMfKM%3D&amp;reserved=0" originalsrc="http://wiki.eprints.org/" shash="sFqr&#43;&#43;&#43;OpXJVPflgJy2HxUWoH&#43;8cf/wBMBak9zO/4CJZ6&#43;voO8B80cir5OT33DeuvnEHzdolOChQoWBWEuXJTAAww45guysHt6&#43;Aqdks1Y6WTeAiGvrwfxXVH2Rb7RXQuA&#43;zb4A2JlpWkYkAMXaCQUjmuLI8A2mkkPj3wEZvbDw=">
http://wiki.eprints.org/</a></div>
<div>*** EPrints developers Forum: <a href="https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fforum.eprints.org%2F&amp;data=01%7C01%7C%7C1b45f7ce28ec4c60989908d674c6a2c9%7C4a5378f929f44d3ebe89669d03ada9d8%7C1&amp;sdata=1y0p1Gl%2FmRC3xn%2FPQX6s2MtjYtCx10BeuVLZMy1XIVI%3D&amp;reserved=0" originalsrc="http://forum.eprints.org/" shash="yFoFA7gMDs/lEZ&#43;WoBrQvqDLWCdrBNrWNCeam5lT7siQx5O/iS63ntvWdTY8WokrVEDpKrVNJ8SsxzzstxNGNvZ&#43;NLlCzkhkuo3s/X/iutcmiS/KR9eWDH3cq9CWH49SPzVCtuGHk6trR6WyeW5WSFZFNXdJI9Pn1az35yibI10=">
http://forum.eprints.org/</a></div>
</blockquote>
</body>
</html>