2023-12-13 10:42:59 +01:00
|
|
|
package eu.eudat.service.deposit;
|
|
|
|
|
|
|
|
import eu.eudat.authorization.AuthorizationFlags;
|
|
|
|
import eu.eudat.authorization.Permission;
|
2024-03-19 11:48:17 +01:00
|
|
|
import eu.eudat.authorization.authorizationcontentresolver.AuthorizationContentResolver;
|
2024-03-04 15:36:15 +01:00
|
|
|
import eu.eudat.commonmodels.models.FileEnvelopeModel;
|
2024-03-06 17:18:10 +01:00
|
|
|
import eu.eudat.commonmodels.models.dmp.DmpModel;
|
2024-04-15 14:11:35 +02:00
|
|
|
import eu.eudat.commons.JsonHandlingService;
|
|
|
|
import eu.eudat.commons.enums.ContactInfoType;
|
|
|
|
import eu.eudat.commons.enums.IsActive;
|
2024-03-11 14:01:56 +01:00
|
|
|
import eu.eudat.commons.enums.StorageType;
|
2024-04-15 14:11:35 +02:00
|
|
|
import eu.eudat.commons.notification.NotificationProperties;
|
2024-03-11 14:01:56 +01:00
|
|
|
import eu.eudat.commons.scope.user.UserScope;
|
2024-04-19 14:34:07 +02:00
|
|
|
import eu.eudat.commons.types.deposit.DepositSourceEntity;
|
2024-04-15 14:11:35 +02:00
|
|
|
import eu.eudat.commons.types.notification.*;
|
|
|
|
import eu.eudat.convention.ConventionService;
|
2023-12-13 10:42:59 +01:00
|
|
|
import eu.eudat.data.DmpEntity;
|
2024-04-15 14:11:35 +02:00
|
|
|
import eu.eudat.data.DmpUserEntity;
|
|
|
|
import eu.eudat.data.UserEntity;
|
2023-12-13 10:42:59 +01:00
|
|
|
import eu.eudat.depositinterface.repository.DepositClient;
|
|
|
|
import eu.eudat.depositinterface.repository.DepositConfiguration;
|
2024-04-15 14:11:35 +02:00
|
|
|
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEvent;
|
|
|
|
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEventHandler;
|
2023-12-13 10:42:59 +01:00
|
|
|
import eu.eudat.model.EntityDoi;
|
2024-03-11 14:01:56 +01:00
|
|
|
import eu.eudat.model.StorageFile;
|
2024-04-15 14:11:35 +02:00
|
|
|
import eu.eudat.model.UserContactInfo;
|
2024-03-04 15:36:15 +01:00
|
|
|
import eu.eudat.model.builder.commonmodels.DepositConfigurationBuilder;
|
2024-03-06 17:18:10 +01:00
|
|
|
import eu.eudat.model.builder.commonmodels.dmp.DmpCommonModelBuilder;
|
2024-03-11 14:01:56 +01:00
|
|
|
import eu.eudat.model.persist.StorageFilePersist;
|
2023-12-13 10:42:59 +01:00
|
|
|
import eu.eudat.model.persist.deposit.DepositAuthenticateRequest;
|
|
|
|
import eu.eudat.model.persist.deposit.DepositRequest;
|
|
|
|
import eu.eudat.model.persist.EntityDoiPersist;
|
|
|
|
import eu.eudat.query.DmpQuery;
|
2024-04-15 14:11:35 +02:00
|
|
|
import eu.eudat.query.DmpUserQuery;
|
|
|
|
import eu.eudat.query.UserContactInfoQuery;
|
|
|
|
import eu.eudat.query.UserQuery;
|
2023-12-13 10:42:59 +01:00
|
|
|
import eu.eudat.service.entitydoi.EntityDoiService;
|
2024-03-11 14:01:56 +01:00
|
|
|
import eu.eudat.service.storage.StorageFileProperties;
|
|
|
|
import eu.eudat.service.storage.StorageFileService;
|
2024-04-19 14:34:07 +02:00
|
|
|
import eu.eudat.service.filetransformer.FileTransformerService;
|
2023-12-13 10:42:59 +01:00
|
|
|
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeCacheService;
|
2024-03-04 15:36:15 +01:00
|
|
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
2023-12-13 10:42:59 +01:00
|
|
|
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeFilterFunction;
|
|
|
|
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeModel;
|
|
|
|
import gr.cite.tools.data.builder.BuilderFactory;
|
2024-04-15 14:11:35 +02:00
|
|
|
import gr.cite.tools.data.query.Ordering;
|
2023-12-13 10:42:59 +01:00
|
|
|
import gr.cite.tools.data.query.QueryFactory;
|
|
|
|
import gr.cite.tools.exception.MyNotFoundException;
|
2024-03-11 14:01:56 +01:00
|
|
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
2023-12-13 10:42:59 +01:00
|
|
|
import gr.cite.tools.fieldset.FieldSet;
|
2024-03-11 14:01:56 +01:00
|
|
|
import gr.cite.tools.validation.ValidatorFactory;
|
|
|
|
import org.apache.commons.io.FilenameUtils;
|
2023-12-13 10:42:59 +01:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.context.MessageSource;
|
|
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.web.reactive.function.client.WebClient;
|
|
|
|
|
2024-04-15 14:11:35 +02:00
|
|
|
import javax.management.InvalidApplicationException;
|
2024-03-11 14:01:56 +01:00
|
|
|
import java.io.IOException;
|
2023-12-13 10:42:59 +01:00
|
|
|
import java.net.URI;
|
2024-03-11 14:01:56 +01:00
|
|
|
import java.net.URLConnection;
|
|
|
|
import java.time.Duration;
|
|
|
|
import java.util.*;
|
2024-04-15 14:11:35 +02:00
|
|
|
import java.util.stream.Collectors;
|
2023-12-13 10:42:59 +01:00
|
|
|
|
|
|
|
@Service
|
|
|
|
public class DepositServiceImpl implements DepositService {
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(DepositServiceImpl.class);
|
|
|
|
|
|
|
|
private final DepositProperties depositProperties;
|
|
|
|
private final Map<String, DepositClient> clients;
|
|
|
|
private final TokenExchangeCacheService tokenExchangeCacheService;
|
|
|
|
private final AuthorizationService authorizationService;
|
|
|
|
private final EntityDoiService doiService;
|
|
|
|
private final QueryFactory queryFactory;
|
|
|
|
private final MessageSource messageSource;
|
|
|
|
private final BuilderFactory builderFactory;
|
|
|
|
private final DepositConfigurationCacheService depositConfigurationCacheService;
|
2024-03-11 14:01:56 +01:00
|
|
|
private final FileTransformerService fileTransformerService;
|
|
|
|
private final StorageFileService storageFileService;
|
|
|
|
private final UserScope userScope;
|
|
|
|
private final ValidatorFactory validatorFactory;
|
|
|
|
private final StorageFileProperties storageFileProperties;
|
2024-03-19 11:48:17 +01:00
|
|
|
private final AuthorizationContentResolver authorizationContentResolver;
|
2024-04-15 14:11:35 +02:00
|
|
|
private final ConventionService conventionService;
|
|
|
|
private final JsonHandlingService jsonHandlingService;
|
|
|
|
private final NotificationProperties notificationProperties;
|
|
|
|
private final NotifyIntegrationEventHandler eventHandler;
|
2023-12-13 10:42:59 +01:00
|
|
|
@Autowired
|
|
|
|
public DepositServiceImpl(DepositProperties depositProperties,
|
|
|
|
TokenExchangeCacheService tokenExchangeCacheService,
|
|
|
|
AuthorizationService authorizationService,
|
|
|
|
EntityDoiService doiService,
|
|
|
|
QueryFactory queryFactory,
|
|
|
|
MessageSource messageSource,
|
2024-04-15 14:11:35 +02:00
|
|
|
BuilderFactory builderFactory, DepositConfigurationCacheService depositConfigurationCacheService, FileTransformerService fileTransformerService, StorageFileService storageFileService, UserScope userScope, ValidatorFactory validatorFactory, StorageFileProperties storageFileProperties, AuthorizationContentResolver authorizationContentResolver, ConventionService conventionService, JsonHandlingService jsonHandlingService, NotificationProperties notificationProperties, NotifyIntegrationEventHandler eventHandler) {
|
2023-12-13 10:42:59 +01:00
|
|
|
this.depositProperties = depositProperties;
|
|
|
|
this.tokenExchangeCacheService = tokenExchangeCacheService;
|
|
|
|
this.authorizationService = authorizationService;
|
|
|
|
this.doiService = doiService;
|
|
|
|
this.queryFactory = queryFactory;
|
|
|
|
this.messageSource = messageSource;
|
|
|
|
this.builderFactory = builderFactory;
|
|
|
|
this.depositConfigurationCacheService = depositConfigurationCacheService;
|
2024-03-11 14:01:56 +01:00
|
|
|
this.fileTransformerService = fileTransformerService;
|
|
|
|
this.storageFileService = storageFileService;
|
|
|
|
this.userScope = userScope;
|
|
|
|
this.validatorFactory = validatorFactory;
|
|
|
|
this.storageFileProperties = storageFileProperties;
|
2024-03-19 11:48:17 +01:00
|
|
|
this.authorizationContentResolver = authorizationContentResolver;
|
2024-04-15 14:11:35 +02:00
|
|
|
this.conventionService = conventionService;
|
|
|
|
this.jsonHandlingService = jsonHandlingService;
|
|
|
|
this.notificationProperties = notificationProperties;
|
|
|
|
this.eventHandler = eventHandler;
|
|
|
|
this.clients = new HashMap<>();
|
2023-12-13 10:42:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private DepositClient getDepositClient(String repositoryId) {
|
|
|
|
if (this.clients.containsKey(repositoryId)) return this.clients.get(repositoryId);
|
|
|
|
|
|
|
|
//GK: It's register time
|
2024-04-19 14:34:07 +02:00
|
|
|
DepositSourceEntity source = depositProperties.getSources().stream().filter(depositSource -> depositSource.getRepositoryId().equals(repositoryId)).findFirst().orElse(null);
|
2023-12-13 10:42:59 +01:00
|
|
|
if (source != null) {
|
|
|
|
String host = URI.create(source.getUrl()).getHost();
|
|
|
|
TokenExchangeModel tokenExchangeModel = new TokenExchangeModel("deposit:" + source.getRepositoryId(), source.getIssuerUrl(), source.getClientId(), source.getClientSecret(), source.getScope());
|
|
|
|
TokenExchangeFilterFunction apiKeyExchangeFilterFunction = new TokenExchangeFilterFunction(this.tokenExchangeCacheService, tokenExchangeModel);
|
2024-03-22 12:49:26 +01:00
|
|
|
WebClient webClient = WebClient.builder().baseUrl(source.getUrl() + "/api/deposit").filters(exchangeFilterFunctions -> exchangeFilterFunctions.add(apiKeyExchangeFilterFunction)).build();
|
2023-12-13 10:42:59 +01:00
|
|
|
DepositClientImpl repository = new DepositClientImpl(webClient);
|
|
|
|
this.clients.put(source.getRepositoryId(), repository);
|
|
|
|
return repository;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<eu.eudat.model.deposit.DepositConfiguration> getAvailableConfigurations(FieldSet fieldSet) {
|
2024-03-27 13:57:02 +01:00
|
|
|
this.authorizationService.authorizeForce(Permission.BrowseDeposit, Permission.DeferredAffiliation);
|
2023-12-13 10:42:59 +01:00
|
|
|
|
|
|
|
List<eu.eudat.model.deposit.DepositConfiguration> configurations = new ArrayList<>();
|
|
|
|
|
2024-04-19 14:34:07 +02:00
|
|
|
for (DepositSourceEntity depositSource : depositProperties.getSources()) {
|
2023-12-13 10:42:59 +01:00
|
|
|
DepositConfigurationCacheService.DepositConfigurationCacheValue cacheValue = this.depositConfigurationCacheService.lookup(this.depositConfigurationCacheService.buildKey(depositSource.getRepositoryId()));
|
|
|
|
if (cacheValue == null){
|
|
|
|
DepositClient depositClient = getDepositClient(depositSource.getRepositoryId());
|
|
|
|
if (depositClient == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{depositSource.getRepositoryId(), DepositClient.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
|
|
|
|
|
|
DepositConfiguration configuration = depositClient.getConfiguration();
|
|
|
|
cacheValue = new DepositConfigurationCacheService.DepositConfigurationCacheValue(depositSource.getRepositoryId(), configuration);
|
|
|
|
this.depositConfigurationCacheService.put(cacheValue);
|
|
|
|
}
|
|
|
|
eu.eudat.model.deposit.DepositConfiguration depositConfiguration = this.builderFactory.builder(DepositConfigurationBuilder.class).build(fieldSet, cacheValue.getConfiguration());
|
|
|
|
configurations.add(depositConfiguration);
|
|
|
|
}
|
|
|
|
|
|
|
|
return configurations;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public EntityDoi deposit(DepositRequest dmpDepositModel) throws Exception {
|
2024-03-19 11:48:17 +01:00
|
|
|
this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.dmpAffiliation(dmpDepositModel.getDmpId())), Permission.DepositDmp);
|
2023-12-13 10:42:59 +01:00
|
|
|
//GK: First get the right client
|
|
|
|
DepositClient depositClient = getDepositClient(dmpDepositModel.getRepositoryId());
|
|
|
|
if (depositClient == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDepositModel.getRepositoryId(), DepositClient.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
|
|
|
|
|
|
//GK: Second get the Target Data Management Plan
|
|
|
|
DmpEntity dmpEntity = this.queryFactory.query(DmpQuery.class).ids(dmpDepositModel.getDmpId()).first();
|
|
|
|
if (dmpEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDepositModel.getDmpId(), DmpEntity.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
|
|
|
|
|
|
//GK: Forth make the required files to be uploaded with the deposit
|
|
|
|
//TODO: Properly create required files
|
2024-04-19 14:34:07 +02:00
|
|
|
DepositSourceEntity source = depositProperties.getSources().stream().filter(depositSource -> depositSource.getRepositoryId().equals(dmpDepositModel.getRepositoryId())).findFirst().orElse(null);
|
|
|
|
if (source == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDepositModel.getRepositoryId(), DepositSourceEntity.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
2024-03-11 14:01:56 +01:00
|
|
|
|
|
|
|
eu.eudat.model.file.FileEnvelope pdfFile = this.fileTransformerService.exportDmp(dmpEntity.getId(), source.getPdfTransformerId(),"pdf");
|
|
|
|
eu.eudat.model.file.FileEnvelope rda = this.fileTransformerService.exportDmp(dmpEntity.getId(), source.getRdaTransformerId(),"json");
|
|
|
|
|
2024-03-04 15:36:15 +01:00
|
|
|
FileEnvelopeModel pdfEnvelope = new FileEnvelopeModel();
|
|
|
|
FileEnvelopeModel jsonEnvelope = new FileEnvelopeModel();
|
2024-03-11 14:01:56 +01:00
|
|
|
|
|
|
|
pdfEnvelope.setFilename(pdfFile.getFilename());
|
2024-03-12 10:07:47 +01:00
|
|
|
jsonEnvelope.setMimeType("application/pdf");
|
2024-03-11 14:01:56 +01:00
|
|
|
jsonEnvelope.setFilename(rda.getFilename());
|
2024-03-12 10:07:47 +01:00
|
|
|
jsonEnvelope.setMimeType("application/json");
|
2024-03-11 14:01:56 +01:00
|
|
|
if (!depositClient.getConfiguration().isUseSharedStorage()){
|
|
|
|
pdfEnvelope.setFile(pdfFile.getFile());
|
|
|
|
jsonEnvelope.setFile(rda.getFile());
|
|
|
|
} else {
|
|
|
|
pdfEnvelope.setFileRef(this.addFileToSharedStorage(pdfFile));
|
|
|
|
jsonEnvelope.setFileRef(this.addFileToSharedStorage(rda));
|
|
|
|
}
|
|
|
|
|
2023-12-13 10:42:59 +01:00
|
|
|
//GK: Fifth Transform them to the DepositModel
|
2024-03-12 17:27:16 +01:00
|
|
|
DmpModel depositModel = this.builderFactory.builder(DmpCommonModelBuilder.class).useSharedStorage(depositClient.getConfiguration().isUseSharedStorage()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission)
|
2024-03-11 14:01:56 +01:00
|
|
|
.setRepositoryId(dmpDepositModel.getRepositoryId()).setPdfFile(pdfEnvelope).setRdaJsonFile(jsonEnvelope).build(dmpEntity);
|
|
|
|
|
2023-12-13 10:42:59 +01:00
|
|
|
|
|
|
|
//GK: Sixth Perform the deposit
|
|
|
|
String doi = depositClient.deposit(depositModel, dmpDepositModel.getAccessToken());
|
|
|
|
//GK: Something has gone wrong return null
|
|
|
|
if (doi.isEmpty()) return null;
|
|
|
|
//GK: doi is fine store it in database
|
|
|
|
EntityDoiPersist doiPersist = new EntityDoiPersist();
|
|
|
|
doiPersist.setRepositoryId(dmpDepositModel.getRepositoryId());
|
|
|
|
doiPersist.setDoi(doi);
|
|
|
|
doiPersist.setEntityId(dmpEntity.getId());
|
2024-04-15 14:11:35 +02:00
|
|
|
this.sendNotification(dmpEntity);
|
2023-12-13 10:42:59 +01:00
|
|
|
return doiService.persist(doiPersist, dmpDepositModel.getProject());
|
|
|
|
}
|
2024-04-15 14:11:35 +02:00
|
|
|
|
|
|
|
private void sendNotification(DmpEntity dmpEntity) throws InvalidApplicationException {
|
2024-04-19 12:50:11 +02:00
|
|
|
List<DmpUserEntity> dmpUsers = this.queryFactory.query(DmpUserQuery.class).dmpIds(dmpEntity.getId()).isActives(IsActive.Active).collect();
|
2024-04-15 14:11:35 +02:00
|
|
|
if (this.conventionService.isListNullOrEmpty(dmpUsers)){
|
|
|
|
throw new MyNotFoundException("Dmp does not have Users");
|
|
|
|
}
|
|
|
|
|
|
|
|
List<UserEntity> users = this.queryFactory.query(UserQuery.class).ids(dmpUsers.stream().map(x -> x.getUserId()).collect(Collectors.toList())).isActive(IsActive.Active).collect();
|
|
|
|
|
|
|
|
for (UserEntity user: users) {
|
|
|
|
if (!user.getId().equals(this.userScope.getUserIdSafe()) && !this.conventionService.isListNullOrEmpty(dmpUsers.stream().filter(x -> x.getUserId().equals(user.getId())).collect(Collectors.toList()))){
|
|
|
|
this.createDmpDepositNotificationEvent(dmpEntity, user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void createDmpDepositNotificationEvent(DmpEntity dmp, UserEntity user) throws InvalidApplicationException {
|
|
|
|
NotifyIntegrationEvent event = new NotifyIntegrationEvent();
|
|
|
|
event.setUserId(user.getId());
|
|
|
|
UserContactInfoQuery query = this.queryFactory.query(UserContactInfoQuery.class).userIds(user.getId());
|
|
|
|
query.setOrder(new Ordering().addAscending(UserContactInfo._ordinal));
|
|
|
|
|
|
|
|
List<ContactPair> contactPairs = new ArrayList<>();
|
|
|
|
contactPairs.add(new ContactPair(ContactInfoType.Email, query.first().getValue()));
|
|
|
|
NotificationContactData contactData = new NotificationContactData(contactPairs, null, null);
|
|
|
|
event.setContactHint(jsonHandlingService.toJsonSafe(contactData));
|
|
|
|
event.setNotificationType(notificationProperties.getDmpDepositType());
|
|
|
|
NotificationFieldData data = new NotificationFieldData();
|
|
|
|
List<FieldInfo> fieldInfoList = new ArrayList<>();
|
|
|
|
fieldInfoList.add(new FieldInfo("{recipient}", DataType.String, user.getName()));
|
|
|
|
fieldInfoList.add(new FieldInfo("{reasonName}", DataType.String, this.queryFactory.query(UserQuery.class).ids(this.userScope.getUserId()).first().getName()));
|
|
|
|
fieldInfoList.add(new FieldInfo("{name}", DataType.String, dmp.getLabel()));
|
|
|
|
fieldInfoList.add(new FieldInfo("{id}", DataType.String, dmp.getId().toString()));
|
|
|
|
data.setFields(fieldInfoList);
|
|
|
|
event.setData(jsonHandlingService.toJsonSafe(data));
|
|
|
|
|
|
|
|
eventHandler.handle(event);
|
|
|
|
}
|
2024-03-11 14:01:56 +01:00
|
|
|
|
|
|
|
private String addFileToSharedStorage(eu.eudat.model.file.FileEnvelope file) throws IOException {
|
|
|
|
StorageFilePersist storageFilePersist = new StorageFilePersist();
|
|
|
|
storageFilePersist.setName(FilenameUtils.removeExtension(file.getFilename()));
|
|
|
|
storageFilePersist.setExtension(FilenameUtils.getExtension(file.getFilename()));
|
|
|
|
storageFilePersist.setMimeType(URLConnection.guessContentTypeFromName(file.getFilename()));
|
|
|
|
storageFilePersist.setOwnerId(this.userScope.getUserIdSafe());
|
|
|
|
storageFilePersist.setStorageType(StorageType.Temp);
|
|
|
|
storageFilePersist.setLifetime(Duration.ofSeconds(this.storageFileProperties.getTempStoreLifetimeSeconds())); //TODO
|
|
|
|
this.validatorFactory.validator(StorageFilePersist.StorageFilePersistValidator.class).validateForce(storageFilePersist);
|
|
|
|
StorageFile persisted = this.storageFileService.persistBytes(storageFilePersist, file.getFile(), new BaseFieldSet(StorageFile._id, StorageFile._fileRef));
|
|
|
|
return persisted.getFileRef();
|
|
|
|
}
|
2023-12-13 10:42:59 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getLogo(String repositoryId) {
|
2024-03-27 13:57:02 +01:00
|
|
|
this.authorizationService.authorizeForce(Permission.BrowseDeposit, Permission.DeferredAffiliation);
|
2023-12-13 10:42:59 +01:00
|
|
|
|
|
|
|
DepositClient depositClient = getDepositClient(repositoryId);
|
|
|
|
if (depositClient == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{repositoryId, DepositClient.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
|
|
return depositClient.getLogo();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String authenticate(DepositAuthenticateRequest model) {
|
2024-03-27 13:57:02 +01:00
|
|
|
this.authorizationService.authorizeForce(Permission.BrowseDeposit, Permission.DeferredAffiliation);
|
2023-12-13 10:42:59 +01:00
|
|
|
|
|
|
|
DepositClient depositClient = getDepositClient(model.getRepositoryId());
|
|
|
|
if (depositClient == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getRepositoryId(), DepositClient.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
|
|
return depositClient.authenticate(model.getCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|