Add missing catch blocks. Add warning in getCustomListViewConfigFileName() if property can't be found.

This commit is contained in:
ryounes 2011-08-04 19:00:37 +00:00
parent f49460245b
commit 74c0edabda
3 changed files with 35 additions and 15 deletions

View file

@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.dao.jena;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -362,6 +363,12 @@ public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPro
Literal value = sol.getLiteral("value");
values.add(value);
}
return values;
} catch (Exception e) {
log.error("Error getting data property values for individual " + subjectUri + " and property " + propertyUri);
return Collections.emptyList();
} finally {
dataset.getLock().leaveCriticalSection();
w.close();
@ -369,6 +376,6 @@ public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPro
qexec.close();
}
}
return values;
}
}

View file

@ -913,9 +913,14 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
ResultSet results = qexec.execSelect();
while (results.hasNext()) {
QuerySolution soln = results.next();
ObjectProperty prop = getObjectPropertyByURI(soln.getResource("property").getURI());
String filename = soln.getLiteral("filename").getLexicalForm();
customListViewConfigFileMap.put(prop, filename);
String propertyUri = soln.getResource("property").getURI();
ObjectProperty prop = getObjectPropertyByURI(propertyUri);
if (prop == null) {
log.warn("Can't find property for uri " + propertyUri);
} else {
String filename = soln.getLiteral("filename").getLexicalForm();
customListViewConfigFileMap.put(prop, filename);
}
}
qexec.close();
}

View file

@ -321,7 +321,11 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
list.add(QueryUtils.querySolutionToStringValueMap(soln));
}
}
return list;
} catch (Exception e) {
log.error("Error getting object property values for subject " + subjectUri + " and property " + propertyUri);
return Collections.emptyList();
} finally {
dataset.getLock().leaveCriticalSection();
w.close();
@ -329,7 +333,7 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
qexec.close();
}
}
return list;
}
private Model constructModelForSelectQueries(String subjectUri,
@ -366,17 +370,17 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
DatasetWrapper w = dwf.getDatasetWrapper();
Dataset dataset = w.getDataset();
dataset.getLock().enterCriticalSection(Lock.READ);
QueryExecution qe = null;
try {
QueryExecution qe = QueryExecutionFactory.create(
qe = QueryExecutionFactory.create(
query, dataset, initialBindings);
try {
qe.execConstruct(constructedModel);
} finally {
qe.execConstruct(constructedModel);
} catch (Exception e) {
log.error("Error getting constructed model for subject " + subjectUri + " and property " + propertyUri);
} finally {
if (qe != null) {
qe.close();
}
} finally {
dataset.getLock().leaveCriticalSection();
w.close();
}
@ -444,6 +448,11 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
types.put(type, label);
}
}
return types;
} catch (Exception e) {
log.error("Error getting most specific types for subject " + subjectUri);
return Collections.emptyMap();
} finally {
dataset.getLock().leaveCriticalSection();
@ -453,6 +462,5 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
w.close();
}
return types;
}
}