67 lines
1.9 KiB
Java
67 lines
1.9 KiB
Java
|
package eu.eudat.service.deposit;
|
||
|
|
||
|
import eu.eudat.depositinterface.repository.DepositConfiguration;
|
||
|
import gr.cite.tools.cache.CacheService;
|
||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
import org.springframework.stereotype.Service;
|
||
|
|
||
|
import java.util.HashMap;
|
||
|
|
||
|
@Service
|
||
|
public class DepositConfigurationCacheService extends CacheService<DepositConfigurationCacheService.DepositConfigurationCacheValue> {
|
||
|
|
||
|
public static class DepositConfigurationCacheValue {
|
||
|
|
||
|
public DepositConfigurationCacheValue() {
|
||
|
}
|
||
|
|
||
|
public DepositConfigurationCacheValue(String repositoryId, DepositConfiguration configuration) {
|
||
|
this.repositoryId = repositoryId;
|
||
|
this.configuration = configuration;
|
||
|
}
|
||
|
|
||
|
private String repositoryId;
|
||
|
|
||
|
public String getRepositoryId() {
|
||
|
return repositoryId;
|
||
|
}
|
||
|
|
||
|
public void setRepositoryId(String repositoryId) {
|
||
|
this.repositoryId = repositoryId;
|
||
|
}
|
||
|
|
||
|
private DepositConfiguration configuration;
|
||
|
|
||
|
public DepositConfiguration getConfiguration() {
|
||
|
return configuration;
|
||
|
}
|
||
|
|
||
|
public void setConfiguration(DepositConfiguration configuration) {
|
||
|
this.configuration = configuration;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
@Autowired
|
||
|
public DepositConfigurationCacheService(DepositConfigurationCacheOptions options) {
|
||
|
super(options);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected Class<DepositConfigurationCacheValue> valueClass() {
|
||
|
return DepositConfigurationCacheValue.class;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public String keyOf(DepositConfigurationCacheValue value) {
|
||
|
return this.buildKey(value.getRepositoryId());
|
||
|
}
|
||
|
|
||
|
|
||
|
public String buildKey(String subject) {
|
||
|
HashMap<String, String> keyParts = new HashMap<>();
|
||
|
keyParts.put("$repositoryId$", subject);
|
||
|
return this.generateKey(keyParts);
|
||
|
}
|
||
|
}
|