X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.support.jcr%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fjcr%2Fdao%2FTreeTestResultCollectionDaoJcr.java;h=96b3fe8dc6ca097a38abc4508340a6c56bb6b04e;hb=b26f6f65dd1da46a675c618c39194ae534e040bb;hp=6daf16641600bc89618e707c7b0d18057f328e35;hpb=0ebe6753b6569ff52b4ba86cd61c6e08a19e0c5f;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/TreeTestResultCollectionDaoJcr.java b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/TreeTestResultCollectionDaoJcr.java index 6daf16641..96b3fe8dc 100644 --- a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/TreeTestResultCollectionDaoJcr.java +++ b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/TreeTestResultCollectionDaoJcr.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2010 Mathieu Baudier + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.argeo.slc.jcr.dao; import java.util.ArrayList; @@ -10,9 +26,7 @@ import java.util.TreeSet; import javax.jcr.Node; import javax.jcr.NodeIterator; import javax.jcr.RepositoryException; -import javax.jcr.query.InvalidQueryException; import javax.jcr.query.Query; -import javax.jcr.query.QueryManager; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -43,7 +57,7 @@ public class TreeTestResultCollectionDaoJcr extends AbstractSlcJcrDao implements curNode.setProperty(ttrColProp, colId); } getSession().save(); - } catch (Exception e) { + } catch (RepositoryException e) { throw new SlcException("Cannot create TreeTestResultCollection " + ttrCollection, e); } @@ -91,7 +105,7 @@ public class TreeTestResultCollectionDaoJcr extends AbstractSlcJcrDao implements } // We remove those who are not part of the collection anymore String queryString = "//*[@" + ttrColProp + "='" + colId + "']"; - Query query = queryManager.createQuery(queryString, Query.XPATH); + Query query = createQuery(queryString, Query.XPATH); log.debug("Query :" + queryString); NodeIterator ni = query.execute().getNodes(); int i = 0; @@ -113,7 +127,7 @@ public class TreeTestResultCollectionDaoJcr extends AbstractSlcJcrDao implements } } getSession().save(); - } catch (Exception e) { + } catch (RepositoryException e) { throw new SlcException("Cannot update TreeTestResultCollection " + ttrCollection, e); } @@ -180,7 +194,7 @@ public class TreeTestResultCollectionDaoJcr extends AbstractSlcJcrDao implements Node curNode; queryString = "//testresult[@uuid='" + resultUuid + "' and " + ttrColProp + "='" + ttrc.getId() + "']"; - Query query = queryManager.createQuery(queryString, Query.XPATH); + Query query = createQuery(queryString, Query.XPATH); curNode = JcrUtils.querySingleNode(query); if (curNode == null) { throw new SlcException("Cannot find test result #" + resultUuid); @@ -188,7 +202,7 @@ public class TreeTestResultCollectionDaoJcr extends AbstractSlcJcrDao implements curNode.getProperty(ttrColProp).remove(); } getSession().save(); - } catch (Exception e) { + } catch (RepositoryException e) { throw new SlcException("Cannot remove TreeTestResult of Id " + resultUuid + " from collection " + ttrc, e); } @@ -288,9 +302,9 @@ public class TreeTestResultCollectionDaoJcr extends AbstractSlcJcrDao implements try { if (log.isDebugEnabled()) log.debug("Retrieve nodes from query: " + query); - Query q = queryManager.createQuery(query, Query.XPATH); + Query q = createQuery(query, Query.XPATH); return q.execute().getNodes(); - } catch (Exception e) { + } catch (RepositoryException e) { throw new SlcException("Cannot load nodes from query: " + query); } } @@ -298,20 +312,15 @@ public class TreeTestResultCollectionDaoJcr extends AbstractSlcJcrDao implements private String property(Node node, String key) { try { return node.getProperty(key).getString(); - } catch (Exception e) { + } catch (RepositoryException e) { log.warn("Cannot retrieve property " + key + " of node " + node, e); return null; } } private Node singleNode(String query, String queryType) { - try { - Query q = queryManager.createQuery(query, queryType); + Query q = createQuery(query, queryType); return JcrUtils.querySingleNode(q); - } catch (RepositoryException e) { - throw new SlcException("Cannot retrieve single node with query " - + query, e); - } } }