@Test void toRestPageSummary() throws Exception { DocumentReference documentReference = new DocumentReference("wiki", Arrays.asList("Path", "To"), "Page"); Document document = mock(Document.class); when(document.getDocumentReference()).thenReturn(documentReference); when(document.getWiki()).thenReturn(documentReference.getWikiReference().getName()); when(document.getTitle()).thenReturn("Some > title"); when(document.getDisplayTitle()).thenReturn("Some &gt; title"); when(document.getDefaultLocale()).thenReturn(Locale.ITALIAN); when(document.getSyntax()).thenReturn(Syntax.XWIKI_2_1); when(document.getComments()).thenReturn(new Vector<>()); PageSummary pageSummary = this.modelFactory.toRestPageSummary(this.baseURI, document, true); assertEquals(document.getDisplayTitle(), pageSummary.getTitle()); assertEquals(document.getTitle(), pageSummary.getRawTitle()); }
private void toRestPageSummary(PageSummary pageSummary, URI baseUri, Document doc, boolean useVersion, Boolean withPrettyNames) throws XWikiException { XWikiContext xwikiContext = this.xcontextProvider.get(); pageSummary.setWiki(doc.getWiki()); pageSummary.setFullName(doc.getFullName()); pageSummary.setId(doc.getPrefixedFullName()); pageSummary.setSpace(doc.getSpace()); pageSummary.setName(doc.getDocumentReference().getName()); pageSummary.setTitle(doc.getDisplayTitle()); pageSummary.setRawTitle(doc.getTitle()); pageSummary.setXwikiRelativeUrl(doc.getURL("view")); pageSummary.setXwikiAbsoluteUrl(doc.getExternalURL("view")); pageSummary.setTranslations(toRestTranslations(baseUri, doc)); pageSummary.setSyntax(doc.getSyntax().toIdString()); pageSummary.setVersion(doc.getVersion()); pageSummary.setAuthor(doc.getAuthor()); if (withPrettyNames) { pageSummary.setAuthorName(xwikiContext.getWiki().getUserName(doc.getAuthor(), null, false, xwikiContext)); } pageSummary.setParent(doc.getParent()); DocumentReference parentReference = doc.getParentReference(); boolean parentExist = parentReference != null && xwikiContext.getWiki().exists(parentReference, xwikiContext); if (parentExist) { pageSummary.setParentId(this.serializer.serialize(parentReference)); } else { pageSummary.setParentId(""); } List<String> spaces = Utils.getSpacesFromSpaceId(doc.getSpace()); String spaceUri = Utils.createURI(baseUri, SpaceResource.class, doc.getWiki(), spaces).toString(); Link spaceLink = this.objectFactory.createLink(); spaceLink.setHref(spaceUri); spaceLink.setRel(Relations.SPACE); pageSummary.getLinks().add(spaceLink); if (parentExist) { String parentUri = Utils.createURI(baseUri, PageResource.class, parentReference.getWikiReference().getName(), spaces, parentReference.getName()).toString(); Link parentLink = this.objectFactory.createLink(); parentLink.setHref(parentUri); parentLink.setRel(Relations.PARENT); pageSummary.getLinks().add(parentLink); } String historyUri = Utils.createURI(baseUri, PageHistoryResource.class, doc.getWiki(), Utils.getSpacesFromSpaceId(doc.getSpace()), doc.getDocumentReference().getName()).toString(); Link historyLink = this.objectFactory.createLink(); historyLink.setHref(historyUri); historyLink.setRel(Relations.HISTORY); pageSummary.getLinks().add(historyLink); if (!doc.getChildren().isEmpty()) { String pageChildrenUri = Utils.createURI(baseUri, PageChildrenResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); Link pageChildrenLink = this.objectFactory.createLink(); pageChildrenLink.setHref(pageChildrenUri); pageChildrenLink.setRel(Relations.CHILDREN); pageSummary.getLinks().add(pageChildrenLink); } if (!doc.getComments().isEmpty()) { String commentsUri; if (useVersion) { commentsUri = Utils.createURI(baseUri, CommentsVersionResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName(), doc.getVersion()).toString(); } else { commentsUri = Utils.createURI(baseUri, CommentsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); } Link commentsLink = this.objectFactory.createLink(); commentsLink.setHref(commentsUri); commentsLink.setRel(Relations.COMMENTS); pageSummary.getLinks().add(commentsLink); } if (!doc.getAttachmentList().isEmpty()) { String attachmentsUri; if (useVersion) { attachmentsUri = Utils.createURI(baseUri, AttachmentsAtPageVersionResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName(), doc.getVersion()).toString(); } else { attachmentsUri = Utils.createURI(baseUri, AttachmentsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); } Link attachmentsLink = this.objectFactory.createLink(); attachmentsLink.setHref(attachmentsUri); attachmentsLink.setRel(Relations.ATTACHMENTS); pageSummary.getLinks().add(attachmentsLink); } if (!doc.getxWikiObjects().keySet().isEmpty()) { String objectsUri; if (useVersion) { objectsUri = Utils.createURI(baseUri, ObjectsAtPageVersionResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName(), doc.getVersion()).toString(); } else { objectsUri = Utils.createURI(baseUri, ObjectsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); } Link objectsLink = this.objectFactory.createLink(); objectsLink.setHref(objectsUri); objectsLink.setRel(Relations.OBJECTS); pageSummary.getLinks().add(objectsLink); } com.xpn.xwiki.api.Object tagsObject = doc.getObject("XWiki.TagClass", 0); if (tagsObject != null) { if (tagsObject.getProperty("tags") != null) { String tagsUri = Utils.createURI(baseUri, PageTagsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); Link tagsLink = this.objectFactory.createLink(); tagsLink.setHref(tagsUri); tagsLink.setRel(Relations.TAGS); pageSummary.getLinks().add(tagsLink); } } String syntaxesUri = Utils.createURI(baseUri, SyntaxesResource.class).toString(); Link syntaxesLink = this.objectFactory.createLink(); syntaxesLink.setHref(syntaxesUri); syntaxesLink.setRel(Relations.SYNTAXES); pageSummary.getLinks().add(syntaxesLink); }
ModelFactory { private void toRestPageSummary(PageSummary pageSummary, URI baseUri, Document doc, boolean useVersion, Boolean withPrettyNames) throws XWikiException { XWikiContext xwikiContext = this.xcontextProvider.get(); pageSummary.setWiki(doc.getWiki()); pageSummary.setFullName(doc.getFullName()); pageSummary.setId(doc.getPrefixedFullName()); pageSummary.setSpace(doc.getSpace()); pageSummary.setName(doc.getDocumentReference().getName()); pageSummary.setTitle(doc.getDisplayTitle()); pageSummary.setRawTitle(doc.getTitle()); pageSummary.setXwikiRelativeUrl(doc.getURL("view")); pageSummary.setXwikiAbsoluteUrl(doc.getExternalURL("view")); pageSummary.setTranslations(toRestTranslations(baseUri, doc)); pageSummary.setSyntax(doc.getSyntax().toIdString()); pageSummary.setVersion(doc.getVersion()); pageSummary.setAuthor(doc.getAuthor()); if (withPrettyNames) { pageSummary.setAuthorName(xwikiContext.getWiki().getUserName(doc.getAuthor(), null, false, xwikiContext)); } pageSummary.setParent(doc.getParent()); DocumentReference parentReference = doc.getParentReference(); boolean parentExist = parentReference != null && xwikiContext.getWiki().exists(parentReference, xwikiContext); if (parentExist) { pageSummary.setParentId(this.serializer.serialize(parentReference)); } else { pageSummary.setParentId(""); } List<String> spaces = Utils.getSpacesFromSpaceId(doc.getSpace()); String spaceUri = Utils.createURI(baseUri, SpaceResource.class, doc.getWiki(), spaces).toString(); Link spaceLink = this.objectFactory.createLink(); spaceLink.setHref(spaceUri); spaceLink.setRel(Relations.SPACE); pageSummary.getLinks().add(spaceLink); if (parentExist) { String parentUri = Utils.createURI(baseUri, PageResource.class, parentReference.getWikiReference().getName(), spaces, parentReference.getName()).toString(); Link parentLink = this.objectFactory.createLink(); parentLink.setHref(parentUri); parentLink.setRel(Relations.PARENT); pageSummary.getLinks().add(parentLink); } String historyUri = Utils.createURI(baseUri, PageHistoryResource.class, doc.getWiki(), Utils.getSpacesFromSpaceId(doc.getSpace()), doc.getDocumentReference().getName()).toString(); Link historyLink = this.objectFactory.createLink(); historyLink.setHref(historyUri); historyLink.setRel(Relations.HISTORY); pageSummary.getLinks().add(historyLink); if (!doc.getChildren().isEmpty()) { String pageChildrenUri = Utils.createURI(baseUri, PageChildrenResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); Link pageChildrenLink = this.objectFactory.createLink(); pageChildrenLink.setHref(pageChildrenUri); pageChildrenLink.setRel(Relations.CHILDREN); pageSummary.getLinks().add(pageChildrenLink); } if (!doc.getComments().isEmpty()) { String commentsUri; if (useVersion) { commentsUri = Utils.createURI(baseUri, CommentsVersionResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName(), doc.getVersion()).toString(); } else { commentsUri = Utils.createURI(baseUri, CommentsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); } Link commentsLink = this.objectFactory.createLink(); commentsLink.setHref(commentsUri); commentsLink.setRel(Relations.COMMENTS); pageSummary.getLinks().add(commentsLink); } if (!doc.getAttachmentList().isEmpty()) { String attachmentsUri; if (useVersion) { attachmentsUri = Utils.createURI(baseUri, AttachmentsAtPageVersionResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName(), doc.getVersion()).toString(); } else { attachmentsUri = Utils.createURI(baseUri, AttachmentsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); } Link attachmentsLink = this.objectFactory.createLink(); attachmentsLink.setHref(attachmentsUri); attachmentsLink.setRel(Relations.ATTACHMENTS); pageSummary.getLinks().add(attachmentsLink); } if (!doc.getxWikiObjects().keySet().isEmpty()) { String objectsUri; if (useVersion) { objectsUri = Utils.createURI(baseUri, ObjectsAtPageVersionResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName(), doc.getVersion()).toString(); } else { objectsUri = Utils.createURI(baseUri, ObjectsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); } Link objectsLink = this.objectFactory.createLink(); objectsLink.setHref(objectsUri); objectsLink.setRel(Relations.OBJECTS); pageSummary.getLinks().add(objectsLink); } com.xpn.xwiki.api.Object tagsObject = doc.getObject("XWiki.TagClass", 0); if (tagsObject != null) { if (tagsObject.getProperty("tags") != null) { String tagsUri = Utils.createURI(baseUri, PageTagsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); Link tagsLink = this.objectFactory.createLink(); tagsLink.setHref(tagsUri); tagsLink.setRel(Relations.TAGS); pageSummary.getLinks().add(tagsLink); } } String syntaxesUri = Utils.createURI(baseUri, SyntaxesResource.class).toString(); Link syntaxesLink = this.objectFactory.createLink(); syntaxesLink.setHref(syntaxesUri); syntaxesLink.setRel(Relations.SYNTAXES); pageSummary.getLinks().add(syntaxesLink); } }
ModelFactory { private void toRestPageSummary(PageSummary pageSummary, URI baseUri, Document doc, boolean useVersion, Boolean withPrettyNames) throws XWikiException { XWikiContext xwikiContext = this.xcontextProvider.get(); pageSummary.setWiki(doc.getWiki()); pageSummary.setFullName(doc.getFullName()); pageSummary.setId(doc.getPrefixedFullName()); pageSummary.setSpace(doc.getSpace()); pageSummary.setName(doc.getDocumentReference().getName()); pageSummary.setTitle(doc.getDisplayTitle()); pageSummary.setRawTitle(doc.getTitle()); pageSummary.setXwikiRelativeUrl(doc.getURL("view")); pageSummary.setXwikiAbsoluteUrl(doc.getExternalURL("view")); pageSummary.setTranslations(toRestTranslations(baseUri, doc)); pageSummary.setSyntax(doc.getSyntax().toIdString()); pageSummary.setVersion(doc.getVersion()); pageSummary.setAuthor(doc.getAuthor()); if (withPrettyNames) { pageSummary.setAuthorName(xwikiContext.getWiki().getUserName(doc.getAuthor(), null, false, xwikiContext)); } pageSummary.setParent(doc.getParent()); DocumentReference parentReference = doc.getParentReference(); boolean parentExist = parentReference != null && xwikiContext.getWiki().exists(parentReference, xwikiContext); if (parentExist) { pageSummary.setParentId(this.serializer.serialize(parentReference)); } else { pageSummary.setParentId(""); } List<String> spaces = Utils.getSpacesFromSpaceId(doc.getSpace()); String spaceUri = Utils.createURI(baseUri, SpaceResource.class, doc.getWiki(), spaces).toString(); Link spaceLink = this.objectFactory.createLink(); spaceLink.setHref(spaceUri); spaceLink.setRel(Relations.SPACE); pageSummary.getLinks().add(spaceLink); if (parentExist) { String parentUri = Utils.createURI(baseUri, PageResource.class, parentReference.getWikiReference().getName(), spaces, parentReference.getName()).toString(); Link parentLink = this.objectFactory.createLink(); parentLink.setHref(parentUri); parentLink.setRel(Relations.PARENT); pageSummary.getLinks().add(parentLink); } String historyUri = Utils.createURI(baseUri, PageHistoryResource.class, doc.getWiki(), Utils.getSpacesFromSpaceId(doc.getSpace()), doc.getDocumentReference().getName()).toString(); Link historyLink = this.objectFactory.createLink(); historyLink.setHref(historyUri); historyLink.setRel(Relations.HISTORY); pageSummary.getLinks().add(historyLink); if (!doc.getChildren().isEmpty()) { String pageChildrenUri = Utils.createURI(baseUri, PageChildrenResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); Link pageChildrenLink = this.objectFactory.createLink(); pageChildrenLink.setHref(pageChildrenUri); pageChildrenLink.setRel(Relations.CHILDREN); pageSummary.getLinks().add(pageChildrenLink); } if (!doc.getComments().isEmpty()) { String commentsUri; if (useVersion) { commentsUri = Utils.createURI(baseUri, CommentsVersionResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName(), doc.getVersion()).toString(); } else { commentsUri = Utils.createURI(baseUri, CommentsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); } Link commentsLink = this.objectFactory.createLink(); commentsLink.setHref(commentsUri); commentsLink.setRel(Relations.COMMENTS); pageSummary.getLinks().add(commentsLink); } if (!doc.getAttachmentList().isEmpty()) { String attachmentsUri; if (useVersion) { attachmentsUri = Utils.createURI(baseUri, AttachmentsAtPageVersionResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName(), doc.getVersion()).toString(); } else { attachmentsUri = Utils.createURI(baseUri, AttachmentsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); } Link attachmentsLink = this.objectFactory.createLink(); attachmentsLink.setHref(attachmentsUri); attachmentsLink.setRel(Relations.ATTACHMENTS); pageSummary.getLinks().add(attachmentsLink); } if (!doc.getxWikiObjects().keySet().isEmpty()) { String objectsUri; if (useVersion) { objectsUri = Utils.createURI(baseUri, ObjectsAtPageVersionResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName(), doc.getVersion()).toString(); } else { objectsUri = Utils.createURI(baseUri, ObjectsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); } Link objectsLink = this.objectFactory.createLink(); objectsLink.setHref(objectsUri); objectsLink.setRel(Relations.OBJECTS); pageSummary.getLinks().add(objectsLink); } com.xpn.xwiki.api.Object tagsObject = doc.getObject("XWiki.TagClass", 0); if (tagsObject != null) { if (tagsObject.getProperty("tags") != null) { String tagsUri = Utils.createURI(baseUri, PageTagsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); Link tagsLink = this.objectFactory.createLink(); tagsLink.setHref(tagsUri); tagsLink.setRel(Relations.TAGS); pageSummary.getLinks().add(tagsLink); } } String syntaxesUri = Utils.createURI(baseUri, SyntaxesResource.class).toString(); Link syntaxesLink = this.objectFactory.createLink(); syntaxesLink.setHref(syntaxesUri); syntaxesLink.setRel(Relations.SYNTAXES); pageSummary.getLinks().add(syntaxesLink); } ModelFactory(); }
ModelFactory { private void toRestPageSummary(PageSummary pageSummary, URI baseUri, Document doc, boolean useVersion, Boolean withPrettyNames) throws XWikiException { XWikiContext xwikiContext = this.xcontextProvider.get(); pageSummary.setWiki(doc.getWiki()); pageSummary.setFullName(doc.getFullName()); pageSummary.setId(doc.getPrefixedFullName()); pageSummary.setSpace(doc.getSpace()); pageSummary.setName(doc.getDocumentReference().getName()); pageSummary.setTitle(doc.getDisplayTitle()); pageSummary.setRawTitle(doc.getTitle()); pageSummary.setXwikiRelativeUrl(doc.getURL("view")); pageSummary.setXwikiAbsoluteUrl(doc.getExternalURL("view")); pageSummary.setTranslations(toRestTranslations(baseUri, doc)); pageSummary.setSyntax(doc.getSyntax().toIdString()); pageSummary.setVersion(doc.getVersion()); pageSummary.setAuthor(doc.getAuthor()); if (withPrettyNames) { pageSummary.setAuthorName(xwikiContext.getWiki().getUserName(doc.getAuthor(), null, false, xwikiContext)); } pageSummary.setParent(doc.getParent()); DocumentReference parentReference = doc.getParentReference(); boolean parentExist = parentReference != null && xwikiContext.getWiki().exists(parentReference, xwikiContext); if (parentExist) { pageSummary.setParentId(this.serializer.serialize(parentReference)); } else { pageSummary.setParentId(""); } List<String> spaces = Utils.getSpacesFromSpaceId(doc.getSpace()); String spaceUri = Utils.createURI(baseUri, SpaceResource.class, doc.getWiki(), spaces).toString(); Link spaceLink = this.objectFactory.createLink(); spaceLink.setHref(spaceUri); spaceLink.setRel(Relations.SPACE); pageSummary.getLinks().add(spaceLink); if (parentExist) { String parentUri = Utils.createURI(baseUri, PageResource.class, parentReference.getWikiReference().getName(), spaces, parentReference.getName()).toString(); Link parentLink = this.objectFactory.createLink(); parentLink.setHref(parentUri); parentLink.setRel(Relations.PARENT); pageSummary.getLinks().add(parentLink); } String historyUri = Utils.createURI(baseUri, PageHistoryResource.class, doc.getWiki(), Utils.getSpacesFromSpaceId(doc.getSpace()), doc.getDocumentReference().getName()).toString(); Link historyLink = this.objectFactory.createLink(); historyLink.setHref(historyUri); historyLink.setRel(Relations.HISTORY); pageSummary.getLinks().add(historyLink); if (!doc.getChildren().isEmpty()) { String pageChildrenUri = Utils.createURI(baseUri, PageChildrenResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); Link pageChildrenLink = this.objectFactory.createLink(); pageChildrenLink.setHref(pageChildrenUri); pageChildrenLink.setRel(Relations.CHILDREN); pageSummary.getLinks().add(pageChildrenLink); } if (!doc.getComments().isEmpty()) { String commentsUri; if (useVersion) { commentsUri = Utils.createURI(baseUri, CommentsVersionResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName(), doc.getVersion()).toString(); } else { commentsUri = Utils.createURI(baseUri, CommentsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); } Link commentsLink = this.objectFactory.createLink(); commentsLink.setHref(commentsUri); commentsLink.setRel(Relations.COMMENTS); pageSummary.getLinks().add(commentsLink); } if (!doc.getAttachmentList().isEmpty()) { String attachmentsUri; if (useVersion) { attachmentsUri = Utils.createURI(baseUri, AttachmentsAtPageVersionResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName(), doc.getVersion()).toString(); } else { attachmentsUri = Utils.createURI(baseUri, AttachmentsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); } Link attachmentsLink = this.objectFactory.createLink(); attachmentsLink.setHref(attachmentsUri); attachmentsLink.setRel(Relations.ATTACHMENTS); pageSummary.getLinks().add(attachmentsLink); } if (!doc.getxWikiObjects().keySet().isEmpty()) { String objectsUri; if (useVersion) { objectsUri = Utils.createURI(baseUri, ObjectsAtPageVersionResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName(), doc.getVersion()).toString(); } else { objectsUri = Utils.createURI(baseUri, ObjectsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); } Link objectsLink = this.objectFactory.createLink(); objectsLink.setHref(objectsUri); objectsLink.setRel(Relations.OBJECTS); pageSummary.getLinks().add(objectsLink); } com.xpn.xwiki.api.Object tagsObject = doc.getObject("XWiki.TagClass", 0); if (tagsObject != null) { if (tagsObject.getProperty("tags") != null) { String tagsUri = Utils.createURI(baseUri, PageTagsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); Link tagsLink = this.objectFactory.createLink(); tagsLink.setHref(tagsUri); tagsLink.setRel(Relations.TAGS); pageSummary.getLinks().add(tagsLink); } } String syntaxesUri = Utils.createURI(baseUri, SyntaxesResource.class).toString(); Link syntaxesLink = this.objectFactory.createLink(); syntaxesLink.setHref(syntaxesUri); syntaxesLink.setRel(Relations.SYNTAXES); pageSummary.getLinks().add(syntaxesLink); } ModelFactory(); boolean toDocument(Document doc, org.xwiki.rest.model.jaxb.Page restPage); ObjectSummary toRestObjectSummary(URI baseUri, Document doc, BaseObject xwikiObject, boolean useVersion,
        Boolean withPrettyNames); void toObject(com.xpn.xwiki.api.Object xwikiObject, org.xwiki.rest.model.jaxb.Object restObject); Object toRestObject(URI baseUri, Document doc, BaseObject xwikiObject, boolean useVersion,
        Boolean withPrettyNames); Wiki toRestWiki(URI baseUri, String wikiName); Space toRestSpace(URI baseUri, String wikiName, List<String> spaces, Document home); Translations toRestTranslations(URI baseUri, Document doc); PageSummary toRestPageSummary(URI baseUri, Document doc, Boolean withPrettyNames); Page toRestPage(URI baseUri, URI self, Document doc, boolean useVersion, Boolean withPrettyNames,
        Boolean withObjects, Boolean withXClass, Boolean withAttachments); Class toRestClass(URI baseUri, com.xpn.xwiki.api.Class xwikiClass); Attachment toRestAttachment(URI baseUri, com.xpn.xwiki.api.Attachment xwikiAttachment,
        Boolean withPrettyNames, boolean versionURL); Attachment toRestAttachment(URI baseUri, com.xpn.xwiki.api.Attachment xwikiAttachment,
        String xwikiRelativeUrl, String xwikiAbsoluteUrl, Boolean withPrettyNames, boolean versionURL); Hierarchy toRestHierarchy(EntityReference targetEntityReference, Boolean withPrettyNames); JobRequest toRestJobRequest(Request request); JobId toRestJobId(List<String> id); MapEntry toRestMapEntry(String key, java.lang.Object value); DefaultRequest toJobRequest(JobRequest restJobRequest); JobStatus toRestJobStatus(org.xwiki.job.event.status.JobStatus jobStatus, URI self, boolean request,
        boolean progress, boolean log, String logFromLevel); JobProgress toRestJobProgress(org.xwiki.job.event.status.JobProgress progress); JobLog toRestJobLog(LogTail logQueue, URI self, String level, String fromLevel); JobLog toRestJobLog(Iterable<LogEvent> logs, URI self); }
ModelFactory { private void toRestPageSummary(PageSummary pageSummary, URI baseUri, Document doc, boolean useVersion, Boolean withPrettyNames) throws XWikiException { XWikiContext xwikiContext = this.xcontextProvider.get(); pageSummary.setWiki(doc.getWiki()); pageSummary.setFullName(doc.getFullName()); pageSummary.setId(doc.getPrefixedFullName()); pageSummary.setSpace(doc.getSpace()); pageSummary.setName(doc.getDocumentReference().getName()); pageSummary.setTitle(doc.getDisplayTitle()); pageSummary.setRawTitle(doc.getTitle()); pageSummary.setXwikiRelativeUrl(doc.getURL("view")); pageSummary.setXwikiAbsoluteUrl(doc.getExternalURL("view")); pageSummary.setTranslations(toRestTranslations(baseUri, doc)); pageSummary.setSyntax(doc.getSyntax().toIdString()); pageSummary.setVersion(doc.getVersion()); pageSummary.setAuthor(doc.getAuthor()); if (withPrettyNames) { pageSummary.setAuthorName(xwikiContext.getWiki().getUserName(doc.getAuthor(), null, false, xwikiContext)); } pageSummary.setParent(doc.getParent()); DocumentReference parentReference = doc.getParentReference(); boolean parentExist = parentReference != null && xwikiContext.getWiki().exists(parentReference, xwikiContext); if (parentExist) { pageSummary.setParentId(this.serializer.serialize(parentReference)); } else { pageSummary.setParentId(""); } List<String> spaces = Utils.getSpacesFromSpaceId(doc.getSpace()); String spaceUri = Utils.createURI(baseUri, SpaceResource.class, doc.getWiki(), spaces).toString(); Link spaceLink = this.objectFactory.createLink(); spaceLink.setHref(spaceUri); spaceLink.setRel(Relations.SPACE); pageSummary.getLinks().add(spaceLink); if (parentExist) { String parentUri = Utils.createURI(baseUri, PageResource.class, parentReference.getWikiReference().getName(), spaces, parentReference.getName()).toString(); Link parentLink = this.objectFactory.createLink(); parentLink.setHref(parentUri); parentLink.setRel(Relations.PARENT); pageSummary.getLinks().add(parentLink); } String historyUri = Utils.createURI(baseUri, PageHistoryResource.class, doc.getWiki(), Utils.getSpacesFromSpaceId(doc.getSpace()), doc.getDocumentReference().getName()).toString(); Link historyLink = this.objectFactory.createLink(); historyLink.setHref(historyUri); historyLink.setRel(Relations.HISTORY); pageSummary.getLinks().add(historyLink); if (!doc.getChildren().isEmpty()) { String pageChildrenUri = Utils.createURI(baseUri, PageChildrenResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); Link pageChildrenLink = this.objectFactory.createLink(); pageChildrenLink.setHref(pageChildrenUri); pageChildrenLink.setRel(Relations.CHILDREN); pageSummary.getLinks().add(pageChildrenLink); } if (!doc.getComments().isEmpty()) { String commentsUri; if (useVersion) { commentsUri = Utils.createURI(baseUri, CommentsVersionResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName(), doc.getVersion()).toString(); } else { commentsUri = Utils.createURI(baseUri, CommentsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); } Link commentsLink = this.objectFactory.createLink(); commentsLink.setHref(commentsUri); commentsLink.setRel(Relations.COMMENTS); pageSummary.getLinks().add(commentsLink); } if (!doc.getAttachmentList().isEmpty()) { String attachmentsUri; if (useVersion) { attachmentsUri = Utils.createURI(baseUri, AttachmentsAtPageVersionResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName(), doc.getVersion()).toString(); } else { attachmentsUri = Utils.createURI(baseUri, AttachmentsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); } Link attachmentsLink = this.objectFactory.createLink(); attachmentsLink.setHref(attachmentsUri); attachmentsLink.setRel(Relations.ATTACHMENTS); pageSummary.getLinks().add(attachmentsLink); } if (!doc.getxWikiObjects().keySet().isEmpty()) { String objectsUri; if (useVersion) { objectsUri = Utils.createURI(baseUri, ObjectsAtPageVersionResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName(), doc.getVersion()).toString(); } else { objectsUri = Utils.createURI(baseUri, ObjectsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); } Link objectsLink = this.objectFactory.createLink(); objectsLink.setHref(objectsUri); objectsLink.setRel(Relations.OBJECTS); pageSummary.getLinks().add(objectsLink); } com.xpn.xwiki.api.Object tagsObject = doc.getObject("XWiki.TagClass", 0); if (tagsObject != null) { if (tagsObject.getProperty("tags") != null) { String tagsUri = Utils.createURI(baseUri, PageTagsResource.class, doc.getWiki(), spaces, doc.getDocumentReference().getName()).toString(); Link tagsLink = this.objectFactory.createLink(); tagsLink.setHref(tagsUri); tagsLink.setRel(Relations.TAGS); pageSummary.getLinks().add(tagsLink); } } String syntaxesUri = Utils.createURI(baseUri, SyntaxesResource.class).toString(); Link syntaxesLink = this.objectFactory.createLink(); syntaxesLink.setHref(syntaxesUri); syntaxesLink.setRel(Relations.SYNTAXES); pageSummary.getLinks().add(syntaxesLink); } ModelFactory(); boolean toDocument(Document doc, org.xwiki.rest.model.jaxb.Page restPage); ObjectSummary toRestObjectSummary(URI baseUri, Document doc, BaseObject xwikiObject, boolean useVersion,
        Boolean withPrettyNames); void toObject(com.xpn.xwiki.api.Object xwikiObject, org.xwiki.rest.model.jaxb.Object restObject); Object toRestObject(URI baseUri, Document doc, BaseObject xwikiObject, boolean useVersion,
        Boolean withPrettyNames); Wiki toRestWiki(URI baseUri, String wikiName); Space toRestSpace(URI baseUri, String wikiName, List<String> spaces, Document home); Translations toRestTranslations(URI baseUri, Document doc); PageSummary toRestPageSummary(URI baseUri, Document doc, Boolean withPrettyNames); Page toRestPage(URI baseUri, URI self, Document doc, boolean useVersion, Boolean withPrettyNames,
        Boolean withObjects, Boolean withXClass, Boolean withAttachments); Class toRestClass(URI baseUri, com.xpn.xwiki.api.Class xwikiClass); Attachment toRestAttachment(URI baseUri, com.xpn.xwiki.api.Attachment xwikiAttachment,
        Boolean withPrettyNames, boolean versionURL); Attachment toRestAttachment(URI baseUri, com.xpn.xwiki.api.Attachment xwikiAttachment,
        String xwikiRelativeUrl, String xwikiAbsoluteUrl, Boolean withPrettyNames, boolean versionURL); Hierarchy toRestHierarchy(EntityReference targetEntityReference, Boolean withPrettyNames); JobRequest toRestJobRequest(Request request); JobId toRestJobId(List<String> id); MapEntry toRestMapEntry(String key, java.lang.Object value); DefaultRequest toJobRequest(JobRequest restJobRequest); JobStatus toRestJobStatus(org.xwiki.job.event.status.JobStatus jobStatus, URI self, boolean request,
        boolean progress, boolean log, String logFromLevel); JobProgress toRestJobProgress(org.xwiki.job.event.status.JobProgress progress); JobLog toRestJobLog(LogTail logQueue, URI self, String level, String fromLevel); JobLog toRestJobLog(Iterable<LogEvent> logs, URI self);  }