Merged HEAD (5.2) to 5.2.N (5.2.1)

126453 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)
      122165 gjames: RA-823 Adding an interface


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126798 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ancuta Morarasu
2016-05-11 11:22:59 +00:00
parent 89702bf9d0
commit c251e39309
3 changed files with 50 additions and 6 deletions

View File

@@ -27,6 +27,7 @@ package org.alfresco.rest.framework.jacksonextensions;
import java.io.IOException;
import org.alfresco.rest.framework.resource.SerializablePagedCollection;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.webscripts.ResourceWebScriptHelper;
import org.codehaus.jackson.JsonGenerationException;
@@ -36,21 +37,21 @@ import org.codehaus.jackson.map.SerializerProvider;
import org.codehaus.jackson.map.ser.std.SerializerBase;
/**
* Serializes CollectionWithPagingInfo into the correct response format, with Paging information and entries//
* Serializes SerializablePagedCollection into the correct response format, with Paging information and entries
*
* @author Gethin James
*/
@SuppressWarnings("rawtypes")
public class SerializerOfCollectionWithPaging extends SerializerBase<CollectionWithPagingInfo>
public class SerializerOfCollectionWithPaging extends SerializerBase<SerializablePagedCollection>
{
protected SerializerOfCollectionWithPaging()
{
super(CollectionWithPagingInfo.class);
super(SerializablePagedCollection.class);
}
@Override
public void serialize(CollectionWithPagingInfo pagedCol, JsonGenerator jgen, SerializerProvider provider)
public void serialize(SerializablePagedCollection pagedCol, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonGenerationException
{
if (pagedCol != null)
@@ -65,7 +66,7 @@ public class SerializerOfCollectionWithPaging extends SerializerBase<CollectionW
}
}
private void serializePagination(CollectionWithPagingInfo pagedCol, JsonGenerator jgen) throws IOException,
private void serializePagination(SerializablePagedCollection pagedCol, JsonGenerator jgen) throws IOException,
JsonProcessingException
{
jgen.writeFieldName("pagination");

View File

@@ -0,0 +1,37 @@
package org.alfresco.rest.framework.resource;
import org.alfresco.rest.framework.resource.parameters.Paging;
import java.util.Collection;
/**
* A specialist representation of a Collection that can be serialized to json with paging information
*
* @author Gethin James.
*/
public interface SerializablePagedCollection<T>
{
/**
* Returns the Collection object
* @return Collection
*/
Collection<T> getCollection();
/**
* Indicates if the returned collection has more items after the current returned list.
*/
boolean hasMoreItems();
/**
* Indicates the total number of items available.
*
* Can be greater than the number of items returned in the list.
*
*/
Integer getTotalItems();
/**
* The requested paging parameters set by the client
*/
Paging getPaging();
}

View File

@@ -25,6 +25,8 @@
*/
package org.alfresco.rest.framework.resource.parameters;
import org.alfresco.rest.framework.resource.SerializablePagedCollection;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -40,7 +42,7 @@ import java.util.Collections;
*
* @author Gethin James.
*/
public class CollectionWithPagingInfo<T>
public class CollectionWithPagingInfo<T> implements SerializablePagedCollection
{
private final Collection<T> collection;
@@ -120,6 +122,7 @@ public class CollectionWithPagingInfo<T>
* Returns the Collection object
* @return Collection
*/
@Override
public Collection<T> getCollection()
{
return this.collection;
@@ -128,6 +131,7 @@ public class CollectionWithPagingInfo<T>
/**
* Indicates if the returned collection has more items after the current returned list.
*/
@Override
public boolean hasMoreItems()
{
return this.hasMoreItems;
@@ -139,6 +143,7 @@ public class CollectionWithPagingInfo<T>
* Can be greater than the number of items returned in the list.
*
*/
@Override
public Integer getTotalItems()
{
return this.totalItems;
@@ -147,6 +152,7 @@ public class CollectionWithPagingInfo<T>
/**
* The requested paging parameters set by the client
*/
@Override
public Paging getPaging()
{
return this.paging;