1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.component.wiki.internal

File AbstractAsyncContentBaseObjectWikiComponent.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
8
1
1
82
32
1
0.12
8
1
1

Classes

Class Line # Actions
AbstractAsyncContentBaseObjectWikiComponent 41 8 0% 1 0
1.0100%
 

Contributing tests

This file is covered by 16 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 org.xwiki.component.wiki.internal;
21   
22    import java.lang.reflect.Type;
23   
24    import org.xwiki.component.manager.ComponentLookupException;
25    import org.xwiki.component.manager.ComponentManager;
26    import org.xwiki.component.wiki.WikiComponentException;
27    import org.xwiki.component.wiki.internal.bridge.ContentParser;
28    import org.xwiki.rendering.async.internal.block.BlockAsyncRendererExecutor;
29    import org.xwiki.rendering.block.XDOM;
30    import org.xwiki.rendering.syntax.Syntax;
31   
32    import com.xpn.xwiki.doc.XWikiDocument;
33    import com.xpn.xwiki.objects.BaseObject;
34   
35    /**
36    * Add support for a wiki content property to execute to {@link AbstractAsyncBaseObjectWikiComponent}.
37    *
38    * @version $Id: 3ce2e03e8ca1b66c7ce9b13794a190293a004163 $
39    * @since 10.10RC1
40    */
 
41    public abstract class AbstractAsyncContentBaseObjectWikiComponent extends AbstractAsyncBaseObjectWikiComponent
42    {
43    protected final ContentParser parser;
44   
45    protected final XDOM xdom;
46   
47    protected final Syntax syntax;
48   
49    protected final ComponentManager componentManager;
50   
51    protected final BlockAsyncRendererExecutor executor;
52   
53    /**
54    * @param baseObject the object containing ui extension setup
55    * @param roleType the role Type implemented
56    * @param roleHint the role hint for this role implementation
57    * @param componentManager The XWiki content manager
58    * @throws ComponentLookupException If module dependencies are missing
59    * @throws WikiComponentException When failing to parse content
60    */
 
61  6330 toggle public AbstractAsyncContentBaseObjectWikiComponent(BaseObject baseObject, Type roleType, String roleHint,
62    ComponentManager componentManager) throws ComponentLookupException, WikiComponentException
63    {
64  6330 super(baseObject, roleType, roleHint);
65   
66  6330 this.componentManager = componentManager;
67  6330 this.executor = componentManager.getInstance(BlockAsyncRendererExecutor.class);
68   
69  6330 XWikiDocument ownerDocument = baseObject.getOwnerDocument();
70   
71  6330 this.parser = componentManager.getInstance(ContentParser.class);
72   
73  6330 this.syntax = ownerDocument.getSyntax();
74  6330 String content = baseObject.getStringValue(getContentPropertyName());
75  6330 this.xdom = this.parser.parse(content, syntax, ownerDocument.getDocumentReference());
76    }
77   
78    /**
79    * @return the name of the property containing the wiki content
80    */
81    protected abstract String getContentPropertyName();
82    }