changes in dmp deposit model
This commit is contained in:
parent
586f161b9a
commit
17817d7fb5
|
@ -36,18 +36,21 @@ public class ConfigLoaderImpl implements ConfigLoader{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] getLogo() {
|
public byte[] getLogo() {
|
||||||
String logo = environment.getProperty("configuration.logo");
|
String logo = environment.getProperty("configuration.dataverse.logo");
|
||||||
if(logo != null && !logo.isEmpty()){
|
InputStream logoStream;
|
||||||
InputStream logoStream = getStreamFromPath(logo);
|
if(logo != null && !logo.isEmpty()) {
|
||||||
try {
|
logoStream = getStreamFromPath(logo);
|
||||||
return logoStream.readAllBytes();
|
}
|
||||||
}
|
else{
|
||||||
catch (IOException e){
|
logoStream = getClass().getClassLoader().getResourceAsStream("dataverse.png");
|
||||||
logger.error(e.getMessage(), e);
|
}
|
||||||
return null;
|
try {
|
||||||
}
|
return (logoStream != null) ? logoStream.readAllBytes() : null;
|
||||||
|
}
|
||||||
|
catch (IOException e){
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private InputStream getStreamFromPath(String filePath) {
|
private InputStream getStreamFromPath(String filePath) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import com.researchspace.dataverse.entities.facade.DatasetFacade;
|
||||||
import com.researchspace.dataverse.http.DataverseAPIImpl;
|
import com.researchspace.dataverse.http.DataverseAPIImpl;
|
||||||
import eu.eudat.depositinterface.dataverserepository.config.ConfigLoader;
|
import eu.eudat.depositinterface.dataverserepository.config.ConfigLoader;
|
||||||
import eu.eudat.depositinterface.models.DMPDepositModel;
|
import eu.eudat.depositinterface.models.DMPDepositModel;
|
||||||
|
import eu.eudat.depositinterface.models.FileEnvelope;
|
||||||
import eu.eudat.depositinterface.repository.RepositoryDeposit;
|
import eu.eudat.depositinterface.repository.RepositoryDeposit;
|
||||||
import eu.eudat.depositinterface.repository.RepositoryDepositConfiguration;
|
import eu.eudat.depositinterface.repository.RepositoryDepositConfiguration;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -142,14 +143,26 @@ public class DataverseDeposit implements RepositoryDeposit {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void uploadFiles(DMPDepositModel dmpDepositModel, String doi) throws IOException {
|
private void uploadFiles(DMPDepositModel dmpDepositModel, String doi) throws IOException {
|
||||||
this.uploadFile(dmpDepositModel.getPdfFileName(), dmpDepositModel.getPdfFile(), doi);
|
this.uploadFile(dmpDepositModel.getPdfFile().getFilename(), dmpDepositModel.getPdfFile().getFile(), doi);
|
||||||
|
|
||||||
String contentDisposition = dmpDepositModel.getRdaJson().getHeaders().get("Content-Disposition").get(0);
|
FileEnvelope rdaJsonEnvelope = dmpDepositModel.getRdaJsonFile();
|
||||||
|
HttpHeaders responseHeaders = new HttpHeaders();
|
||||||
|
responseHeaders.setContentLength(rdaJsonEnvelope.getFile().length());
|
||||||
|
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||||
|
responseHeaders.set("Content-Disposition", "attachment;filename=" + rdaJsonEnvelope.getFilename());
|
||||||
|
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
|
||||||
|
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
|
||||||
|
|
||||||
|
byte[] content = Files.readAllBytes(rdaJsonEnvelope.getFile().toPath());
|
||||||
|
|
||||||
|
ResponseEntity<byte[]> jsonFile = new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
|
||||||
|
|
||||||
|
String contentDisposition = jsonFile.getHeaders().get("Content-Disposition").get(0);
|
||||||
String jsonFileName = contentDisposition.substring(contentDisposition.lastIndexOf('=') + 1);
|
String jsonFileName = contentDisposition.substring(contentDisposition.lastIndexOf('=') + 1);
|
||||||
File rdaJson = new File(this.environment.getProperty("storage.temp") + jsonFileName);
|
File rdaJson = new File(this.environment.getProperty("storage.temp") + jsonFileName);
|
||||||
OutputStream output = new FileOutputStream(rdaJson);
|
OutputStream output = new FileOutputStream(rdaJson);
|
||||||
try {
|
try {
|
||||||
output.write(Objects.requireNonNull(dmpDepositModel.getRdaJson().getBody()));
|
output.write(Objects.requireNonNull(jsonFile.getBody()));
|
||||||
output.flush();
|
output.flush();
|
||||||
output.close();
|
output.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
storage.temp=${STORAGE_TMP_DATAVERSE}
|
storage.temp=${STORAGE_TMP_DATAVERSE}
|
||||||
configuration.dataverse=${CONFIGURATION_DATAVERSE}
|
configuration.dataverse=${CONFIGURATION_DATAVERSE}
|
||||||
configuration.logo=
|
configuration.dataverse.logo=${CONFIGURATION_LOGO_DATAVERSE}
|
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
Loading…
Reference in New Issue