| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package org.xwiki.security.authorization.testwikis.internal.parser; |
| 22 |
|
|
| 23 |
|
import java.util.Arrays; |
| 24 |
|
import java.util.List; |
| 25 |
|
|
| 26 |
|
import org.xml.sax.Attributes; |
| 27 |
|
import org.xml.sax.SAXException; |
| 28 |
|
import org.xwiki.model.EntityType; |
| 29 |
|
import org.xwiki.model.reference.EntityReference; |
| 30 |
|
import org.xwiki.model.reference.WikiReference; |
| 31 |
|
import org.xwiki.security.authorization.testwikis.TestEntity; |
| 32 |
|
import org.xwiki.security.authorization.testwikis.TestWiki; |
| 33 |
|
import org.xwiki.security.authorization.testwikis.internal.entities.DefaultTestDocument; |
| 34 |
|
import org.xwiki.security.authorization.testwikis.internal.entities.DefaultTestWiki; |
| 35 |
|
import org.xwiki.security.authorization.testwikis.internal.entities.DefaultTestDefinition; |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
@version |
| 41 |
|
@since |
| 42 |
|
|
| |
|
| 90.5% |
Uncovered Elements: 2 (21) |
Complexity: 7 |
Complexity Density: 0.54 |
|
| 43 |
|
public class TestWikiFactory extends AbstractSecureEntityFactory<TestWiki> |
| 44 |
|
{ |
| 45 |
|
|
| 46 |
|
|
| 47 |
|
@param |
| 48 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 49 |
15 |
TestWikiFactory(TestEntity parent)... |
| 50 |
|
{ |
| 51 |
15 |
setParent(parent); |
| 52 |
|
} |
| 53 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 54 |
15 |
@Override... |
| 55 |
|
public List<String> getTagNames() |
| 56 |
|
{ |
| 57 |
15 |
return Arrays.asList("wiki"); |
| 58 |
|
} |
| 59 |
|
|
| |
|
| 81.8% |
Uncovered Elements: 2 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
| 60 |
55 |
@Override... |
| 61 |
|
TestWiki getNewInstance(ElementParser parser, String name, TestEntity parent, Attributes attributes) |
| 62 |
|
throws SAXException |
| 63 |
|
{ |
| 64 |
55 |
EntityReference reference = new WikiReference(attributes.getValue("name")); |
| 65 |
55 |
boolean isMainWiki = "true".equals(attributes.getValue("mainWiki")); |
| 66 |
55 |
String ownerString = attributes.getValue("owner"); |
| 67 |
55 |
EntityReference owner = (ownerString) != null ? parser.getResolver().resolve(ownerString, |
| 68 |
|
DefaultTestDocument.TYPE, new EntityReference(XWikiConstants.XWIKI_SPACE, EntityType.SPACE, reference)) |
| 69 |
|
: null; |
| 70 |
|
|
| 71 |
55 |
if (isMainWiki && ((DefaultTestDefinition) parent).getMainWiki() != null) { |
| 72 |
0 |
throw new SAXException(parser.getLocatedMessage("Only one main wiki may be defined.")); |
| 73 |
|
} |
| 74 |
|
|
| 75 |
55 |
return new DefaultTestWiki(reference, isMainWiki, owner, attributes.getValue("alt"), parent); |
| 76 |
|
} |
| 77 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 78 |
55 |
@Override... |
| 79 |
|
protected void registerFactories(ElementParser parser, TestWiki entity) |
| 80 |
|
{ |
| 81 |
55 |
super.registerFactories(parser, entity); |
| 82 |
55 |
parser.register(new TestSpaceFactory(entity)); |
| 83 |
55 |
parser.register(new TestUserFactory(entity)); |
| 84 |
55 |
parser.register(new TestGroupFactory(entity)); |
| 85 |
|
} |
| 86 |
|
} |