Author: rdickens
Date: 2013-02-04 18:31:31 -0500 (Mon, 04 Feb 2013)
New Revision: 9114
Added:
epp/docs/branches/6.0/Reference_Guide/en-US/modules/PortalDevelopment/UploadComponent.xml
Modified:
epp/docs/branches/6.0/Reference_Guide/en-US/modules/PortalDevelopment.xml
Log:
Incorporated content from:
https://docs.jboss.org/author/display/GTNPORTAL35/Upload+Component, up to version 3
Added:
epp/docs/branches/6.0/Reference_Guide/en-US/modules/PortalDevelopment/UploadComponent.xml
===================================================================
---
epp/docs/branches/6.0/Reference_Guide/en-US/modules/PortalDevelopment/UploadComponent.xml
(rev 0)
+++
epp/docs/branches/6.0/Reference_Guide/en-US/modules/PortalDevelopment/UploadComponent.xml 2013-02-04
23:31:31 UTC (rev 9114)
@@ -0,0 +1,189 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % BOOK_ENTITIES SYSTEM "Reference_Guide.ent">
+%BOOK_ENTITIES;
+]>
+<chapter id="chap-Reference_Guide-Upload_Component">
+ <remark>Source:
https://docs.jboss.org/author/display/GTNPORTAL35/Upload+Component. Incorporated up to
version: 3</remark>
+ <title>Upload Component</title>
+ <section id="sect-Reference_Guide-Upload_Component-Overview">
+ <title>Overview</title>
+ <para>
+ In this section, you will learn how to configure the
+ <emphasis role="italics">Upload service</emphasis>
+ that is defined by the
+ <code>org.exoplatform.upload.UploadService</code>
+ class.
+ </para>
+ <para>This can be configured with the following XML code:</para>
+ <informalexample>
+ <programlisting language="XML">
+ <component>
+ <type>org.exoplatform.upload.UploadService</type>
+ <init-params>
+ <value-param>
+ <name>upload.limit.size</name>
+ <description>Maximum size of the file to upload in
MB</description>
+ <value>10</value>
+ </value-param>
+ </init-params>
+ </component>
+</programlisting>
+ </informalexample>
+ <para>This code allows uploading files with the default size limit (10MB).
The default value unit is in megabytes.</para>
+ <para>This limitation will be used by default by all applications if no
application-specific limit is set. Setting a different limit for applications is discussed
in a later section.</para>
+ <para>
+ If the value is set to
+ <code>0</code>
+ , the upload size is unlimited.
+ </para>
+ </section>
+ <section id="sid-54264598_UploadComponent-Usetheuploadcomponent">
+
+ <title>Use the upload component</title>
+ <orderedlist>
+ <listitem>
+ <para>
+ Create an
+ <code>org.exoplatform.webui.form.input.UIUploadInput</code>
+ object type by using one of three following constructors:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>The default constructor that allows uploading the file with
the size of 10 MB.</para>
+ <informalexample>
+ <programlisting language="Java">
+public UIUploadInput(String name, String bindingExpression, int limitFile)
+</programlisting>
+ </informalexample>
+ </listitem>
+ <listitem>
+ <para>
+ This constructor allows you to customize the size limit of uploaded
files by using the
+ <code>limitSize</code>
+ parameter. The default value unit is in megabytes.
+ </para>
+ <informalexample>
+ <programlisting language="Java">
+public UIUploadInput(String name, String bindingExpression,int limitFile, int limitSize)
+</programlisting>
+ </informalexample>
+ </listitem>
+ <listitem>
+ <para>
+ This constructor allows you to customize the size limit and the value
unit by using the
+ <code>limitSize</code>
+ and
+ <code>unit</code>
+ parameters respectively.
+
+ In JBoss Portal Platform, you can set the value unit to megabytes (MB),
kilobytes (KB) or gigabytes (GB).
+ </para>
+ <informalexample>
+ <programlisting>
+public UIUploadInput(String name, String bindingExpression, int limitFile, int limitSize,
UploadUnit unit)
+</programlisting>
+ </informalexample>
+ <para>The following is an example using the third
form:</para>
+ <informalexample>
+ <programlisting language="Java">
+PortletRequestContext pcontext =
(PortletRequestContext)WebuiRequestContext.getCurrentInstance();
+PortletPreferences portletPref = pcontext.getRequest().getPreferences();
+int limitFile = Integer.parseInt(portletPref.getValue("uploadFileLimit",
"1").trim());
+int limitSize = Integer.parseInt(portletPref.getValue("uploadFileSizeLimit",
"").trim());
+UploadUnit limitUnit =
UploadUnit.valueOf(portletPref.getValue("uploadFileLimitUnit",
"MB").trim());
+UIUploadInput uiInput = new UIUploadInput("upload", "upload",
limitFile, limitSize, limitUnit);
+</programlisting>
+ </informalexample>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ <listitem>
+ <para>
+ Obtain the limit from the
+ <code>XML</code>
+ configuration by adding the following code to either
+ <code>portlet.xml</code>
+ or
+ <code>portlet-preferences.xml</code>
+ :
+ </para>
+ <informalexample>
+ <programlisting language="XML">
+<! The number of files are uploaded -->
+ <preference>
+ <name>uploadFileLimit</name>
+ <value>3</value>
+ <read-only>false</read-only>
+ </preference>
+<! The size limit -->
+ <preference>
+ <name>uploadFileSizeLimit</name>
+ <value>300</value>
+ <read-only>false</read-only>
+ </preference>
+<! The unit limit -->
+ <preference>
+ <name>uploadFileLimitUnit</name>
+ <value>KB</value>
+ <read-only>false</read-only>
+ </preference>
+</programlisting>
+ </informalexample>
+ <note>
+ <para>
+ The
+ <code>0</code>
+ value means the upload size is unlimited, and the value unit is set to
megabytes.
+ </para>
+ </note>
+ </listitem>
+ <listitem>
+ <para>
+ Use the
+ <code>getUploadDataAsStream()</code>
+ method to get the uploaded data:
+ </para>
+ <informalexample>
+ <programlisting language="Java">
+UIUploadInput input = (UIUploadInput)uiForm.getUIInput("upload");
+InputStream[] inputStreams = input.getUploadDataAsStreams();
+...
+</programlisting>
+ </informalexample>
+ <para>The upload service stores a temporary file on the file system
during the upload process. When the upload is finished, the service must be cleaned
to:</para>
+ <itemizedlist>
+ <listitem>
+ <para>Delete the temporary file.</para>
+ </listitem>
+ <listitem>
+ <para>Delete the classes used for the upload.</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ <listitem>
+ <para>
+ Use the
+ <code>removeUploadResource(String uploadId)</code>
+ method defined in the upload service to purge the file:
+ </para>
+ <informalexample>
+ <programlisting language="Java">
+UploadService uploadService = uiForm.getApplicationComponent(UploadService.class);
+UIUploadInput uiChild = uiForm.getChild(UIFormUploadInput.class);
+for(String uploadId : uiChild.getUploadIds()) {
+ uploadService.removeUpload(uploadId);
+}
+</programlisting>
+ </informalexample>
+ <note>
+ <para>
+ Ensure the file is saved
+ <emphasis role="italics">before</emphasis>
+ the service is cleaned.
+ </para>
+ </note>
+ </listitem>
+ </orderedlist>
+ </section>
+</chapter>
Modified: epp/docs/branches/6.0/Reference_Guide/en-US/modules/PortalDevelopment.xml
===================================================================
--- epp/docs/branches/6.0/Reference_Guide/en-US/modules/PortalDevelopment.xml 2013-02-04
22:22:33 UTC (rev 9113)
+++ epp/docs/branches/6.0/Reference_Guide/en-US/modules/PortalDevelopment.xml 2013-02-04
23:31:31 UTC (rev 9114)
@@ -14,6 +14,7 @@
<xi:include
href="PortalDevelopment/InternationalizationConfiguration.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="PortalDevelopment/LocalizationConfiguration.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="PortalDevelopment/XMLResourceBundles.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="PortalDevelopment/UploadComponent.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="PortalDevelopment/RTLFramework.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include
href="PortalDevelopment/JavascriptInterApplicationCommunication.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
<!-- <xi:include
href="PortalDevelopment/JavascriptConfiguration.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" /> -->