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

File SafeExtensionPlan.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

4
12
3
1
83
42
6
0.5
4
3
2

Classes

Class Line # Actions
SafeExtensionPlan 39 12 0% 6 19
0.00%
 

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 java.util.ArrayList;
23    import java.util.Collection;
24    import java.util.Collections;
25   
26    import org.xwiki.extension.job.plan.ExtensionPlan;
27    import org.xwiki.extension.job.plan.ExtensionPlanAction;
28    import org.xwiki.extension.job.plan.ExtensionPlanTree;
29    import org.xwiki.job.internal.script.safe.SafeJobStatus;
30    import org.xwiki.script.internal.safe.ScriptSafeProvider;
31   
32    /**
33    * Provide a public script access to an extension plan.
34    *
35    * @param <J> the type of the job status
36    * @version $Id: 5c6fb4599b653ad3300880f77e03ba2d4aa65e65 $
37    * @since 4.0M2
38    */
 
39    public class SafeExtensionPlan<J extends ExtensionPlan> extends SafeJobStatus<J> implements ExtensionPlan
40    {
41    /**
42    * @see #getActions()
43    */
44    private Collection<ExtensionPlanAction> wrappedActions;
45   
46    /**
47    * @param plan the wrapped plan
48    * @param safeProvider the provider of instances safe for public scripts
49    */
 
50  0 toggle public SafeExtensionPlan(J plan, ScriptSafeProvider<?> safeProvider)
51    {
52  0 super(plan, safeProvider);
53    }
54   
 
55  0 toggle @Override
56    public ExtensionPlanTree getTree()
57    {
58  0 try {
59  0 return new SafeExtensionPlanTree(getWrapped().getTree(), this.safeProvider);
60    } catch (Exception e) {
61    // should never happen
62  0 return null;
63    }
64    }
65   
 
66  0 toggle @Override
67    public Collection<ExtensionPlanAction> getActions()
68    {
69  0 if (this.wrappedActions == null) {
70  0 Collection<ExtensionPlanAction> actions = getWrapped().getActions();
71  0 if (actions.isEmpty()) {
72  0 this.wrappedActions = Collections.emptyList();
73    } else {
74  0 this.wrappedActions = new ArrayList<ExtensionPlanAction>(actions.size());
75  0 for (ExtensionPlanAction action : actions) {
76  0 this.wrappedActions.add(new SafeExtensionPlanAction(action, this.safeProvider));
77    }
78    }
79    }
80   
81  0 return this.wrappedActions;
82    }
83    }