1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.security.authorization.internal.resolver

File UserAndGroupEntityReferenceResolver.java

 

Coverage histogram

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

Code metrics

4
6
2
1
69
34
4
0.67
3
2
2

Classes

Class Line # Actions
UserAndGroupEntityReferenceResolver 41 6 0% 4 0
1.0100%
 

Contributing tests

This file is covered by 19 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.security.authorization.internal.resolver;
21   
22    import javax.inject.Inject;
23    import javax.inject.Singleton;
24   
25    import org.xwiki.component.annotation.Component;
26    import org.xwiki.model.EntityType;
27    import org.xwiki.model.internal.reference.AbstractStringEntityReferenceResolver;
28    import org.xwiki.model.reference.EntityReference;
29    import org.xwiki.model.reference.EntityReferenceProvider;
30    import org.xwiki.security.internal.XWikiConstants;
31   
32    /**
33    * Specialized version of {@link org.xwiki.model.reference.EntityReferenceResolver<String>} which ensure the proper
34    * space is used to find user documents and allow overwriting the wiki only.
35    *
36    * @version $Id: f9e8a787c66f71542bc7e5129d52725a666b50f6 $
37    * @since 6.2M1
38    */
39    @Component(hints = {"user", "group"})
40    @Singleton
 
41    public class UserAndGroupEntityReferenceResolver extends AbstractStringEntityReferenceResolver
42    {
43    /**
44    * Entity reference value provider used to provide default value.
45    */
46    @Inject
47    private EntityReferenceProvider provider;
48   
 
49  65555 toggle @Override
50    public EntityReference resolve(String entityReferenceRepresentation, EntityType type, Object... parameters)
51    {
52    // Special case: if null is passed then consider it's the guest user and return null.
53  65565 if (entityReferenceRepresentation == null) {
54  1 return null;
55    } else {
56  65560 return super.resolve(entityReferenceRepresentation, type, parameters);
57    }
58    }
59   
 
60  47 toggle @Override
61    protected EntityReference getDefaultReference(EntityType type, Object... parameters)
62    {
63  47 if (type == EntityType.SPACE) {
64  45 return XWikiConstants.XWIKI_SPACE_REFERENCE;
65    } else {
66  2 return this.provider.getDefaultReference(type);
67    }
68    }
69    }