add repository logo

This commit is contained in:
Aldo Mihasi 2023-01-17 14:43:10 +02:00
parent ea1992b895
commit 1e1889d671
6 changed files with 38 additions and 1 deletions

View File

@ -4,5 +4,6 @@ import java.util.List;
public interface ConfigLoader {
List<DOIFunder> getDOIFunders();
byte[] getLogo();
ZenodoConfig getZenodoConfig();
}

View File

@ -39,7 +39,6 @@ public class ConfigLoaderImpl implements ConfigLoader{
@Override
public ZenodoConfig getZenodoConfig() {
logger.debug("configuration.zenodo = " + environment.getProperty("configuration.zenodo"));
if (zenodoConfig == null) {
try {
zenodoConfig = mapper.readValue(getStreamFromPath(environment.getProperty("configuration.zenodo")), ZenodoConfig.class);
@ -51,6 +50,22 @@ public class ConfigLoaderImpl implements ConfigLoader{
return zenodoConfig;
}
@Override
public byte[] getLogo() {
String logo = "zenodo.jpg";
if(logo != null && !logo.isEmpty()){
InputStream logoStream = getStreamFromPath(logo);
try {
return logoStream.readAllBytes();
}
catch (IOException e){
logger.error(e.getMessage(), e);
return null;
}
}
return null;
}
private InputStream getStreamFromPath(String filePath) {
try {
return new FileInputStream(filePath);

View File

@ -52,6 +52,8 @@ public class ZenodoConfig {
private String repositoryClientSecret;
@JsonProperty("redirectUri")
private String redirectUri;
@JsonProperty("hasLogo")
private boolean hasLogo;
public int getDepositType() {
return depositType;
@ -123,6 +125,13 @@ public class ZenodoConfig {
this.redirectUri = redirectUri;
}
public boolean isHasLogo() {
return hasLogo;
}
public void setHasLogo(boolean hasLogo) {
this.hasLogo = hasLogo;
}
public RepositoryDepositConfiguration toRepoConfig() {
RepositoryDepositConfiguration config = new RepositoryDepositConfiguration();
config.setDepositType(this.depositType);
@ -135,6 +144,7 @@ public class ZenodoConfig {
config.setRepositoryClientId(this.repositoryClientId);
config.setRepositoryClientSecret(this.repositoryClientSecret);
config.setRedirectUri(this.redirectUri);
config.setHasLogo(this.hasLogo);
return config;
}
}

View File

@ -228,6 +228,16 @@ public class ZenodoDeposit implements RepositoryDeposit {
return null;
}
@Override
public String getLogo() {
RepositoryDepositConfiguration conf = this.getConfiguration();
if(conf.isHasLogo()){
byte[] logo = this.configLoader.getLogo();
return (logo != null && logo.length != 0) ? Base64.getEncoder().encodeToString(logo) : null;
}
return null;
}
private String getUnpublishedDOI(String zenodoUrl, String DOI, String token, Integer version) {
try {
RestTemplate restTemplate = new RestTemplate();

View File

@ -1,3 +1,4 @@
configuration.doi_funder=DOI_Funder.json
configuration.logo=zenodo.jpg
storage.temp=${STORAGE_TMP_ZENODO}
configuration.zenodo=${CONFIGURATION_ZENODO}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB