1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package com.xpn.xwiki.internal.skin

File AbstractWikiResource.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart9.png
41% of files have more coverage

Code metrics

0
11
6
1
94
54
6
0.55
1.83
6
1

Classes

Class Line # Actions
AbstractWikiResource 38 11 0% 6 2
0.8823529588.2%
 

Contributing tests

This file is covered by 3 tests. .

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 com.xpn.xwiki.internal.skin;
21   
22    import javax.inject.Provider;
23   
24    import org.xwiki.filter.input.InputSource;
25    import org.xwiki.model.EntityType;
26    import org.xwiki.model.reference.DocumentReference;
27    import org.xwiki.model.reference.EntityReference;
28    import org.xwiki.skin.ResourceRepository;
29   
30    import com.xpn.xwiki.XWikiContext;
31    import com.xpn.xwiki.XWikiException;
32    import com.xpn.xwiki.doc.XWikiDocument;
33   
34    /**
35    * @version $Id: 5a624778a13eeb5f7593fcf0693eeb705b4d4cf8 $
36    * @since 6.4M1
37    */
 
38    public abstract class AbstractWikiResource<R extends EntityReference, I extends InputSource> extends AbstractResource<I>
39    implements WikiResource<I>
40    {
41    protected final Provider<XWikiContext> xcontextProvider;
42   
43    protected final R reference;
44   
45    protected final DocumentReference authorReference;
46   
47    protected final DocumentReference documentReference;
48   
 
49  3 toggle public AbstractWikiResource(String id, String path, String resourceName, ResourceRepository repository, R reference,
50    DocumentReference authorReference, Provider<XWikiContext> xcontextProvider)
51    {
52  3 super(id, path, resourceName, repository);
53   
54  3 this.reference = reference;
55  3 this.authorReference = authorReference;
56  3 this.documentReference = (DocumentReference) this.reference.extractReference(EntityType.DOCUMENT);
57  3 this.xcontextProvider = xcontextProvider;
58    }
59   
 
60  3 toggle @Override
61    public DocumentReference getAuthorReference()
62    {
63  3 return this.authorReference;
64    }
65   
 
66  6 toggle @Override
67    public DocumentReference getDocumentReference()
68    {
69  6 return this.documentReference;
70    }
71   
 
72  3 toggle protected XWikiDocument getDocument() throws XWikiException
73    {
74  3 XWikiContext xcontext = this.xcontextProvider.get();
75   
76  3 return xcontext.getWiki().getDocument(getDocumentReference(), xcontext);
77    }
78   
 
79  3 toggle @Override
80    public I getInputSource() throws Exception
81    {
82  3 return getInputSourceInternal(getDocument());
83    }
84   
85    protected abstract I getInputSourceInternal(XWikiDocument document) throws Exception;
86   
 
87  0 toggle @Override
88    public String getURL(boolean forceSkinAction) throws Exception
89    {
90  0 return getURL(getDocument());
91    }
92   
93    public abstract String getURL(XWikiDocument document) throws Exception;
94    }