33 lines
1.0 KiB
Java
33 lines
1.0 KiB
Java
package eu.eudat.logic.services;
|
|
|
|
import eu.eudat.commons.scope.user.UserScope;
|
|
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
|
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
|
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
|
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 NoURLFound, HugeResultSet {
|
|
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(identifier);
|
|
Integer count = this.remoteFetcher.findEntries(externalUrlCriteria, type);
|
|
return userScope.isSet() && count > 0;
|
|
}
|
|
|
|
|
|
|
|
}
|