Dear Karla,
In data giovedì 2 luglio 2009, Karla Gabriela Robles Bernal scribacchiaste
dette parole:
> Hello
>
> Im using cds invenio 0.99.1 and this is the situation, When I insert a new
> record of DEMOART with a PDF file, the file displays perfectly, but, I need
> to restrict the file for only logged users, so I create a xml file
> (attached to this mail) to restrict the access and executed:
>
> bibupload -r cds-invenio/var/tmp/restricted.xml
>
> Now the file is restricted for guest, but when I logged with admin account,
> the file is available but when I tried to open it, it displays the next
> error: "File does not begin with %PDF-"
>
> I wonder if you can help me, or give me another alternative to restrict
> files PDF or DOc, at the moment of submit the file (SBI), so I dont need to
> run bibupload after submit the record,
>
> I want the guest user be capable of reading all the article's reference and
> viewing and downloading files (PDF or DOC) only if they're logged.
In the XML file you attached, what you exactly did with your FFT tag has been
to revise your document with a copy of your document while restricting it.
In order to simply restrict the document you just needed to upload something
like:
<record>
<controlfield tag="001">13</controlfield>
<datafield tag="FFT" ind1="" ind2=" ">
<subfield code="n">CIAD-ARTICULO-011</subfield>
<subfield code="r">Restricted</subfield>
</datafield>
</record>
In this way you don't create a new revision.
In Invenio-0.99.1 it was not directly possible to restrict a document upon
submission (while it will be possible with the next release, together with
many other fulltext related features). However you can customize the
Move_Files_to_Storage function (which is responsible in DEMOART for uploading
the document) to perform such a restriction.
For this just copy it into a new function in e.g. in
</opt/cds-
invenio/lib/python/invenio/websubmit_functions/Move_Files_to_Storage_Restrict.py>
and modify it by adding just before the 'return ""' statement something
similar to:
for bibdoc in bibrecdocs.list_bibdocs():
bibdoc.set_status('Restricted')
You will also have to register in the WebSubmit Admin interface this new
function, which will have the same parameters of Move_Files_to_Storage, and
you have to use it in DEMOART.
For restricting document only to guest user, as you may already know, you have
to set-up in WebAccess a new role, called e.g. GuestUsers, with a FireRole
(<http://invenio-demo.cern.ch/help/admin/webaccess-admin-guide#6>) similar to:
allow guest '0'
You will then have to authorize such a role to the 'viewrestrdoc' action with
status parameter set to 'Restricted'.
For why with your procedure you've obtained a corrupted PDF, I'm not quite
sure at the moment, but it might be that bibupload first restricted the
document, and then tried to download it (because you provided the explicit
URL) and failed because the URL was restricted. Thus, if this guess is
correct, I think that if you open the corrupted PDF in a text editor you will
find the HTML code of the page you would obtain as a guest by visiting:
<http://cds.ciad.mx/record/13/files/CIAD-ARTICULO-011.pdf>
We should probably fix this on our side, by recognizing when a URL is an
internal URL and by trying to not download it like any other URLs, but by
access it directly from disk...
Please let us know in case you need further help.
Best regards,
Samuele
--
Samuele Kaplun ** CERN Document Server ** <http://cds.cern.ch/>