1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.internal.skin

File AbstractWikiResource.java

 

Coverage histogram

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

Code metrics

0
10
5
1
87
48
5
0.5
2
5
1

Classes

Class Line # Actions
AbstractWikiResource 38 10 0% 5 2
0.866666786.7%
 

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: c07ba119c9d880c052718de58fb324158c9acd29 $
36    * @since 6.4M1
37    */
 
38    public abstract class AbstractWikiResource<R extends EntityReference, I extends InputSource> extends
39    AbstractResource<I> implements WikiResource<I>
40    {
41    protected final Provider<XWikiContext> xcontextProvider;
42   
43    protected final R reference;
44   
45    protected final DocumentReference authorReference;
46   
 
47  3 toggle public AbstractWikiResource(String id, String path, String resourceName, ResourceRepository repository,
48    R reference, DocumentReference authorReference, Provider<XWikiContext> xcontextProvider)
49    {
50  3 super(id, path, resourceName, repository);
51   
52  3 this.reference = reference;
53  3 this.authorReference = authorReference;
54  3 this.xcontextProvider = xcontextProvider;
55    }
56   
 
57  3 toggle @Override
58    public DocumentReference getAuthorReference()
59    {
60  3 return this.authorReference;
61    }
62   
 
63  3 toggle protected XWikiDocument getDocument() throws XWikiException
64    {
65  3 EntityReference documentReference = this.reference.extractReference(EntityType.DOCUMENT);
66   
67  3 XWikiContext xcontext = this.xcontextProvider.get();
68   
69  3 return xcontext.getWiki().getDocument(documentReference, xcontext);
70    }
71   
 
72  3 toggle @Override
73    public I getInputSource() throws Exception
74    {
75  3 return getInputSourceInternal(getDocument());
76    }
77   
78    protected abstract I getInputSourceInternal(XWikiDocument document) throws Exception;
79   
 
80  0 toggle @Override
81    public String getURL(boolean forceSkinAction) throws Exception
82    {
83  0 return getURL(getDocument());
84    }
85   
86    public abstract String getURL(XWikiDocument document) throws Exception;
87    }