argos/dmp-backend/web/src/main/java/eu/eudat/logic/services/ExternalValidationService.java

33 lines
1.1 KiB
Java

package eu.eudat.logic.services;
import eu.eudat.commons.scope.user.UserScope;
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
import eu.eudat.commons.exceptions.HugeResultSetException;
import eu.eudat.service.reference.external.RemoteFetcher;
import gr.cite.tools.exception.MyNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ExternalValidationService {
private RemoteFetcher remoteFetcher;
private final UserScope userScope;
@Autowired
public ExternalValidationService(RemoteFetcher remoteFetcher, UserScope userScope) {
super();
this.remoteFetcher = remoteFetcher;
this.userScope = userScope;
}
public Boolean validateIdentifier(String identifier, String type) throws MyNotFoundException, HugeResultSetException {
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(identifier);
Integer count = this.remoteFetcher.findEntries(externalReferenceCriteria, type);
return userScope.isSet() && count > 0;
}
}