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.pages; |
21 |
|
|
22 |
|
import javax.inject.Inject; |
23 |
|
import javax.ws.rs.core.Response; |
24 |
|
import javax.ws.rs.core.Response.Status; |
25 |
|
|
26 |
|
import org.xwiki.rest.XWikiResource; |
27 |
|
import org.xwiki.rest.internal.ModelFactory; |
28 |
|
import org.xwiki.rest.model.jaxb.Page; |
29 |
|
|
30 |
|
import com.xpn.xwiki.XWikiException; |
31 |
|
import com.xpn.xwiki.api.Document; |
32 |
|
|
33 |
|
|
34 |
|
@version |
35 |
|
|
|
|
| 87.5% |
Uncovered Elements: 2 (16) |
Complexity: 5 |
Complexity Density: 0.5 |
|
36 |
|
public class ModifiablePageResource extends XWikiResource |
37 |
|
{ |
38 |
|
@Inject |
39 |
|
protected ModelFactory factory; |
40 |
|
|
|
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 4 |
Complexity Density: 0.5 |
|
41 |
186 |
public Response putPage(DocumentInfo documentInfo, Page page) throws XWikiException... |
42 |
|
{ |
43 |
186 |
Document doc = documentInfo.getDocument(); |
44 |
|
|
45 |
|
|
46 |
186 |
if (this.factory.toDocument(doc, page) || doc.isNew()) { |
47 |
186 |
doc.save(page.getComment()); |
48 |
|
|
49 |
185 |
page = |
50 |
|
this.factory.toRestPage(uriInfo.getBaseUri(), uriInfo.getAbsolutePath(), doc, false, false, false, false, |
51 |
|
false); |
52 |
|
|
53 |
185 |
if (documentInfo.isCreated()) { |
54 |
107 |
return Response.created(uriInfo.getAbsolutePath()).entity(page).build(); |
55 |
|
} else { |
56 |
78 |
return Response.status(Status.ACCEPTED).entity(page).build(); |
57 |
|
} |
58 |
|
} else { |
59 |
0 |
return Response.status(Status.NOT_MODIFIED).build(); |
60 |
|
} |
61 |
|
} |
62 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
63 |
49 |
void deletePage(DocumentInfo documentInfo) throws XWikiException... |
64 |
|
{ |
65 |
49 |
Document doc = documentInfo.getDocument(); |
66 |
|
|
67 |
49 |
doc.delete(); |
68 |
|
} |
69 |
|
} |