Skip to content

Add the raw_parser option to pass XML directly to the exporter #4

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pieterdp
Copy link
Contributor

Add the raw_parser option to pass XML parsed by AOI::Parser::raw directly to the exporter. See this issue in Datahub-Factory.

@@ -90,7 +91,8 @@ sub add {
my $token = $self->access_token;
my $response;

$response = $self->client->post($url, Content_Type => 'application/lido+xml', Authorization => sprintf('Bearer %s', $token), Content => $data);
my $enc_data = encode_utf8($data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you this here? What's the added benefit of doing an encode_utf8()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If $data contains non-ascii-characters, the client will fail.

return $self->api->update($data->{'id'}, $data->{'_'});

if ($self->store->raw_parser == 1) {
return $self->api->add($data->{'_metadata'});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the Datahub API should make any assumptions about the datamodel of the incoming data. the _metadata construct is a typical ouptput of OAI. I think this would violate the open/closed principle.

Maybe a separate optional parser object could be injected here. Maybe not in the API implementation itself, but right before the data is passed of to this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, should be part of the transformation (perhaps in a fix?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants