add repository logo
This commit is contained in:
parent
ea1992b895
commit
1e1889d671
|
@ -4,5 +4,6 @@ import java.util.List;
|
|||
|
||||
public interface ConfigLoader {
|
||||
List<DOIFunder> getDOIFunders();
|
||||
byte[] getLogo();
|
||||
ZenodoConfig getZenodoConfig();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 |
Loading…
Reference in New Issue