1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rest.internal.resources.pages

File PageTranslationResourceImpl.java

 

Coverage histogram

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

Code metrics

0
13
3
1
81
49
6
0.46
4.33
3
2

Classes

Class Line # Actions
PageTranslationResourceImpl 38 13 0% 6 3
0.812581.2%
 

Contributing tests

No tests hitting this source file were found.

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.rest.internal.resources.pages;
21   
22    import javax.inject.Named;
23    import javax.ws.rs.core.Response;
24   
25    import org.xwiki.component.annotation.Component;
26    import org.xwiki.rest.XWikiRestException;
27    import org.xwiki.rest.model.jaxb.Page;
28    import org.xwiki.rest.resources.pages.PageTranslationResource;
29   
30    import com.xpn.xwiki.XWikiException;
31    import com.xpn.xwiki.api.Document;
32   
33    /**
34    * @version $Id: c9ad7b2740cad383052fc52ca53a9d8ccc02af5e $
35    */
36    @Component
37    @Named("org.xwiki.rest.internal.resources.pages.PageTranslationResourceImpl")
 
38    public class PageTranslationResourceImpl extends ModifiablePageResource implements PageTranslationResource
39    {
 
40  8 toggle @Override
41    public Page getPageTranslation(String wikiName, String spaceName, String pageName, String language,
42    Boolean withPrettyNames) throws XWikiRestException
43    {
44  8 try {
45  8 DocumentInfo documentInfo = getDocumentInfo(wikiName, spaceName, pageName, language, null, true, false);
46   
47  5 Document doc = documentInfo.getDocument();
48   
49  5 return this.factory.toRestPage(this.uriInfo.getBaseUri(), this.uriInfo.getAbsolutePath(), doc, false,
50    withPrettyNames, false, false, false);
51    } catch (XWikiException e) {
52  0 throw new XWikiRestException(e);
53    }
54    }
55   
 
56  2 toggle @Override
57    public Response putPageTranslation(String wikiName, String spaceName, String pageName, String language, Page page)
58    throws XWikiRestException
59    {
60  2 try {
61  2 DocumentInfo documentInfo = getDocumentInfo(wikiName, spaceName, pageName, language, null, false, true);
62   
63  2 return putPage(documentInfo, page);
64    } catch (XWikiException e) {
65  0 throw new XWikiRestException(e);
66    }
67    }
68   
 
69  4 toggle @Override
70    public void deletePageTranslation(String wikiName, String spaceName, String pageName, String language)
71    throws XWikiRestException
72    {
73  4 try {
74  4 DocumentInfo documentInfo = getDocumentInfo(wikiName, spaceName, pageName, language, null, true, false);
75   
76  1 deletePage(documentInfo);
77    } catch (XWikiException e) {
78  0 throw new XWikiRestException(e);
79    }
80    }
81    }