001/* 002 * (C) Copyright 2006-2008 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * mcedica 016 */ 017package org.nuxeo.ecm.platform.management.statuses; 018 019import org.nuxeo.ecm.core.api.DocumentModelList; 020import org.nuxeo.ecm.core.api.UnrestrictedSessionRunner; 021import org.nuxeo.ecm.core.api.repository.RepositoryManager; 022import org.nuxeo.ecm.core.management.api.ProbeStatus; 023import org.nuxeo.runtime.api.Framework; 024 025public class QueryRepositoryProbe implements org.nuxeo.ecm.core.management.api.Probe { 026 027 protected static final String queryString = "SELECT * FROM Document"; 028 029 public static class Runner extends UnrestrictedSessionRunner { 030 031 public Runner(String repositoryName) { 032 super(repositoryName); 033 } 034 035 protected String info; 036 037 @Override 038 public void run() { 039 DocumentModelList list = session.query(queryString, null, 1, 0, false); 040 info = " selected " + list.size() + " documents"; 041 } 042 043 } 044 045 public ProbeStatus run() { 046 RepositoryManager mgr = Framework.getLocalService(RepositoryManager.class); 047 Runner runner = new Runner(mgr.getDefaultRepositoryName()); 048 runner.runUnrestricted(); 049 return ProbeStatus.newSuccess(runner.info); 050 } 051 052}