();
+ args.put("type", "FOLDER_OBJECT_TYPE");
+ args.put("includePropertyDefinitions", "true");
+ args.put("maxItems", "5");
+ while (typesHREF != null)
+ {
+ Feed types = getFeed(typesHREF, args);
+
+ // TODO: spec issue 40
+ for (Entry type : types.getEntries())
+ {
+ Entry retrievedType = getEntry(type.getSelfLink().getHref());
+ assertEquals(type.getId(), retrievedType.getId());
+ assertEquals(type.getTitle(), retrievedType.getTitle());
+ // TODO: type specific properties - extension to Abdera
+ }
+
+ // next page
+ Link nextLink = types.getLink("next");
+ typesHREF = (nextLink != null) ? nextLink.getHref() : null;
+ args.remove("maxItems");
+ };
+ }
+
// public void testUnfiled()
// {
// }
diff --git a/source/java/org/alfresco/repo/cmis/rest/CMISTypeIdMethod.java b/source/java/org/alfresco/repo/cmis/rest/CMISTypeIdMethod.java
new file mode 100644
index 0000000000..3f2df04d8d
--- /dev/null
+++ b/source/java/org/alfresco/repo/cmis/rest/CMISTypeIdMethod.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.repo.cmis.rest;
+
+import java.util.List;
+
+import org.alfresco.cmis.dictionary.CMISMapping;
+import org.alfresco.cmis.dictionary.CMISTypeId;
+import org.alfresco.repo.jscript.ScriptNode;
+import org.alfresco.repo.template.TemplateNode;
+import org.alfresco.service.namespace.QName;
+
+import freemarker.ext.beans.BeanModel;
+import freemarker.template.TemplateMethodModelEx;
+import freemarker.template.TemplateModelException;
+
+/**
+ * Custom FreeMarker Template language method.
+ *
+ * Retrieve the CMIS Type Id for an Alfresco node
+ *
+ * Usage: cmisTypeId(ScriptNode node)
+ * cmisTypeId(QName nodeType)
+ *
+ * @author davidc
+ */
+public final class CMISTypeIdMethod implements TemplateMethodModelEx
+{
+ private CMISMapping mappingService;
+
+ /**
+ * Construct
+ */
+ public CMISTypeIdMethod(CMISMapping mappingService)
+ {
+ this.mappingService = mappingService;
+ }
+
+ /**
+ * @see freemarker.template.TemplateMethodModel#exec(java.util.List)
+ */
+ public Object exec(List args) throws TemplateModelException
+ {
+ CMISTypeId result = null;
+
+ if (args.size() == 1)
+ {
+ Object arg0 = args.get(0);
+ if (arg0 instanceof BeanModel)
+ {
+ // extract node type qname
+ QName nodeType = null;
+ Object wrapped = ((BeanModel)arg0).getWrappedObject();
+ if (wrapped != null)
+ {
+ if (wrapped instanceof TemplateNode)
+ {
+ nodeType = ((TemplateNode)wrapped).getType();
+ }
+ else if (wrapped instanceof QName)
+ {
+ nodeType = (QName)wrapped;
+ }
+ }
+
+ // convert to CMIS type id
+ if (nodeType != null)
+ {
+ result = mappingService.getCmisTypeId(nodeType);
+ }
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/source/java/org/alfresco/repo/web/scripts/RepositoryContainer.java b/source/java/org/alfresco/repo/web/scripts/RepositoryContainer.java
index 5639dce413..f8ef4c63cf 100644
--- a/source/java/org/alfresco/repo/web/scripts/RepositoryContainer.java
+++ b/source/java/org/alfresco/repo/web/scripts/RepositoryContainer.java
@@ -180,7 +180,6 @@ public class RepositoryContainer extends AbstractRuntimeContainer implements Ten
Map params = new HashMap();
params.putAll(super.getTemplateParameters());
params.put(TemplateService.KEY_IMAGE_RESOLVER, imageResolver.getImageResolver());
- params.put("cropContent", new CropContentMethod());
addRepoParameters(params);
return params;
}
diff --git a/source/java/org/alfresco/repo/web/scripts/TestWebScriptRepoServer.java b/source/java/org/alfresco/repo/web/scripts/TestWebScriptRepoServer.java
index 9a64634fba..8155e1e2eb 100644
--- a/source/java/org/alfresco/repo/web/scripts/TestWebScriptRepoServer.java
+++ b/source/java/org/alfresco/repo/web/scripts/TestWebScriptRepoServer.java
@@ -156,5 +156,5 @@ public class TestWebScriptRepoServer extends TestWebScriptServer
}
}, username);
}
-
+
}
diff --git a/source/java/org/alfresco/repo/web/util/paging/Paging.java b/source/java/org/alfresco/repo/web/util/paging/Paging.java
index bc4f3255ab..fa29066ba9 100644
--- a/source/java/org/alfresco/repo/web/util/paging/Paging.java
+++ b/source/java/org/alfresco/repo/web/util/paging/Paging.java
@@ -24,6 +24,8 @@
*/
package org.alfresco.repo.web.util.paging;
+import java.util.Map;
+
/**
* Paging. A utility for maintaining paged indexes for a collection of N items.
*
@@ -134,6 +136,90 @@ public class Paging
{
return zeroBasedRow;
}
+
+ /**
+ * Create a Page or Window from standardised request arguments / headers
+ *
+ * For Paged based index (take precedence over window based index, if both are specified):
+ *
+ * - request args
+ * pageNo => page number index
+ * pageSize => size of page
+ *
+ * For Window based index (as defined by CMIS):
+ *
+ * - request args (take precedence over header values if both are specified)
+ * skipCount => row number start index
+ * maxItems => size of page
+ *
+ * - header values
+ * CMIS-skipCount => row number start index
+ * CMIS-maxItems => size of page
+ *
+ * @param args request args
+ * @param headers request headers
+ * @return page (if pageNumber driven) or window (if skipCount driven)
+ */
+ public Page createPageOrWindow(Map args, Map headers)
+ {
+ // page number
+ String strPageNo = args.get("pageNo");
+ Integer pageNo = null;
+ if (strPageNo != null)
+ {
+ try
+ {
+ pageNo = new Integer(strPageNo);
+ }
+ catch(NumberFormatException e) {};
+ }
+
+ // page size
+ String strPageSize = args.get("pageSize");
+ Integer pageSize = null;
+ if (strPageSize != null)
+ {
+ try
+ {
+ pageSize = new Integer(strPageSize);
+ }
+ catch(NumberFormatException e) {};
+ }
+
+ // skip count
+ String strSkipCount = args.get("skipCount");
+ if (strSkipCount == null)
+ {
+ strSkipCount = (headers == null) ? null : headers.get("CMIS-skipCount");
+ }
+ Integer skipCount = null;
+ if (strSkipCount != null)
+ {
+ try
+ {
+ skipCount = new Integer(strSkipCount);
+ }
+ catch(NumberFormatException e) {};
+ }
+
+ // max items
+ String strMaxItems = args.get("maxItems");
+ if (strMaxItems == null)
+ {
+ strMaxItems = (headers == null) ? null : headers.get("CMIS-maxItems");
+ }
+ Integer maxItems = null;
+ if (strMaxItems != null)
+ {
+ try
+ {
+ maxItems = new Integer(strMaxItems);
+ }
+ catch(NumberFormatException e) {};
+ }
+
+ return createPageOrWindow(pageNo, pageSize, skipCount, maxItems);
+ }
/**
* Create a Page or Window
@@ -146,13 +232,13 @@ public class Paging
*/
public Page createPageOrWindow(Integer pageNumber, Integer pageSize, Integer skipCount, Integer maxItems)
{
- if (pageNumber != null)
+ if (pageNumber != null || pageSize != null)
{
- return createPage(pageNumber, pageSize == null ? 0 : pageSize);
+ return createPage(pageNumber == null ? isZeroBasedPage() ? 0 : 1 : pageNumber, pageSize == null ? 0 : pageSize);
}
- else if (skipCount != null)
+ else if (skipCount != null || maxItems != null)
{
- return createWindow(skipCount, maxItems == null ? 0 : maxItems);
+ return createWindow(skipCount == null ? isZeroBasedRow() ? 0 : 1 : skipCount, maxItems == null ? 0 : maxItems);
}
return createUnlimitedPage();
}