Skip to content

Conversation

diya17
Copy link
Contributor

@diya17 diya17 commented Sep 21, 2023

Guidelines for Pull Requests

If you haven't yet read our code review guidelines, please do so, You can find them here.

Please confirm the following by adding an x for each item (turn [ ] into [x]).

  • I have removed all code style changes that are not necessary (e.g. changing blanks across the whole file that don’t need to be changed, adding empty lines in parts other than your own code)
  • I am not making any changes to files that don’t have any effect (e.g. imports added that don’t need to be added)
  • I do not have any sysout statements in my code or commented out code that isn’t needed anymore
  • I am not reformatting any files in the wrong format or without cause.
  • I am not changing file encoding or line endings to something else than UTF-8, LF
  • My pull request does not show an insane amount of files being changed although my ticket only requires a few files being changed
  • I have added Javadoc/documentation where appropriate
  • I have added test cases where appropriate
  • I have explained any part of my code/implementation decisions that is not be self-explanatory

Please provide a brief description of your ticket

https://diging.atlassian.net/browse/CITE-173

Added the reprocessing button for reprocessing the files

Are there any other pull requests that this one depends on?

Anything else the reviewer needs to know?

... describe here ...

@diging-jenkins
Copy link

Can one of the admins verify this patch?

@diya17 diya17 requested a review from jdamerow September 21, 2023 22:26
@jdamerow
Copy link
Member

jdamerow commented Oct 9, 2023

pr description needs to be filled out

@jdamerow jdamerow closed this Oct 9, 2023
@diya17 diya17 reopened this Oct 10, 2023
@Override
public ResponseEntity<String> reprocessDocument(IUser user, String documentId) {
ResponseEntity<String> response = sendRequest(user, reprocessingEndpoint.replace("{0}", documentId), String.class, HttpMethod.POST);
return response;
Copy link
Member

Choose a reason for hiding this comment

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

merge with line 75

throws GroupDoesNotExistException, CannotFindCitationException, ZoteroHttpStatusException,
ZoteroConnectionException, CitationIsOutdatedException, ZoteroItemCreationFailedException {
ICitation citation = getCitation(user, zoteroGroupId, itemId);
for (Iterator<IGilesUpload> gilesUpload = citation.getGilesUploads().iterator(); gilesUpload.hasNext();) {
Copy link
Member

Choose a reason for hiding this comment

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

should be a while loop

Copy link
Member

Choose a reason for hiding this comment

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

should actually be a stream that filters for the upload with the document id

checkedUploads.add(reprocessedUpload);
updateCitationWithUpdatedGilesUpload(checkedUploads, user, citation, documentId);
gilesUploadChecker.add(citation);
} catch (IOException e) {
Copy link
Member

Choose a reason for hiding this comment

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

move catch block up to where it is thrown.

try {
jsonNode = objectMapper.readTree(responseBody);
String checkUrl = jsonNode.get("checkUrl").asText();
String[] urlSegments = checkUrl.split("/");
Copy link
Member

Choose a reason for hiding this comment

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

should be taken directly from id property of response

}
}

private void updateCitationWithUpdatedGilesUpload(Set<IGilesUpload> checkedUploads, IUser user, ICitation citation, String documentId) {
Copy link
Member

Choose a reason for hiding this comment

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

shorten method name

@jdamerow jdamerow closed this Oct 20, 2023
@diya17 diya17 reopened this Oct 25, 2023
Copy link
Member

@jdamerow jdamerow left a comment

Choose a reason for hiding this comment

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

  • there is a code factor issue


private void initiateReprocessing(IUser user, String documentId, ICitation citation) {
ResponseEntity<String> reprocessingResponse = gilesConnector.reprocessDocument(user, documentId);
if (reprocessingResponse.getStatusCode().equals(HttpStatus.OK)) {
Copy link
Member

Choose a reason for hiding this comment

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

if it's not ok, the user needs to know this.

JsonNode jsonNode = objectMapper.readTree(responseBody);
progressId = jsonNode.get("id").asText();
} catch (IOException e) {
logger.error("Could not deserialize response.", e);
Copy link
Member

Choose a reason for hiding this comment

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

this should probably not simply be ignored but the user needs to know. the rest doesn't really make sense if this fails, does it?

logger.error("Could not get citation.", e);
} catch (ZoteroHttpStatusException e) {
logger.error("Could not get citation.", e);
}
Copy link
Member

Choose a reason for hiding this comment

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

again, it seems like a bad idea to just ignore this

throws GroupDoesNotExistException, CannotFindCitationException, ZoteroHttpStatusException,
ZoteroConnectionException, CitationIsOutdatedException, ZoteroItemCreationFailedException {
citationManager.reprocessFile((IUser) authentication.getPrincipal(), zoteroGroupId, itemId, documentId);
return new ResponseEntity<>(HttpStatus.OK);
Copy link
Member

Choose a reason for hiding this comment

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

if the reprocessing throws an error, the return should not be ok.

@jdamerow jdamerow closed this Apr 24, 2024
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.

4 participants