class KewTypeBoServiceImpl implements KewTypeRepositoryService {

    @Override
    public KewTypeDefinition getTypeByNameAndNamespace(final String name, final String namespace) {
        if (StringUtils.isBlank(name)) {
            throw new RiceIllegalArgumentException("name is blank");
        }
        if (StringUtils.isBlank(namespace)) {
            throw new RiceIllegalArgumentException("namespace is blank");
        }

        QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
        criteria.setPredicates(equal("name", name), equal("namespace", namespace));
        List<KewTypeBo> myTypes = dataObjectService.findMatching(KewTypeBo.class, criteria.build()).getResults();
        if (myTypes.isEmpty()) {
            return null;
        } else if (myTypes.size() == 1) {
            return KewTypeBo.to(myTypes.get(0));
        } else {
            throw new RiceIllegalStateException("More than one type found for the given name and namespace - (name=" +
                    name + ", namespace=" + namespace + ").");
        }

    }

}