Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Resplit PDF" button produces error #80

Open
3 tasks
ndroark opened this issue Jun 9, 2024 · 6 comments
Open
3 tasks

"Resplit PDF" button produces error #80

ndroark opened this issue Jun 9, 2024 · 6 comments
Assignees
Labels
bug something isn't working High Priority needs rework issue needs additional work

Comments

@ndroark
Copy link
Collaborator

ndroark commented Jun 9, 2024

The "Resplit this pdf" button on the Fileset page produces a "You are not authorized to access this page" for a superadmin user, example: https://nicdon.palni-palci-staging.notch8.cloud/concern/parent/f7a1fe4c-c553-420d-9205-0402d577df4a/file_sets/3e3e018f-096c-486d-8dc2-22b3cd665d7a

Acceptance Criteria

  • Fix PDF resplitting option

Screenshots or Video

Hyku Main:
Image

Testing Instructions

Create a work with a PDF (be sure feature flipper is set so the PDF splits into child works).
Go to the PDF file set page and click the option to re-split the pdf.

  • New child works are created from the PDF and attached to the parent work
  • All prior child works are deleted

Notes

v3 no longer supports active fedora

@ndroark ndroark converted this from a draft issue Jun 9, 2024
@laritakr laritakr added the bug something isn't working label Dec 3, 2024
@jillpe
Copy link

jillpe commented Jan 13, 2025

IIIF print issue. Related to notch8/iiif_print#294

@jillpe jillpe changed the title "Resplit PDF" button produces error Spike: "Resplit PDF" button produces error Jan 13, 2025
@ShanaLMoore ShanaLMoore self-assigned this Jan 22, 2025
@ShanaLMoore ShanaLMoore moved this to In Development in PalsKnapsack Jan 22, 2025
@ShanaLMoore ShanaLMoore assigned laritakr and unassigned ShanaLMoore Jan 22, 2025
@ShanaLMoore
Copy link
Contributor

ShanaLMoore commented Jan 22, 2025

I've only done some sleuthing so far; I don't have a branch with code changes.

I was able to reproduce this in local Hyku.

I noticed the where clauses need to be updated to valkyrie queries.

Then the #pdf? is not a method error is because file_set.pdf? needs to be updated to file_set.original_file.pdf?. Same goes for #mime_type => file_set.original_file.mime_type. Or I suppose we could introduce a helper method.

cc @laritakr handing it back over to you since you may already have had WIP.

@laritakr laritakr changed the title Spike: "Resplit PDF" button produces error "Resplit PDF" button produces error Jan 29, 2025
laritakr pushed a commit to notch8/iiif_print that referenced this issue Jan 29, 2025
There were a few pieces of the pdf resplitting process that were not
fully valkyrized. This commit valkyrizes the resplitting, and fixes
a bug with removing the child works from the initial split.

Ref notch8/palni_palci_knapsack#80
laritakr pushed a commit to samvera/hyku that referenced this issue Jan 30, 2025
Bring in fixes for resplitting & deleting the child works along with the
parent work.

Refs notch8/palni_palci_knapsack#80
laritakr pushed a commit to samvera/hyku that referenced this issue Jan 31, 2025
Bring in fixes for resplitting & deleting the child works along with the
parent work.

Refs notch8/palni_palci_knapsack#80
laritakr added a commit to samvera/hyku that referenced this issue Jan 31, 2025
Bring in fixes for resplitting & deleting the child works along with the
parent work.

Refs notch8/palni_palci_knapsack#80

Co-authored-by: LaRita Robinson <[email protected]>
@laritakr laritakr moved this from In Development to Code Review in PalsKnapsack Jan 31, 2025
@laritakr laritakr moved this from Code Review to Deploy to Staging in PalsKnapsack Jan 31, 2025
@laritakr laritakr moved this from Deploy to Staging to Code Review in PalsKnapsack Jan 31, 2025
@laritakr laritakr moved this from Code Review to Deploy to Staging in PalsKnapsack Jan 31, 2025
@ShanaLMoore ShanaLMoore moved this from Deploy to Staging to SoftServ QA in PalsKnapsack Feb 3, 2025
@ShanaLMoore
Copy link
Contributor

ShanaLMoore commented Feb 3, 2025

QA RESULTS: ❌ NEEDS REWORK

tested on STAGING

Before clicking re split led to a 500 error page.

Now the user will get a success message that the job is enqueued:
Image

However, after the jobs completed I am not able to view the pages in the UV and the pages have lost their thumbnails.

Image

Additionally, if I try to download one of the pages it says it cant be found:

Image

cc @laritakr could you have a look and pull this back for rework if more needs to be done here?

@ShanaLMoore ShanaLMoore added the needs rework issue needs additional work label Feb 3, 2025
@ShanaLMoore ShanaLMoore moved this from SoftServ QA to In Development in PalsKnapsack Feb 3, 2025
@laritakr
Copy link
Contributor

laritakr commented Feb 3, 2025

The remaining problem is that Hyrax's BatchCreateJob is not consistently enqueuing the CreateWorkJob with the uploaded_files attribute.

In BatchCreateJob below, the array of upload_ids ["1639", "1640"] should iterate and create two CreateWorkJobs, with attributes uploaded_files: [upload_id]. However, in almost every situation in staging, the uploaded_files attribute is missing so the job can't find the file to attach.

I, [2025-02-03T21:20:09.511182 #1]  INFO -- : [ActiveJob] [IiifPrint::Jobs::ChildWorksFromPdfJob] [bc288646-6e67-4b16-bc17-61d3d7fab203] Enqueued BatchCreateJob (Job ID: b6626a13-0372-4847-ae5e-c165792123ab) to Sidekiq(default) with arguments: #<GlobalID:0x00007f8e25af48e8 @uri=#<URI::GID gid://hyku/User/1>>, {"1639"=>"7c23603a-346e-4ec6-bcde-aac7c3d86e47 - iiif-print-test.pdf Page 1", "1640"=>"7c23603a-346e-4ec6-bcde-aac7c3d86e47 - iiif-print-test.pdf Page 2"}, {"1639"=>["Image"], "1640"=>["Image"]}, ["1639", "1640"], {"admin_set_id"=>"admin_set/default", "creator"=>["snoopy"], "keyword"=>["snoopy"], "rights_statement"=>["http://rightsstatements.org/vocab/NKC/1.0/"], "is_child"=>true, "visibility"=>"open", "model"=>"GenericWorkResource", "split_from_pdf_id"=>"41c75dc9-ffa5-4b46-aaf7-f8975b0cc4ee"}, #<GlobalID:0x00007f8e25af3330 @uri=#<URI::GID gid://hyku/Hyrax::BatchCreateOperation/1151>>

I, [2025-02-03T21:22:05.985647 #1]  INFO -- : [ActiveJob] Enqueued CreateWorkJob (Job ID: b7a01964-7c08-40fd-b9e3-66ecdb66b153) to Sidekiq(default) at 2025-02-03 21:26:23 UTC with arguments: #<GlobalID:0x00007f8e327c7528 @uri=#<URI::GID gid://hyku/User/1>>, "GenericWorkResource", {"admin_set_id"=>"admin_set/default", "creator"=>["snoopy"], "keyword"=>["snoopy"], "rights_statement"=>["http://rightsstatements.org/vocab/NKC/1.0/"], "is_child"=>true, "visibility"=>"open", "split_from_pdf_id"=>"41c75dc9-ffa5-4b46-aaf7-f8975b0cc4ee", "title"=>["7c23603a-346e-4ec6-bcde-aac7c3d86e47 - iiif-print-test.pdf Page 1"], "resource_type"=>["Image"]}, #<GlobalID:0x00007f8e327c2bb8 @uri=#<URI::GID gid://hyku/Hyrax::Operation/1152>>

The logic in Hyrax has not changed anytime recently, and it doesn't make sense why this would be happening:

  def create(user, titles, resource_types, uploaded_files, attributes, operation)
    model = attributes.delete(:model) || attributes.delete('model')
    raise ArgumentError, 'attributes must include "model" => ClassName.to_s' unless model

    uploaded_files.each do |upload_id|
      title = [titles[upload_id]] if titles[upload_id]
      resource_type = Array.wrap(resource_types[upload_id]) if resource_types[upload_id]
      attributes = attributes.merge(uploaded_files: [upload_id],
                                    title: title,
                                    resource_type: resource_type)
      child_operation = Hyrax::Operation.create!(user: user,
                                                 operation_type: "Create Work",
                                                 parent: operation)
      CreateWorkJob.perform_later(user, model, attributes, child_operation)
    end

laritakr pushed a commit to samvera/hyku that referenced this issue Feb 4, 2025
Refs:
notch8/palni_palci_knapsack#229
notch8/palni_palci_knapsack#80

Adds a new decorator to override the IiifPrint FileSetPresenterDecorator
and prevent the resplit PDF button from appearing.

This is a temporary fix until we can get the resplit button to work.
@laritakr
Copy link
Contributor

laritakr commented Feb 4, 2025

Additional notes to above:

CreateWorkJob is submitted correctly with parameters. As it runs it receives an error RuntimeError (The value for :adapter was not found in the blacklight.yml config). When it gets resubmitted, it no longer has the uploaded_files: [upload_id] attribute, causing it to fail with a different error.

@laritakr
Copy link
Contributor

laritakr commented Feb 5, 2025

Fixed by samvera/hyku#2445 and #231

@laritakr laritakr moved this from In Development to SoftServ QA in PalsKnapsack Feb 5, 2025
@laritakr laritakr moved this from SoftServ QA to Deploy to Staging in PalsKnapsack Feb 5, 2025
@laritakr laritakr moved this from Deploy to Staging to Client QA in PalsKnapsack Feb 5, 2025
@jillpe jillpe moved this from Client QA to In Development in PalsKnapsack Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something isn't working High Priority needs rework issue needs additional work
Projects
Status: In Development
Development

No branches or pull requests

4 participants