diff --git a/config/alfresco/templates/webscripts/org/alfresco/cmis/client/cmisbrowser/connect.post.js b/config/alfresco/templates/webscripts/org/alfresco/cmis/client/cmisbrowser/connect.post.js index 692f3fcfb1..cc31e2729c 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/cmis/client/cmisbrowser/connect.post.js +++ b/config/alfresco/templates/webscripts/org/alfresco/cmis/client/cmisbrowser/connect.post.js @@ -34,5 +34,9 @@ try { model.repoinfo = model.conn.session.repositoryInfo; model.rootFolder = model.conn.session.rootFolder; } catch (e) { + if(connection != null) { + connection.close(); + } + model.error = (e.javaException == null ? e.rhinoException.message : e.javaException.message); } \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/site/site.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/site/site.lib.ftl index e0fa0b3187..49d87b510d 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/site/site.lib.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/site/site.lib.ftl @@ -16,12 +16,22 @@ "customProperties" : { <#list site.customProperties?keys as prop> + <#assign propDetails = site.customProperties[prop]> "${prop}" : { - "name" : "${prop}", - "value" : "${site.customProperties[prop].value?string}", - "type" : "${site.customProperties[prop].type}", - "title" : "${site.customProperties[prop].title}" + "name" : "${prop}", + "value" : + <#if propDetails.value?is_enumerable> + [ + <#list propDetails.value as v> + "${v?string}"<#if v_has_next>, + + ] + <#else> + "${propDetails.value?string}" + , + "type" : <#if propDetails.type??>"${propDetails.type}"<#else>null, + "title" : <#if propDetails.title??>"${propDetails.title}"<#else>null } <#if prop_has_next>, diff --git a/source/java/org/alfresco/repo/cmis/rest/CMISScript.java b/source/java/org/alfresco/repo/cmis/rest/CMISScript.java index 0aabb06d41..5aaf2ebf06 100644 --- a/source/java/org/alfresco/repo/cmis/rest/CMISScript.java +++ b/source/java/org/alfresco/repo/cmis/rest/CMISScript.java @@ -407,7 +407,8 @@ public class CMISScript extends BaseScopableProcessorExtension } Cursor cursor = paging.createCursor(children.length, page); - ScriptNode[] nodes = new ScriptNode[cursor.getRowCount()]; + int cnt = (cursor.getRowCount() < 0 ? 0 : cursor.getRowCount()); + ScriptNode[] nodes = new ScriptNode[cnt]; for (int i = cursor.getStartRow(); i <= cursor.getEndRow(); i++) { nodes[i - cursor.getStartRow()] = new ScriptNode(children[i], services, getScope()); diff --git a/source/java/org/alfresco/repo/web/scripts/site/SiteServiceTest.java b/source/java/org/alfresco/repo/web/scripts/site/SiteServiceTest.java index 5c13d4b833..87c6aafdda 100644 --- a/source/java/org/alfresco/repo/web/scripts/site/SiteServiceTest.java +++ b/source/java/org/alfresco/repo/web/scripts/site/SiteServiceTest.java @@ -20,6 +20,7 @@ package org.alfresco.repo.web.scripts.site; import java.io.Serializable; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -114,7 +115,7 @@ public class SiteServiceTest extends BaseWebScriptTest ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle"); this.personService.createPerson(ppOne); - } + } } @Override @@ -574,11 +575,15 @@ public class SiteServiceTest extends BaseWebScriptTest public void testSiteCustomProperties() throws Exception { - // Create a site with a custom property + QName custPropSingle = QName.createQName(SiteModel.SITE_CUSTOM_PROPERTY_URL, "additionalInformation"); + QName custPropMuliple = QName.createQName(SiteModel.SITE_CUSTOM_PROPERTY_URL, "siteTags"); + + // Create a site with custom properties, one single and one multiple SiteInfo siteInfo = this.siteService.createSite("testPreset", "mySiteWithCustomProperty2", "testTitle", "testDescription", SiteVisibility.PUBLIC); NodeRef siteNodeRef = siteInfo.getNodeRef(); Map properties = new HashMap(1); - properties.put(QName.createQName(SiteModel.SITE_CUSTOM_PROPERTY_URL, "additionalInformation"), "information"); + properties.put(custPropSingle, "information"); + properties.put(custPropMuliple, (Serializable)Arrays.asList(new String[]{ "tag1", "tag2", "tag333" })); this.nodeService.addAspect(siteNodeRef, QName.createQName(SiteModel.SITE_MODEL_URL, "customSiteProperties"), properties); this.createdSites.add("mySiteWithCustomProperty2"); @@ -595,6 +600,18 @@ public class SiteServiceTest extends BaseWebScriptTest assertEquals("{http://www.alfresco.org/model/dictionary/1.0}text", addInfo.get("type")); assertEquals("Additional Site Information", addInfo.get("title")); + JSONObject tags = customProperties.getJSONObject("{http://www.alfresco.org/model/sitecustomproperty/1.0}siteTags"); + assertNotNull(tags); + assertEquals("{http://www.alfresco.org/model/sitecustomproperty/1.0}siteTags", tags.get("name")); + assertEquals(JSONObject.NULL, tags.get("type")); + assertEquals(JSONObject.NULL, tags.get("title")); + // TODO Fix ALF-2707 so this works + System.err.println(response.getContentAsString()); +// JSONArray tagsA = tags.getJSONArray("value"); +// assertEquals(3, tagsA.length()); +// assertEquals("tag1", tagsA.getString(0)); +// assertEquals("tag2", tagsA.getString(1)); +// assertEquals("tag333", tagsA.getString(2)); } /**