argos/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ValidationManager.java

34 lines
1.1 KiB
Java

package eu.eudat.logic.managers;
import eu.eudat.commons.scope.user.UserScope;
import gr.cite.tools.exception.MyNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import eu.eudat.service.reference.external.criteria.ExternalReferenceCriteria;
import eu.eudat.commons.exceptions.HugeResultSetException;
import eu.eudat.service.reference.external.RemoteFetcher;
@Component
public class ValidationManager {
private RemoteFetcher remoteFetcher;
private final UserScope userScope;
@Autowired
public ValidationManager(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 this.userScope.isSet() && count > 0;
}
}