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

File SafeExtensionRepository.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart7.png
64% of files have more coverage

Code metrics

0
19
7
1
116
68
10
0.53
2.71
7
1.43

Classes

Class Line # Actions
SafeExtensionRepository 40 19 0% 10 8
0.692307769.2%
 

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.ExtensionDependency;
25    import org.xwiki.extension.ExtensionId;
26    import org.xwiki.extension.repository.ExtensionRepository;
27    import org.xwiki.extension.repository.ExtensionRepositoryDescriptor;
28    import org.xwiki.extension.repository.ExtensionRepositoryId;
29    import org.xwiki.extension.repository.result.IterableResult;
30    import org.xwiki.extension.version.Version;
31    import org.xwiki.script.internal.safe.ScriptSafeProvider;
32   
33    /**
34    * Provide a public script access to a repository.
35    *
36    * @param <T>
37    * @version $Id: 136d0fa37bd96b0ac30e6ac80d727b21b4111761 $
38    * @since 4.0M2
39    */
 
40    public class SafeExtensionRepository<T extends ExtensionRepository> extends AbstractNoExceptionSafeObject<T> implements
41    ExtensionRepository
42    {
43    /**
44    * @param repository the wrapped repository
45    * @param safeProvider the provider of instances safe for public scripts
46    * @param execution provide access to the current context
47    * @param hasProgrammingRight does the caller script has programming right
48    */
 
49  1620 toggle public SafeExtensionRepository(T repository, ScriptSafeProvider< ? > safeProvider, Execution execution,
50    boolean hasProgrammingRight)
51    {
52  1620 super(repository, safeProvider, execution, hasProgrammingRight);
53    }
54   
55    // ExtensionRepository
56   
 
57  322 toggle @Override
58    public Extension resolve(ExtensionId extensionId)
59    {
60  322 setError(null);
61   
62  322 try {
63  322 return safe(getWrapped().resolve(extensionId));
64    } catch (Exception e) {
65  169 setError(e);
66    }
67   
68  169 return null;
69    }
70   
 
71  105 toggle @Override
72    public Extension resolve(ExtensionDependency extensionDependency)
73    {
74  105 setError(null);
75   
76  105 try {
77  105 return safe(getWrapped().resolve(extensionDependency));
78    } catch (Exception e) {
79  37 setError(e);
80    }
81   
82  37 return null;
83    }
84   
 
85  3 toggle @Override
86    public ExtensionRepositoryId getId()
87    {
88  3 return getWrapped().getId();
89    }
90   
 
91  469 toggle @Override
92    public ExtensionRepositoryDescriptor getDescriptor()
93    {
94  469 return getWrapped().getDescriptor();
95    }
96   
 
97  0 toggle @Override
98    public boolean exists(ExtensionId extensionId)
99    {
100  0 return getWrapped().exists(extensionId);
101    }
102   
 
103  0 toggle @Override
104    public IterableResult<Version> resolveVersions(String id, int offset, int nb)
105    {
106  0 setError(null);
107   
108  0 try {
109  0 return getWrapped().resolveVersions(id, offset, nb);
110    } catch (Exception e) {
111  0 setError(e);
112    }
113   
114  0 return null;
115    }
116    }