1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.extension.script.internal.safe

File SafeSearchableExtensionRepository.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart8.png
54% of files have more coverage

Code metrics

0
6
2
1
66
28
3
0.5
3
2
1.5

Classes

Class Line # Actions
SafeSearchableExtensionRepository 36 6 0% 3 2
0.7575%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.extension.script.internal.safe;
21   
22    import org.xwiki.context.Execution;
23    import org.xwiki.extension.Extension;
24    import org.xwiki.extension.repository.ExtensionRepository;
25    import org.xwiki.extension.repository.result.IterableResult;
26    import org.xwiki.extension.repository.search.SearchException;
27    import org.xwiki.extension.repository.search.Searchable;
28    import org.xwiki.script.internal.safe.ScriptSafeProvider;
29   
30    /**
31    * Provide a public script access to a {@link Searchable} extension repository.
32    *
33    * @param <T>
34    * @version $Id: 2aefe2f2976c1fa543ba77d2407a8a5a41f5ea31 $
35    */
 
36    public class SafeSearchableExtensionRepository<T extends ExtensionRepository> extends SafeExtensionRepository<T>
37    implements Searchable
38    {
39    /**
40    * @param repository wrapped repository
41    * @param safeProvider the provider of instances safe for public scripts
42    * @param execution provide access to the current context
43    * @param hasProgrammingRight does the caller script has programming right
44    */
 
45  1520 toggle public SafeSearchableExtensionRepository(T repository, ScriptSafeProvider<?> safeProvider, Execution execution,
46    boolean hasProgrammingRight)
47    {
48  1520 super(repository, safeProvider, execution, hasProgrammingRight);
49    }
50   
51    // Searchable
52   
 
53  21 toggle @Override
54    public IterableResult<Extension> search(String pattern, int offset, int nb) throws SearchException
55    {
56  21 setError(null);
57   
58  21 try {
59  21 return safe(((Searchable) getWrapped()).search(pattern, offset, nb));
60    } catch (Exception e) {
61  0 setError(e);
62    }
63   
64  0 return null;
65    }
66    }