<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>AMIS Technology Blog &#187; Johan Tuitel</title>
	<atom:link href="http://technology.amis.nl/blog/author/johan-tuitel/feed/" rel="self" type="application/rss+xml" />
	<link>http://technology.amis.nl</link>
	<description></description>
	<lastBuildDate>Sat, 15 Jun 2013 14:57:43 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Howto show and save image as blob type with seam</title>
		<link>http://technology.amis.nl/2008/12/03/howto-show-and-save-image-as-blob-type-with-seam/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=howto-show-and-save-image-as-blob-type-with-seam</link>
		<comments>http://technology.amis.nl/2008/12/03/howto-show-and-save-image-as-blob-type-with-seam/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 14:49:36 +0000</pubDate>
		<dc:creator>Johan Tuitel</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[J(2)EE/Java]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java, JEE, OAS and WebLogic Server]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[blob]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[seam]]></category>
		<category><![CDATA[upload]]></category>

		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=4216</guid>
		<description><![CDATA[In a project where i am working on, we needed to show an image and the image should be change when a user would like to do that. For that we need to hava an attribute in a table called photo and it has to be a blob. See below:

We have now a photo attribute as a blob, the next thing we need to do,  [...]]]></description>
				<content:encoded><![CDATA[<p>In a project where i am working on, we needed to show an image and the image should be change when a user would like to do that. For that we need to hava an attribute in a table called <strong>photo</strong> and it has to be a <strong>blob</strong>. See below:<a href="http://technology.amis.nl/wp-content/uploads/images/screenshot_blob_datatype.bmp"><br />
<img src="http://technology.amis.nl/wp-content/uploads/images/screenshot_blob_datatype.bmp" alt="" class="alignnone size-medium wp-image-4217" /></a><br />
We have now a photo attribute as a blob, the next thing we need to do, is to make an entity with a photo attribute. The entity is called <strong>Person</strong> and has a <strong>byte[]</strong> variable called <strong>photo</strong>. See below for an example:<span id="more-4216"></span><br />
@Entity<br />
@Table(name=&quot;PERSON&quot;)<br />
public class Person{<br />
private byte[] photo = null;</p>
<p>@Column(name=&quot;PHOTO&quot;)<br />
@Lob<br />
public byte[] getPhoto(){<br />
return photo;<br />
}</p>
<p>public void setPhoto(byte[] photo){<br />
this.photo = photo;<br />
}<br />
}</p>
<p>For the front-end we need to make a page with the next part(just make a simple xhtml page):<br />
&nbsp;&lt;h:panelGrid columns=&quot;2&quot;&gt;<br />
&nbsp;&nbsp;&lt;h:panelGroup&gt;<br />
&nbsp;&nbsp;&lt;s:graphicImage id=&quot;currentImage&quot; value=&quot;#{person.photo}&quot;<br />
&nbsp;&nbsp;&nbsp;rendered=&quot;#{person.photo != null}&quot; styleClass=&quot;vpaPhoto&quot; /&gt;<br />
&nbsp;&nbsp;&lt;s:graphicImage id=&quot;defaultImage&quot; value=&quot;/img/default.png&quot;<br />
&nbsp;&nbsp;&nbsp;rendered=&quot;#{person.photo == null}&quot; styleClass=&quot;vpaPhoto&quot; /&gt;&nbsp;<br />
&nbsp;&nbsp;&lt;/h:panelGroup&gt;&nbsp;<br />
&nbsp;&nbsp;&lt;s:fileUpload id=&quot;imageUploader&quot; data=&quot;#{person.photo}&quot; onchange=&quot;submit()&quot; styleClass=&quot;imageUploader&quot;&nbsp; /&gt;<br />
&nbsp;&lt;/h:panelGrid&gt;</p>
<p>The appearance should look like this(you can choose any picture you would like for the default.png file):<br />
<a href="http://technology.amis.nl/wp-content/uploads/images/screenshot_default_image.bmp"><img src="http://technology.amis.nl/wp-content/uploads/images/screenshot_default_image.bmp" alt="" class="alignnone size-medium wp-image-4221" /></a><br />
Ok and now we click on browse an select an image(i&#8217;ve downloaded one from google, m_mylle.jpg)<br />
&nbsp;<a href="http://technology.amis.nl/wp-content/uploads/images/screenshot_select_image.bmp"><img src="http://technology.amis.nl/wp-content/uploads/images/screenshot_select_image.bmp" alt="" class="alignnone size-medium wp-image-4222" /></a><br />
So i&#8217;ve selected the m_mylle.jpg file and then i click open. The result is shown below:<br />
<a href="http://technology.amis.nl/wp-content/uploads/images/screenshot_selected_image.bmp"><img src="http://technology.amis.nl/wp-content/uploads/images/screenshot_selected_image.bmp" alt="" class="alignnone size-medium wp-image-4225" /></a><br />
Good luck, all suggestions and improvements are welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://technology.amis.nl/2008/12/03/howto-show-and-save-image-as-blob-type-with-seam/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using database tables for authentication in ADF applications</title>
		<link>http://technology.amis.nl/2008/02/08/using-database-table-for-authentication-in-adf-applications/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-database-table-for-authentication-in-adf-applications</link>
		<comments>http://technology.amis.nl/2008/02/08/using-database-table-for-authentication-in-adf-applications/#comments</comments>
		<pubDate>Fri, 08 Feb 2008 11:24:11 +0000</pubDate>
		<dc:creator>Johan Tuitel</dc:creator>
				<category><![CDATA[ADF & JHeadstart]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[J(2)EE/Java]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=2851</guid>
		<description><![CDATA[This article describes how to make a login feature for your application, which uses database tables for authentication and authorization.
I have made this loginmodule from examples of the AMIS adf training and i have made use of the DBLoginModule class which Frank Nimphius and Duncan Mills  [...]]]></description>
				<content:encoded><![CDATA[<p>This article describes how to make a login feature for your application, which uses database tables for authentication and authorization.<img alt="...." src="wp-content/plugins/xinha4wp/xinha_core/plugins/InsertMore/img/ed_more.png" /><span id="more-2851"></span><br /><!--more--></p>
<p>I have made this loginmodule from examples of the AMIS adf training and i have made use of the DBLoginModule class which Frank Nimphius and Duncan Mills build.</p>
<p>First thing we need to build is the tables in the database.</p>
<p><font size="4"><strong>Tables</strong></font></p>
<p>The loginmodule uses three tables. <br />1 table for users: which we call AMIS_STAFF <br />1 table for roles: which we call ROLES <br />1 table for association between the AMIS_STAFF and the ROLES tables <br />So make the tables in your database. The picture bellow shows how you could make it. </p>
<p><img hspace="0" src="http://technology.amis.nl/wp-content/uploads/images/tables.JPG" align="baseline" border="0" /></p>
<p><font size="4"><strong>Authorization </strong></font></p>
<p>Before we configure the authorization of your webapplication we need to make a new application.</p>
<p>So build a new application.<br />- Call the new application: SecureWebApp<br />- Directory name: c:\projects\SecureWebApp<br />- Application Package Prefix: nl.amis.als.secureWebApp<br />- Application Template: Web Application[JSF, ADF BC]<br />(these are just my settings, change them if you like)</p>
<p>- ok now we have an application<br />- make a new jsp page and call it: login.jsp<br />- save the page in â€¦..\public_html\security\pages<br />- the source of the page look like this:</p>
<p>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;<br />&lt;%@ page contentType=&quot;text/html;charset=UTF-8&quot;%&gt;<br />&lt;html&gt;<br />&nbsp; &lt;head&gt;<br />&nbsp;&nbsp;&nbsp; &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;/&gt;<br />&nbsp;&nbsp;&nbsp; &lt;title&gt;Login&lt;/title&gt;<br />&nbsp; &lt;/head&gt;<br />&nbsp; &lt;body style=&quot;font-family:sans-serif; background-color:rgb(214,231,255); color:rgb(0,0,255);&quot;&gt;<br />&nbsp;<br />&nbsp;&nbsp;&nbsp; &lt;form action=&quot;j_security_check&quot; method=&quot;post&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;table cellspacing=&quot;3&quot; cellpadding=&quot;2&quot; border=&quot;0&quot; width=&quot;100%&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;tr&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td width=&quot;120&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;b style=&quot;whitespace:nowrap&quot;&gt;Username&lt;/b&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/td&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;text&quot; name=&quot;j_username&quot;/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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&nbsp;&nbsp; &lt;/td&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/tr&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;tr&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td&gt;&lt;/td&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;submit&quot; name=&quot;logon&quot; value=&quot;Sign On&quot;/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/td&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/tr&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/table&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/form&gt;</p>
<p>&nbsp;&nbsp;&nbsp; &lt;p&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (c) AMIS &#8211; (2002-2006) &#8211; &lt;a href=&quot;http://www.amis.nl&quot;&gt;http://www.amis.nl&lt;/a&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/p&gt;<br />&nbsp;&lt;/body&gt;<br />&lt;/html&gt;</p>
<p>Now we have a login page. The next thing is to make the correct settings to use the page, the proper constraints and the roles.</p>
<p><font size="4"><strong>Roles </strong></font></p>
<p>Select the web.xml of your project and click rightmousebutton, select properties. <br />Select the Security Roles, add several roles, for example MANAGER, USER. <br />An important note is that the entered roles in your security roles, has to be exact the same as in the ROLES table weâ€™ve made in the database. </p>
<p><strong><font size="4">Constraints </font></strong></p>
<p>Select the web.xml of your project and click rightmousebutton, select properties. <br />Select Security Contraints, make a new constraint. <br />Select the new made constraint and add an Url Pattern. An example: /faces/pages/*. <br />The constraint is made, now we need to add roles to the constraint. <br />Select the Auhtorization tab and select the roles which use the constraint. </p>
<p><font size="4"><strong>Login configuration</strong></font> </p>
<p>Select the web.xml of your project and click rightmousebutton, select properties. <br />Select the Login Configuration: Form-Based Authentication&nbsp;<br />Enter the next settings: <br />Login page: /faces/security/pages/login.jsp <br />Error page: /faces/security/pages/login.jsp </p>
<p><font size="4"><strong>Authentication</strong></font></p>
<p>Install jar file <br />We need to download a loginmodule, which we add a java class. <br />The file is available at a blog about a login configuration with an pl/sql procedure: <a href="http://technology.amis.nl/blog/?p=1462">http://technology.amis.nl/blog/?p=1462</a> or direct from: <a href="http://technology.amis.nl/wp-content/uploads/images/JaasSecureWebApp.zip">http://technology.amis.nl/wp-content/uploads/images/JaasSecureWebApp.zip</a><br />The file we needed is: jaasdatabaseloginmodule.zip <br />Download the file <br />Unzip the file and run the project, the project should look like this:</p>
<p><img hspace="0" src="http://technology.amis.nl/wp-content/uploads/images/loginmodule-without-java-class.JPG" align="baseline" border="0" /></p>
<p>Ok now we are making a new java class in: oracle.sample.dbloginmodule.DBTableLM <br />The name of the file is: ALSDBTableLoginModule <br />The result should look like this: <br />&nbsp;</p>
<p><img hspace="0" src="http://technology.amis.nl/wp-content/uploads/images/loginmodule-with-java-class.JPG" align="baseline" border="0" /></p>
<p>Now we open the DBTableLoginModule.java file and copy paste all code into: ALS DBTableLoginModule. <br />The code we just pasted into our new class will be adjusted to our preferences. <br />First the need to adjust the class name: public class DBTableLoginModule implements DBLoginModule into: public class ALSDBTableLoginModule implements DBLoginModule. <br />The file should be correct at this point (so no file errors should occur if you run the file). <br />The performDbAuthentication is the only thing we adjust in the java class, the code of the method is as follow: <br />&nbsp; <br />&nbsp; protected boolean performDbAuthentication(String username, char[] password)<br />&nbsp; {<br />&nbsp;&nbsp;&nbsp; boolean success = false;<br />&nbsp;&nbsp;&nbsp; Connection conn = null;<br />&nbsp;&nbsp;&nbsp; Statement stmt = null;<br />&nbsp;&nbsp;&nbsp; ResultSet rset = null;<br />&nbsp;&nbsp;&nbsp; ArrayList _dbauth = new ArrayList(); </p>
<p>&nbsp;&nbsp;&nbsp; String _sqlStatement = &quot;select roles.ROLENAME, amis_staff.USERNAME FROM roles LEFT JOIN userrole ON roles.ID = userrole.ROLE LEFT JOIN amis_staff ON userrole.EMPLOYEE = amis_staff.ID WHERE amis_staff.USERNAME = &#8216;&quot; + username + &quot;&#8217; AND amis_staff.PASSWORD = &#8216;&quot; + new String(password) + &quot;&#8217;&quot;;</p>
<p>&nbsp;&nbsp;&nbsp; try <br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //database connection from the data-sources.xml file<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Context ic;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ic = new InitialContext();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataSource dataSource = (DataSource) ic.lookup(_data_source_name);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; conn = dataSource.getConnection();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (NamingException e)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.err.println(e.getMessage());<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stmt = conn.createStatement();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rset = stmt.executeQuery(_sqlStatement);<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (rset.next()) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; success = true;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String rolename = rset.getString(1);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String user = rset.getString(2);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _dbauth.add(new DBRolePrincipal(rolename));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _dbauth.add(new DBUserPrincipal(user));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _authPrincipals=(Principal[]) _dbauth.toArray(new Principal[_dbauth.size()]); </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rset = stmt.executeQuery(_sqlStatement);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(!rset.next()) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FacesContext facesContext = FacesContext.getCurrentInstance();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,&quot;Your username and/or password is incorrect! &quot;,null);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; facesContext.addMessage(&quot;messages&quot;,message);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp; catch (SQLException e) <br />&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.err.println(e.getMessage());<br />&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp; finally<br />&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rset.close();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stmt.close();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; conn.close();<br />&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; catch (SQLException e)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp; System.err.println(e.getMessage());<br />&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; return success;<br />&nbsp; }</p>
<p>Compile the project <br />Select DBLoginModule.deploy, rightmousebutton and click deploy to JAR file. <br />The jar has to be used in the library of the project. <br />Copy the jar file to the jdev\lib map of your jdeveloper installation. For example: C:\Program Files\jdevstudiobase10133\jdev\lib.&nbsp;<br />The jar file is ready to use, only we have to make is available in the OC4J container. <br />So open the application.xml file, located in JDEV_HOME\jdev\system\oracle.j2ee.10.1.3.41.57 \embedded-oc4j\config map. <br />Replace: &lt;jazn provider=&quot;XML&quot;/&gt; by: </p>
<p>&lt;jazn provider=&quot;XML&quot;&gt;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;property name=&quot;custom.loginmodule.provider&quot; value=&quot;true&quot;/&gt;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;property name=&quot;role.mapping.dynamic&quot; value=&quot;true&quot;/&gt;<br />&lt;/jazn&gt;</p>
<p>And add: &lt;library path=&quot;C:\Program Files\jdevstudiobase10133\jdev\lib\DBLoginModule.jar&quot;/&gt;<br />&nbsp;<br /><font size="4"><strong>Configure system-jazn-data.xml</strong></font> </p>
<p>Letâ€™s open the system-jazn-data.xml file in an editor. The file is located in the JDEV_HOME\jdev\system\oracle.j2ee.10.1.3.41.57 \embedded-oc4j\config map. <br />In the file we add the next lines: <br />&nbsp;&nbsp;&nbsp; &lt;application&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;name&gt;current-workspace-app&lt;/name&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp; &lt;login-modules&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;login-module&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;class&gt;oracle.sample.dbloginmodule.DBTableLM.ALSDBTableLoginModule&lt;/class&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;control-flag&gt;required&lt;/control-flag&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;options&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;option&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;name&gt;addAllRoles&lt;/name&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;true&lt;/value&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/option&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;option&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;name&gt;debug&lt;/name&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;true&lt;/value&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/option&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;option&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;name&gt;data_source_name&lt;/name&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;jdbc/OracleDSSecurity&lt;/value&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/option&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;option&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;name&gt;log_level&lt;/name&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value&gt;ALL&lt;/value&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/option&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/options&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/login-module&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/login-modules&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/application&gt;</p>
<p>These settings we use to make the ALSDBTableLoginModule class available to the application. </p>
<p><font size="4"><strong>Configure data-source.xml</strong></font> </p>
<p>Letâ€™s open the data-source.xml file in an editor. The file is located in the JDEV_HOME\jdev\system\oracle.j2ee.10.1.3.41.57 \embedded-oc4j\config map. <br />In the file we add the next lines: <br />&lt;managed-data-source name=&quot;OracleDSSecurity&quot; connection-pool-name=&quot;Security Pool&quot; jndi-name=&quot;jdbc/OracleDSSecurity&quot;/&gt;</p>
<p>&lt;connection-pool name=&quot;Security Pool&quot;&gt;<br />&lt;connection-factory factory-class=&quot;oracle.jdbc.pool.OracleDataSource&quot; user=&quot;als&quot; password=&quot;als&quot; url=&quot;jdbc:oracle:thin:@localhost:1521:xe&quot;/&gt;<br />&lt;/connection-pool&gt;<br />&nbsp;</p>
<p>User is the database user, and the password is the userâ€™s password. <br />The url is the url of the database. <br />These settings weâ€™ve made, are necessary to make a database connection. <br />&nbsp;</p>
<p>We are now able to login.</p>
]]></content:encoded>
			<wfw:commentRss>http://technology.amis.nl/2008/02/08/using-database-table-for-authentication-in-adf-applications/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>How to implement Amazon webservice in ADF</title>
		<link>http://technology.amis.nl/2007/12/10/how-to-implement-amazon-webservice-in-adf/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-implement-amazon-webservice-in-adf</link>
		<comments>http://technology.amis.nl/2007/12/10/how-to-implement-amazon-webservice-in-adf/#comments</comments>
		<pubDate>Mon, 10 Dec 2007 15:45:58 +0000</pubDate>
		<dc:creator>Johan Tuitel</dc:creator>
				<category><![CDATA[ADF & JHeadstart]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[J(2)EE/Java]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java, JEE, OAS and WebLogic Server]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=2654</guid>
		<description><![CDATA[This article demonstrates how to&#160;build an ADF application on top of the Amazon WebServices for searching books.
1.&#160;Start jdeveloper 10.1.3. 2.0(or newer)
2.&#160;Build a new Application&#160;Application name: AmazonWebservice&#160;Directory name: c:\projects\AmazonWebservice&#160;Application Package prefix:  [...]]]></description>
				<content:encoded><![CDATA[<p>This article demonstrates how to&nbsp;build an ADF application on top of the Amazon WebServices for searching books.<img alt="...." src="wp-content/plugins/xinha4wp/xinha_core/plugins/InsertMore/img/ed_more.png" /></p>
<p>1.&nbsp;Start jdeveloper 10.1.3. 2.0(or newer)</p>
<p>2.&nbsp;Build a new Application<br />&nbsp;Application name: AmazonWebservice<br />&nbsp;Directory name: c:\projects\AmazonWebservice<br />&nbsp;Application Package prefix: aws<br />&nbsp;Application Template: Web Application[JSF, ADF BC]</p>
<p>3.&nbsp;Rightmousebutton at viewController &gt; click new. New Gallery window opens.<br />&nbsp;Select Business Tier &gt; Web Services &gt; Web Service Proxy.<span id="more-2654"></span></p>
<p>4.&nbsp;You will see the Create Web Service Proxy window. Enter at the WSDL Document URL:<br />&nbsp;<a href="http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl">http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl</a><br />&nbsp;and click next.</p>
<p>&nbsp;- The proxy model has been made.<br />&nbsp;- At step 2 click finish.<br />&nbsp;- The webservice proxy is ready to use.<br />&nbsp;- The projectstructure should&nbsp;look like this:</p>
<p><img alt="project structure" hspace="0" src="http://technology.amis.nl/wp-content/uploads/images/pic_1.JPG" align="bottom" border="0" /><br />&nbsp;</p>
<p>5.&nbsp;We are going to make a new java class file. This file represents the book object, which we need for the library.<br />&nbsp;- Rightmousebutton at viewController &gt; click new. New Gallery window opens.<br />&nbsp;- Select general &gt; Java Class<br />&nbsp;- Name: book<br />&nbsp;- Package: aws.item<br />&nbsp;- Extends: java.lang.Object<br />&nbsp;- Public: checked<br />&nbsp;- Generate Default Constructor: checked<br />&nbsp;- Generate Main Method: unchecked</p>
<p>6.&nbsp;We are now implementing the getters and setters for the book.java class.<br />&nbsp;Enter the following in book.java class:<br />&nbsp;private String title;<br />&nbsp;private String url;<br />&nbsp;private String isbn;<br />&nbsp;private String publisher;<br />&nbsp;private String author;<br />&nbsp;Look at the picture below.<br />&nbsp; <img hspace="0" src="http://technology.amis.nl/wp-content/uploads/images/pic_8.JPG" align="bottom" border="0" /></p>
<p>&nbsp;- select in the main menu of jdeveloper &gt; source &gt; Generate Accessors<br />&nbsp;- select all items and click ok.<br />&nbsp;- the getters and setter will be generated.<br />&nbsp;</p>
<p>7.&nbsp;Define the book constructor in book.java class, like the example below.</p>
<p>&nbsp;&nbsp; public book(String title, String url, String isbn , String publisher, String author) {<br />&nbsp;&nbsp;&nbsp;&nbsp; this.title = title;<br />&nbsp;&nbsp;&nbsp;&nbsp; this.url = url;<br />&nbsp;&nbsp;&nbsp;&nbsp; this.isbn = isbn;<br />&nbsp;&nbsp;&nbsp;&nbsp; this.publisher = publisher;<br />&nbsp;&nbsp;&nbsp;&nbsp; this.author = author;<br />&nbsp;&nbsp; }</p>
<p>8.&nbsp;Book.java file is ready </p>
<p>9.&nbsp;The next step for building an Amazon Webservice implementation with ADF in jdeveloper, is building a front-end to show the results from our search actions. For our front-end we will build a jsp file. <br />&nbsp;- Rightmousebutton at viewController &gt; click new<br />&nbsp;Step 1<br />&nbsp;- Select in New gallery window Web Tier &gt; JSF &gt; JSF JSP<br />&nbsp;- File Name: AmazonSearch.jsp<br />&nbsp;- Directory Name: c:\projects\AmazonWebservice\ViewController\public_html<br />&nbsp;- Type: JSP_Page<br />&nbsp;- Mobile: unckeched<br />&nbsp;Step 2<br />&nbsp;- Select: Do Not Automatically Expose UI Components in a Managed Bean<br />&nbsp;Step 3<br />&nbsp;- select the libraries:<br />&nbsp;&nbsp;- ADF Faces Components 10_1_3_2_0<br />&nbsp; &nbsp;- ADF Faces HTML 10_1_3_2_0<br />&nbsp;&nbsp;- JSF Core 1.0<br />&nbsp;&nbsp;- JSF HTML 1.0<br />&nbsp;Click finish.</p>
<p>10.&nbsp;Open faces-config.xml file.<br />&nbsp;<img hspace="0" src="http://technology.amis.nl/wp-content/uploads/images/pic_2.JPG" align="bottom" border="0" /><br />&nbsp;- Select the overview tab<br />&nbsp;- Select managed beans and click new.<br />&nbsp;- Enter the next settings in your create managed bean window:<br />&nbsp;&nbsp;- Name: AmazonWebSearch<br />&nbsp;&nbsp;- Class: aws.backing.AmazonSearch<br />&nbsp;&nbsp;- Scope: session<br />&nbsp;&nbsp;- Generate Class I fit Does Not Exist: checked<br />&nbsp;- An AmazonSearch.java class file is generated in the aws.backing package:<br />&nbsp;<img hspace="0" src="http://technology.amis.nl/wp-content/uploads/images/pic_3.JPG" align="bottom" border="0" /></p>
<p>11.&nbsp;Return to AmazonSearch.jsp file<br />&nbsp;Open the structure window for the AmazonSearch.jsp file(the file is in design mode).<br />&nbsp;- Select tab â€œdesignâ€ in the structure window<br />&nbsp;- Drag from the Component Palette &gt; ADF Faces Core &gt; PanelPage element to h:form in the structure window.</p>
<p>&nbsp;- Drag from the Component palette &gt; ADF Faces Core &gt; Table element to af:PanelPage<br />&nbsp;- An Insert Table window opens in your screen.<br />&nbsp;Step 1<br />&nbsp;- Select Bind now<br />&nbsp;- value: #{AmazonWebSearch.books}<br />&nbsp;- var: book<br />&nbsp;Step 2<br />&nbsp;- header: Title. Value: #{book.title}. Component: af:outputText<br />&nbsp;- header: Isbn. Value: #{book.isbn}. Component: af:outputText<br />&nbsp;- header: Book_image. Value: #{book.url}. Component: af:objectImage<br />&nbsp;Step 3<br />&nbsp;- Select Title &gt; is sortable: checked &gt; sort property: #{book.title}<br />&nbsp;- Select Isbn &gt; is sortable: checked &gt; sort property: #{book.isbn}<br />&nbsp;Step 4<br />&nbsp;- Include Table Banding: checked &gt; select rows &gt; Banding interval: 1<br />&nbsp;- Click finish.</p>
<p>&nbsp;- Enter in the table properties &gt; rows: 10</p>
<p>&nbsp;- Drag from the Component Palette &gt; ADF Faces Core &gt; MenuBar element to the menu2 facet in the panelpage<br />&nbsp;- Drag from the Component Palette &gt; JSF HTML &gt; Panel grid element to the af:menuBar element. Define the number of columns for the panelGrid is 4.<br />&nbsp;- Drag from the Component Palette &gt; ADF Faces Core &gt; OutputText element to the panelgrid.<br />&nbsp;&nbsp;&nbsp;- Enter Selection at the value property, define color &gt; white<br />&nbsp;- Drag from the Component Palette &gt; ADF Faces Core &gt; SelectOneChoice element to the panelgrid.<br />&nbsp;&nbsp;&nbsp;- Insert SelectOneChoice window opens.<br />&nbsp;&nbsp;&nbsp;- Select create list<br />&nbsp;&nbsp;&nbsp;- Item Label: Title. Item Value: title<br />&nbsp;&nbsp;&nbsp;- Item Label: Author. Item Value: author<br />&nbsp;&nbsp;&nbsp;- Item Label: Isbn. Item Value: isbn<br />&nbsp;&nbsp;&nbsp;- Item Label: Keyword. Item Value: keyword<br />&nbsp;&nbsp;&nbsp;- Make sure that the label property is empty, then click ok.<br />&nbsp;- Drag from the Component Palette &gt; ADF Faces Core &gt; inputText element to the panelgrid. Make sure that the label property is empty.<br />&nbsp;- Drag the Component Palette &gt; ADF Faces Core &gt; CommandButton element to the panelgrid. Enter Search at the text property of the commandButton object.</p>
<p>&nbsp;- Select selectOneChoice element and enter: searchCriteria at the id property.<br />&nbsp;- Select inputText element and enter: searchValue at the id property.<br />&nbsp;- Select commandButten element and enter: searchButton at the id property.</p>
<p>&nbsp;The structure of the components should look like this.<br />&nbsp; <img hspace="0" src="http://technology.amis.nl/wp-content/uploads/images/pic_4.JPG" align="bottom" border="0" /></p>
<p>&nbsp;12.&nbsp;The next step that we are going to make is realising a connection with the AmazonSearch.java class with the components selectOneChoice, inputText and commandButton.<br />&nbsp;- Select selectOneChoice &gt; binding(Propery Inspector) &gt; click&nbsp; . <br />&nbsp;&nbsp;- Binding window opens.<br />&nbsp;&nbsp;- Managed Bean: AmazonWebSearch<br />&nbsp;&nbsp;- Property &gt; new.<br />&nbsp;&nbsp;- Create Property window opens<br />&nbsp;&nbsp;- Type searchCriteria &gt; ok &gt; ok</p>
<p>&nbsp;- Select inputText &gt; binding(Propery Inspector) &gt; click&nbsp; . <br />&nbsp;&nbsp;- Binding window opens.<br />&nbsp;&nbsp;- Managed Bean: AmazonWebSearch<br />&nbsp;&nbsp;- Property &gt; new.<br />&nbsp;&nbsp;- Create Property window opens<br />&nbsp;&nbsp;- Type searchValue &gt; ok &gt; ok</p>
<p>&nbsp;&nbsp;- Select AmazonSearch.java and insert:<br />&nbsp;&nbsp; &nbsp;ArrayList books = new ArrayList();<br />&nbsp;&nbsp; See example:<br />&nbsp;&nbsp; <img hspace="0" src="http://technology.amis.nl/wp-content/uploads/images/pic_5.JPG" align="bottom" border="0" /><br />&nbsp;&nbsp;- ArrayList will be red underlined, import java.util.ArrayList package.<br />&nbsp;&nbsp;- We need the get and set method for the books ArrayList. Select in the main menu source &gt; Generate Accessors, then select books item and click ok.</p>
<p>&nbsp;Copy and paste the search() method in the search.java class.</p>
<p>&nbsp;&nbsp; public String search() throws Exception<br />&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp; String criteria = (String) searchCriteria.getValue();<br />&nbsp;&nbsp;&nbsp;&nbsp; String value = (String) searchValue.getValue();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; books = searchBooks(criteria, value);<br />&nbsp;&nbsp;&nbsp;&nbsp; this.setBooks(books);<br />&nbsp;&nbsp;&nbsp;&nbsp; return null;<br />&nbsp;&nbsp; }<br />&nbsp;Open the AmazonSearch.jsp file<br />&nbsp;- Select commandButton &gt; action(Property Inspector)<br />&nbsp;- Enter the value: #{AmazonWebSearch.search} <br />&nbsp;The EL expression uses the method search() in the AmazonSearch.java class.</p>
<p>13.&nbsp;We must now implement the methods for obtaining results of the search action we will do in our AmazonSearch.jsp page. Weâ€™ve already made a method which is used by the commandButton.<br />14.&nbsp;The method search() triggers the method searchBooks(). This method has two parameters. The first parameter is the selected criteria in the jsp file and the second parameter is the entered value by the user.<br />&nbsp;- The for loop within the method is used to call different pages. Amazon has restricted the maximum page at 400.<br />&nbsp;- An if statement is used to determine which method must be called to get the proper data.<br />&nbsp;- The rest of the method is used to put the book items in an ArrayList.</p>
<p>&nbsp;Copy and paste the method displayed below in the AmazonSearch.java file:<br />&nbsp;&nbsp; public ArrayList searchBooks(String criteria, String value) throws Exception<br />&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp; ArrayList books = new ArrayList();<br />&nbsp;&nbsp;&nbsp;&nbsp; ItemsType2 [] itemsArray;<br />&nbsp;&nbsp;&nbsp;&nbsp; int pageNo = 1;<br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp; for(int counter = 1; counter &lt; pageNo + 1; counter++)<br />&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(!criteria.equals(&quot;isbn&quot;))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; itemsArray = OtherSearch(criteria, value, counter);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; itemsArray = ISBNSearch(value);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( itemsArray == null ) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new Exception ( &quot;Server Error &#8211; empty response!&quot; ); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( itemsArray[0].getRequest().getErrors() != null ) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new Exception ( itemsArray [0].getRequest().getErrors().getError()[0].getMessage() );<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( itemsArray != null )<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for ( ItemsType2 items : itemsArray )<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pageNo = 399;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /**********************************************************<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * Items::Item<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /**********************************************************/<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ItemType2 [] itemArray = items.getItem();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( itemArray != null ) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for ( ItemType2 item : itemArray ) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( item != null ) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /**********************************************************<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * Item::ItemAttributes<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /**********************************************************/<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Image smallImage = item.getSmallImage(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch ( Exception ex )<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println( ex.toString());<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp; return books;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp; }</p>
<p>15.&nbsp;The ItemSearchRequest object is been used to search with the criteriaâ€™s: author, title, keyword. Therefore there has been made a different method which returns a ItemsType2[] array. The returnvalue will be used to retrieve the items for the searchBooks method. The method is displayed below. Copy and paste this method into AmazonSearch.java class.</p>
<p>&nbsp;&nbsp; private ItemsType2[] OtherSearch(String searchCriteria, String searchValue, int pageNo) throws Exception<br />&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aws.view.proxy.AWSECommerceServicePortClient myPort = new aws.view.proxy.AWSECommerceServicePortClient();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ItemSearch itemSearch = new ItemSearch();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ItemSearchRequest request = new ItemSearchRequest();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //AWS subscription ID from Amazon so you can use their Web services<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; itemSearch.setSubscriptionId (&quot;08YCQ8XR0HCKRJZFBK82&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request.setResponseGroup (new String [] {&quot;Images&quot;,&quot;ItemAttributes&quot;,&quot;ItemIds&quot;});<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(searchCriteria.equals(&quot;author&quot;))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request.setAuthor(searchValue);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(searchCriteria.equals(&quot;title&quot;))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request.setTitle(searchValue);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(searchCriteria.equals(&quot;keyword&quot;))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request.setKeywords(searchValue);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request.setItemPage(new BigInteger(&quot;&quot;+pageNo));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request.setSearchIndex (&quot;Books&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; itemSearch.setRequest ( new ItemSearchRequest [] { request } );<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Get the response<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MultiOperationResponse response =&nbsp; myPort.multiOperation(null,itemSearch,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( response == null )<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new Exception (&quot;Server Error &#8211; no response recieved!&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ItemsType2 [] itemsArray = response.getItemSearchResponse().getItems(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return itemsArray;&nbsp; <br />&nbsp;&nbsp; }</p>
<p>16.&nbsp;To enable the searchcriteria: isbn, we cannot use the ItemSearchRequest object, but we must use the ItemLookupRequest object. Therefore we have to make an extra method to retrieve the items in an ItemsType2[] array. The method is displayed below. Copy and paste the method to the AmazonSearch.java class file.<br />&nbsp;<br />&nbsp;&nbsp; private ItemsType2[] ISBNSearch(String isbn) throws Exception <br />&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aws.view.proxy.AWSECommerceServicePortClient myPort = new aws.view.proxy.AWSECommerceServicePortClient();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ItemLookup itemLookup = new ItemLookup(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ItemLookupRequest request = new ItemLookupRequest(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //AWS subscription ID from Amazon so you can use their Web services<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; itemLookup.setSubscriptionId ( &quot;0525E2PQ81DD7ZTWTK82&quot; ); </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request.setMerchantId(&quot;All&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request.setCondition(Condition.New); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request.setItemId(new String[]{isbn});<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request.setResponseGroup (new String [] {&quot;Images&quot;,&quot;ItemAttributes&quot;,&quot;ItemIds&quot;});</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; itemLookup.setRequest ( new ItemLookupRequest [] { request } ); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Get the response <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MultiOperationResponse response = myPort.multiOperation(null,null,itemLookup,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( response == null ) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new Exception ( &quot;Server Error &#8211; no response recieved!&quot; );<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ItemsType2 [] itemsArray = response.getItemLookupResponse().getItems();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return itemsArray;&nbsp; <br />&nbsp;&nbsp; }<br />&nbsp;If the myPort.multiOperation, doesnâ€™t work! You have to search in AWSECommerceServicePortClient.java file the correct method to use for returning a correct response object.</p>
<p>17.&nbsp;The next import statements must be realised in AmazonSearch.java(Suggestion! Copy and paste)<br />&nbsp;import aws.item.book;</p>
<p>&nbsp;import aws.view.proxy.Condition;<br />&nbsp;import aws.view.proxy.Image;<br />&nbsp;import aws.view.proxy.ItemAttributes;<br />&nbsp;import aws.view.proxy.ItemLookup;<br />&nbsp;import aws.view.proxy.ItemLookupRequest;<br />&nbsp;import aws.view.proxy.ItemSearch;<br />&nbsp;import aws.view.proxy.ItemSearchRequest;<br />&nbsp;import aws.view.proxy.ItemType2;<br />&nbsp;import aws.view.proxy.ItemsType2;<br />&nbsp;import aws.view.proxy.MultiOperationResponse;</p>
<p>&nbsp;import java.math.BigInteger;</p>
<p>&nbsp;import java.util.ArrayList;</p>
<p>&nbsp;import oracle.adf.view.faces.component.core.input.CoreInputText;<br />&nbsp;import oracle.adf.view.faces.component.core.input.CoreSelectOneChoice;<br />18.&nbsp;The final thing we have to do is creating a map in de project and insert a transparent gif file in this map.<br />&nbsp;- Create a map in the window explorer like the example below, call the map: images<br />&nbsp;<img hspace="0" src="http://technology.amis.nl/wp-content/uploads/images/pic_6.JPG" align="bottom" border="0" /> <br />&nbsp;- Find a transparant picture at google pictures<br />&nbsp;- Call it k4transparant.gif<br />&nbsp;- Resize the picture if you are compelled to. <br />&nbsp;- An example of a transparent picture is shown next.<br />&nbsp;<img hspace="0" src="http://technology.amis.nl/wp-content/uploads/images/pic_7.JPG" align="bottom" border="0" /><br />19.&nbsp;Finished, you are now able to run the AmazonSearch.jsp file, an example of the project is shown below.</p>
<p><img hspace="0" src="http://technology.amis.nl/wp-content/uploads/images/pic_9.JPG" align="baseline" border="0" /></p>
<p>20.&nbsp;Look at the <a href="http://www.awszone.com/">http://www.awszone.com/</a> for any useful documentation.<br />21.&nbsp;Developer guide: <a href="http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=19">http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=19</a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://technology.amis.nl/2007/12/10/how-to-implement-amazon-webservice-in-adf/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
