-
Notifications
You must be signed in to change notification settings - Fork 0
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
Story/cite 163 - - We need a bulk upload for files. #23
Closed
Closed
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
7b2b4a9
[CITE-163] Add Giles Implementation
Charishma0249 ef6d573
[CITE-163] Giles Implementation
Charishma0249 afea37f
[CITE-163] Giles Implementation
Charishma0249 179f0b5
[CITE-163] Adding OAuth properties
Charishma0249 3a562d5
[CITE-163] Added collection import kafka topic
PradnyaC11 6a61a1f
[CITE-163] Added supporting methods to process the file
PradnyaC11 45f6008
[CITE-163] Added code to process the collection import
PradnyaC11 73f3db3
[CITE-163] Removed unwanted old code
PradnyaC11 d97177e
[CITE-163] Added BibFileHandler
PradnyaC11 6235fec
[CITE-163] Added Bib file iterator code
PradnyaC11 264a5ba
[CITE-163] Updated BibFile Iterator
PradnyaC11 c05de5c
[CITE-163] Parsed article Type of bib file
PradnyaC11 f3cee64
[CITE-163] Parsed data for Bib Iterator
PradnyaC11 46fc54a
[CITE-163] Added code to parse author list
PradnyaC11 318f193
[CITE-163] Parsed some more details of citation
PradnyaC11 d281d39
[CITE-163] Created item from bib file text
PradnyaC11 91925ec
[CITE-163] Parsed Citation to BibEntry in BibFileIterator
PradnyaC11 3d2802f
[CITE-163] Mapped references and authors from citation to bibentry
PradnyaC11 3717bf4
[CITE-163] Solved some errors that bib Iterator
PradnyaC11 2fb3a4f
[CITE-163] Changed the logic to parse extra/note
PradnyaC11 1477e37
[CITE-163] Cleaned code and resolved error related to parsing
PradnyaC11 86078c5
[CITE-163] Resolving parsing note issues
PradnyaC11 d6305ef
[CITE-163] Resolving error with JSON parser
PradnyaC11 304cb17
[CITE-163] Correctly parsed extra and note
PradnyaC11 74c0248
[CITE-163] Resolved authors & editors issue
PradnyaC11 3f2f3fc
[CITE-163] Resolved DOI & ISBN parsing issue
PradnyaC11 2b3a888
[CITE-163] Added collectionId to JobInfo, so as to import to it
PradnyaC11 fb3fb21
[CITE-163] Cleaned code for bibFileIterator
PradnyaC11 35075f9
[CITE-163] Resolving issue with CollectionIds
PradnyaC11 604a621
[CITE-163] Resolved importing to collection issue
PradnyaC11 e9cbdbe
[CITE-163] Added file path to Article Meta
PradnyaC11 bb79bdd
[CITE-163] Added method to CitesphereConnector to getItem
PradnyaC11 b51c18c
[CITE-163] Added uploadFile & makePostApiCall to CitesphereConnector
PradnyaC11 ab8fb23
[CITE-163] Added Giles connector & supporting classes
PradnyaC11 0b3af9b
[CITE-163] Updated GilesConnector with Giles token from job info
PradnyaC11 9081531
[CITE-163] Cleaned-up code & fixed some errors
PradnyaC11 98319b6
[CITE-163] Updated giles upload part to map files with items
PradnyaC11 26bc2b7
[CITE-163] Updated Citesphere cinnecter get Item mapping
PradnyaC11 91c1380
[CITE-163] Updated BibEntry and ExtraFieldHelper for giles upload
PradnyaC11 7d4c332
[CITE-163] Updated bibFileIterator & tested the giles upload
PradnyaC11 f732652
[CITE-163] Address the User class error
PradnyaC11 fd79011
[CITE-163] Fixed user issue in giles connector
PradnyaC11 b890552
[CITE-163] Resolved the null pointer exception related to GilesConnector
PradnyaC11 725c08b
[CITEE-163] Cleaned up code
PradnyaC11 7c5d730
[CITE-163] Removed unwanted changes
PradnyaC11 4aac546
[CITE-163] Resolving code factor issues
PradnyaC11 8d64005
[CITE-163] Resolving code factor issues
PradnyaC11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,9 @@ | |
<spring-data.version>Lovelace-RELEASE</spring-data.version> | ||
<thymeleaf.version>3.0.11.RELEASE</thymeleaf.version> | ||
<spring.kafka.version>2.2.6.RELEASE</spring.kafka.version> | ||
<citesphere.messages.version>0.2</citesphere.messages.version> | ||
<citesphere.messages.version>0.6</citesphere.messages.version> | ||
<citesphere.model.version>1.24</citesphere.model.version> | ||
<spring-security-oauth2-version>2.4.0.RELEASE</spring-security-oauth2-version> | ||
|
||
<admin.password>$2a$04$oQo44vqcDIFRoYKiAXoNheurzkwX9dcNmowvTX/hsWuBMwijqn44i</admin.password> | ||
|
||
|
@@ -69,7 +71,11 @@ | |
<artifactId>citesphere-messages</artifactId> | ||
<version>${citesphere.messages.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>edu.asu.diging</groupId> | ||
<artifactId>citesphere-model</artifactId> | ||
<version>${citesphere.model.version}</version> | ||
</dependency> | ||
<!-- Spring --> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
|
@@ -122,6 +128,12 @@ | |
<artifactId>spring-aop</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.security.oauth</groupId> | ||
<artifactId>spring-security-oauth2</artifactId> | ||
<version>${spring-security-oauth2-version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.aspectj</groupId> | ||
<artifactId>aspectjrt</artifactId> | ||
|
@@ -302,6 +314,12 @@ | |
<version>1.10.19</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where is that used? |
||
|
||
<dependency> | ||
<groupId>com.opencsv</groupId> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...porter/src/main/java/edu/asu/diging/citesphere/importer/core/service/IGilesConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package edu.asu.diging.citesphere.importer.core.service; | ||
|
||
import edu.asu.diging.citesphere.model.bib.IGilesUpload; | ||
|
||
public interface IGilesConnector { | ||
|
||
IGilesUpload uploadFile(String username, String token, String filename, byte[] fileBytes); | ||
} |
87 changes: 87 additions & 0 deletions
87
.../main/java/edu/asu/diging/citesphere/importer/core/service/giles/impl/GilesConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package edu.asu.diging.citesphere.importer.core.service.giles.impl; | ||
|
||
import javax.annotation.PostConstruct; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.PropertySource; | ||
import org.springframework.core.io.ByteArrayResource; | ||
import org.springframework.http.HttpEntity; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpMethod; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.util.LinkedMultiValueMap; | ||
import org.springframework.util.MultiValueMap; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
import edu.asu.diging.citesphere.importer.core.service.IGilesConnector; | ||
import edu.asu.diging.citesphere.model.bib.IGilesUpload; | ||
import edu.asu.diging.citesphere.model.bib.impl.GilesUpload; | ||
|
||
@Service | ||
@PropertySource("classpath:/config.properties") | ||
public class GilesConnector implements IGilesConnector { | ||
|
||
private final Logger logger = LoggerFactory.getLogger(getClass()); | ||
|
||
private RestTemplate restTemplate; | ||
|
||
@Value("${_giles_baseurl}") | ||
private String gilesBaseurl; | ||
|
||
@Value("${_giles_upload_endpoint}") | ||
private String uploadEndpoint; | ||
|
||
@PostConstruct | ||
public void init() { | ||
restTemplate = new RestTemplate(); | ||
} | ||
|
||
@Override | ||
public IGilesUpload uploadFile(String username, String token, String filename, byte[] fileBytes) { | ||
|
||
if (restTemplate == null) { | ||
restTemplate = new RestTemplate(); // Ensure restTemplate is initialized | ||
} | ||
|
||
HttpHeaders headers = new HttpHeaders(); | ||
headers.setContentType(MediaType.MULTIPART_FORM_DATA); | ||
headers.setBearerAuth(token); | ||
|
||
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>(); | ||
body.add("files", new MultipartFileResource(fileBytes, filename)); | ||
|
||
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers); | ||
|
||
ResponseEntity<UploadResponse> response = null; | ||
try { | ||
response = restTemplate.exchange(gilesBaseurl + uploadEndpoint, HttpMethod.POST, requestEntity, UploadResponse.class); | ||
} catch (Exception ex) { | ||
logger.error("Upload request failed", ex); | ||
return null; | ||
} | ||
IGilesUpload upload = new GilesUpload(); | ||
upload.setProgressId(response.getBody().getId()); | ||
upload.setUploadingUser(username); | ||
return upload; | ||
} | ||
|
||
public class MultipartFileResource extends ByteArrayResource { | ||
|
||
private String filename; | ||
|
||
public MultipartFileResource(byte[] bytearray, String filename) { | ||
super(bytearray); | ||
this.filename = filename; | ||
} | ||
|
||
@Override | ||
public String getFilename() { | ||
return this.filename; | ||
} | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
.../main/java/edu/asu/diging/citesphere/importer/core/service/giles/impl/UploadResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package edu.asu.diging.citesphere.importer.core.service.giles.impl; | ||
|
||
class UploadResponse { | ||
private String id; | ||
private String checkUrl; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getCheckUrl() { | ||
return checkUrl; | ||
} | ||
|
||
public void setCheckUrl(String checkUrl) { | ||
this.checkUrl = checkUrl; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is this needed?