Merged V2.1 to HEAD

6374: AR-1639 Web Script Content Upload
         Patch merge: Schema target 71 changed to 101


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6404 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-08-02 23:44:15 +00:00
parent feca4b296a
commit 9f7c5d6443
10 changed files with 360 additions and 19 deletions

View File

@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0">
<view:reference xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:wf="http://www.alfresco.org/model/workflow/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:wcm="http://www.alfresco.org/model/wcmmodel/1.0" xmlns:wca="http://www.alfresco.org/model/wcmappmodel/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:wcmwf="http://www.alfresco.org/model/wcmworkflow/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:bpm="http://www.alfresco.org/model/bpm/1.0" xmlns:custom="custom.model" xmlns="" view:pathref="/app:company_home/app:dictionary/cm:webscripts/cm:org/cm:alfresco/cm:sample">
<view:associations>
<cm:contains>
<cm:content view:childName="cm:upload.get.desc.xml">
<view:aspects>
<cm:titled></cm:titled>
<cm:author></cm:author>
<app:inlineeditable></app:inlineeditable>
</view:aspects>
<view:properties>
<app:editInline>true</app:editInline>
<cm:content>contentUrl=classpath:alfresco/bootstrap/webscripts/upload.get.desc.xml|mimetype=text/xml|size=|encoding=UTF-8|locale=en_US_</cm:content>
<cm:title></cm:title>
<cm:author></cm:author>
<cm:name>upload.get.desc.xml</cm:name>
</view:properties>
</cm:content>
<cm:content view:childName="cm:upload.get.html.ftl">
<view:aspects>
<cm:titled></cm:titled>
<cm:author></cm:author>
<app:inlineeditable></app:inlineeditable>
</view:aspects>
<view:properties>
<app:editInline>true</app:editInline>
<cm:content>contentUrl=classpath:alfresco/bootstrap/webscripts/upload.get.html.ftl|mimetype=text/plain|size=|encoding=UTF-8|locale=en_US_</cm:content>
<cm:title></cm:title>
<cm:author></cm:author>
<cm:name>upload.get.html.ftl</cm:name>
</view:properties>
</cm:content>
<cm:content view:childName="cm:upload.post.desc.xml">
<view:aspects>
<cm:titled></cm:titled>
<cm:author></cm:author>
<app:inlineeditable></app:inlineeditable>
</view:aspects>
<view:properties>
<app:editInline>true</app:editInline>
<cm:content>contentUrl=classpath:alfresco/bootstrap/webscripts/upload.post.desc.xml|mimetype=text/xml|size=|encoding=UTF-8|locale=en_US_</cm:content>
<cm:title></cm:title>
<cm:author></cm:author>
<cm:name>upload.post.desc.xml</cm:name>
</view:properties>
</cm:content>
<cm:content view:childName="cm:upload.post.js">
<view:aspects>
<cm:titled></cm:titled>
<cm:author></cm:author>
<app:inlineeditable></app:inlineeditable>
</view:aspects>
<view:properties>
<app:editInline>true</app:editInline>
<cm:content>contentUrl=classpath:alfresco/bootstrap/webscripts/upload.post.js|mimetype=application/x-javascript|size=|encoding=UTF-8|locale=en_US_</cm:content>
<cm:title></cm:title>
<cm:author></cm:author>
<cm:name>upload.post.js</cm:name>
</view:properties>
</cm:content>
<cm:content view:childName="cm:upload.post.html.ftl">
<view:aspects>
<cm:titled></cm:titled>
<cm:author></cm:author>
<app:inlineeditable></app:inlineeditable>
</view:aspects>
<view:properties>
<app:editInline>true</app:editInline>
<cm:content>contentUrl=classpath:alfresco/bootstrap/webscripts/upload.post.html.ftl|mimetype=text/plain|size=|encoding=UTF-8|locale=en_US_</cm:content>
<cm:title></cm:title>
<cm:author></cm:author>
<cm:name>upload.post.html.ftl</cm:name>
</view:properties>
</cm:content>
</cm:contains>
</view:associations>
</view:reference>
</view:view>

View File

@@ -0,0 +1,6 @@
<webscript>
<shortname>File Upload Form Sample</shortname>
<description>Form for uploading file content and meta-data into Repository</description>
<url>/sample/upload</url>
<authentication>user</authentication>
</webscript>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Upload Web Script Sample</title>
<link rel="stylesheet" href="${url.context}/css/main.css" TYPE="text/css">
</head>
<body>
<table>
<tr>
<td><img src="${url.context}/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
<td><nobr><span class="mainTitle">Upload Web Script Sample</span></nobr></td>
</tr>
<tr><td><td>Alfresco ${server.edition} v${server.version}
</table>
<p>
<table>
<form action="${url.service}" method="post" enctype="multipart/form-data" charset="utf-8">
<tr><td>File:<td><input type="file" name="file">
<tr><td>Title:<td><input name="title">
<tr><td>Description:<td><input name="desc">
<tr><td><td>
<tr><td><td><input type="submit" name="submit" value="Upload">
</form>
</table>
</body>
</html>

View File

@@ -0,0 +1,6 @@
<webscript>
<shortname>File Upload Sample</shortname>
<description>Upload file content and meta-data into Repository</description>
<url>/sample/upload</url>
<authentication>user</authentication>
</webscript>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Upload Web Script Sample</title>
<link rel="stylesheet" href="${url.context}/css/main.css" TYPE="text/css">
</head>
<body>
<table>
<tr>
<td><img src="${url.context}/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
<td><nobr><span class="mainTitle">Upload Web Script Sample</span></nobr></td>
</tr>
<tr><td><td>Alfresco ${server.edition} v${server.version}
<tr><td><td>&nbsp;
<tr><td><td>Uploaded <a href="${url.serviceContext}/sample/folder${upload.displayPath}">${upload.name}</a> of size ${upload.properties.content.size}.
</table>
</body>
</html>

View File

@@ -0,0 +1,43 @@
var filename = null;
var content = null;
var title = "";
var description = "";
// locate file attributes
for each (field in formdata.fields)
{
if (field.name == "title")
{
title = field.value;
}
else if (field.name == "desc")
{
description = field.value;
}
else if (field.name == "file" && field.isFile)
{
filename = field.filename;
content = field.content;
}
}
// ensure mandatory file attributes have been located
if (filename == undefined || content == undefined)
{
status.code = 400;
status.message = "Uploaded file cannot be located in request";
status.redirect = true;
}
else
{
// create document in company home for uploaded file
upload = companyhome.createFile("upload" + companyhome.children.length + "_" + filename) ;
upload.properties.content.write(content);
upload.properties.content.mimetype = "UTF-8";
upload.properties.title = title;
upload.properties.description = description;
upload.save();
// setup model for response template
model.upload = upload;
}