Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature restimprovements #56

Closed
wants to merge 20 commits into from
Closed
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9889a1b
XWIKI-7966 Missing rest features for search and page listing needed f…
ldubost Jun 24, 2012
8916f29
XWIKI-7966 Missing rest features for search and page listing needed f…
ldubost Jun 24, 2012
1ad2712
XWIKI-7966 Missing rest features for search and page listing needed f…
ldubost Jun 24, 2012
b35646c
XWIKI-7966 Missing rest features for search and page listing needed f…
ldubost Jun 24, 2012
d221322
XWIKI-7966 Missing rest features for search and page listing needed f…
ldubost Jun 24, 2012
25bbb22
XWIKI-7966 Missing rest features for search and page listing needed f…
ldubost Jun 24, 2012
6ab1de1
XWIKI-7966 Missing rest features for search and page listing needed f…
ldubost Jun 24, 2012
e0ed9b2
XWIKI-7966 Missing rest features for search and page listing needed f…
ldubost Jun 24, 2012
4457d28
XWIKI-7966 Missing rest features for search and page listing needed f…
ldubost Jun 24, 2012
0b494ba
XWIKI-7966 Missing rest features for search and page listing needed f…
ldubost Jun 24, 2012
5f1207a
XWIKI-7966 Missing rest features for search and page listing needed f…
ldubost Jul 21, 2012
bd49bcc
XWIKI-7966 Missing rest features for search and page listing needed f…
ldubost Jul 21, 2012
fb915b3
XWIKI-7966 Missing rest features for search and page listing needed f…
ldubost Jul 27, 2012
b79167c
XWIKI-7966 Missing rest features for search and page listing needed f…
ldubost Jul 27, 2012
b49e733
XWIKI-7966 Missing rest features for search and page listing needed f…
ldubost Jul 27, 2012
fbdb7ac
Merge branch 'master' of git://github.com/xwiki/xwiki-platform into f…
ldubost Oct 5, 2012
7a0f70a
XWIKI-7966 Missing rest features for search and page listing needed f…
ldubost Oct 5, 2012
478ed62
Merge branch 'master' of git://github.com/xwiki/xwiki-platform into f…
ldubost Oct 7, 2012
179f23d
XWIKI-7966 Missing rest features for search and page listing needed f…
ldubost Oct 10, 2012
2be818c
XWIKI-7966 Missing rest features for search and page listing needed f…
ldubost Oct 10, 2012
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -260,7 +260,12 @@
<exclude>org/xwiki/uiextension/UIExtension</exclude>
<!-- Added a common method to all elements to set all the data from another element -->
<!-- Technically this does not really break anything because all elements are supposed to extends BaseElement -->
<exclude>com/xpn/xwiki/objects/ElementInterface</exclude>
<exclude>com.xpn.xwiki.objects.ElementInterface</exclude>
<!-- Ignoring error on field version which has been moved from Page to PageSummary which is the superclass of Page -->
<exclude>org/xwiki/rest/model/jaxb/Page</exclude>
<!-- Ignoring error on rest DomainObjectFactory as it is internal code -->
<exclude>org/xwiki/rest/DomainObjectFactory</exclude>
<exclude>org/xwiki/rest/resources/**</exclude>
</excludes>
</configuration>
</plugin>
@@ -105,6 +105,9 @@
<element name="title" type="string"></element>
<element name="parent" type="string"></element>
<element name="parentId" type="string"></element>
<element name="version" type="string"></element>
<element name="author" type="string"></element>
<element name="authorName" type="string"></element>
<element name="xwikiRelativeUrl" type="string"></element>
<element name="xwikiAbsoluteUrl" type="string"></element>
<element name="translations" type="xwiki:Translations"></element>
@@ -119,13 +122,14 @@
<extension base="xwiki:PageSummary">
<sequence>
<element name="language" type="string"></element>
<element name="version" type="string"></element>
<element name="majorVersion" type="int"></element>
<element name="minorVersion" type="int"></element>
<element name="created" type="dateTime"></element>
<element name="creator" type="string"></element>
<element name="creatorName" type="string"></element>
<element name="modified" type="dateTime"></element>
<element name="modifier" type="string"></element>
<element name="modifierName" type="string"></element>
<element name="content" type="string"></element>
</sequence>
</extension>
@@ -145,6 +149,7 @@
<element name="minorVersion" type="int"></element>
<element name="modified" type="dateTime"></element>
<element name="modifier" type="string"></element>
<element name="modifierName" type="string"></element>
<element name="language" type="string"></element>
</sequence>
</extension>
@@ -163,6 +168,7 @@
<element name="pageVersion" type="string"></element>
<element name="mimeType" type="string"></element>
<element name="author" type="string"></element>
<element name="authorName" type="string"></element>
<element name="date" type="dateTime"></element>
<element name="xwikiRelativeUrl" type="string"></element>
<element name="xwikiAbsoluteUrl" type="string"></element>
@@ -178,6 +184,7 @@
<element name="id" type="int"></element>
<element name="pageId" type="string"></element>
<element name="author" type="string"></element>
<element name="authorName" type="string"></element>
<element name="date" type="dateTime"></element>
<element name="highlight" type="string"></element>
<element name="text" type="string"></element>
@@ -194,9 +201,12 @@
<element name="id" type="string"></element>
<element name="guid" type="string"></element>
<element name="pageId" type="string"></element>
<element name="pageVersion" type="string"></element>
<element name="wiki" type="string"></element>
<element name="space" type="string"></element>
<element name="pageName" type="string"></element>
<element name="pageAuthor" type="string"></element>
<element name="pageAuthorName" type="string"></element>
<element name="className" type="string"></element>
<element name="number" type="int"></element>
<element name="headline" type="string"></element>
@@ -443,13 +453,21 @@
<element name="type" type="string"></element>
<element name="id" type="string"></element>
<element name="pageFullName" type="string"></element>
<element name="title" type="string"></element>
<element name="wiki" type="string"></element>
<element name="space" type="string"></element>
<element name="pageName" type="string"></element>
<element name="modified" type="dateTime"></element>
<element name="author" type="string"></element>
<element name="authorName" type="string"></element>
<element name="version" type="string"></element>
<element name="language" type="string"></element>
<element name="className" type="string" minOccurs="0"></element>
<element name="objectNumber" type="int" minOccurs="0"></element>
</sequence>
<element name="filename" type="string" minOccurs="0"></element>
<element name="score" type="float" minOccurs="0"></element>
<element name="object" type="xwiki:Object" minOccurs="0"></element>
</sequence>
</extension>
</complexContent>
</complexType>
@@ -482,4 +500,4 @@
</complexType>

<element name="syntaxes" type="xwiki:Syntaxes"></element>
</schema>
</schema>
@@ -81,6 +81,11 @@
<artifactId>xwiki-commons-component-api</artifactId>
<version>${commons.version}</version>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-search-lucene</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-fluent-api</artifactId>
@@ -163,6 +168,7 @@
org/xwiki/rest/resources/wikis/WikiAttachmentsResource.java,
org/xwiki/rest/resources/wikis/WikiPagesResource.java,
org/xwiki/rest/resources/wikis/WikiSearchResource.java,
org/xwiki/rest/resources/wikis/WikiSearchQueryResource.java,
org/xwiki/rest/resources/wikis/WikisResource.java,
org/xwiki/rest/Utils.java,
org/xwiki/rest/XWikiAuthentication.java,
@@ -81,6 +81,7 @@
import org.xwiki.rest.resources.spaces.SpaceSearchResource;
import org.xwiki.rest.resources.spaces.SpacesResource;
import org.xwiki.rest.resources.wikis.WikiSearchResource;
import org.xwiki.rest.resources.wikis.WikiSearchQueryResource;
import org.xwiki.rest.resources.wikis.WikisResource;

import com.xpn.xwiki.XWikiContext;
@@ -150,6 +151,12 @@ public static Wiki createWiki(ObjectFactory objectFactory, URI baseUri, String w
searchLink.setRel(Relations.SEARCH);
wiki.getLinks().add(searchLink);

String queryUri = UriBuilder.fromUri(baseUri).path(WikiSearchQueryResource.class).build(wikiName).toString();
Link queryLink = objectFactory.createLink();
queryLink.setHref(queryUri);
queryLink.setRel(Relations.QUERY);
wiki.getLinks().add(queryLink);

return wiki;
}

@@ -255,7 +262,7 @@ public static Translations createTranslations(ObjectFactory objectFactory, URI b

/* This method is used to fill the "common part" of a Page and a PageSummary */
private static void fillPageSummary(PageSummary pageSummary, ObjectFactory objectFactory, URI baseUri,
Document doc, boolean useVersion, XWiki xwikiApi) throws XWikiException
Document doc, boolean useVersion, XWiki xwikiApi, Boolean withPrettyNames) throws XWikiException
{
pageSummary.setWiki(doc.getWiki());
pageSummary.setFullName(doc.getFullName());
@@ -267,6 +274,10 @@ private static void fillPageSummary(PageSummary pageSummary, ObjectFactory objec
pageSummary.setXwikiAbsoluteUrl(doc.getExternalURL("view"));
pageSummary.setTranslations(createTranslations(objectFactory, baseUri, doc));
pageSummary.setSyntax(doc.getSyntaxId());
pageSummary.setVersion(doc.getVersion());
pageSummary.setAuthor(doc.getAuthor());
if (withPrettyNames)
pageSummary.setAuthorName(xwikiApi.getUserName(doc.getAuthor(), false));

Document parent = Utils.getParentDocument(doc, xwikiApi);
pageSummary.setParent(doc.getParent());
@@ -386,11 +397,11 @@ private static void fillPageSummary(PageSummary pageSummary, ObjectFactory objec
pageSummary.getLinks().add(syntaxesLink);
}

public static PageSummary createPageSummary(ObjectFactory objectFactory, URI baseUri, Document doc, XWiki xwikiApi)
public static PageSummary createPageSummary(ObjectFactory objectFactory, URI baseUri, Document doc, XWiki xwikiApi, Boolean withPrettyNames)
throws XWikiException
{
PageSummary pageSummary = objectFactory.createPageSummary();
fillPageSummary(pageSummary, objectFactory, baseUri, doc, false, xwikiApi);
fillPageSummary(pageSummary, objectFactory, baseUri, doc, false, xwikiApi, withPrettyNames);

String pageUri =
UriBuilder.fromUri(baseUri).path(PageResource.class).build(doc.getWiki(), doc.getSpace(), doc.getName())
@@ -404,22 +415,27 @@ public static PageSummary createPageSummary(ObjectFactory objectFactory, URI bas
}

public static Page createPage(ObjectFactory objectFactory, URI baseUri, URI self, Document doc, boolean useVersion,
XWiki xwikiApi) throws XWikiException
XWiki xwikiApi, Boolean withPrettyNames) throws XWikiException
{
Page page = objectFactory.createPage();
fillPageSummary(page, objectFactory, baseUri, doc, useVersion, xwikiApi);
fillPageSummary(page, objectFactory, baseUri, doc, useVersion, xwikiApi, withPrettyNames);

page.setVersion(doc.getVersion());
page.setMajorVersion(doc.getRCSVersion().at(0));
page.setMinorVersion(doc.getRCSVersion().at(1));
page.setLanguage(doc.getLanguage());
page.setCreator(doc.getCreator());
if (withPrettyNames)
page.setCreatorName(xwikiApi.getUserName(doc.getCreator(), false));

Calendar calendar = Calendar.getInstance();
calendar.setTime(doc.getCreationDate());
page.setCreated(calendar);

page.setModifier(doc.getContentAuthor());
if (withPrettyNames)
page.setModifierName(xwikiApi.getUserName(doc.getContentAuthor(), false));


calendar = Calendar.getInstance();
calendar.setTime(doc.getContentUpdateDate());
@@ -449,7 +465,7 @@ public static Page createPage(ObjectFactory objectFactory, URI baseUri, URI self
}

public static HistorySummary createHistorySummary(ObjectFactory objectFactory, URI baseUri, String wikiName,
String spaceName, String pageName, String language, Version version, String modifier, Date modified)
String spaceName, String pageName, String language, Version version, String modifier, Date modified, XWiki xwikiApi, Boolean withPrettyNames)
{
HistorySummary historySummary = objectFactory.createHistorySummary();

@@ -463,6 +479,9 @@ public static HistorySummary createHistorySummary(ObjectFactory objectFactory, U
historySummary.setMajorVersion(version.at(0));
historySummary.setMinorVersion(version.at(1));
historySummary.setModifier(modifier);
if (withPrettyNames)
historySummary.setModifierName(xwikiApi.getUserName(modifier, false));

historySummary.setLanguage(language);

Calendar calendar = Calendar.getInstance();
@@ -491,7 +510,7 @@ public static HistorySummary createHistorySummary(ObjectFactory objectFactory, U
}

private static void fillAttachment(Attachment attachment, ObjectFactory objectFactory, URI baseUri,
com.xpn.xwiki.api.Attachment xwikiAttachment, String xwikiRelativeUrl, String xwikiAbsoluteUrl)
com.xpn.xwiki.api.Attachment xwikiAttachment, String xwikiRelativeUrl, String xwikiAbsoluteUrl, XWiki xwikiApi, Boolean withPrettyNames)
{
Document doc = xwikiAttachment.getDocument();

@@ -503,6 +522,8 @@ private static void fillAttachment(Attachment attachment, ObjectFactory objectFa
attachment.setPageVersion(doc.getVersion());
attachment.setMimeType(xwikiAttachment.getMimeType());
attachment.setAuthor(xwikiAttachment.getAuthor());
if (withPrettyNames)
attachment.setAuthorName(xwikiApi.getUserName(xwikiAttachment.getAuthor(), false));

Calendar calendar = Calendar.getInstance();
calendar.setTime(xwikiAttachment.getDate());
@@ -561,11 +582,11 @@ protected static String createAttachmentUri(URI baseUri, com.xpn.xwiki.api.Attac
}

public static Attachment createAttachment(ObjectFactory objectFactory, URI baseUri,
com.xpn.xwiki.api.Attachment xwikiAttachment, String xwikiRelativeUrl, String xwikiAbsoluteUrl)
com.xpn.xwiki.api.Attachment xwikiAttachment, String xwikiRelativeUrl, String xwikiAbsoluteUrl, XWiki xwikiApi, Boolean withPrettyNames)
{
Attachment attachment = objectFactory.createAttachment();

fillAttachment(attachment, objectFactory, baseUri, xwikiAttachment, xwikiRelativeUrl, xwikiAbsoluteUrl);
fillAttachment(attachment, objectFactory, baseUri, xwikiAttachment, xwikiRelativeUrl, xwikiAbsoluteUrl, xwikiApi, withPrettyNames);

String attachmentUri = createAttachmentUri(baseUri, xwikiAttachment, xwikiAttachment.getDocument(), false);

@@ -578,11 +599,11 @@ public static Attachment createAttachment(ObjectFactory objectFactory, URI baseU
}

public static Attachment createAttachmentAtVersion(ObjectFactory objectFactory, URI baseUri,
com.xpn.xwiki.api.Attachment xwikiAttachment, String xwikiRelativeUrl, String xwikiAbsoluteUrl)
com.xpn.xwiki.api.Attachment xwikiAttachment, String xwikiRelativeUrl, String xwikiAbsoluteUrl, XWiki xwikiApi, Boolean withPrettyNames)
{
Attachment attachment = new Attachment();

fillAttachment(attachment, objectFactory, baseUri, xwikiAttachment, xwikiRelativeUrl, xwikiAbsoluteUrl);
fillAttachment(attachment, objectFactory, baseUri, xwikiAttachment, xwikiRelativeUrl, xwikiAbsoluteUrl, xwikiApi, withPrettyNames);

Document doc = xwikiAttachment.getDocument();

@@ -597,14 +618,16 @@ public static Attachment createAttachmentAtVersion(ObjectFactory objectFactory,
}

public static Comment createComment(ObjectFactory objectFactory, URI baseUri, Document doc,
com.xpn.xwiki.api.Object xwikiComment)
com.xpn.xwiki.api.Object xwikiComment, XWiki xwikiApi, Boolean withPrettyNames)
{
Comment comment = objectFactory.createComment();
comment.setId(xwikiComment.getNumber());

com.xpn.xwiki.api.Property property = xwikiComment.getProperty("author");
if (property != null) {
comment.setAuthor((String) property.getValue());
if (withPrettyNames)
comment.setAuthorName(xwikiApi.getUserName((String) property.getValue(), false));
}

property = xwikiComment.getProperty("date");
@@ -641,11 +664,17 @@ public static Comment createComment(ObjectFactory objectFactory, URI baseUri, Do
}

private static void fillObjectSummary(ObjectSummary objectSummary, ObjectFactory objectFactory, URI baseUri,
Document doc, BaseObject xwikiObject) throws XWikiException
Document doc, BaseObject xwikiObject, XWiki xwikiApi, Boolean withPrettyNames) throws XWikiException
{


objectSummary.setId(String.format("%s:%s", doc.getPrefixedFullName(), xwikiObject.getGuid()));
objectSummary.setGuid(xwikiObject.getGuid());
objectSummary.setPageId(doc.getPrefixedFullName());
objectSummary.setPageVersion(doc.getVersion());
objectSummary.setPageAuthor(doc.getAuthor());
if (withPrettyNames)
objectSummary.setPageAuthorName(xwikiApi.getUserName(doc.getAuthor(), false));
objectSummary.setWiki(doc.getWiki());
objectSummary.setSpace(doc.getSpace());
objectSummary.setPageName(doc.getName());
@@ -660,10 +689,10 @@ private static void fillObjectSummary(ObjectSummary objectSummary, ObjectFactory
}

public static ObjectSummary createObjectSummary(ObjectFactory objectFactory, URI baseUri,
XWikiContext xwikiContext, Document doc, BaseObject xwikiObject, boolean useVersion) throws XWikiException
XWikiContext xwikiContext, Document doc, BaseObject xwikiObject, boolean useVersion, XWiki xwikiApi, Boolean withPrettyNames) throws XWikiException
{
ObjectSummary objectSummary = objectFactory.createObjectSummary();
fillObjectSummary(objectSummary, objectFactory, baseUri, doc, xwikiObject);
fillObjectSummary(objectSummary, objectFactory, baseUri, doc, xwikiObject, xwikiApi, withPrettyNames);

Link objectLink = getObjectLink(objectFactory, baseUri, doc, xwikiObject, useVersion, Relations.OBJECT);
objectSummary.getLinks().add(objectLink);
@@ -695,10 +724,10 @@ public static ObjectSummary createObjectSummary(ObjectFactory objectFactory, URI
}

public static Object createObject(ObjectFactory objectFactory, URI baseUri, XWikiContext xwikiContext,
Document doc, BaseObject xwikiObject, boolean useVersion) throws XWikiException
Document doc, BaseObject xwikiObject, boolean useVersion, XWiki xwikiApi, Boolean withPrettyNames) throws XWikiException
{
Object object = objectFactory.createObject();
fillObjectSummary(object, objectFactory, baseUri, doc, xwikiObject);
fillObjectSummary(object, objectFactory, baseUri, doc, xwikiObject, xwikiApi, withPrettyNames);

BaseClass xwikiClass = xwikiObject.getXClass(xwikiContext);

@@ -78,6 +78,8 @@

public static final String SEARCH = "http://www.xwiki.org/rel/search";

public static final String QUERY = "http://www.xwiki.org/rel/query";

public static final String SYNTAXES = "http://www.xwiki.org/rel/syntaxes";

}
@@ -27,6 +27,7 @@
import com.xpn.xwiki.XWikiException;
import com.xpn.xwiki.api.Document;
import com.xpn.xwiki.doc.XWikiDocument;
import com.xpn.xwiki.objects.BaseObject;
import com.xpn.xwiki.user.api.XWikiUser;

/**
@@ -216,4 +217,38 @@ public static String getXWikiUser(ComponentManager componentManager)

return user.getUser();
}

/**
* <p>
* Retrieve the XWiki private API object
* </p>
*
* @param componentManager The component manager to be used to retrieve the execution context.
* @return The XWiki private API object.
*/
public static String getAuthorName(String author, ComponentManager componentManager)
{
return getXWikiContext(componentManager).getWiki().getUserName(author, null, false, getXWikiContext(componentManager));
}

/**
* <p>
* Retrieve the BaseObject from the Document
* </p>
* @param doc Public API document
* @param className Classname
* @param objectNumber Object Number
* @return The BaseObject field
* @throws XWikiException
*/
public static BaseObject getBaseObject(Document doc, String className, int objectNumber, ComponentManager componentManager) throws XWikiException
{
XWikiDocument xwikiDocument =
Utils.getXWiki(componentManager).getDocument(doc.getPrefixedFullName(),
Utils.getXWikiContext(componentManager));

return xwikiDocument.getObject(className, objectNumber);
}


}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.