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