Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c3c5bb7
[CITE-173] Frontend for reprocessing
diya17 Aug 8, 2023
c4344a2
[CITE-173] Implementing reprocessing in citation manager and giles co…
diya17 Aug 9, 2023
6eba322
[CITE-173] Adding giles endpoint
diya17 Aug 29, 2023
2fc2246
[CITE-173] Changes to UI
diya17 Aug 30, 2023
7be90f9
[CITE-173] Adding changes in the controller and citation manager
diya17 Aug 31, 2023
ed05b54
[CITE-173] : Fixing UI Jquery
diya17 Sep 5, 2023
050995d
[CITE-173] Update CitationManager
diya17 Sep 6, 2023
97cb808
[CITE-173] Fixing duplication bug and css
diya17 Sep 7, 2023
3cee57b
[CITE-173] Making css changes and adding tests
diya17 Sep 13, 2023
0ece8b6
[CITE-173] Fixing testcase and config.properies
diya17 Sep 14, 2023
b662de3
[CITE-173] Fixing code factor issues
diya17 Sep 21, 2023
ec2db03
[CITE-173] Fixing intendation
diya17 Sep 21, 2023
459db44
[CITE-173] Addressing review comments in citation manager
diya17 Oct 20, 2023
8520d9f
[CITE-173] Changing tests
diya17 Oct 24, 2023
eb8a85f
Update Citation Manager to use collector
diya17 Oct 25, 2023
8286dfd
Update pom with latest java version used for build
diya17 Oct 25, 2023
f7a8991
[CITE-173] Addressing review comments
diya17 Apr 26, 2024
c8bfddc
Merge branch 'develop' into story/CITE-173
rajvi-patel-22 Aug 7, 2025
85de85a
[CITE-173] Address review comments
rajvi-patel-22 Aug 20, 2025
b0922ad
[CITE-173] Code cleanup
rajvi-patel-22 Sep 12, 2025
cfb6579
[CITE-173] Fixed invalid char in URL error
rajvi-patel-22 Sep 17, 2025
d7e2c63
[CITE-173] Add method to determine if upload can be reprocessed
rajvi-patel-22 Sep 24, 2025
8e5b213
CITE-173] Fix failing test cases
rajvi-patel-22 Sep 24, 2025
b660fb4
[CITE-173] Address codefactor comments
rajvi-patel-22 Sep 25, 2025
9e07704
[CITE-173] Merge conflicts
Girik1105 Dec 17, 2025
4cb64ff
[CITE-173] Fixed codefactor issues
Girik1105 Dec 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.concurrent.ExecutionException;

import org.springframework.data.util.CloseableIterator;
import org.springframework.http.HttpStatus;
import org.springframework.social.zotero.api.ZoteroUpdateItemsStatuses;
import org.springframework.social.zotero.exception.ZoteroConnectionException;

Expand Down Expand Up @@ -88,10 +89,15 @@ CloseableIterator<ICitation> getAllGroupItems(IUser user, String groupId, String

void deleteLocalGroupCitations(String groupId);

HttpStatus reprocessFile(IUser user, String zoteroGroupId, String itemId, String documentId)
throws GroupDoesNotExistException, CannotFindCitationException, ZoteroHttpStatusException,
ZoteroConnectionException, CitationIsOutdatedException, ZoteroItemCreationFailedException;


Citations findAuthorityCitations(IAuthorityEntry entry, IUser user);

ICitation addCitationToReferences(IUser user, ICitation citation, String zoteroGroupId, String referenceCitationKey,
String reference) throws SelfCitationException, ZoteroConnectionException, CitationIsOutdatedException,
ZoteroHttpStatusException, ZoteroItemCreationFailedException;

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.asu.diging.citesphere.core.service.giles;

import edu.asu.diging.citesphere.model.bib.IGilesUpload;
import edu.asu.diging.citesphere.user.IUser;

public interface GilesUploadChecker {
Expand All @@ -12,5 +13,7 @@ public interface GilesUploadChecker {
void checkUploadStatus(String citationKey);

void checkFileUploadStatus(String itemId, IUser principal, String fileId);

boolean canReprocess(IGilesUpload upload, IUser user);

}
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package edu.asu.diging.citesphere.core.service.giles;

import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.HttpClientErrorException;

import edu.asu.diging.citesphere.user.IUser;

public interface IGilesConnector {

<T> ResponseEntity<T> sendRequest(IUser user, String endpoint, Class<T> returnType)
<T> ResponseEntity<T> sendRequest(IUser user, String endpoint, Class<T> returnType, HttpMethod httpMethod)
throws HttpClientErrorException;

byte[] getFile(IUser user, String fileId);

}

ResponseEntity<String> reprocessDocument(IUser user, String documentId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;
Expand All @@ -29,6 +30,9 @@ public class GilesConnector implements IGilesConnector {
@Value("${giles_file_endpoint}")
private String fileEndpoint;

@Value("${giles_file_reprocessing_endpoint}")
private String reprocessingEndpoint;

@Autowired
private InternalTokenManager internalTokenManager;

Expand All @@ -44,7 +48,7 @@ public void init() {
* @see edu.asu.diging.citesphere.core.service.giles.impl.IGilesConnector#sendRequest(edu.asu.diging.citesphere.user.IUser, java.lang.String, java.lang.Class)
*/
@Override
public <T> ResponseEntity<T> sendRequest(IUser user, String endpoint,Class<T> returnType) throws HttpClientErrorException {
public <T> ResponseEntity<T> sendRequest(IUser user, String endpoint,Class<T> returnType, HttpMethod httpMethod) throws HttpClientErrorException {
String token = internalTokenManager.getAccessToken(user).getValue();

HttpHeaders headers = new HttpHeaders();
Expand All @@ -54,15 +58,20 @@ public <T> ResponseEntity<T> sendRequest(IUser user, String endpoint,Class<T> re

return restTemplate.exchange(
gilesBaseurl + endpoint,
HttpMethod.GET, requestEntity, returnType);
httpMethod, requestEntity, returnType);
}

/* (non-Javadoc)
* @see edu.asu.diging.citesphere.core.service.giles.impl.IGilesConnector#getFile(edu.asu.diging.citesphere.user.IUser, java.lang.String)
*/
@Override
public byte[] getFile(IUser user, String fileId) {
ResponseEntity<byte[]> content = sendRequest(user, fileEndpoint.replace("{0}", fileId), byte[].class);
ResponseEntity<byte[]> content = sendRequest(user, fileEndpoint.replace("{0}", fileId), byte[].class, HttpMethod.GET);
return content.getBody();
}

@Override
public ResponseEntity<String> reprocessDocument(IUser user, String documentId) {
return sendRequest(user, reprocessingEndpoint.replace("{0}", documentId), String.class, HttpMethod.POST);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,33 @@ public void checkFileUploadStatus(String citationKey, IUser user, String process
updateCitation(citation, checkedUploads, user, currentCitation);
}
}

/**
* Check if an upload can be reprocessed based on Giles API v2 status
* @param upload The upload to check
* @param user The user making the request
* @return true if upload can be reprocessed, false otherwise
*/
public boolean canReprocess(IGilesUpload upload, IUser user) {
if (upload.getProgressId() == null) {
return false;
}

String token = internalTokenManager.getAccessToken(user).getValue();
HttpHeaders headers = new HttpHeaders();
headers.setBearerAuth(token);
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(headers);

try {
ResponseEntity<String> response = restTemplate.exchange(
gilesBaseurl + gilesCheckEndpoint + upload.getProgressId(),
HttpMethod.GET, requestEntity, String.class);

return response.getStatusCode() == HttpStatus.OK;

} catch (HttpClientErrorException ex) {
return ex.getStatusCode() == HttpStatus.NOT_FOUND ||
ex.getStatusCode() == HttpStatus.INTERNAL_SERVER_ERROR;
}
}
}
Loading