add repository logo
This commit is contained in:
parent
ea1992b895
commit
1e1889d671
|
@ -4,5 +4,6 @@ import java.util.List;
|
||||||
|
|
||||||
public interface ConfigLoader {
|
public interface ConfigLoader {
|
||||||
List<DOIFunder> getDOIFunders();
|
List<DOIFunder> getDOIFunders();
|
||||||
|
byte[] getLogo();
|
||||||
ZenodoConfig getZenodoConfig();
|
ZenodoConfig getZenodoConfig();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ public class ConfigLoaderImpl implements ConfigLoader{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ZenodoConfig getZenodoConfig() {
|
public ZenodoConfig getZenodoConfig() {
|
||||||
logger.debug("configuration.zenodo = " + environment.getProperty("configuration.zenodo"));
|
|
||||||
if (zenodoConfig == null) {
|
if (zenodoConfig == null) {
|
||||||
try {
|
try {
|
||||||
zenodoConfig = mapper.readValue(getStreamFromPath(environment.getProperty("configuration.zenodo")), ZenodoConfig.class);
|
zenodoConfig = mapper.readValue(getStreamFromPath(environment.getProperty("configuration.zenodo")), ZenodoConfig.class);
|
||||||
|
@ -51,6 +50,22 @@ public class ConfigLoaderImpl implements ConfigLoader{
|
||||||
return zenodoConfig;
|
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) {
|
private InputStream getStreamFromPath(String filePath) {
|
||||||
try {
|
try {
|
||||||
return new FileInputStream(filePath);
|
return new FileInputStream(filePath);
|
||||||
|
|
|
@ -52,6 +52,8 @@ public class ZenodoConfig {
|
||||||
private String repositoryClientSecret;
|
private String repositoryClientSecret;
|
||||||
@JsonProperty("redirectUri")
|
@JsonProperty("redirectUri")
|
||||||
private String redirectUri;
|
private String redirectUri;
|
||||||
|
@JsonProperty("hasLogo")
|
||||||
|
private boolean hasLogo;
|
||||||
|
|
||||||
public int getDepositType() {
|
public int getDepositType() {
|
||||||
return depositType;
|
return depositType;
|
||||||
|
@ -123,6 +125,13 @@ public class ZenodoConfig {
|
||||||
this.redirectUri = redirectUri;
|
this.redirectUri = redirectUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isHasLogo() {
|
||||||
|
return hasLogo;
|
||||||
|
}
|
||||||
|
public void setHasLogo(boolean hasLogo) {
|
||||||
|
this.hasLogo = hasLogo;
|
||||||
|
}
|
||||||
|
|
||||||
public RepositoryDepositConfiguration toRepoConfig() {
|
public RepositoryDepositConfiguration toRepoConfig() {
|
||||||
RepositoryDepositConfiguration config = new RepositoryDepositConfiguration();
|
RepositoryDepositConfiguration config = new RepositoryDepositConfiguration();
|
||||||
config.setDepositType(this.depositType);
|
config.setDepositType(this.depositType);
|
||||||
|
@ -135,6 +144,7 @@ public class ZenodoConfig {
|
||||||
config.setRepositoryClientId(this.repositoryClientId);
|
config.setRepositoryClientId(this.repositoryClientId);
|
||||||
config.setRepositoryClientSecret(this.repositoryClientSecret);
|
config.setRepositoryClientSecret(this.repositoryClientSecret);
|
||||||
config.setRedirectUri(this.redirectUri);
|
config.setRedirectUri(this.redirectUri);
|
||||||
|
config.setHasLogo(this.hasLogo);
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,6 +228,16 @@ public class ZenodoDeposit implements RepositoryDeposit {
|
||||||
return null;
|
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) {
|
private String getUnpublishedDOI(String zenodoUrl, String DOI, String token, Integer version) {
|
||||||
try {
|
try {
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
configuration.doi_funder=DOI_Funder.json
|
configuration.doi_funder=DOI_Funder.json
|
||||||
|
configuration.logo=zenodo.jpg
|
||||||
storage.temp=${STORAGE_TMP_ZENODO}
|
storage.temp=${STORAGE_TMP_ZENODO}
|
||||||
configuration.zenodo=${CONFIGURATION_ZENODO}
|
configuration.zenodo=${CONFIGURATION_ZENODO}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 9.1 KiB |
Loading…
Reference in New Issue