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.remotefetcher.criteria.ExternalReferenceCriteria;
import eu.eudat.commons.exceptions.HugeResultSetException;
import eu.eudat.service.remotefetcher.RemoteFetcherService;
@Component
public class ValidationManager {
private RemoteFetcherService remoteFetcherService;
private final UserScope userScope;
@Autowired
public ValidationManager(RemoteFetcherService remoteFetcherService, UserScope userScope) {
super();
this.remoteFetcherService = remoteFetcherService;
this.userScope = userScope;
}
public Boolean validateIdentifier(String identifier, String type) throws MyNotFoundException, HugeResultSetException {
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(identifier);
Integer count = this.remoteFetcherService.countEntries(externalReferenceCriteria, type);
return this.userScope.isSet() && count > 0;
}
}