Send-Clob-Stream
Description
Sends any CLOB information from an object as a stream to the browser or other application that calls the webject.
Definition
CLOB is an acronym for Character Large Object. A CLOB column stores single-byte fixed-width character objects such as text documents that must be stored in a database but cannot be interpreted within the database itself.
Syntax
<ie:webject name="Send-Clob-Stream" type="ACT">
<ie:param name="ATTRIBUTE" data="attribute_with_clob_data"/>
<ie:param name="BLOB_COUNT" data="number_of_BLOBs"/>
<ie:param name="CLASS" data="tablename"/>
<ie:param name="CONNECTION_ATTEMPT_INTERVAL" data="interval"/>
<ie:param name="CONNECTION_ATTEMPTS" data="attempts"/>
<ie:param name="DBUSER" data="dbuser_name"/>
<ie:param name="GROUP_OUT" data="group"/>
<ie:param name="INSTANCE" data="instance"/>
<ie:param name="MIMETYPE" data="mimetype"/>
<ie:param name="PASSWD" data="dbpassword"/>
<ie:param name="WHERE" data="where_clause"/>
</ie:webject>
Parameters
Required
Select
Optional
ATTRIBUTE
BLOB_COUNT
CLASS
CONNECTION_ATTEMPTS
INSTANCE
CONNECTION_ATTEMPT_INTERVAL
MIMETYPE
DBUSER
WHERE
GROUP_OUT
PASSWD
ATTRIBUTE
Specifies the attribute or column in the database table from which to return the character data. This parameter is required.
BLOB_COUNT
Specifies how many BLOBs to deliver to the webject. Specifying a value of 0 results in no BLOBs being delivered. Specifying a value of more than 0 results in up to that specified number of BLOBs being delivered. For example, if this parameter is specified with a value of 5, then no more than five BLOBs are delivered to the webject.
The default behavior for this parameter is that all remaining BLOBs are delivered to the webject. This parameter is optional.
CLASS
Identifies the name of the object containing the CLOB attribute being returned. This parameter is required.
CONNECTION_ATTEMPTS
Defines the maximum number of times to attempt establishing a connection to an adapter before returning an error. The default value is 1. This parameter is optional.
If multiple INSTANCE parameter values are specified, the value of CONNECTION_ATTEMPTS defines the maximum number of times to iterate through the list of adapter instances.
CONNECTION_ATTEMPT_INTERVAL
Defines the amount of time, in seconds, to delay between connection attempts. The default value is 60 seconds. This parameter is optional.
If multiple INSTANCE parameter values are specified, the value of CONNECTION_ATTEMPT_INTERVAL defines the number of seconds to wait between the attempts to iterate through the entire list of adapter instances.
DBUSER
Specifies the name to use when logging in to the data repository. If this parameter is specified in this webject, the webject value takes precedence over any value specified in the credentials mapping settings or in the adapter LDAP entry. If this parameter is not specified here, it must be specified in the credentials mapping settings or in the adapter LDAP entry. For more information about credentials mapping, see the section Credentials Mapping.
GROUP_OUT
Identifies the group returned by the webject. This parameter is optional.
INSTANCE
Specifies the name of the adapter that executes the webject. Adapter names are defined when the adapter is configured for use in your Info*Engine environment. This parameter is required.
In order to provide the ability to connect to other adapters if a specific adapter is not available, this parameter can be multi-valued. Info*Engine attempts to connect to the adapters in the order given. If the first adapter specified is not available, the next adapter listed is tried, and so on, until a connection is made. If a connection cannot be established with any listed adapter, an error is returned.
In conjunction with this parameter, you can include two other parameters: CONNECTION_ATTEMPTS and CONNECTION_ATTEMPT_INTERVAL.
MIMETYPE
Specifies the name of the attribute that has a MIME type. If placed in single quotes, the string typed here is then used as the MIME type for the CLOB data, otherwise this value represents a column in the table. This parameter is required.
PASSWD
Specifies the password to use when logging in to the data repository. If this parameter is specified in this webject, the webject value takes precedence over any value specified in the credentials mapping settings or in the adapter LDAP entry. If this parameter is not specified here, it must be specified in the credentials mapping settings or in the adapter LDAP entry. For more information about credentials mapping, see the section Credentials Mapping.
WHERE
Specifies search criteria for the database object containing CLOB data to return. The value for this parameter is specified as an SQL-formatted where clause. This parameter is required.
Example
The following example documents SendClobStream.jsp located in the Windchill installation directory:
codebase/infoengine/jsp/examples/JDBCAdapter/examples
This example uses the JSP useBean directive in order to display the image. To understand this example you must be familiar with the JSP useBean directive and its use. For more information about the API methods called within the useBean directive, see the API documentation:
<Windchill>/codebase/infoengine/docs/apidocs
In this example, the DownloadClob.jsp file, located in the same examples directory, provides the input form necessary for providing the appropriate parameter values for this example and should be run to execute SendClobStream.jsp.
The input form contains the following fields:
The JDBC Adapter Instance field should specify the INSTANCE parameter value appropriate to your installation.
The Name field specifies the name of the attribute containing the CLOB data being returned.
The File Name field specifies the name of the object containing the CLOB attribute being returned.
The Mime Type field specifies the name of the attribute that has a MIME type.
When the form is submitted, SendClobStream.jsp is called. The data specified on the form provides the parameter values for the webjects.
<%@page language="java" session="false"
errorPage="IEError.jsp"%>
<%@ taglib uri="http://www.ptc.com/infoengine/taglib/core"
prefix="ie" %>
<html>
<head>
<title> CLOB Download</title>
</head>
<BODY>
<H2> Download File</H2>
<form method="POST" action="SendClobStream.jsp" >
<TABLE>
<tr>
<td align=right>
<B>JDBC Adapter Instance: </B>
</td>
<td>
<INPUT name="instance" type="text" size=50>
</td>
</tr>
<tr>
<td align=right>
<B>Name: </B>
</td>
<td>
<INPUT name="name" type="text" size=50>
</td>
</tr>
<tr>
<td align=right>
<B>File Name : </B>
</td>
<td>
<INPUT name="filename" type="text" size=50>
</td>
</tr>
<tr>
<td align=right>
<B>Mime Type: </B>
</td>
<td>
<INPUT name="mimetype" type="text" size=50>
</td>
</tr>
<tr>
<td align=left>
<INPUT name="submit" type="submit" value="Retrieve" id=button>
</td>
</tr>
</table>
</form>
</body>
</html>
The following SendClobStream.jsp file streams the specified plain.txt file from the FILECONTENT column of the CLOBTEST table to the calling application.
* 
To run this example on your own system, you need to replace the values of the DBUSER and PASSWD parameters with values appropriate to your installation.
The SendClobStream.jsp file that gets executed upon submitting the above form is shown below:
<%@page language="java" errorPage="IEError.jsp"
import="java.util.*,com.infoengine.object.factory.*,
com.infoengine.SAK.*,com.infoengine.object.*" %>

%@ taglib uri="http://www.ptc.com/infoengine/taglib/core"
prefix="ie"%>

<ie:getService varName="vdb"/>
<jsp:useBean id="qa" class="com.infoengine.SAK.ActionWebject">
% qa.setService(vdb);
qa.setName("Send-Clob-Stream");
boolean user_input_file_name = true;
boolean user_input_mime_type = false;
String file_name = request.getParameter("filename");
if(file_name != null){
file_name = file_name.trim();
if(!(file_name.startsWith("'")&& file_name.endsWith("'"))){
user_input_file_name = false;
}
}else{
file_name ="";
user_input_file_name = false;
}
String mtype = request.getParameter("mimetype");
if(mtype != null){
mtype = mtype.trim();
if(mtype.startsWith("'") && mtype.endsWith("'"))
user_input_mime_type = true;
}else
mtype = "";
StringBuffer name=new StringBuffer("NAME='");
name.append(request.getParameter("name"));
name.append("'");
if(user_input_file_name == false || user_input_mime_type ==
false)
{
/* No value was input by the user for File Name and/or
MIME type; the following webject fetches these from the
database and stores in group "temp" */
%><ie:webject name="Query-Objects" type="OBJ">
<ie:param name="INSTANCE"
data="${@FORM[]instance[]}" default="jdbcAdapter"/>
<ie:param name="CLASS" data="CLOBTEST"/>
<%if(user_input_mime_type == false){%>
<ie:param name="ATTRIBUTE" data="${@FORM[]mimetype[]}"/>
<%}%>

<%if(user_input_file_name == false){%>
<ie:param name="ATTRIBUTE" data="${@FORM[]filename[]}"/>
<%}%>
<ie:param name="WHERE"
data="<%=name.toString()%>"/>
<ie:param name="GROUP_OUT" data="temp"/>
</ie:webject><%

/* Fetch the MIME type and/or file name from the group
"temp" */
IeGroup ie_group = (vdb.getCollection()).getGroup("temp");
Group group = new Group(ie_group);
Enumeration elements = group.getElements();
Element elem = null;
Att att1 = null, att2 = null;
if(elements.hasMoreElements())
{
elem = (Element)elements.nextElement();
att1 = elem.getAtt(mtype);
if(user_input_mime_type == false && att1 != null)
{
mtype = (att1.getValue()).toString();
mtype = "'" + mtype + "'";
}
att2 = elem.getAtt(file_name);
if(user_input_file_name == false && att2 != null)
{
file_name = (att2.getValue()).toString();
}
}
}
StringBuffer fname=new StringBuffer("filename='");
fname.append(file_name);
fname.append("'");
qa.addParam("INSTANCE",request.getParameter("instance"));
qa.addParam("ATTRIBUTE","FILECONTENT");
qa.addParam("DBUSER","dbuser_name");
qa.addParam("PASSWD","dbuser_passwd");
qa.addParam("CLASS","CLOBTEST");
qa.addParam("WHERE",name.toString());
qa.addParam("MIMETYPE",mtype);
qa.addParam("FILENAME",file_name);
qa.addParam("GROUP_OUT","SendClob");
qa.setOutputStream(response.getWriter());
response.addHeader("Content-
Disposition",fname.toString());
/* Make sure the single quotes in mtype are not passed
to setContentType() */
if(!mtype.equals("") && mtype != null)

response.setContentType(mtype.substring(1, mtype.length()-1));
qa.invoke();
response.getWriter().close();
%>
</jsp:useBean>
War dies hilfreich?