| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.rest.internal.resources.spaces; |
| 21 |
|
|
| 22 |
|
import java.util.List; |
| 23 |
|
|
| 24 |
|
import javax.inject.Named; |
| 25 |
|
|
| 26 |
|
import org.xwiki.component.annotation.Component; |
| 27 |
|
import org.xwiki.rest.XWikiResource; |
| 28 |
|
import org.xwiki.rest.XWikiRestException; |
| 29 |
|
import org.xwiki.rest.internal.DomainObjectFactory; |
| 30 |
|
import org.xwiki.rest.internal.Utils; |
| 31 |
|
import org.xwiki.rest.model.jaxb.Space; |
| 32 |
|
import org.xwiki.rest.resources.spaces.SpaceResource; |
| 33 |
|
|
| 34 |
|
import com.xpn.xwiki.XWikiException; |
| 35 |
|
import com.xpn.xwiki.api.Document; |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
@version |
| 39 |
|
|
| 40 |
|
@Component |
| 41 |
|
@Named("org.xwiki.rest.internal.resources.spaces.SpaceResourceImpl") |
| |
|
| 78.6% |
Uncovered Elements: 3 (14) |
Complexity: 3 |
Complexity Density: 0.27 |
|
| 42 |
|
public class SpaceResourceImpl extends XWikiResource implements SpaceResource |
| 43 |
|
{ |
| |
|
| 76.9% |
Uncovered Elements: 3 (13) |
Complexity: 3 |
Complexity Density: 0.27 |
|
| 44 |
5 |
@Override... |
| 45 |
|
public Space getSpace(String wikiName, String spaceName) throws XWikiRestException |
| 46 |
|
{ |
| 47 |
5 |
String database = Utils.getXWikiContext(componentManager).getWikiId(); |
| 48 |
5 |
List<String> spaces = parseSpaceSegments(spaceName); |
| 49 |
|
|
| 50 |
5 |
try { |
| 51 |
5 |
Utils.getXWikiContext(componentManager).setWikiId(wikiName); |
| 52 |
|
|
| 53 |
5 |
String homeId = Utils.getPageId(wikiName, spaces, "WebHome"); |
| 54 |
5 |
Document home = null; |
| 55 |
|
|
| 56 |
5 |
if (Utils.getXWikiApi(componentManager).exists(homeId)) { |
| 57 |
0 |
home = Utils.getXWikiApi(componentManager).getDocument(homeId); |
| 58 |
|
} |
| 59 |
|
|
| 60 |
5 |
return DomainObjectFactory.createSpace(objectFactory, uriInfo.getBaseUri(), wikiName, spaces, home); |
| 61 |
|
} catch (XWikiException e) { |
| 62 |
0 |
throw new XWikiRestException(e); |
| 63 |
|
} finally { |
| 64 |
5 |
Utils.getXWikiContext(componentManager).setWikiId(database); |
| 65 |
|
} |
| 66 |
|
} |
| 67 |
|
} |