diff --git a/config/alfresco/templates/webscripts/org/alfresco/office/navigation.get.html.ftl b/config/alfresco/templates/webscripts/org/alfresco/office/navigation.get.html.ftl index 5a92e8cd65..e2b3e3d2c8 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/office/navigation.get.html.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/office/navigation.get.html.ftl @@ -104,14 +104,15 @@ <#assign spacesFound = 0> <#list thisSpace.children?sort_by('name') as child> - <#if child.isContainer> + <#if child.isContainer || (child.typeShort = "app:folderlink")> <#assign spacesFound = spacesFound + 1> + <#assign destId><#if child.isContainer>${child.id}<#else>${child.properties.destination.id}
- ${message( + ${message( - + ${child.name?html} <#if child.properties.description??> @@ -134,30 +135,33 @@
<#assign documentsFound = 0> <#list thisSpace.children?sort_by('name') as child> - <#if child.isDocument> - <#assign isVersionable = child.hasAspect("cm:versionable")> + <#if child.isDocument || (child.typeShort = "app:filelink")> + <#if child.isDocument><#assign doc = child><#else><#assign doc = child.properties.destination> + <#assign isVersionable = doc.hasAspect("cm:versionable")> <#assign documentsFound = documentsFound + 1> - <#assign relativePath = child.displayPath?substring(chLen + 1) + '/' + child.name /> + <#assign relativePath = doc.displayPath?substring(chLen + 1) + '/' + doc.name> <#assign isSupportedExtn = false> <#list extList as ext> - <#if child.name?ends_with(ext)> + <#if doc.name?ends_with(ext)> <#assign isSupportedExtn = true> <#break>
- <#if child.name?ends_with(extn) || child.name?ends_with(extnx) || isSupportedExtn> - Open ${child.name?html} + <#assign icon = child.icon32> + <#if child.typeShort = "app:filelink"><#assign icon = "/images/filetypes32/url.gif"> + <#if doc.name?ends_with(extn) || doc.name?ends_with(extnx) || isSupportedExtn> + Open ${doc.name?html} <#else> - Open ${child.name?html} + Open ${doc.name?html} - <#if child.name?ends_with(extn) || child.name?ends_with(extnx) || isSupportedExtn> - ${child.name?html} + <#if doc.name?ends_with(extn) || doc.name?ends_with(extnx) || isSupportedExtn> + ${child.name?html} <#else> - ${child.name?html} + ${child.name?html}
<#if child.properties.description??> @@ -166,17 +170,19 @@ ${message("office.property.modified")}: ${child.properties.modified?datetime}, ${message("office.property.size")}: ${(child.size / 1024)?int}${message("office.unit.kb")}
- <#if child.isLocked > + <#if child.isDocument> + <#if child.isLocked > Locked - <#elseif child.hasAspect("cm:workingcopy")> + <#elseif child.hasAspect("cm:workingcopy")> ${message( - <#else> + <#else> ${message( - + ${message( ${message( - <#if !child.name?ends_with(".pdf")> + <#if !child.name?ends_with(".pdf")> ${message( + <#if !child.isLocked> ${message( diff --git a/config/alfresco/templates/webscripts/org/alfresco/office/searchResults.get.html.ftl b/config/alfresco/templates/webscripts/org/alfresco/office/searchResults.get.html.ftl index 8451ff7712..b798257be2 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/office/searchResults.get.html.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/office/searchResults.get.html.ftl @@ -21,41 +21,47 @@ <#else> <#assign totalResults = results?size> <#list results?sort_by(["properties","cm:modified"])?reverse as child> + <#assign dest = child> + <#if child.typeShort = "app:filelink" || child.typeShort = "app:folderlink"><#assign dest = child.properties.destination> <#assign resCount=resCount + 1> <#assign isSupportedExtn = false> - <#list extList as ext> - <#if child.name?ends_with(ext)> - <#assign isSupportedExtn = true> - <#break> - - - <#if child.isDocument> - <#assign relativePath = child.displayPath?substring(chLen + 1) + '/' + child.name /> - <#if child.name?ends_with(extn) || child.name?ends_with(extnx) || isSupportedExtn> + <#if child.isDocument || (child.typeShort = "app:filelink")> + <#assign relativePath = dest.displayPath?substring(chLen + 1) + '/' + dest.name /> + <#list extList as ext> + <#if dest.name?ends_with(ext)> + <#assign isSupportedExtn = true> + <#break> + + + <#if dest.name?ends_with(extn) || dest.name?ends_with(extnx) || isSupportedExtn> <#assign openURL = "#"> <#assign hrefExtra = " onClick=\"ExternalComponent.openDocument('${relativePath?js_string}')\""> <#else> - <#assign openURL = "${url.context}${child.url}"> + <#assign openURL = "${url.context}${dest.url}"> <#assign hrefExtra = " target=\"_blank\""> <#else> - <#assign openURL = "${url.serviceContext}/office/navigation?p=${path?url}&e=${extn}&n=${child.id}&search=${searchString?url}&maxresults=${maxresults}"> + <#assign openURL = "${url.serviceContext}/office/navigation?p=${path?url}&e=${extn}&n=${dest.id}&search=${searchString?url}&maxresults=${maxresults}"> <#assign hrefExtra = "">
- ${message( + <#assign icon = child.icon32> + <#if child.typeShort = "app:filelink"><#assign icon = "/images/filetypes32/url.gif"> + ${message( - ${child.name?html} + ${child.name?html}
<#if child.properties.description??> <#if (child.properties.description?length > 0)> ${child.properties.description?html}
- <#if child.isDocument> + <#if child.isDocument || (child.typeShort = "app:filelink")> ${message("office.property.modified")}: ${child.properties.modified?datetime} (${(child.size / 1024)?int}${message("office.unit.kb")})
+ + <#if child.isDocument> <#if child.isLocked > ${message( <#elseif child.hasAspect("cm:workingcopy")> @@ -68,6 +74,8 @@ <#if !child.name?ends_with(".pdf")> ${message( + + <#if child.isDocument || (child.typeShort = "app:filelink")> <#if !child.isLocked> ${message( diff --git a/config/alfresco/templates/webscripts/org/alfresco/portlets/mytasks.get.html.ftl b/config/alfresco/templates/webscripts/org/alfresco/portlets/mytasks.get.html.ftl index 0c80f596b3..e952332feb 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/portlets/mytasks.get.html.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/portlets/mytasks.get.html.ftl @@ -250,7 +250,6 @@ font-size: 12px; margin: 0px; padding: 0px; - display: none; overflow: hidden; } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/post.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/post.lib.ftl index cb88134162..a090ce1177 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/post.lib.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/post.lib.ftl @@ -81,7 +81,7 @@ "replyCount": <#if post.sourceAssocs["cm:references"]??>${post.sourceAssocs["cm:references"]?size?c}<#else>0, "permissions": { - "edit": ${post.hasPermission("Write")?string}, + "edit": ${postData.canEdit?string}, "reply": ${post.parent.hasPermission("CreateChildren")?string}, "delete": ${post.hasPermission("Delete")?string} } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/topicpost.lib.js b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/topicpost.lib.js index 87f73fdcce..b6c838062b 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/topicpost.lib.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/topicpost.lib.js @@ -72,6 +72,7 @@ function getTopicPostDataFromTopicAndPosts(topicNode, posts) item.isTopicPost = true; item.topic = topicNode; item.post = posts[0]; + item.canEdit = canUserEditPost(item.post); item.author = people.getPerson(item.post.properties["cm:creator"]); item.totalReplyCount = posts.length - 1; // in case of replies, find the last reply @@ -102,6 +103,40 @@ function getReplyPostData(post) var item = {}; item.isTopicPost = false; item.post = post; + item.canEdit = canUserEditPost(item.post); item.author = people.getPerson(item.post.properties["cm:creator"]); return item; } + +/** + * Returns true if the current user can edit the post. + * + * Site managers can edit any post, everyone else should only + * be able to edit their own posts. + */ +function canUserEditPost(post) +{ + // see if user has write permission first of all + var canEdit = post.hasPermission("Write"); + + // if current user is not the same user as the author check + // that they are a site manager otherwise they can't edit the post + if (canEdit) + { + // get the site id + var siteId = url.templateArgs.site; + + if (siteId !== null) + { + var username = person.properties["cm:userName"]; + var postAuthor = post.properties["cm:creator"]; + + if (username != postAuthor) + { + canEdit = siteService.isSiteManager(siteId); + } + } + } + + return canEdit; +} diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerchildren.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerchildren.get.js index fa563029d0..53d18c43bb 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerchildren.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerchildren.get.js @@ -285,8 +285,8 @@ function findUsers(searchTerm, maxResults, results) { searchTerm = searchTerm.replace(/\"/g, ""); - query += ' AND (@cm\\:firstName:"*' + searchTerm + '*" @cm\\:lastName:"*' + searchTerm + - '*" @cm\\:userName:' + searchTerm + '* )'; + query += ' AND (@cm\\:firstName:"' + searchTerm + '*" @cm\\:lastName:"' + searchTerm + + '*" @cm\\:userName:"' + searchTerm + '*" )'; } if (logger.isLoggingEnabled()) diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickeritems.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickeritems.post.desc.xml index de7fbf702c..11cce93640 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickeritems.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickeritems.post.desc.xml @@ -4,5 +4,5 @@ /api/forms/picker/items user - required + required \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerresults.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerresults.lib.ftl index 1e2ef01cfa..f32fc643ef 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerresults.lib.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerresults.lib.ftl @@ -1,52 +1,50 @@ <#macro renderParent node indent=" "> - <#escape x as jsonUtils.encodeJSONString(x)> - ${indent}"parent": - ${indent}{ - <#if (node != rootNode) && node.parent??> - <@renderParent node.parent indent+" " /> - - ${indent}"type": "${node.typeShort}", - ${indent}"isContainer": ${node.isContainer?string}, - ${indent}"hasChildren": ${(node.children?size > 0)?string}, - ${indent}"name": "${node.properties.name!""}", - ${indent}"title": "${node.properties.title!""}", - ${indent}"description": "${node.properties.description!""}", - <#if node.properties.modified??>${indent}"modified": "${xmldate(node.properties.modified)}", - <#if node.properties.modifier??>${indent}"modifier": "${node.properties.modifier}", - ${indent}"displayPath": "${node.displayPath!""}", - ${indent}"nodeRef": "${node.nodeRef}" - ${indent}}, - + <#escape x as jsonUtils.encodeJSONString(x)> + ${indent}"parent": + ${indent}{ + <#if (node != rootNode) && node.parent??> + <@renderParent node.parent indent+" " /> + + ${indent}"type": "${node.typeShort}", + ${indent}"isContainer": ${node.isContainer?string}, + ${indent}"name": "${node.properties.name!""}", + ${indent}"title": "${node.properties.title!""}", + ${indent}"description": "${node.properties.description!""}", + <#if node.properties.modified??>${indent}"modified": "${xmldate(node.properties.modified)}", + <#if node.properties.modifier??>${indent}"modifier": "${node.properties.modifier}", + ${indent}"displayPath": "${node.displayPath!""}", + ${indent}"nodeRef": "${node.nodeRef}" + ${indent}}, + <#macro pickerResultsJSON results> - <#escape x as jsonUtils.encodeJSONString(x)> + <#escape x as jsonUtils.encodeJSONString(x)> { - "data": - { + "data": + { <#if parent??> - <@renderParent parent /> + <@renderParent parent /> - "items": - [ - <#list results as row> - { - "type": "${row.item.typeShort}", - "isContainer": ${row.item.isContainer?string}, - "hasChildren": ${(row.item.children?size > 0)?string}, - "name": "${row.item.properties.name!""}", - "title": "${row.item.properties.title!""}", - "description": "${row.item.properties.description!""}", - <#if row.item.properties.modified??>"modified": "${xmldate(row.item.properties.modified)}", - <#if row.item.properties.modifier??>"modifier": "${row.item.properties.modifier}", - <#if row.item.siteShortName??>"site": "${row.item.siteShortName}", - "displayPath": "${row.item.displayPath!""}", - "nodeRef": "${row.item.nodeRef}"<#if row.selectable?exists>, - "selectable" : ${row.selectable?string} - }<#if row_has_next>, - - ] - } + "items": + [ + <#list results as row> + { + "type": "${row.item.typeShort}", + "isContainer": ${row.item.isContainer?string}, + "name": "${row.item.properties.name!""}", + "title": "${row.item.properties.title!""}", + "description": "${row.item.properties.description!""}", + <#if row.item.properties.modified??>"modified": "${xmldate(row.item.properties.modified)}", + <#if row.item.properties.modifier??>"modifier": "${row.item.properties.modifier}", + <#if row.item.siteShortName??>"site": "${row.item.siteShortName}", + "displayPath": "${row.item.displayPath!""}", + "nodeRef": "${row.item.nodeRef}"<#if row.selectable?exists>, + "selectable" : ${row.selectable?string} + }<#if row_has_next>, + + ] + } } - + \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerresults.lib.js b/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerresults.lib.js index e368b0d002..692c77d6a9 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerresults.lib.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerresults.lib.js @@ -11,7 +11,6 @@ function createPersonResult(node) { typeShort: node.typeShort, isContainer: false, - children: [], properties: {}, displayPath: node.displayPath, nodeRef: "" + node.nodeRef @@ -40,7 +39,6 @@ function createGroupResult(node) { typeShort: node.typeShort, isContainer: false, - children: [], properties: {}, displayPath: node.displayPath, nodeRef: "" + node.nodeRef diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/groups/children.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/groups/children.get.desc.xml index fb0a4782b8..b553846d11 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/groups/children.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/groups/children.get.desc.xml @@ -4,9 +4,11 @@ Get a list of the child authorities of a group. The list contains both people and groups.
The authorityType parameter is used to specify return authorities of the given type. Valid values are GROUP and USER. + The optional maxItems parameter sets the maximum number of items to be returned. If no value is set then all items are returned. + The optional skipCount parameter determines how many items to skip before returning the first result. If no skipCount value is set then no items are skipped. ]]> - /api/groups/{shortName}/children?authorityType={authorityType?} + /api/groups/{shortName}/children?authorityType={authorityType?}&maxItems={maxItems?}&skipCount={skipCount?} argument user required diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/groups/children.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/groups/children.get.js index 0a13f60303..4c92d0c480 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/groups/children.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/groups/children.get.js @@ -8,7 +8,17 @@ function main() var shortName = urlElements[0]; var authorityType = args["authorityType"]; - + var maxItems = args["maxItems"]; + var skipCount= args["skipCount"]; + + if(maxItems == null) + { + maxItems = -1; + } + if(skipCount == null) + { + skipCount = -1; + } var group = groups.getGroup(shortName); if (group == null) { @@ -28,7 +38,7 @@ function main() } if (authorityType == "GROUP") { - model.children = group.getChildGroups(); + model.children = group.getChildGroups(maxItems, skipCount); } if (authorityType == "USER") { diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/groups/groups.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/groups/groups.get.desc.xml index 50fa1f274b..64ec42a94b 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/groups/groups.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/groups/groups.get.desc.xml @@ -12,7 +12,7 @@ Returns an Array of groups in JSON format. ]]> - /api/groups?shortNameFilter={shortNameFilter?}&zone={zone?} + /api/groups?shortNameFilter={shortNameFilter?}&zone={zone?}&maxItems={maxItems?}&skipCount={skipCount?} argument user required diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/groups/groups.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/groups/groups.get.js index 4ca276191a..f0d655877d 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/groups/groups.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/groups/groups.get.js @@ -7,23 +7,26 @@ function main () // Get the args var shortNameFilter = args["shortNameFilter"]; var zone = args["zone"]; + var maxItems = args["maxItems"]; + var skipCount = args["skipCount"]; if(shortNameFilter == null) { shortNameFilter = ""; } - if(zone == null) + if(maxItems== null) { - // Do the search - model.groups = groups.searchGroups(shortNameFilter); - + maxItems = -1; } - else + + if(skipCount== null) { - // Do the search - model.groups = groups.searchGroupsInZone(shortNameFilter, zone); + skipCount = -1; } + + // Do the search + model.groups = groups.searchGroupsInZone(shortNameFilter, zone, maxItems, skipCount); } main(); \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/groups/parent.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/groups/parent.get.desc.xml index 4bc61cb590..1c73654a99 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/groups/parent.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/groups/parent.get.desc.xml @@ -4,9 +4,11 @@ Gets a list of the parent authorities of a group.
The optional level attribute can be ALL, in which case all parents are returned. + The optional maxItems parameter sets the maximum number of items to be returned. If no value is set then all items are returned. + The optional skipCount parameter determines how many items to skip before returning the first result. If no skipCount value is set then no items are skipped. ]]> - /api/groups/{shortName}/parents?level={level?} + /api/groups/{shortName}/parents?level={level?}&maxItems={maxItems?}&skipCount={skipCount?} argument user required diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/groups/parent.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/groups/parent.get.js index 6a67f9eb81..c3a26fc6dc 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/groups/parent.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/groups/parent.get.js @@ -8,6 +8,8 @@ function main () var shortName = urlElements[0]; var level = args["level"]; + var maxItems = args["maxItems"]; + var skipCount = args["skipCount"]; var group = groups.getGroup(shortName); if (group == null) @@ -18,6 +20,14 @@ function main () } model.group = group; + if(maxItems == null) + { + maxItems = -1; + } + if(skipCount == null) + { + skipCount = -1; + } if (level != null) { @@ -26,11 +36,11 @@ function main () status.setCode(status.STATUS_BAD_REQUEST, "The level argument has does not have a correct value."); return; } - model.parents = group.getAllParentGroups(); + model.parents = group.getAllParentGroups(maxItems, skipCount); } else { - model.parents = group.getParentGroups(); + model.parents = group.getParentGroups(maxItems, skipCount); } } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/groups/rootgroups.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/groups/rootgroups.get.desc.xml index 77e7e9742c..daae1c8dbe 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/groups/rootgroups.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/groups/rootgroups.get.desc.xml @@ -1,19 +1,18 @@ List all root groups -
  • zone - If set to 'true', returns root groups from the specified zone. - If not specified, returns groups from all zones. -
  • -
  • - shortNameFilter - Returns those root groups with a partial match on shortName. + List all root groups. +
    + If the optional zone parameter is set to 'true' then returns root groups from the specified zone. + If not specified will return groups from all zones. +
    + If the optional shortNameFilter parameter is set then returns those root groups with a partial match on shortName. The shortname filter can contain the wild card characters * and ? but these must be url encoded for this script. -
  • - + The optional maxItems parameter sets the maximum number of items to be returned. If no value is set then all items are returned. + The optional skipCount parameter determines how many items to skip before returning the first result. If no skipCount value is set then no items are skipped. ]]>
    - /api/rootgroups?shortNameFilter={shortNameFilter?}&zone={zone?} + /api/rootgroups?shortNameFilter={shortNameFilter?}&zone={zone?}&maxItems={maxItems?}&skipCount={skipCount?} argument user required diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/groups/rootgroups.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/groups/rootgroups.get.js index 11c6cc0833..68a808ec28 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/groups/rootgroups.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/groups/rootgroups.get.js @@ -7,30 +7,27 @@ function main () // Get the args var shortNameFilter = args["shortNameFilter"]; var zone = args["zone"]; + var maxItems= args["maxItems"]; + var skipCount= args["skipCount"]; - if(zone == null) + if(maxItems == null) + { + maxItems = -1; + } + + if(skipCount == null) + { + skipCount = -1; + } + + if(shortNameFilter == null) { - if(shortNameFilter == null) - { - model.groups = groups.getAllRootGroups(); - } - else - { - // Do the search - model.groups = groups.searchRootGroups(shortNameFilter); - } + model.groups = groups.getAllRootGroupsInZone(zone, maxItems, skipCount); } else { - if(shortNameFilter == null) - { - model.groups = groups.getAllRootGroupsInZone(zone); - } - else - { - // Do the search - model.groups = groups.searchRootGroupsInZone(shortNameFilter, zone); - } + // Do the search + model.groups = groups.searchRootGroupsInZone(shortNameFilter, zone, maxItems, skipCount); } } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/person/changepassword.post.json.401.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/person/changepassword.post.json.401.ftl new file mode 100644 index 0000000000..cfa0d487f6 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/person/changepassword.post.json.401.ftl @@ -0,0 +1,4 @@ +{ + "success" : false, + "message" : "${status.message}" +} diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rule.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rule.lib.ftl index bfc76f3aa0..9bee96ef5a 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rule.lib.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/rule/rule.lib.ftl @@ -145,14 +145,18 @@ "name" : "${actionConstraint.name}", "values" : [ - <#if actionConstraint.allowableValues?? && actionConstraint.allowableValues?size > 0> - <#list actionConstraint.allowableValues?keys as allowableValue> - <#assign val = actionConstraint.allowableValues[allowableValue]> + <#if actionConstraint.allowableValues??> + <#assign allowableValues = actionConstraint.allowableValues> + + <#if allowableValues?size > 0> + <#list allowableValues?keys as allowableValue> + <#assign val = allowableValues[allowableValue]> { "value" : "${allowableValue}", "displayLabel" : "${val}" }<#if allowableValue_has_next>, + ] } diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/site/membership/memberships.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/site/membership/memberships.get.js index f5c54f462e..459abf3e80 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/site/membership/memberships.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/site/membership/memberships.get.js @@ -13,6 +13,7 @@ function main() var roleFilter = args["rf"]; var authorityType = args["authorityType"]; var sizeString = args["size"]; + var collapseGroups = false; if (authorityType != null) { @@ -21,11 +22,21 @@ function main() status.setCode(status.STATUS_BAD_REQUEST, "The 'authorityType' argument must be either USER or GROUP."); return; } + if (authorityType == "USER") + { + collapseGroups = true; + } + } + + var sizeSearch = 0; + if(sizeString != null) + { + sizeSearch = parseInt(sizeString); } // Get the filtered memberships // Comes back as a Map containing the full authority name and role - var memberships = site.listMembers(nameFilter, roleFilter, sizeString != null ? parseInt(sizeString) : 0); + var memberships = site.listMembers(nameFilter, roleFilter, sizeSearch, collapseGroups); // Get a list of all the users resolved to person nodes var authorities = Array(memberships.length); 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 83d8e7dac7..e0fa0b3187 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 @@ -29,7 +29,7 @@ "siteManagers" : [ - <#assign managers = site.listMembers(null, "SiteManager", 0)?keys /> + <#assign managers = site.listMembers(null, "SiteManager", 0, true)?keys /> <#list managers as manager> "${manager}" <#if manager_has_next>, @@ -37,4 +37,4 @@ ] } - \ No newline at end of file + diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/end-task.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/end-task.post.desc.xml index 66605eb0b5..df4e322b3f 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/end-task.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/end-task.post.desc.xml @@ -5,4 +5,5 @@ /api/workflow/task/end/{taskId} user + internal
    \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/task-instance.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/task-instance.get.desc.xml index 79b0864287..c5c71635cc 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/task-instance.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/task-instance.get.desc.xml @@ -1,8 +1,106 @@ Gets Workflow Task Instance Gets the details of a task. - /api/task-instances/{task_instance_id} + /api/task-instances/{task_instance_id} user required + public_api + + + task_instance_id + The id of the task to retrieve details for. + + + + + json + + + + + \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/task-instance.put.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/task-instance.put.desc.xml index e5a11cca3a..aad296fbfc 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/task-instance.put.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/task-instance.put.desc.xml @@ -5,4 +5,115 @@ user required + public_api + + + task_instance_id + The id of the task to update details for. + + + + + json + + + + + + + + json + + + + + \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/task-instances.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/task-instances.get.desc.xml index 82b7ddd462..b22062a42e 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/task-instances.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/task-instances.get.desc.xml @@ -1,12 +1,129 @@ - List Workflow Tasks - - Lists all Workflow Task Instances associated with an authority and of a given State. - The list of returned tasks also includes pooled tasks which the specified authority is eligible to claim. - - /api/task-instances?authority={authority?}&state={state?}&priority={priority?}&pooledTasks={pooledTasks?}&dueBefore={dueBefore?}&dueAfter={dueAfter?}&properties={properties?}&maxItems={maxItems?}&skipCount={skipCount?}&exclude={exclude?} - /api/workflow-instances/{workflow_instance_id}/task-instances?authority={authority?}&state={state?}&priority={priority?}&dueBefore={isoDate?}&dueAfter={isoDate?}&properties={prop1, prop2, prop3...?}&maxItems={maxItems?}&skipCount={skipCount?}&exclude={exclude?} - - user - required + List Workflow Tasks + + Lists all Workflow Task Instances associated with an authority and of a given State. + The list of returned tasks also includes pooled tasks which the specified authority is eligible to claim. + + /api/task-instances?authority={authority?}&state={state?}&priority={priority?}&pooledTasks={pooledTasks?}&dueBefore={dueBefore?}&dueAfter={dueAfter?}&properties={properties?}&maxItems={maxItems?}&skipCount={skipCount?}&exclude={exclude?} + /api/workflow-instances/{workflow_instance_id}/task-instances?authority={authority?}&state={state?}&priority={priority?}&dueBefore={isoDate?}&dueAfter={isoDate?}&properties={prop1, prop2, prop3...?}&maxItems={maxItems?}&skipCount={skipCount?}&exclude={exclude?} + + user + required + public_api + + + authority + The username of the authority to retrieve the tasks for. If this argument is omitted the tasks for the current user are returned. + + + state + Filters the returned tasks by state, IN_PROGRESS or COMPLETED (lower case is also acceptable). If this argument is omitted tasks in progress are returned. + + + priority + Filters the returned tasks by priority, a numerical value is expected, either 1, 2 or 3. + + + pooledTasks + Determines whether pooled tasks for the user are included in the results. To omit pooled tasks set this argument to false. + + + dueBefore + Restricts the returned tasks to only those that are due before the provided date (the date must be in ISO8601 format) + + + dueAfter + Restricts the returned tasks to only those that are due after the provided date (the date must be in ISO8601 format) + + + properties + Comma separated list of property names to include in the results. If this argument is omitted all properties are returned. + + + maxItems + Specifies the maximum number of results to return. + + + skipCount + Specifies the position in the results to start, used for paging results. + + + exclude + Comma separated list of task types to exclude from the the results. + + + workflow_instance_id + Restricts the returned tasks to those that belong to the given workflow process instance id. + + + + + json + + + + + diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-definitions.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-definitions.get.desc.xml index 22af620eb5..d8a1c7c302 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-definitions.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-definitions.get.desc.xml @@ -1,10 +1,40 @@ - List Deployed Workflow Definitions - - Returns a simple representation of all deployed workflow definitions. - - /api/workflow-definitions?exclude={exclude?} - - user - required + List Deployed Workflow Definitions + + Returns a simple representation of all deployed workflow definitions. + + /api/workflow-definitions?exclude={exclude?} + + user + required + public_api + + + exclude + Comma separated list of workflow definitions to exclude from the the results. + + + + + json + + + + + \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instance.delete.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instance.delete.desc.xml index ea38626642..aa503eb51d 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instance.delete.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instance.delete.desc.xml @@ -1,8 +1,19 @@ - Delete Workflow Instance - Either cancels or deletes the specified workflow instance. + Delete or Cancel Workflow Instance + Either cancels or deletes the specified workflow instance. To cancel call with no arguments, to delete set the forced argument to true. /api/workflow-instances/{workflow_instance_id}?forced={forced?} user required + public_api + + + workflow_instance_id + The id of workflow process instance to delete or cancel. + + + forced + Setting this argument to true will delete the workflow instance, if it is false or omitted the workflow instance will be cancelled. + + \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instance.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instance.get.desc.xml index e7da1fd660..07db975597 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instance.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instance.get.desc.xml @@ -5,4 +5,122 @@ user required + public_api + + + workflow_instance_id + The id of workflow process instance to retrieve. + + + includeTasks + Determines whether the response contains all the tasks that belong to the workflow instance. If this argument is omitted no tasks will be returned. + + + + + json + + + + + \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instances-for-node.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instances-for-node.get.desc.xml index 439ef9fb09..e9556fb370 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instances-for-node.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instances-for-node.get.desc.xml @@ -5,4 +5,56 @@ user required - \ No newline at end of file + public_api + + + store_type + The store type of the node + + + store_id + The store id of the node + + + id + The id of the node + + + + + json + + + + + + diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instances.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instances.get.desc.xml index ec8a53fbfa..a3663ef3b0 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instances.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/workflow-instances.get.desc.xml @@ -1,9 +1,115 @@ Get Workflow Instance Collection - Retrieves all workflow instances, the returned list can be optionally filtered by the state of the workflow instance and by the authority that initiated the workflow instance. + Retrieves all workflow instances, the returned list can also be optionally filtered. /api/workflow-instances?state={state?}&initiator={initiator?}&priority={priority?}&dueBefore={dueBefore?}&dueAfter={dueAfter?}&definitionId={definitionId?}&definitionName={definitionName?}&startedBefore={startedBefore?}&startedAfter={startedAfter?}&completedBefore={completedBefore?}&completedAfter={completedAfter?}&maxItems={maxItems?}&skipCount={skipCount?}&exclude={exclude?} /api/workflow-definitions/{workflow_definition_id}/workflow-instances?state={state?}&initiator={initiator?}&priority={priority?}&dueBefore={dueBefore?}&dueAfter={dueAfter?}&startedBefore={startedBefore?}&startedAfter={startedAfter?}&completedBefore={completedBefore?}&completedAfter={completedAfter?}&maxItems={maxItems?}&skipCount={skipCount?}&exclude={exclude?} user required + public_api + + + state + Filters the returned workflow instances by state, ACTIVE or COMPLETED (lower case is also acceptable). If this argument is omitted only active workflow instances are returned. + + + initiator + Filter the list of workflow instances by the authority that initiated the workflow instance. + + + priority + Filters the returned workflow instances by priority, a numerical value is expected, either 1, 2 or 3. + + + dueBefore + Restricts the returned workflow instances to only those that are due before the provided date (the date must be in ISO8601 format) + + + dueAfter + Restricts the returned workflow instances to only those that are due after the provided date (the date must be in ISO8601 format) + + + startedBefore + Restricts the returned workflow instances to only those that were started before the provided date (the date must be in ISO8601 format) + + + startedAfter + Restricts the returned workflow instances to only those that were started after the provided date (the date must be in ISO8601 format) + + + completedBefore + Restricts the returned workflow instances to only those that were completed before the provided date (the date must be in ISO8601 format) + + + completedAfter + Restricts the returned workflow instances to only those that were completed after the provided date (the date must be in ISO8601 format) + + + definitionId + Restricts the list of workflow instances returned to those started by the given workflow definition id. + + + workflow_definition_id + Restricts the list of workflow instances returned to those started by the given workflow definition id. + + + definitionName + Restricts the list of workflow instances returned to those started by the given workflow definition name i.e. any deployed version of that definition. + + + maxItems + Specifies the maximum number of results to return. + + + skipCount + Specifies the position in the results to start, used for paging results. + + + exclude + Comma separated list of workflow definitions to exclude from the the results. + + + + + json + + + + + \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/activity/create-activity.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/activity/create-activity.post.desc.xml index 25d85fec5b..0e9abfa46d 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/activity/create-activity.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/activity/create-activity.post.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.delete.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.delete.desc.xml index c17531cfe4..40687eed40 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.delete.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.delete.desc.xml @@ -5,4 +5,5 @@ argument user required + internal diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.get.desc.xml index 318c8e45b7..4e6b3464ee 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.get.desc.xml @@ -5,4 +5,5 @@ argument user required + internal diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.post.desc.xml index 5e9a2dd538..3fcd56bfb0 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.post.desc.xml @@ -5,4 +5,5 @@ extension user required + internal diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.put.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.put.desc.xml index 163b76ca70..5e63797de5 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.put.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.put.desc.xml @@ -5,4 +5,5 @@ argument user required + internal diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/eventList.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/eventList.get.desc.xml index 418d50258d..0837724d02 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/eventList.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/eventList.get.desc.xml @@ -5,4 +5,5 @@ argument guest required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/userevents.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/userevents.get.desc.xml index 5b74c7c077..2a37d85cc8 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/userevents.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/userevents.get.desc.xml @@ -6,4 +6,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-contents.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-contents.get.desc.xml index e80f4648d2..d9a5178bf0 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-contents.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-contents.get.desc.xml @@ -5,4 +5,5 @@ user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-tasks.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-tasks.get.desc.xml index 36cc163b34..2f040e0152 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-tasks.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-tasks.get.desc.xml @@ -5,4 +5,5 @@ user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/action/duplicate.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/action/duplicate.post.desc.xml index 243f9add69..080eeac44a 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/action/duplicate.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/action/duplicate.post.desc.xml @@ -5,4 +5,5 @@ argument user required + internal diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/action/items.delete.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/action/items.delete.desc.xml index 66d1385765..2aa6054d66 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/action/items.delete.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/action/items.delete.desc.xml @@ -5,4 +5,5 @@ argument user required + internal diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/data.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/data.post.desc.xml index b85fd1ee9a..7e7c793dbd 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/data.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/data.post.desc.xml @@ -6,4 +6,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/data.post.json.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/data.post.json.js index 2829f9827a..64134057d2 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/data.post.json.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/data.post.json.js @@ -46,7 +46,7 @@ function getData() for (count = 0; count < numFields; count++) { - fields.push(jsonFields.get(count).replace("_", ":")); + fields.push(jsonFields.get(count).replaceFirst("_", ":")); } } diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/item.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/item.post.desc.xml index ff31516a8d..216fee2fb3 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/item.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/item.post.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/item.post.json.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/item.post.json.js index 2fad1624db..301dad9458 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/item.post.json.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/item.post.json.js @@ -45,7 +45,7 @@ function getData() for (count = 0; count < numFields; count++) { - fields.push(jsonFields.get(count).replace("_", ":")); + fields.push(jsonFields.get(count).replaceFirst("_", ":")); } } diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/list.delete.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/list.delete.desc.xml index 516318e1cf..4ac3faf877 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/list.delete.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/list.delete.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/lists.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/lists.get.desc.xml index 2559e84268..54adc3ba1c 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/lists.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/lists.get.desc.xml @@ -7,4 +7,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/parse-args.lib.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/parse-args.lib.js index e80072cea5..3d2d2f37bf 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/parse-args.lib.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/datalists/parse-args.lib.js @@ -144,15 +144,12 @@ var ParseArgs = rootNode = siteNode.getContainer(containerId); if (rootNode === null) { - rootNode = siteNode.createContainer(containerId, containerType || "cm:folder"); + rootNode = siteNode.createAndSaveContainer(containerId, containerType || "cm:folder", "Data Lists"); if (rootNode === null) { status.setCode(status.STATUS_NOT_FOUND, "Data Lists container '" + containerId + "' not found in '" + siteId + "'. (No permission?)"); return null; } - - rootNode.properties["cm:description"] = "Data Lists"; - rootNode.save(); } listNode = rootNode; diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/action.lib.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/action.lib.js index aeb777d3b5..17123eca74 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/action.lib.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/action.lib.js @@ -38,6 +38,13 @@ function main() return; } + // Resolve parent if available + var parent = getInputParam("parentId"); + if (parent !== null) + { + params.parent = parent; + } + // Resolve path if available var path = url.templateArgs.path || ""; // Fix-up parent path to have no leading or trailing slashes @@ -286,6 +293,28 @@ function getMultipleInputValues(param) return (error !== null ? error : values); } +function getInputParam(param) +{ + var value = null; + + try + { + if (typeof json == "object") + { + if (!json.isNull(param)) + { + var value = json.get(param); + } + } + } + catch(e) + { + } + + // Return the values array, or the error string if it was set + return value; +} + /** * Obtain the asset node for the given rootNode and filepath @@ -302,6 +331,9 @@ function getAssetNode(p_rootNode, p_assetPath) try { + // make sure asset path is a string + p_assetPath = String(p_assetPath); + if (p_assetPath && (p_assetPath.length > 0)) { assetNode = assetNode.childByNamePath(p_assetPath); diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/add-child.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/add-child.post.desc.xml index 1c4dee47fa..6cf9a0feec 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/add-child.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/add-child.post.desc.xml @@ -8,4 +8,5 @@ argument user required + internal diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/aspects.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/aspects.post.desc.xml index 2b1a69b70d..1c6d03608b 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/aspects.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/aspects.post.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/cancel-checkout.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/cancel-checkout.post.desc.xml index a194481738..fdd56e6354 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/cancel-checkout.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/cancel-checkout.post.desc.xml @@ -6,4 +6,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/checkin.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/checkin.post.desc.xml index 2f72592bd8..3337af4246 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/checkin.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/checkin.post.desc.xml @@ -6,4 +6,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/checkout.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/checkout.post.desc.xml index c2cab8e9d9..fca4f3a5ba 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/checkout.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/checkout.post.desc.xml @@ -6,4 +6,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/copy-to.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/copy-to.post.desc.xml index 6ffecc34b6..e2f2551324 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/copy-to.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/copy-to.post.desc.xml @@ -8,4 +8,5 @@ argument user required + internal diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/file.delete.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/file.delete.desc.xml index 52af3d8ca0..345b3a412a 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/file.delete.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/file.delete.desc.xml @@ -8,4 +8,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/files.delete.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/files.delete.desc.xml index 01de524da7..f154ddb921 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/files.delete.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/files.delete.desc.xml @@ -6,4 +6,5 @@ argument user required + internal diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/move-to.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/move-to.post.desc.xml index 42b2ff668d..f2526c246e 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/move-to.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/move-to.post.desc.xml @@ -8,4 +8,5 @@ argument user required + internal diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/move-to.post.json.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/move-to.post.json.js index 4c7c578aa7..a4c2db6385 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/move-to.post.json.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/move-to.post.json.js @@ -17,6 +17,7 @@ function runAction(p_params) var results = [], destNode = p_params.destNode, files = p_params.files, + parent = null, file, fileNode, result, nodeRef; // Must have array of files @@ -47,10 +48,14 @@ function runAction(p_params) } else { + if (p_params.parent !== null) + { + parent = search.findNode(p_params.parent); + } result.id = fileNode.name; result.type = fileNode.isContainer ? "folder" : "document"; // move the node - result.success = fileNode.move(destNode); + result.success = fileNode.move(parent, destNode); } } catch (e) diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/permissions.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/permissions.post.desc.xml index 0797ca8330..8d6178a712 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/permissions.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/permissions.post.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/activity.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/activity.post.desc.xml index 3223807b45..11f770fc20 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/activity.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/activity.post.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/aspects.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/aspects.get.desc.xml index a381bd505e..998402f0b8 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/aspects.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/aspects.get.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/categorynode.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/categorynode.get.desc.xml index 64830d273a..5f2f33d213 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/categorynode.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/categorynode.get.desc.xml @@ -6,4 +6,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/container.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/container.get.desc.xml index 46b9298d8e..12a540235b 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/container.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/container.get.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/containers.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/containers.get.desc.xml index 2ca60d44ef..07e7ceba2d 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/containers.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/containers.get.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.desc.xml index d408d0e676..a52518cfcb 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.desc.xml @@ -8,4 +8,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/images.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/images.get.desc.xml index 2557c74ab9..8968e1faa2 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/images.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/images.get.desc.xml @@ -6,4 +6,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/location.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/location.get.desc.xml index ec681a5178..9277ab04a4 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/location.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/location.get.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/node.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/node.get.desc.xml index d1233e8b75..e9ed5635d7 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/node.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/node.get.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/node.get.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/node.get.js index 5bcb73a3d3..f341b76614 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/node.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/node.get.js @@ -44,7 +44,13 @@ function getDoclist() path: parsedArgs.location.path, file: node.name }; - + + item.location.parent = {}; + if (node.parent != null && node.parent.hasPermission("Read")) + { + item.location.parent.nodeRef = String(node.parent.nodeRef.toString()); + } + // Special case for container and libraryRoot nodes if ((parsedArgs.location.containerNode && String(parsedArgs.location.containerNode.nodeRef) == String(node.nodeRef)) || (parsedArgs.libraryRoot && String(parsedArgs.libraryRoot.nodeRef) == String(node.nodeRef))) diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/permissions.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/permissions.get.desc.xml index bb4615cbc5..ec232e5f7a 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/permissions.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/permissions.get.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/permissions.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/permissions.post.desc.xml index 8b54ece535..c5d8fdc1fd 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/permissions.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/permissions.post.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/roles.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/roles.get.desc.xml index 82df8e0738..8d0121c4c5 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/roles.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/roles.get.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/treenode.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/treenode.get.desc.xml index 116699c5ef..130d0d54e6 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/treenode.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/treenode.get.desc.xml @@ -8,4 +8,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/type.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/type.post.desc.xml index 023a955282..321a1099d7 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/type.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/type.post.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/edit-metadata/node-type.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/edit-metadata/node-type.get.desc.xml index 776fb7cdc8..8333dacbe9 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/edit-metadata/node-type.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/edit-metadata/node-type.get.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/resetavatar.put.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/resetavatar.put.desc.xml index 4b483b2e84..ce0d21af7a 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/resetavatar.put.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/resetavatar.put.desc.xml @@ -5,4 +5,5 @@ user required /slingshot/profile/resetavatar/{userName} + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/uploadavatar.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/uploadavatar.post.desc.xml index 746e52b4e6..d6a0280f72 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/uploadavatar.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/uploadavatar.post.desc.xml @@ -5,4 +5,5 @@ user required /slingshot/profile/uploadavatar + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/usercontents.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/usercontents.get.desc.xml index 913882893c..a807ece184 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/usercontents.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/usercontents.get.desc.xml @@ -5,4 +5,5 @@ guest /slingshot/profile/usercontents required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userprofile.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userprofile.post.desc.xml index f3823bd94b..9380df58ec 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userprofile.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userprofile.post.desc.xml @@ -5,4 +5,5 @@ user required /slingshot/profile/userprofile + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userstatus.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userstatus.post.desc.xml index 875da15b32..432f906b38 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userstatus.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userstatus.post.desc.xml @@ -5,4 +5,5 @@ user required /slingshot/profile/userstatus + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.get.desc.xml index f09429ee5c..19a3c85f32 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.get.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.lib.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.lib.js index 63c4b109b5..36e12f8015 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.lib.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.lib.js @@ -18,7 +18,8 @@ */ const DEFAULT_MAX_RESULTS = 250; const SITES_SPACE_QNAME_PATH = "/app:company_home/st:sites/"; -const COMMENT_QNAMEPATH = "/fm:discussion/cm:Comments/"; +const DISCUSSION_QNAMEPATH = "/fm:discussion"; +const COMMENT_QNAMEPATH = DISCUSSION_QNAMEPATH + "/cm:Comments/"; const QUERY_TEMPLATES = [ {field: "keywords", template: "%(cm:name cm:title cm:description ia:whatEvent ia:descriptionEvent lnk:title lnk:description TEXT)"}]; @@ -114,7 +115,8 @@ function getRepositoryItem(folderPath, node) // check whether this is a valid folder or a file var item = t = null; - if (node.qnamePath.indexOf(COMMENT_QNAMEPATH) == -1) + if (node.qnamePath.indexOf(COMMENT_QNAMEPATH) == -1 && + !(node.qnamePath.match(DISCUSSION_QNAMEPATH+"$") == DISCUSSION_QNAMEPATH)) { if (node.isContainer || node.isDocument) { @@ -168,7 +170,8 @@ function getDocumentItem(siteId, containerId, pathParts, node) // check whether this is a valid folder or a file var item = t = null; - if (node.qnamePath.indexOf(COMMENT_QNAMEPATH) == -1) + if (node.qnamePath.indexOf(COMMENT_QNAMEPATH) == -1 && + !(node.qnamePath.match(DISCUSSION_QNAMEPATH+"$") == DISCUSSION_QNAMEPATH)) { if (node.isContainer || node.isDocument) { @@ -408,7 +411,8 @@ function getLinkItem(siteId, containerId, pathParts, node) addToProcessed(cat, refkey); var item = t = null; - if (node.qnamePath.indexOf(COMMENT_QNAMEPATH) == -1) + if (node.qnamePath.indexOf(COMMENT_QNAMEPATH) == -1 && + !(node.qnamePath.match(DISCUSSION_QNAMEPATH+"$") == DISCUSSION_QNAMEPATH)) { item = { diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/move.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/move.post.desc.xml index 45b039d7ed..0851444d08 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/move.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/move.post.desc.xml @@ -5,4 +5,5 @@ argument user required + internal diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/page.delete.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/page.delete.desc.xml index c103820010..b2040f4e9f 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/page.delete.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/page.delete.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/page.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/page.get.desc.xml index a142b27a8f..dfc2b28ab2 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/page.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/page.get.desc.xml @@ -5,4 +5,5 @@ argument user required + internal diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/page.put.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/page.put.desc.xml index d4aa62c7e9..c166c0fb36 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/page.put.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/page.put.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/pagelist.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/pagelist.get.desc.xml index 5ad625ac0d..a50c5a040a 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/pagelist.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/pagelist.get.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/version.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/version.get.desc.xml index ce2579e271..4b606f0226 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/version.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/wiki/version.get.desc.xml @@ -5,4 +5,5 @@ argument user required + internal \ No newline at end of file diff --git a/config/alfresco/web-scripts-application-context.xml b/config/alfresco/web-scripts-application-context.xml index df1ca93931..6e681d2e78 100644 --- a/config/alfresco/web-scripts-application-context.xml +++ b/config/alfresco/web-scripts-application-context.xml @@ -56,16 +56,28 @@ workspace://SpacesStore /${spaces.company_home.childname}/${spaces.dictionary.childname}/cm:webscripts + + - - alfresco/extension/templates/webscripts + + false + webscripts + + + + false + alfresco/webscripts - + true alfresco/templates/webscripts + + alfresco/extension/templates/webscripts + + @@ -641,7 +653,8 @@ commentService - + + diff --git a/source/java/org/alfresco/repo/cmis/rest/test/BaseCMISTest.java b/source/java/org/alfresco/repo/cmis/rest/test/BaseCMISTest.java index 2704042e49..27882c4cb7 100644 --- a/source/java/org/alfresco/repo/cmis/rest/test/BaseCMISTest.java +++ b/source/java/org/alfresco/repo/cmis/rest/test/BaseCMISTest.java @@ -140,8 +140,8 @@ public abstract class BaseCMISTest extends BaseWebScriptTest } catch (ParseException e) { - return null; } + return null; } protected void assertContains(Set actual, String... expected) diff --git a/source/java/org/alfresco/repo/cmis/ws/utils/PropertyUtil.java b/source/java/org/alfresco/repo/cmis/ws/utils/PropertyUtil.java index 6677891d9d..1287c672dc 100644 --- a/source/java/org/alfresco/repo/cmis/ws/utils/PropertyUtil.java +++ b/source/java/org/alfresco/repo/cmis/ws/utils/PropertyUtil.java @@ -672,16 +672,16 @@ public class PropertyUtil CmisPropertyDecimal property = new CmisPropertyDecimal(); property.setPropertyDefinitionId(pdid); - if (value instanceof Collection) + if (value instanceof Collection) { - for (BigDecimal propertyValue : (Collection) value) + for (Serializable propertyValue : (Collection) value) { - property.getValue().add(propertyValue); + property.getValue().add(decimalValue(propertyValue)); } } else { - property.getValue().add(BigDecimal.valueOf((Double) value)); + property.getValue().add(decimalValue(value)); } return property; @@ -712,6 +712,15 @@ public class PropertyUtil } } + private BigDecimal decimalValue(Serializable value) + { + if ((value instanceof Float) || (value instanceof Double)) + { + return BigDecimal.valueOf(((Number) value).doubleValue()); + } + return null; + } + /** * Converts Date object to XMLGregorianCalendar object * diff --git a/source/java/org/alfresco/repo/web/scripts/RepoClassPathStore.java b/source/java/org/alfresco/repo/web/scripts/RepoClassPathStore.java new file mode 100644 index 0000000000..b9c28164ac --- /dev/null +++ b/source/java/org/alfresco/repo/web/scripts/RepoClassPathStore.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2005-2010 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.web.scripts; + +import java.io.IOException; + +import org.springframework.extensions.webscripts.ClassPathStore; + +import freemarker.cache.TemplateLoader; + +/** + * Extension of the SpringSurf ClassPathStore to ensure that the examination of + * last modified dates on classpath bound resources does not cause a performance + * degredation in REST heavy client applications. + *

    + * In the repository, due to the possibility of Repository bound resources, all + * WebScript search path lists have the "delay" set to either zero seconds (no delay) + * or something close to that. This means that the FreeMarker template cache is + * always or often requesting the last modified date of a classpath resource - and + * the resources do not change. Note that the /extension classpath store still uses + * the original ClassPathStore. Otherwise all stores can be refreshed as usual via + * the Refresh WebScripts command. + * + * @author Kevin Roast + */ +public class RepoClassPathStore extends ClassPathStore +{ + @Override + public TemplateLoader getTemplateLoader() + { + return new ClassPathTemplateLoader(); + } + + @Override + public long lastModified(String documentPath) + throws IOException + { + return -1L; + } + + /** + * Class Path Store implementation of a Template Loader + *

    + * Retrieves templates either from classes in the class path or classes inside of JAR files + * within the class path + *

    + * This implementation always returns a fixed last modified date of -1. + */ + private class ClassPathTemplateLoader extends ClassPathStore.ClassPathTemplateLoader + { + /** + * @see freemarker.cache.TemplateLoader#getLastModified(java.lang.Object) + */ + public long getLastModified(Object templateSource) + { + return -1L; + } + } +} diff --git a/source/java/org/alfresco/repo/web/scripts/RepositoryTemplateProcessor.java b/source/java/org/alfresco/repo/web/scripts/RepositoryTemplateProcessor.java index 91d669463b..5e829984f8 100644 --- a/source/java/org/alfresco/repo/web/scripts/RepositoryTemplateProcessor.java +++ b/source/java/org/alfresco/repo/web/scripts/RepositoryTemplateProcessor.java @@ -26,19 +26,19 @@ import java.util.List; import org.alfresco.processor.ProcessorExtension; import org.alfresco.repo.template.FreeMarkerProcessor; import org.alfresco.repo.template.QNameAwareObjectWrapper; -import org.springframework.extensions.surf.util.AbstractLifecycleBean; -import org.springframework.extensions.webscripts.SearchPath; -import org.springframework.extensions.webscripts.Store; -import org.springframework.extensions.webscripts.TemplateProcessor; -import org.springframework.extensions.webscripts.WebScriptException; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; +import org.springframework.extensions.surf.util.AbstractLifecycleBean; +import org.springframework.extensions.webscripts.SearchPath; +import org.springframework.extensions.webscripts.Store; +import org.springframework.extensions.webscripts.TemplateProcessor; +import org.springframework.extensions.webscripts.WebScriptException; -import freemarker.cache.MruCacheStorage; import freemarker.cache.MultiTemplateLoader; +import freemarker.cache.StrongCacheStorage; import freemarker.cache.TemplateLoader; import freemarker.template.Configuration; import freemarker.template.Template; @@ -59,7 +59,6 @@ public class RepositoryTemplateProcessor extends FreeMarkerProcessor protected Configuration templateConfig; protected FreeMarkerProcessor freeMarkerProcessor; private int updateDelay = 1; - private int cacheSize = 512; /* (non-Javadoc) @@ -90,12 +89,9 @@ public class RepositoryTemplateProcessor extends FreeMarkerProcessor /** * @param cacheSize the size of the MRU template cache, default is 256 */ + @Deprecated public void setCacheSize(int cacheSize) { - if (cacheSize >= 0) - { - this.cacheSize = cacheSize; - } } /** @@ -167,7 +163,7 @@ public class RepositoryTemplateProcessor extends FreeMarkerProcessor Configuration config = new Configuration(); // setup template cache - config.setCacheStorage(new MruCacheStorage(this.cacheSize, this.cacheSize << 1)); + config.setCacheStorage(new StrongCacheStorage()); config.setTemplateUpdateDelay(updateDelay); // setup template loaders diff --git a/source/java/org/alfresco/repo/web/scripts/comment/ScriptCommentService.java b/source/java/org/alfresco/repo/web/scripts/comment/ScriptCommentService.java index cad3b2d065..eacc8c63e5 100644 --- a/source/java/org/alfresco/repo/web/scripts/comment/ScriptCommentService.java +++ b/source/java/org/alfresco/repo/web/scripts/comment/ScriptCommentService.java @@ -27,6 +27,7 @@ import org.alfresco.model.ContentModel; import org.alfresco.repo.jscript.BaseScopableProcessorExtension; import org.alfresco.repo.jscript.Scopeable; import org.alfresco.repo.jscript.ScriptNode; +import org.alfresco.repo.policy.BehaviourFilter; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.repository.ChildAssociationRef; @@ -49,6 +50,7 @@ public class ScriptCommentService extends BaseScopableProcessorExtension private ServiceRegistry serviceRegistry; private NodeService nodeService; + private BehaviourFilter behaviourFilter; public void setServiceRegistry(ServiceRegistry serviceRegistry) { @@ -56,6 +58,11 @@ public class ScriptCommentService extends BaseScopableProcessorExtension this.nodeService = serviceRegistry.getNodeService(); } + public void setBehaviourFilter(BehaviourFilter behaviourFilter) + { + this.behaviourFilter = behaviourFilter; + } + public ScriptNode createCommentsFolder(ScriptNode node) { final NodeRef nodeRef = node.getNodeRef(); @@ -65,21 +72,34 @@ public class ScriptCommentService extends BaseScopableProcessorExtension public NodeRef doWork() throws Exception { NodeRef commentsFolder = null; - nodeService.addAspect(nodeRef, QName.createQName(NamespaceService.FORUMS_MODEL_1_0_URI, "discussable"), null); - List assocs = nodeService.getChildAssocs(nodeRef, QName.createQName(NamespaceService.FORUMS_MODEL_1_0_URI, "discussion"), RegexQNamePattern.MATCH_ALL); - if (assocs.size() != 0) + + // ALF-5240: turn off auditing round the discussion node creation to prevent + // the source document from being modified by the first user leaving a comment + behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE); + + try { - NodeRef forumFolder = assocs.get(0).getChildRef(); - - Map props = new HashMap(1); - props.put(ContentModel.PROP_NAME, COMMENTS_TOPIC_NAME); - commentsFolder = nodeService.createNode( - forumFolder, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, COMMENTS_TOPIC_NAME), - QName.createQName(NamespaceService.FORUMS_MODEL_1_0_URI, "topic"), - props).getChildRef(); + nodeService.addAspect(nodeRef, QName.createQName(NamespaceService.FORUMS_MODEL_1_0_URI, "discussable"), null); + List assocs = nodeService.getChildAssocs(nodeRef, QName.createQName(NamespaceService.FORUMS_MODEL_1_0_URI, "discussion"), RegexQNamePattern.MATCH_ALL); + if (assocs.size() != 0) + { + NodeRef forumFolder = assocs.get(0).getChildRef(); + + Map props = new HashMap(1); + props.put(ContentModel.PROP_NAME, COMMENTS_TOPIC_NAME); + commentsFolder = nodeService.createNode( + forumFolder, + ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, COMMENTS_TOPIC_NAME), + QName.createQName(NamespaceService.FORUMS_MODEL_1_0_URI, "topic"), + props).getChildRef(); + } } + finally + { + behaviourFilter.enableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE); + } + return commentsFolder; } diff --git a/source/java/org/alfresco/repo/web/scripts/groups/GroupsTest.java b/source/java/org/alfresco/repo/web/scripts/groups/GroupsTest.java index 59c2b038d8..25ef02d82f 100644 --- a/source/java/org/alfresco/repo/web/scripts/groups/GroupsTest.java +++ b/source/java/org/alfresco/repo/web/scripts/groups/GroupsTest.java @@ -19,6 +19,8 @@ package org.alfresco.repo.web.scripts.groups; +import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.util.HashSet; import java.util.Set; @@ -31,16 +33,17 @@ import org.alfresco.service.cmr.security.AuthorityType; import org.alfresco.service.cmr.security.MutableAuthenticationService; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.util.PropertyMap; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; import org.springframework.extensions.webscripts.TestWebScriptServer.Response; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.JSONArray; -import org.json.JSONObject; /** * Unit test of Groups REST APIs. @@ -67,6 +70,8 @@ public class GroupsTest extends BaseWebScriptTest private String TEST_GROUPC = "TesTC"; private String TEST_GROUPD = "TESTD"; private String TEST_GROUPE = "TestE"; + private String TEST_GROUPF = "TestF"; + private String TEST_GROUPG = "TestG"; private String TEST_LINK = "TESTLINK"; private String TEST_ROOTGROUP_DISPLAY_NAME = "GROUPS_TESTROOTDisplayName"; @@ -89,6 +94,10 @@ public class GroupsTest extends BaseWebScriptTest * USER_THREE * GROUPC * USER_TWO + * GROUPF + * GROUPD + * GROUPG + * GROUPD */ private synchronized String createTestTree() { @@ -102,7 +111,7 @@ public class GroupsTest extends BaseWebScriptTest if(!authorityService.authorityExists(rootGroupName)) { - this.authenticationComponent.setSystemUserAsCurrentUser(); + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); rootGroupName = authorityService.createAuthority(AuthorityType.GROUP, TEST_ROOTGROUP, TEST_ROOTGROUP_DISPLAY_NAME, authorityService.getDefaultZones()); String groupA = authorityService.createAuthority(AuthorityType.GROUP, TEST_GROUPA, TEST_GROUPA, authorityService.getDefaultZones()); @@ -115,7 +124,13 @@ public class GroupsTest extends BaseWebScriptTest authorityService.addAuthority(groupB, groupE); authorityService.addAuthority(groupB, USER_TWO); authorityService.addAuthority(groupB, USER_THREE); - + String groupF = authorityService.createAuthority(AuthorityType.GROUP, TEST_GROUPF, TEST_GROUPF, authorityService.getDefaultZones()); + authorityService.addAuthority(rootGroupName, groupF); + authorityService.addAuthority(groupF, groupD); + String groupG = authorityService.createAuthority(AuthorityType.GROUP, TEST_GROUPG, TEST_GROUPG, authorityService.getDefaultZones()); + authorityService.addAuthority(rootGroupName, groupG); + authorityService.addAuthority(groupG, groupD); + String groupC = authorityService.createAuthority(AuthorityType.GROUP, TEST_GROUPC, TEST_GROUPC,authorityService.getDefaultZones()); authorityService.addAuthority(rootGroupName, groupC); authorityService.addAuthority(groupC, USER_TWO); @@ -429,7 +444,6 @@ public class GroupsTest extends BaseWebScriptTest */ public void testLinkChild() throws Exception { - String myRootGroup = "GT_LGROOT"; try @@ -799,12 +813,11 @@ public class GroupsTest extends BaseWebScriptTest Response response = sendRequest(new GetRequest(URL_GROUPS + "?shortNameFilter=" + TEST_GROUPE + "&zone=" + AuthorityService.ZONE_APP_SHARE), Status.STATUS_OK); JSONObject top = new JSONObject(response.getContentAsString()); logger.debug(response.getContentAsString()); - System.out.println(response.getContentAsString()); +// System.out.println(response.getContentAsString()); JSONArray data = top.getJSONArray("data"); assertEquals("Can't find Group E in Share zone", 1, data.length()); JSONObject authority = data.getJSONObject(0); assertEquals("", TEST_GROUPE, authority.getString("shortName")); - } // Negative test Search for a group in a wrong zone @@ -812,7 +825,7 @@ public class GroupsTest extends BaseWebScriptTest Response response = sendRequest(new GetRequest(URL_GROUPS + "?shortNameFilter=" + TEST_GROUPE + "&zone=" + AuthorityService.ZONE_APP_WCM), Status.STATUS_OK); JSONObject top = new JSONObject(response.getContentAsString()); logger.debug(response.getContentAsString()); - System.out.println(response.getContentAsString()); +// System.out.println(response.getContentAsString()); JSONArray data = top.getJSONArray("data"); assertEquals("length not 0", 0, data.length()); } @@ -820,6 +833,180 @@ public class GroupsTest extends BaseWebScriptTest } + public void testSearchGroupsPaging() throws Exception + { + createTestTree(); + + JSONArray data = getDataArray(URL_GROUPS + "?shortNameFilter=*"); + int defaultSize = data.length(); + String firstGroup = data.get(0).toString(); + + assertTrue("There should be at least 6 groups in default zone!", defaultSize > 5); + + // Test maxItems works + data = getDataArray(URL_GROUPS + "?shortNameFilter=*" +"&maxItems=3"); + assertEquals("There should only be 3 groups!", 3, data.length()); + assertEquals("The first group should be the same!!", firstGroup, data.get(0).toString()); + + // Test skipCount works + data = getDataArray(URL_GROUPS + "?shortNameFilter=*" + "&skipCount=2"); + assertEquals("The number of groups returned is wrong!", defaultSize-2, data.length()); + assertFalse("The first group should not be the same!!", firstGroup.equals(data.get(0).toString())); + + // Test maxItems and skipCount + data = getDataArray(URL_GROUPS + "?shortNameFilter=*" +"&skipCount=2&maxItems=3"); + assertEquals("The number of groups returned is wrong!", 3, data.length()); + assertFalse("The first group should not be the same!!", firstGroup.equals(data.get(0).toString())); + + // Test maxItems and skipCount when maxItems is too big. + // Shoudl return last 2 items. + int skipCount = defaultSize-2; + data = getDataArray(URL_GROUPS + "?shortNameFilter=*" + "&skipCount="+skipCount+"&maxItems=5"); + assertEquals("The number of groups returned is wrong!", 2, data.length()); + assertFalse("The first group should not be the same!!", firstGroup.equals(data.get(0).toString())); + } + + public void testGetRootGroupsPaging() throws Exception + { + createTestTree(); + + JSONArray data = getDataArray(URL_ROOTGROUPS); + int defaultSize = data.length(); + String firstGroup = data.get(0).toString(); + + assertTrue("There should be at least 3 groups in default zone!", defaultSize > 2); + + // Test maxItems works + data = getDataArray(URL_ROOTGROUPS + "?maxItems=2"); + assertEquals("There should only be 2 groups!", 2, data.length()); + assertEquals("The first group should be the same!!", firstGroup, data.get(0).toString()); + + // Test skipCount works + data = getDataArray(URL_ROOTGROUPS + "?skipCount=1"); + assertEquals("The number of groups returned is wrong!", defaultSize-1, data.length()); + assertFalse("The first group should not be the same!!", firstGroup.equals(data.get(0).toString())); + + // Test maxItems and skipCount + data = getDataArray(URL_ROOTGROUPS + "?skipCount=1&maxItems=2"); + assertEquals("The number of groups returned is wrong!", 2, data.length()); + assertFalse("The first group should not be the same!!", firstGroup.equals(data.get(0).toString())); + + // Test maxItems and skipCount when maxItems is too big. + // Shoudl return last 2 items. + int skipCount = defaultSize-1; + data = getDataArray(URL_ROOTGROUPS + "?skipCount="+skipCount+"&maxItems=5"); + assertEquals("The number of groups returned is wrong!", 1, data.length()); + assertFalse("The first group should not be the same!!", firstGroup.equals(data.get(0).toString())); + } + + public void testGetParentsPaging() throws Exception + { + createTestTree(); + + // Test for immediate parents + String baseUrl = URL_GROUPS + "/" + TEST_GROUPD + "/parents"; + + JSONArray data = getDataArray(baseUrl); + int defaultSize = data.length(); + String firstGroup = data.get(0).toString(); + + assertEquals("There should be at least 3 groups in default zone!", 3, defaultSize); + + // Test maxItems works + data = getDataArray(baseUrl +"?maxItems=2"); + assertEquals("There should only be 2 groups!", 2, data.length()); + assertEquals("The first group should be the same!!", firstGroup, data.get(0).toString()); + + // Test skipCount works + data = getDataArray(baseUrl + "?skipCount=1"); + assertEquals("The number of groups returned is wrong!", 2, data.length()); + assertFalse("The first group should not be the same!!", firstGroup.equals(data.get(0).toString())); + + // Test maxItems and skipCount + data = getDataArray(baseUrl + "?skipCount=1&maxItems=1"); + assertEquals("The number of groups returned is wrong!", 1, data.length()); + assertFalse("The first group should not be the same!!", firstGroup.equals(data.get(0).toString())); + + // Test maxItems and skipCount when maxItems is too big. + // Shoudl return last 2 items. + data = getDataArray(baseUrl + "?skipCount=1&maxItems=5"); + assertEquals("The number of groups returned is wrong!", 2, data.length()); + assertFalse("The first group should not be the same!!", firstGroup.equals(data.get(0).toString())); + + //Test for ALL parents + baseUrl = URL_GROUPS + "/" + TEST_GROUPD + "/parents?level=ALL"; + + data = getDataArray(baseUrl); + defaultSize = data.length(); + firstGroup = data.get(0).toString(); + + assertTrue("There should be at least 3 groups in default zone!", defaultSize > 2); + + // Test maxItems works + data = getDataArray(baseUrl +"&maxItems=2"); + assertEquals("There should only be 3 groups!", 2, data.length()); + assertEquals("The first group should be the same!!", firstGroup, data.get(0).toString()); + + // Test skipCount works + data = getDataArray(baseUrl + "&skipCount=1"); + assertEquals("The number of groups returned is wrong!", defaultSize-1, data.length()); + assertFalse("The first group should not be the same!!", firstGroup.equals(data.get(0).toString())); + + // Test maxItems and skipCount + data = getDataArray(baseUrl + "&skipCount=1&maxItems=2"); + assertEquals("The number of groups returned is wrong!", 2, data.length()); + assertFalse("The first group should not be the same!!", firstGroup.equals(data.get(0).toString())); + + // Test maxItems and skipCount when maxItems is too big. + // Shoudl return last 2 items. + int skipCount = defaultSize-2; + data = getDataArray(baseUrl + "&skipCount="+skipCount+"&maxItems=5"); + assertEquals("The number of groups returned is wrong!", 2, data.length()); + assertFalse("The first group should not be the same!!", firstGroup.equals(data.get(0).toString())); + } + + public void testGetChildGroupsPaging() throws Exception + { + createTestTree(); + + // Test for immediate parents + String baseUrl = URL_GROUPS + "/" + TEST_ROOTGROUP + "/children?authorityType=GROUP"; + + JSONArray data = getDataArray(baseUrl); + int defaultSize = data.length(); + String firstGroup = data.get(0).toString(); + + assertEquals("There should be 6 groups in default zone!", 6, defaultSize); + + // Test maxItems works + data = getDataArray(baseUrl +"&maxItems=2"); + assertEquals("There should only be 3 groups!", 2, data.length()); + assertEquals("The first group should be the same!!", firstGroup, data.get(0).toString()); + + // Test skipCount works + data = getDataArray(baseUrl + "&skipCount=2"); + assertEquals("The number of groups returned is wrong!", 4, data.length()); + assertFalse("The first group should not be the same!!", firstGroup.equals(data.get(0).toString())); + + // Test maxItems and skipCount + data = getDataArray(baseUrl + "&skipCount=2&maxItems=2"); + assertEquals("The number of groups returned is wrong!", 2, data.length()); + assertFalse("The first group should not be the same!!", firstGroup.equals(data.get(0).toString())); + + // Test maxItems and skipCount when maxItems is too big. + // Shoudl return last 2 items. + data = getDataArray(baseUrl + "&skipCount=4&maxItems=5"); + assertEquals("The number of groups returned is wrong!", 2, data.length()); + assertFalse("The first group should not be the same!!", firstGroup.equals(data.get(0).toString())); + } + + private JSONArray getDataArray(String url) throws IOException, JSONException, UnsupportedEncodingException + { + Response response = sendRequest(new GetRequest(url), Status.STATUS_OK); + JSONObject top = new JSONObject(response.getContentAsString()); + JSONArray data = top.getJSONArray("data"); + return data; + } /** * Detailed test of get Parents */ diff --git a/source/java/org/alfresco/repo/web/scripts/invitation/InvitationTest.java b/source/java/org/alfresco/repo/web/scripts/invitation/InvitationTest.java index 445b168f2f..3786e4652e 100644 --- a/source/java/org/alfresco/repo/web/scripts/invitation/InvitationTest.java +++ b/source/java/org/alfresco/repo/web/scripts/invitation/InvitationTest.java @@ -24,11 +24,12 @@ import java.util.List; import java.util.Map; import org.alfresco.model.ContentModel; -import org.alfresco.repo.action.executer.TestModeable; import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.site.SiteModel; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.repo.web.scripts.BaseWebScriptTest; +import org.alfresco.repo.web.scripts.invite.InviteServiceTest; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; @@ -37,6 +38,7 @@ import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.cmr.site.SiteVisibility; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; +import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.GUID; import org.alfresco.util.PropertyMap; import org.json.JSONArray; @@ -62,6 +64,7 @@ public class InvitationTest extends BaseWebScriptTest private AuthenticationComponent authenticationComponent; private PersonService personService; private NodeService nodeService; + private TransactionService transactionService; private String userOne = "InvitationTestOne" + GUID.generate(); private String userTwo = "InvitationTestTwo" + GUID.generate(); @@ -72,7 +75,6 @@ public class InvitationTest extends BaseWebScriptTest private List createdSites = new ArrayList(5); private List createdInvitations = new ArrayList(10); - private TestModeable mailActionExecutor; private final Map> userProperties = new HashMap>(3); @@ -99,13 +101,12 @@ public class InvitationTest extends BaseWebScriptTest "authenticationComponent"); this.personService = (PersonService) getServer().getApplicationContext().getBean("PersonService"); this.nodeService = (NodeService) getServer().getApplicationContext().getBean("NodeService"); + this.transactionService = (TransactionService) getServer().getApplicationContext().getBean("TransactionService"); - // TODO MER 20/11/2009 Bodge - turn off email sending to prevent errors - // during unit testing + // turn off email sending to prevent errors during unit testing // (or sending out email by accident from tests) - mailActionExecutor = (TestModeable) getServer().getApplicationContext().getBean("mail"); - mailActionExecutor.setTestMode(true); - + InviteServiceTest.configureMailExecutorForTestMode(this.getServer()); + this.authenticationComponent.setSystemUserAsCurrentUser(); // Create users @@ -162,11 +163,18 @@ public class InvitationTest extends BaseWebScriptTest // Clear the list this.createdInvitations.clear(); - // Switch the MailActionExecutor back to normal mode. - mailActionExecutor.setTestMode(false); - personService.deletePerson(userOne); - personService.deletePerson(userTwo); - personService.deletePerson(userThree); + RetryingTransactionCallback deleteCallback = new RetryingTransactionCallback() + { + @Override + public Void execute() throws Throwable + { + personService.deletePerson(userOne); + personService.deletePerson(userTwo); + personService.deletePerson(userThree); + return null; + } + }; + transactionService.getRetryingTransactionHelper().doInTransaction(deleteCallback); } private JSONObject createSite(String sitePreset, String shortName, String title, String description, diff --git a/source/java/org/alfresco/repo/web/scripts/invite/InviteServiceTest.java b/source/java/org/alfresco/repo/web/scripts/invite/InviteServiceTest.java index b961430290..10e08d9110 100644 --- a/source/java/org/alfresco/repo/web/scripts/invite/InviteServiceTest.java +++ b/source/java/org/alfresco/repo/web/scripts/invite/InviteServiceTest.java @@ -58,6 +58,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.core.io.ClassPathResource; import org.springframework.extensions.surf.util.URLEncoder; import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer; import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; import org.springframework.extensions.webscripts.TestWebScriptServer.Response; @@ -134,7 +135,7 @@ public class InviteServiceTest extends BaseWebScriptTest this.transactionService = (TransactionService) getServer().getApplicationContext() .getBean("TransactionService"); - configureMailExecutorForTestMode(); + configureMailExecutorForTestMode(this.getServer()); // We're using a MailActionExecuter defined in outboundSMTP-test-context.xml which // sets the testMode property to true via spring injection. This will prevent emails @@ -231,7 +232,7 @@ public class InviteServiceTest extends BaseWebScriptTest /** * This method turns off email-sending within the MailActionExecuter bean. */ - private void configureMailExecutorForTestMode() + public static void configureMailExecutorForTestMode(TestWebScriptServer server) { // This test class depends on a MailActionExecuter bean which sends out emails // in a live system. We want to prevent these emails from being sent during @@ -259,8 +260,8 @@ public class InviteServiceTest extends BaseWebScriptTest // // Therefore we've decided to do [3]. - ChildApplicationContextFactory outboundSmptSubsystem - = (ChildApplicationContextFactory)getServer().getApplicationContext().getBean("OutboundSMTP"); + ChildApplicationContextFactory outboundSmptSubsystem + = (ChildApplicationContextFactory)server.getApplicationContext().getBean("OutboundSMTP"); ApplicationContext childAppCtxt = outboundSmptSubsystem.getApplicationContext(); MailActionExecuter mailActionExecutor = (MailActionExecuter)childAppCtxt.getBean("mail"); mailActionExecutor.setTestMode(true); diff --git a/source/java/org/alfresco/repo/web/scripts/rule/RulePut.java b/source/java/org/alfresco/repo/web/scripts/rule/RulePut.java index c34aacf7b0..d554558a42 100644 --- a/source/java/org/alfresco/repo/web/scripts/rule/RulePut.java +++ b/source/java/org/alfresco/repo/web/scripts/rule/RulePut.java @@ -352,11 +352,11 @@ public class RulePut extends RulePost private ActionCondition getCondition(List conditions, String id) { ActionCondition result = null; - for (ActionCondition сondition : conditions) + for (ActionCondition condition : conditions) { - if (сondition.getId().equalsIgnoreCase(id)) + if (condition.getId().equalsIgnoreCase(id)) { - result = сondition; + result = condition; break; } } diff --git a/source/java/org/alfresco/repo/web/scripts/rule/RuleServiceTest.java b/source/java/org/alfresco/repo/web/scripts/rule/RuleServiceTest.java index 2def66e08f..455a3cdd52 100644 --- a/source/java/org/alfresco/repo/web/scripts/rule/RuleServiceTest.java +++ b/source/java/org/alfresco/repo/web/scripts/rule/RuleServiceTest.java @@ -24,6 +24,7 @@ import java.util.List; import org.alfresco.model.ContentModel; import org.alfresco.repo.rule.LinkRules; import org.alfresco.repo.security.authentication.AuthenticationComponent; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.repo.web.scripts.BaseWebScriptTest; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.ActionService; @@ -35,7 +36,7 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.rule.Rule; import org.alfresco.service.cmr.rule.RuleService; import org.alfresco.service.namespace.QName; -import org.apache.commons.digester.Rules; +import org.alfresco.service.transaction.TransactionService; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -72,6 +73,7 @@ public class RuleServiceTest extends BaseWebScriptTest private static final String TEST_FOLDER = "test_folder-" + System.currentTimeMillis(); private static final String TEST_FOLDER_2 = "test_folder-2-" + System.currentTimeMillis(); + private TransactionService transactionService; private NodeService nodeService; private FileFolderService fileFolderService; private AuthenticationComponent authenticationComponent; @@ -86,6 +88,7 @@ public class RuleServiceTest extends BaseWebScriptTest protected void setUp() throws Exception { super.setUp(); + this.transactionService = (TransactionService) getServer().getApplicationContext().getBean("TransactionService"); this.nodeService = (NodeService) getServer().getApplicationContext().getBean("NodeService"); this.fileFolderService = (FileFolderService) getServer().getApplicationContext().getBean("FileFolderService"); this.ruleService = (RuleService) getServer().getApplicationContext().getBean("RuleService"); @@ -154,9 +157,18 @@ public class RuleServiceTest extends BaseWebScriptTest protected void tearDown() throws Exception { super.tearDown(); - nodeService.deleteNode(testNodeRef2); - nodeService.deleteNode(testNodeRef); - nodeService.deleteNode(testWorkNodeRef); + RetryingTransactionCallback deleteCallback = new RetryingTransactionCallback() + { + @Override + public Void execute() throws Throwable + { + nodeService.deleteNode(testNodeRef2); + nodeService.deleteNode(testNodeRef); + nodeService.deleteNode(testWorkNodeRef); + return null; + } + }; + this.transactionService.getRetryingTransactionHelper().doInTransaction(deleteCallback); this.authenticationComponent.clearCurrentSecurityContext(); } @@ -677,6 +689,7 @@ public class RuleServiceTest extends BaseWebScriptTest assertEquals(0, ruleService.getRules(testNodeRef).size()); } + @SuppressWarnings("unused") public void testRuleReorder() throws Exception { assertEquals(0, ruleService.getRules(testNodeRef).size()); @@ -754,11 +767,6 @@ public class RuleServiceTest extends BaseWebScriptTest return result; } - private JSONObject buildTestRule() throws JSONException - { - return buildTestRule("test_rule"); - } - private JSONObject buildTestRule(String title) throws JSONException { JSONObject result = new JSONObject(); 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 3a5bacd679..2d6b7681f3 100644 --- a/source/java/org/alfresco/repo/web/scripts/site/SiteServiceTest.java +++ b/source/java/org/alfresco/repo/web/scripts/site/SiteServiceTest.java @@ -87,7 +87,8 @@ public class SiteServiceTest extends BaseWebScriptTest this.siteService = (SiteService)getServer().getApplicationContext().getBean("SiteService"); this.nodeService = (NodeService)getServer().getApplicationContext().getBean("NodeService"); this.authorityService = (AuthorityService)getServer().getApplicationContext().getBean("AuthorityService"); - + // sets the testMode property to true via spring injection. This will prevent emails + // from being sent from within this test case. this.authenticationComponent.setSystemUserAsCurrentUser(); // Create users diff --git a/source/java/org/alfresco/repo/web/scripts/transfer/BeginTransferCommandProcessor.java b/source/java/org/alfresco/repo/web/scripts/transfer/BeginTransferCommandProcessor.java index a00ad81406..fb201f7b04 100644 --- a/source/java/org/alfresco/repo/web/scripts/transfer/BeginTransferCommandProcessor.java +++ b/source/java/org/alfresco/repo/web/scripts/transfer/BeginTransferCommandProcessor.java @@ -22,6 +22,7 @@ package org.alfresco.repo.web.scripts.transfer; import java.io.StringWriter; import org.alfresco.repo.transfer.RepoTransferReceiverImpl; +import org.alfresco.repo.transfer.TransferCommons; import org.alfresco.service.cmr.transfer.TransferException; import org.alfresco.service.cmr.transfer.TransferReceiver; import org.apache.commons.logging.Log; @@ -57,8 +58,26 @@ public class BeginTransferCommandProcessor implements CommandProcessor String transferId = null; try { - // attempt to take the transfer lock - transferId = receiver.start(); + String [] fromRepositoryIdValues = req.getParameterValues(TransferCommons.PARAM_FROM_REPOSITORYID); + String [] transferToSelfValues = req.getParameterValues(TransferCommons.PARAM_ALLOW_TRANSFER_TO_SELF); + + String fromRepositoryId = null; + if(fromRepositoryIdValues.length > 0) + { + fromRepositoryId = fromRepositoryIdValues[0]; + } + + boolean transferToSelf = false; + if(transferToSelfValues.length > 0) + { + if(transferToSelfValues[0].equalsIgnoreCase("true")) + { + transferToSelf = true; + } + } + + // attempt to start the transfer + transferId = receiver.start(fromRepositoryId, transferToSelf); // Create a temporary folder into which we can place transferred files receiver.getStagingFolder(transferId); @@ -82,7 +101,8 @@ public class BeginTransferCommandProcessor implements CommandProcessor return Status.STATUS_OK; - } catch (Exception ex) + } + catch (Exception ex) { logger.debug("exception caught", ex); if(transferId != null) diff --git a/source/java/org/alfresco/repo/web/scripts/workflow/AbstractWorkflowRestApiTest.java b/source/java/org/alfresco/repo/web/scripts/workflow/AbstractWorkflowRestApiTest.java index 02f306b056..d024795ff2 100644 --- a/source/java/org/alfresco/repo/web/scripts/workflow/AbstractWorkflowRestApiTest.java +++ b/source/java/org/alfresco/repo/web/scripts/workflow/AbstractWorkflowRestApiTest.java @@ -559,7 +559,14 @@ public abstract class AbstractWorkflowRestApiTest extends BaseWebScriptTest assertNotNull(transition); - assertEquals(startTransition.getId(), transition.getString("id")); + if(startTransition.getId() == null) + { + assertEquals("", transition.getString("id")); + } + else + { + assertEquals(startTransition.getId(), transition.getString("id")); + } assertEquals(startTransition.getTitle(), transition.getString("title")); assertEquals(startTransition.getDescription(), transition.getString("description")); assertEquals(startTransition.isDefault(), transition.getBoolean("isDefault")); diff --git a/source/java/org/alfresco/repo/webdav/AbstractMoveOrCopyMethod.java b/source/java/org/alfresco/repo/webdav/AbstractMoveOrCopyMethod.java index c2da470535..c2d4169505 100644 --- a/source/java/org/alfresco/repo/webdav/AbstractMoveOrCopyMethod.java +++ b/source/java/org/alfresco/repo/webdav/AbstractMoveOrCopyMethod.java @@ -51,6 +51,7 @@ public abstract class AbstractMoveOrCopyMethod extends HierarchicalMethod protected abstract void moveOrCopy( FileFolderService fileFolderService, NodeRef sourceNodeRef, + NodeRef sourceParentNodeRef, NodeRef destParentNodeRef, String name) throws Exception; @@ -84,6 +85,8 @@ public abstract class AbstractMoveOrCopyMethod extends HierarchicalMethod throw new WebDAVServerException(HttpServletResponse.SC_NOT_FOUND); } + FileInfo sourceParentInfo = getDAVHelper().getParentNodeForPath(rootNodeRef, sourcePath, servletPath); + // the destination parent must exist String destPath = getDestinationPath(); FileInfo destParentInfo = null; @@ -137,11 +140,12 @@ public abstract class AbstractMoveOrCopyMethod extends HierarchicalMethod } NodeRef sourceNodeRef = sourceInfo.getNodeRef(); + NodeRef sourceParentNodeRef = sourceParentInfo.getNodeRef(); NodeRef destParentNodeRef = destParentInfo.getNodeRef(); String name = getDAVHelper().splitPath(destPath)[1]; - moveOrCopy(fileFolderService, sourceNodeRef, destParentNodeRef, name); + moveOrCopy(fileFolderService, sourceNodeRef, sourceParentNodeRef, destParentNodeRef, name); // Set the response status if (destInfo == null) @@ -152,5 +156,6 @@ public abstract class AbstractMoveOrCopyMethod extends HierarchicalMethod { m_response.setStatus(HttpServletResponse.SC_NO_CONTENT); } - } + } + } diff --git a/source/java/org/alfresco/repo/webdav/CopyMethod.java b/source/java/org/alfresco/repo/webdav/CopyMethod.java index e0deb378b0..d5c5313e43 100644 --- a/source/java/org/alfresco/repo/webdav/CopyMethod.java +++ b/source/java/org/alfresco/repo/webdav/CopyMethod.java @@ -39,6 +39,7 @@ public class CopyMethod extends AbstractMoveOrCopyMethod protected void moveOrCopy( FileFolderService fileFolderService, NodeRef sourceNodeRef, + NodeRef sourceParentNodeRef, NodeRef destParentNodeRef, String name) throws Exception { diff --git a/source/java/org/alfresco/repo/webdav/LockMethod.java b/source/java/org/alfresco/repo/webdav/LockMethod.java index 1022c82937..30e2ea18b5 100644 --- a/source/java/org/alfresco/repo/webdav/LockMethod.java +++ b/source/java/org/alfresco/repo/webdav/LockMethod.java @@ -344,6 +344,7 @@ public class LockMethod extends WebDAVMethod // Store lock scope (shared/exclusive) getNodeService().setProperty(lockNode.getNodeRef(), WebDAVModel.PROP_LOCK_SCOPE, this.createExclusive ? WebDAV.XML_EXCLUSIVE : WebDAV.XML_SHARED); + logger.debug("Properties of the " + lockNode + " was changed"); } /** @@ -389,27 +390,48 @@ public class LockMethod extends WebDAVMethod xml.startDocument(); - String nsdec = generateNamespaceDeclarations(null); - xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROP + nsdec, WebDAV.XML_NS_PROP + nsdec, getDAVHelper().getNullAttributes()); - // Output the lock details - generateLockDiscoveryXML(xml, lockNode, false, scope, WebDAV.getDepthName(m_depth), lt, owner); + String nsdec = ""; - // Close off the XML - xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP); + if (WebDAV.AGENT_MS_6_1_7600.equals(m_userAgent)) + { + nsdec = generateNamespaceDeclarations(null, true); + xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROP + nsdec, WebDAV.XML_NS_PROP + nsdec, getDAVHelper().getNullAttributes()); + + // Output the lock details + generateLockDiscoveryXML(xml, lockNode, false, scope, WebDAV.getDepthName(m_depth), lt, owner); + + // Close off the XML + xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP); + + } + else + { + nsdec = generateNamespaceDeclarations(null, false); + xml.startElement(EMPTY_NS, WebDAV.XML_PROP, WebDAV.XML_PROP + nsdec, getDAVHelper().getNullAttributes()); + + // Output the lock details + generateLockDiscoveryXML(xml, lockNode, true, scope, WebDAV.getDepthName(m_depth), lt, owner); + + // Close off the XML + xml.endElement(EMPTY_NS, WebDAV.XML_PROP, WebDAV.XML_PROP); + } } /** * Generates a list of namespace declarations for the response */ - protected String generateNamespaceDeclarations(HashMap nameSpaces) + protected String generateNamespaceDeclarations(HashMap nameSpaces, boolean withPrefix) { StringBuilder ns = new StringBuilder(); ns.append(" "); ns.append(WebDAV.XML_NS); - ns.append(":"); - ns.append(WebDAV.DAV_NS); + if (withPrefix) + { + ns.append(":"); + ns.append(WebDAV.DAV_NS); + } ns.append("=\""); ns.append(WebDAV.DEFAULT_NAMESPACE_URI); ns.append("\""); diff --git a/source/java/org/alfresco/repo/webdav/MoveMethod.java b/source/java/org/alfresco/repo/webdav/MoveMethod.java index 20b0b37d61..cc71d87736 100644 --- a/source/java/org/alfresco/repo/webdav/MoveMethod.java +++ b/source/java/org/alfresco/repo/webdav/MoveMethod.java @@ -44,6 +44,7 @@ public class MoveMethod extends AbstractMoveOrCopyMethod protected void moveOrCopy( FileFolderService fileFolderService, NodeRef sourceNodeRef, + NodeRef sourceParentNodeRef, NodeRef destParentNodeRef, String name) throws Exception { @@ -68,15 +69,7 @@ public class MoveMethod extends AbstractMoveOrCopyMethod checkNode(fileInfo); - if (getNodeService().getPrimaryParent(sourceNodeRef).getParentRef().equals(destParentNodeRef)) - { - // It is renaming operation - fileFolderService.rename(sourceNodeRef, name); - } - else - { - // It is move operation - fileFolderService.move(sourceNodeRef, destParentNodeRef, name); - } + // It is move operation + fileFolderService.move(sourceNodeRef, sourceParentNodeRef, destParentNodeRef, name); } } diff --git a/source/java/org/alfresco/repo/webdav/WebDAV.java b/source/java/org/alfresco/repo/webdav/WebDAV.java index a688b89d13..dd1b442fd1 100644 --- a/source/java/org/alfresco/repo/webdav/WebDAV.java +++ b/source/java/org/alfresco/repo/webdav/WebDAV.java @@ -35,6 +35,7 @@ import org.alfresco.model.ContentModel; import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; +import org.apache.commons.lang.time.DateFormatUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -124,6 +125,10 @@ public class WebDAV public static final String HEADER_KEY_NOT = "Not"; + // User agents + + public static final String AGENT_MS_6_1_7600 = "Microsoft-WebDAV-MiniRedir/6.1.7600"; + // General string constants public static final String ASTERISK = "*"; @@ -243,7 +248,7 @@ public class WebDAV // WebDAV creation date/time formatter - private static SimpleDateFormat _creationDateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); + private static String CREATION_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; // HTTP header date/time formatter // NOTE: According to RFC2616 dates should always be in English and in @@ -281,7 +286,7 @@ public class WebDAV */ public static String formatCreationDate(Date date) { - return _creationDateFormatter.format(date); + return DateFormatUtils.formatUTC(date, CREATION_DATE_FORMAT); } /** @@ -292,7 +297,7 @@ public class WebDAV */ public static String formatCreationDate(long ldate) { - return _creationDateFormatter.format(new Date(ldate)); + return DateFormatUtils.formatUTC(ldate, CREATION_DATE_FORMAT); } /** diff --git a/source/java/org/alfresco/repo/webdav/WebDAVMethod.java b/source/java/org/alfresco/repo/webdav/WebDAVMethod.java index beff51a5d2..9bad063b6e 100644 --- a/source/java/org/alfresco/repo/webdav/WebDAVMethod.java +++ b/source/java/org/alfresco/repo/webdav/WebDAVMethod.java @@ -312,7 +312,7 @@ public abstract class WebDAVMethod catch (AccessDeniedException e) { // Return a forbidden status - throw new WebDAVServerException(HttpServletResponse.SC_UNAUTHORIZED, e); + throw new WebDAVServerException(HttpServletResponse.SC_FORBIDDEN, e); } catch (Throwable e) { diff --git a/source/java/org/alfresco/repo/webdav/auth/BaseAuthenticationFilter.java b/source/java/org/alfresco/repo/webdav/auth/BaseAuthenticationFilter.java index f706064c68..8ff24080ba 100644 --- a/source/java/org/alfresco/repo/webdav/auth/BaseAuthenticationFilter.java +++ b/source/java/org/alfresco/repo/webdav/auth/BaseAuthenticationFilter.java @@ -273,7 +273,7 @@ public abstract class BaseAuthenticationFilter { public T doWork() throws Exception { - return transactionService.getRetryingTransactionHelper().doInTransaction(callback); + return transactionService.getRetryingTransactionHelper().doInTransaction(callback, transactionService.isReadOnly()); } }, AuthenticationUtil.SYSTEM_USER_NAME); } @@ -375,7 +375,7 @@ public abstract class BaseAuthenticationFilter authenticationComponent.setCurrentUser(userName); return createUserEnvironment(session, userName, authenticationService.getCurrentTicket(), true); } - }); + }, transactionService.isReadOnly()); } /** diff --git a/source/java/org/alfresco/repo/webdav/auth/BaseNTLMAuthenticationFilter.java b/source/java/org/alfresco/repo/webdav/auth/BaseNTLMAuthenticationFilter.java index 8179f01b5e..60849084ea 100644 --- a/source/java/org/alfresco/repo/webdav/auth/BaseNTLMAuthenticationFilter.java +++ b/source/java/org/alfresco/repo/webdav/auth/BaseNTLMAuthenticationFilter.java @@ -19,10 +19,12 @@ package org.alfresco.repo.webdav.auth; import java.io.IOException; +import java.io.PrintWriter; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Enumeration; import java.util.List; import java.util.Random; @@ -263,7 +265,10 @@ public abstract class BaseNTLMAuthenticationFilter extends BaseSSOAuthentication sreq.getRemoteAddr() + ":" + sreq.getRemotePort() + ") SID:" + sreq.getSession().getId()); // Send back a request for NTLM authentication - restartLoginChallenge(context, sreq, sresp); + sresp.setHeader(WWW_AUTHENTICATE, AUTH_NTLM); + sresp.setStatus(HttpServletResponse.SC_UNAUTHORIZED); + writeLoginPageLink(sreq, sresp); + sresp.flushBuffer(); return false; } else @@ -985,20 +990,50 @@ public abstract class BaseNTLMAuthenticationFilter extends BaseSSOAuthentication */ public void restartLoginChallenge(ServletContext context, HttpServletRequest req, HttpServletResponse res) throws IOException { + if (getLogger().isDebugEnabled()) + getLogger().debug("restartLoginChallenge..."); + // Remove any existing session and NTLM details from the session HttpSession session = req.getSession(false); if (session != null) { - session.invalidate(); + clearSession(session); } - // Force the logon to start again - res.setHeader(WWW_AUTHENTICATE, AUTH_NTLM); - res.setStatus(HttpServletResponse.SC_UNAUTHORIZED); - writeLoginPageLink(req, res); + String userAgent = req.getHeader("user-agent"); + if (userAgent != null && userAgent.indexOf("Safari") != -1) + { + final PrintWriter out = res.getWriter(); + out.println(""); + out.println("

    Login authentication failed. Please close and re-open Safari to try again.

    "); + out.println(""); + out.close(); + } + else + { + // Force the logon to start again + res.setHeader(WWW_AUTHENTICATE, AUTH_NTLM); + res.setStatus(HttpServletResponse.SC_UNAUTHORIZED); + writeLoginPageLink(req, res); + } res.flushBuffer(); } + /** + * Removes all attributes stored in session + * + * @param session Session + */ + @SuppressWarnings("unchecked") + private void clearSession(HttpSession session) + { + Enumeration names = (Enumeration) session.getAttributeNames(); + while (names.hasMoreElements()) + { + session.removeAttribute(names.nextElement()); + } + } + /** * Disable NTLMv2 support, must be called from the implementation constructor diff --git a/source/java/org/alfresco/repo/webdav/auth/BaseSSOAuthenticationFilter.java b/source/java/org/alfresco/repo/webdav/auth/BaseSSOAuthenticationFilter.java index 908761604d..fdee62b105 100644 --- a/source/java/org/alfresco/repo/webdav/auth/BaseSSOAuthenticationFilter.java +++ b/source/java/org/alfresco/repo/webdav/auth/BaseSSOAuthenticationFilter.java @@ -315,7 +315,9 @@ public abstract class BaseSSOAuthenticationFilter extends BaseAuthenticationFilt protected void redirectToLoginPage(HttpServletRequest req, HttpServletResponse res) throws IOException { - if ( hasLoginPage()) + if (getLogger().isDebugEnabled()) + getLogger().debug("redirectToLoginPage..."); + if (hasLoginPage()) res.sendRedirect(req.getContextPath() + "/faces" + getLoginPage()); }