mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.0 to HEAD
12251: Fix for wiki parsing regression 12253: More regression fixes in wiki parser 12255: Update Share web session timeout value to 60 minutes. 12289: Share wiki - ETHREEOH-1021, ETHREEOH-1022, ETHREEOH-880, ETHREEOH-1032 12290: Additional to r12289 12344: Fix for ETHREEOH-1066 - Wiki page editing no longer broken for page titles that don't exist yet. 12355: ETHREEOH-984: External users in Share cannot edit profile 12359: Fixed typo in Flash/HTML uploader type selection 12364: ETHREEOH-1032 - Impossibility to delete Wiki page git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12542 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -24,12 +24,15 @@ function getTemplateArgs(params)
|
||||
/* Format and return error object */
|
||||
function jsonError(errorString)
|
||||
{
|
||||
/*
|
||||
var obj =
|
||||
{
|
||||
"error": errorString
|
||||
};
|
||||
|
||||
return obj;
|
||||
*/
|
||||
status.setCode(status.STATUS_BAD_REQUEST, errorString);
|
||||
}
|
||||
|
||||
// NOTE: may need a custom content type for a wiki entry
|
||||
|
@@ -9,24 +9,25 @@
|
||||
|
||||
function getTemplateParams()
|
||||
{
|
||||
// Grab the URI parameters
|
||||
var siteId = "" + url.templateArgs.siteId;
|
||||
var pageTitle = "" + url.templateArgs.pageTitle;
|
||||
// Grab the URI parameters
|
||||
var siteId = "" + url.templateArgs.siteId;
|
||||
var pageTitle = "" + url.templateArgs.pageTitle;
|
||||
|
||||
if (siteId === null || siteId.length === 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (siteId === null || siteId.length === 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (pageTitle === null || pageTitle.length === 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (pageTitle === null || pageTitle.length === 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
"siteId": siteId,
|
||||
"pageTitle": pageTitle
|
||||
};
|
||||
return (
|
||||
{
|
||||
"siteId": siteId,
|
||||
"pageTitle": pageTitle
|
||||
});
|
||||
}
|
||||
|
||||
function update()
|
||||
@@ -34,14 +35,14 @@ function update()
|
||||
var params = getTemplateArgs(["siteId", "pageTitle"]);
|
||||
if (params === null)
|
||||
{
|
||||
return jsonError("No parameters supplied");
|
||||
return jsonError("No parameters supplied");
|
||||
}
|
||||
|
||||
// Get the site
|
||||
var site = siteService.getSite(params.siteId);
|
||||
if (site === null)
|
||||
{
|
||||
return jsonError("Could not find site: " + siteId);
|
||||
return jsonError("Could not find site: " + siteId);
|
||||
}
|
||||
|
||||
var wiki = getWikiContainer(site);
|
||||
@@ -49,38 +50,47 @@ function update()
|
||||
{
|
||||
return jsonError("Could not locate wiki container");
|
||||
}
|
||||
|
||||
var page = wiki.childByNamePath(params.pageTitle), activityType;
|
||||
// Create the page if it doesn't exist
|
||||
if (page === null)
|
||||
|
||||
var page = wiki.childByNamePath(params.pageTitle), activityType;
|
||||
// Create the page if it doesn't exist
|
||||
if (page === null)
|
||||
{
|
||||
page = createWikiPage(params.pageTitle, wiki,
|
||||
{
|
||||
content: json.get("pagecontent"),
|
||||
versionable: true
|
||||
});
|
||||
|
||||
page = createWikiPage(params.pageTitle, wiki,
|
||||
{
|
||||
content: json.get("pagecontent"),
|
||||
versionable: true
|
||||
});
|
||||
|
||||
activityType = "org.alfresco.wiki.page-created";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a new revision of the page
|
||||
var workingCopy = page.checkout();
|
||||
workingCopy.content = json.get("pagecontent");
|
||||
workingCopy.checkin();
|
||||
|
||||
activityType = "org.alfresco.wiki.page-edited";
|
||||
// Check the version of the page being submitted against the version now in the repo, or a forced save
|
||||
if (pageVersionMatchesSubmitted(page) || json.has("forceSave"))
|
||||
{
|
||||
// Create a new revision of the page
|
||||
var workingCopy = page.checkout();
|
||||
workingCopy.content = json.get("pagecontent");
|
||||
workingCopy.checkin();
|
||||
|
||||
activityType = "org.alfresco.wiki.page-edited";
|
||||
}
|
||||
else
|
||||
{
|
||||
status.setCode(status.STATUS_CONFLICT, "Repository version is newer.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var data =
|
||||
{
|
||||
|
||||
var data =
|
||||
{
|
||||
title: params.pageTitle.replace(/_/g, " "),
|
||||
page: json.get("page") + "?title=" + params.pageTitle
|
||||
}
|
||||
// Log activity
|
||||
activities.postActivity(activityType, params.siteId, "wiki", jsonUtils.toJSONString(data));
|
||||
|
||||
if (!json.isNull("tags"))
|
||||
// Log activity
|
||||
activities.postActivity(activityType, params.siteId, "wiki", jsonUtils.toJSONString(data));
|
||||
|
||||
if (!json.isNull("tags"))
|
||||
{
|
||||
var tags = Array(json.get("tags"));
|
||||
if (tags)
|
||||
@@ -90,7 +100,7 @@ function update()
|
||||
// string and call the (native) method split
|
||||
var tags = [];
|
||||
var tmp = json.get("tags");
|
||||
for (var x=0; x < tmp.length(); x++)
|
||||
for (var x = 0, xx = tmp.length(); x < xx; x++)
|
||||
{
|
||||
tags.push(tmp.get(x));
|
||||
}
|
||||
@@ -102,14 +112,64 @@ function update()
|
||||
}
|
||||
page.save();
|
||||
}
|
||||
|
||||
// NOTE: for now we return the raw page content and do the transformation
|
||||
// of any wiki markup on the client. This is because the edit view needs to display
|
||||
// the raw content (for editing) whereas the page view needs to display the rendered content.
|
||||
return {
|
||||
page: page,
|
||||
tags: page.tags
|
||||
}
|
||||
|
||||
// NOTE: for now we return the raw page content and do the transformation
|
||||
// of any wiki markup on the client. This is because the edit view needs to display
|
||||
// the raw content (for editing) whereas the page view needs to display the rendered content.
|
||||
return (
|
||||
{
|
||||
page: page,
|
||||
tags: page.tags
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the current repository version is newer than a submitted version number.
|
||||
* Returns:
|
||||
* false if currentVersion is older than repoVersion
|
||||
* true otherwise
|
||||
*/
|
||||
function pageVersionMatchesSubmitted(page)
|
||||
{
|
||||
var currentVersion = 0, repoVersion = 0;
|
||||
|
||||
if (json.has("currentVersion"))
|
||||
{
|
||||
currentVersion = json.get("currentVersion");
|
||||
}
|
||||
|
||||
if (page.hasAspect("cm:versionable"))
|
||||
{
|
||||
repoVersion = getLatestVersion(page.versionHistory);
|
||||
}
|
||||
|
||||
return (sortByLabel(
|
||||
{ label: repoVersion},
|
||||
{ label: currentVersion }
|
||||
) != -1);
|
||||
}
|
||||
|
||||
function sortByLabel(version1, version2)
|
||||
{
|
||||
var major1 = new Number(version1.label.substring(0, version1.label.indexOf(".")));
|
||||
var major2 = new Number(version2.label.substring(0, version2.label.indexOf(".")));
|
||||
if (major1 - 0 == major2 - 0)
|
||||
{
|
||||
var minor1 = new Number(version1.label.substring(version1.label.indexOf(".")+1));
|
||||
var minor2 = new Number(version2.label.substring(version2.label.indexOf(".")+1));
|
||||
return (minor1 < minor2) ? 1 : (minor1 > minor2) ? -1 : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (major1 < major2) ? 1 : -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getLatestVersion(versionHistory)
|
||||
{
|
||||
versionHistory.sort(sortByLabel);
|
||||
return versionHistory[0].label;
|
||||
}
|
||||
|
||||
model.result = update();
|
@@ -351,6 +351,7 @@
|
||||
parent="webscript">
|
||||
<property name="workflowService" ref="WorkflowService"/>
|
||||
<property name="personService" ref="PersonService"/>
|
||||
<property name="permissionService" ref="PermissionService"/>
|
||||
<property name="authenticationService" ref="AuthenticationService"/>
|
||||
<property name="mutableAuthenticationDao" ref="authenticationDao"/>
|
||||
<property name="siteService" ref="SiteService"/>
|
||||
|
@@ -43,6 +43,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowException;
|
||||
@@ -100,6 +101,7 @@ public class Invite extends DeclarativeWebScript
|
||||
private WorkflowService workflowService;
|
||||
private PersonService personService;
|
||||
private AuthenticationService authenticationService;
|
||||
private PermissionService permissionService;
|
||||
private MutableAuthenticationDao mutableAuthenticationDao;
|
||||
private SiteService siteService;
|
||||
private NodeService nodeService;
|
||||
@@ -214,6 +216,16 @@ public class Invite extends DeclarativeWebScript
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the permission service
|
||||
*
|
||||
* @param permissionService the permission service
|
||||
*/
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
@@ -419,11 +431,13 @@ public class Invite extends DeclarativeWebScript
|
||||
properties.put(ContentModel.PROP_LASTNAME, inviteeLastName);
|
||||
properties.put(ContentModel.PROP_EMAIL, inviteeEmail);
|
||||
|
||||
final String finalUserName = inviteeUserName;
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
personService.createPerson(properties);
|
||||
NodeRef person = personService.createPerson(properties);
|
||||
permissionService.setPermission(person, finalUserName, PermissionService.ALL_PERMISSIONS, true);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user