changes in dmp deposit model
This commit is contained in:
parent
586f161b9a
commit
17817d7fb5
|
@ -36,18 +36,21 @@ public class ConfigLoaderImpl implements ConfigLoader{
|
|||
|
||||
@Override
|
||||
public byte[] getLogo() {
|
||||
String logo = environment.getProperty("configuration.logo");
|
||||
if(logo != null && !logo.isEmpty()){
|
||||
InputStream logoStream = getStreamFromPath(logo);
|
||||
try {
|
||||
return logoStream.readAllBytes();
|
||||
}
|
||||
catch (IOException e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
String logo = environment.getProperty("configuration.dataverse.logo");
|
||||
InputStream logoStream;
|
||||
if(logo != null && !logo.isEmpty()) {
|
||||
logoStream = getStreamFromPath(logo);
|
||||
}
|
||||
else{
|
||||
logoStream = getClass().getClassLoader().getResourceAsStream("dataverse.png");
|
||||
}
|
||||
try {
|
||||
return (logoStream != null) ? logoStream.readAllBytes() : null;
|
||||
}
|
||||
catch (IOException e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private InputStream getStreamFromPath(String filePath) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.researchspace.dataverse.entities.facade.DatasetFacade;
|
|||
import com.researchspace.dataverse.http.DataverseAPIImpl;
|
||||
import eu.eudat.depositinterface.dataverserepository.config.ConfigLoader;
|
||||
import eu.eudat.depositinterface.models.DMPDepositModel;
|
||||
import eu.eudat.depositinterface.models.FileEnvelope;
|
||||
import eu.eudat.depositinterface.repository.RepositoryDeposit;
|
||||
import eu.eudat.depositinterface.repository.RepositoryDepositConfiguration;
|
||||
import org.json.JSONObject;
|
||||
|
@ -142,14 +143,26 @@ public class DataverseDeposit implements RepositoryDeposit {
|
|||
}
|
||||
|
||||
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);
|
||||
File rdaJson = new File(this.environment.getProperty("storage.temp") + jsonFileName);
|
||||
OutputStream output = new FileOutputStream(rdaJson);
|
||||
try {
|
||||
output.write(Objects.requireNonNull(dmpDepositModel.getRdaJson().getBody()));
|
||||
output.write(Objects.requireNonNull(jsonFile.getBody()));
|
||||
output.flush();
|
||||
output.close();
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
storage.temp=${STORAGE_TMP_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