-
Notifications
You must be signed in to change notification settings - Fork 405
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
Lookup and redirect by uuid and handle #490
Conversation
@artlowel, I have a question about the motivation for this work. The obvious motivation is resolving external handle (or other identifier) requests. Each time one of these external requests happens the application state gets re-initialized, previously cached data is lost, and the REST api is queried by handle for dso data, etc. Following the recommendation in #256, handle ids are added to the object cache. We also query the cache by handle/uuid in I can see a way to do this for |
Integration test failed for one of the node versions. |
After looking at the planning spreadsheet I realized that the REST API task was completed. I looked again and saw that the pid endpoint uses IdentifierService providers. Updating code to use that endpoint. I presume it will work for handles when that's done. We'll see. |
As expected, routing now works for handles. Examples of working routes: id/uuid/9b4f22f4-164a-49db-8817-3316b6ee5746 |
This should be ready for review now. |
I updated the object-not-found page with i18n messages. Should be reviewed. (This isn't necessarily a 404 so I think the message can't just mimic the existing page-not-found.) |
Fixed unit tests. Updated to use pid REST endpoint. Minor change in data.service and unit test update. Updated the objectnotfound page with new text and go home button.
I'm getting back this after some time away from the office. I noticed that I had introduced a bug into the legacy handle lookup -- some unnecessary url encoding. Redirects seem to be working again. Here's a lookup by handle that succeeds (using the demo REST api): http://localhost:3000/handle/10673/703 |
The pid endpoint supports a single GET method that takes an Well actually ... the REST controller just sends a redirect to the endpoint for the actual object. The client code receives the result of that redirect. |
The pid should support DOIs as well as handles. That obviously hasn't been tested in this PR. |
Fixed unit tests. Updated to use pid REST endpoint. Minor change in data.service and unit test update. Updated the objectnotfound page with new text and go home button.
Thanks @mspalti! It works for handles. But it's a shame you need to escape the handle in the second case. I think you could write a custom UrlMatcher to use in the routing module instead of the path. That could cover the case where if the idType is handle, you need to include the slash in the id. Here's an article about it: https://medium.com/@brandontroberts/custom-route-matching-with-the-angular-router-fbdd48665483 |
Thanks for that suggestion, @artlowel . I added a matcher function so a url like this now works: |
…es the need to encode the forward slash). Fixed comment.
There is a separate REST endpoint If we want both uuid and handle lookups in this PR, it would certainly be possible to switch the endpoint based on the |
This PR creates a |
I added uuid lookup and redirect using the http://localhost:3000/id/uuid/98b3e297-dd7e-4da7-a93e-67e5622e37ed I notice that the |
@artlowel , I decided to add uuid lookups by switching between endpoints. I don't know if there was more discussion about the REST endpoints at the last WG meeting. For now, I just assumed the status quo. I'm using the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR creates a object/uuid-to-self-link/handle index that is not used for handle lookups. I'm mentioning that again just to make sure that this is ok.
You're right, I don't think we need that index, the uuid should be the identifier we use internally, support for others should only be available at the /id
and /handle
routes.
@artlowel , I decided to add uuid lookups by switching between endpoints.
I don't know if there was more discussion about the REST endpoints at the last WG meeting. For now, I just assumed the status quo. I'm using the dso endpoint when the identifier is a uuid; otherwise using the pid endpoint. Both uuid and handle lookups are working.
That sounds fine.
If I enter an identifier that doesn't exist I keep seeing the loading component instead of a 404. The console shows an "EmptyError: no elements in sequence", so it's likely due to a first()
somewhere. If you replace it by take(1)
that should solve it. (first
requires the observable to always emit something, take(1)
doesn't)
The 404 response is working. I needed to remove the successful response filter in |
…ys be used internally) and all associated code.
Removed the separate handle index. Back to using the single |
One problem. When I got back to this today, and before making any code changes, I saw only 404 responses from the demo server. Testing against my local dspace instance (which is synced to master) works fine. So I'm assuming that something has changed in the REST demo |
Actually, the uuid lookup works fine on the demo server. Handle lookups do not seem to work. |
I see the same thing. I'll bring it up in the meeting today. |
I think it might be a good idea to add a new message to the i18n files (rather than repurposing existing messages) but I wasn't sure how the translation process worked. Looking at Marie's i18n PR and Bram's comment there, I see translation work is ongoing. Let me know if I should propose language and to add it to the english i18n. (For display in the objectnotfound component.) |
Feel free to add new messages. We ask that you always add new messages in English to en.json5. If you happen to know any of the other languages, it is appreciated if you add it to those as well. But the English file should always be kept up to date. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still get the same issue against the demo rest backend. But as it seems this is a rest issue, this PR can be merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mspalti Thanks for the work
the code looks good, and it works properly on my local rest server.
I don't know why most of the ids are not found on rest demo server, but I found one that works
#256
This initial work on routing by id works with uuid requests. In separate work I was able to test handle routing using cached objects. However, I think we need a real REST endpoint for handle lookups in the actual implementation.
I'm currently using the dso endpoint to look up communities, collections and items. Wondering if that endpoint is the correct place to add support for handle (and other id type) lookups?
UPDATE: Discovered that the pid endpoint is designed for this task. Updated.