protected BeanFactory beanFactory;
public String getClassKey(LayerRequest layer) throws Exception {
this.readConfigFile();
SolrRecord record = layer.getLayerInfo();
JsonNode institutions = this.configContents.path("institutions");
if (!institutions.isArray()){
try{
return this.getDefaultDownloadKey(institutions, layer);
} catch (Exception e){
e.printStackTrace();
logger.error("Class Key not defined for this layer.");
throw new Exception("Class Key not defined for this layer.");
}
}
ArrayNode jsonArray = (ArrayNode) institutions.path(record.getInstitution());
Iterator<JsonNode> institutionIterator = jsonArray.getElements();
String classKey = null;
while (institutionIterator.hasNext()){
JsonNode currentNode = institutionIterator.next();
logger.debug("trying matches...");
Boolean accessMatch = matchNode(currentNode, "accessLevel", record.getAccess().toLowerCase());
if (!accessMatch){
continue;
}
logger.debug("access match");
Boolean dataTypeMatch = matchNode(currentNode, "dataType", getGeneralizedDataType(record.getDataType().toLowerCase()));
if (!dataTypeMatch){
continue;
}
logger.debug("data type match");
Boolean outputFormatMatch = matchNode(currentNode, "outputFormats", layer.getRequestedFormat().toLowerCase());
if (!outputFormatMatch){
continue;
}
logger.debug("requested format match");
classKey = currentNode.path("classKey").getTextValue();
if (accessMatch && dataTypeMatch && outputFormatMatch){
break;
}
}
if (classKey == null){