add repository logo
This commit is contained in:
parent
2f419767eb
commit
153e44986d
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.depositinterface.dataverserepository.config;
|
||||
|
||||
public interface ConfigLoader {
|
||||
byte[] getLogo();
|
||||
DataverseConfig getDataverseConfig();
|
||||
}
|
||||
|
|
|
@ -34,6 +34,22 @@ public class ConfigLoaderImpl implements ConfigLoader{
|
|||
return dataverseConfig;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private InputStream getStreamFromPath(String filePath) {
|
||||
try {
|
||||
return new FileInputStream(filePath);
|
||||
|
|
|
@ -45,6 +45,8 @@ public class DataverseConfig {
|
|||
private String server;
|
||||
@JsonProperty("parentDataverseAlias")
|
||||
private String parentDataverseAlias;
|
||||
@JsonProperty("hasLogo")
|
||||
private boolean hasLogo;
|
||||
|
||||
public int getDepositType() {
|
||||
return depositType;
|
||||
|
@ -95,12 +97,20 @@ public class DataverseConfig {
|
|||
this.parentDataverseAlias = parentDataverseAlias;
|
||||
}
|
||||
|
||||
public boolean isHasLogo() {
|
||||
return hasLogo;
|
||||
}
|
||||
public void setHasLogo(boolean hasLogo) {
|
||||
this.hasLogo = hasLogo;
|
||||
}
|
||||
|
||||
public RepositoryDepositConfiguration toRepoConfig() {
|
||||
RepositoryDepositConfiguration config = new RepositoryDepositConfiguration();
|
||||
config.setDepositType(this.depositType);
|
||||
config.setRepositoryId(this.repositoryId);
|
||||
config.setRepositoryUrl(this.repositoryUrl);
|
||||
config.setRepositoryRecordUrl(this.repositoryRecordUrl);
|
||||
config.setHasLogo(this.hasLogo);
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -197,4 +197,14 @@ public class DataverseDeposit implements RepositoryDeposit {
|
|||
public String authenticate(String code) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
storage.temp=${STORAGE_TMP_DATAVERSE}
|
||||
configuration.dataverse=${CONFIGURATION_DATAVERSE}
|
||||
configuration.dataverse=${CONFIGURATION_DATAVERSE}
|
||||
configuration.logo=
|
Loading…
Reference in New Issue