mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)
101295: Merge RA-SPRINT2 to HEAD-BUG-FIX (5.1) 99847: RA-61: move /slingshot/application webscripts. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@101438 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
<logo>
|
||||
<width>350</width>
|
||||
<height>50</height>
|
||||
</logo>
|
@@ -1,9 +0,0 @@
|
||||
<webscript>
|
||||
<shortname>Logo Upload</shortname>
|
||||
<description>Upload logo file content</description>
|
||||
<format default="json" />
|
||||
<authentication>admin</authentication>
|
||||
<transaction>required</transaction>
|
||||
<url>/slingshot/application/uploadlogo</url>
|
||||
<lifecycle>internal</lifecycle>
|
||||
</webscript>
|
@@ -1,15 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Upload Logo Success</title>
|
||||
</head>
|
||||
<body>
|
||||
<#if (args.success!"")?matches("^[\\w\\d\\._]+$")>
|
||||
<script type="text/javascript">
|
||||
${args.success}({
|
||||
nodeRef: "${logo.nodeRef}",
|
||||
fileName: "${name}"
|
||||
});
|
||||
</script>
|
||||
</#if>
|
||||
</body>
|
||||
</html>
|
@@ -1,19 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Upload Logo Failure</title>
|
||||
</head>
|
||||
<body>
|
||||
<#if (args.failure!"")?matches("^[\\w\\d\\._]+$")>
|
||||
<script type="text/javascript">
|
||||
${args.failure}({
|
||||
status: {
|
||||
"code" : ${status.code},
|
||||
"name" : "${status.codeName}",
|
||||
"description" : "${status.codeDescription}"
|
||||
},
|
||||
message: "${jsonUtils.encodeJSONString(status.message)}"
|
||||
});
|
||||
</script>
|
||||
</#if>
|
||||
</body>
|
||||
</html>
|
@@ -1,80 +0,0 @@
|
||||
/**
|
||||
* Application Log Upload method
|
||||
*
|
||||
* @method POST
|
||||
* @param filedata {file}
|
||||
*/
|
||||
|
||||
function main()
|
||||
{
|
||||
try
|
||||
{
|
||||
var filename = null;
|
||||
var content = null;
|
||||
|
||||
// locate file attributes
|
||||
for each (field in formdata.fields)
|
||||
{
|
||||
if (field.name == "filedata" && field.isFile)
|
||||
{
|
||||
filename = field.filename;
|
||||
content = field.content;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ensure all mandatory attributes have been located
|
||||
if (filename == undefined || content == undefined)
|
||||
{
|
||||
status.code = 400;
|
||||
status.message = "Uploaded file cannot be located in request";
|
||||
status.redirect = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var sitesNode = companyhome.childrenByXPath("st:sites")[0];
|
||||
if (sitesNode == null)
|
||||
{
|
||||
status.code = 500;
|
||||
status.message = "Failed to locate Sites folder.";
|
||||
status.redirect = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var logoConfig = new XML(config.script);
|
||||
var widthxheight = logoConfig.width + "x" + logoConfig.height;
|
||||
|
||||
var transformationOptions = "-resize " + widthxheight + "> -background none -gravity center";
|
||||
|
||||
// create the new image node
|
||||
var nodeName = new Date().getTime() + "_" + filename;
|
||||
var tmpFolder = sitesNode.createFolder(nodeName + "_tmp");
|
||||
logoNode = sitesNode.createNode(nodeName, "cm:content");
|
||||
logoNode.properties.content.write(content);
|
||||
logoNode.properties.content.guessMimetype(filename);
|
||||
var resizedImage = logoNode.transformImage(logoNode.properties.content.mimetype, transformationOptions, tmpFolder);
|
||||
logoNode.properties.content.write(resizedImage.properties.content);
|
||||
// CLOUD-951, no need to delete the resizedImage, as removing the tmpFolder will remove resizedImage too.
|
||||
tmpFolder.remove();
|
||||
logoNode.save();
|
||||
|
||||
// save ref to be returned
|
||||
model.logo = logoNode;
|
||||
model.name = filename;
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
var x = e;
|
||||
status.code = 500;
|
||||
status.message = "Unexpected error occured during upload of new content.";
|
||||
if (x.message && x.message.indexOf("org.alfresco.service.cmr.usage.ContentQuotaException") == 0)
|
||||
{
|
||||
status.code = 413;
|
||||
status.message = x.message;
|
||||
}
|
||||
status.redirect = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
@@ -1,12 +0,0 @@
|
||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||
{
|
||||
"nodeRef": "${logo.nodeRef}",
|
||||
"fileName": "${name}",
|
||||
"status":
|
||||
{
|
||||
"code": 200,
|
||||
"name": "OK",
|
||||
"description" : "File uploaded successfully"
|
||||
}
|
||||
}
|
||||
</#escape>
|
Reference in New Issue
Block a user