forked from jboss-developer/jboss-portal-quickstarts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.html
237 lines (188 loc) · 18.3 KB
/
README.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<!DOCTYPE html><html><head><title>README</title><link href="https://raw.github.com/pmuir/github-flavored-markdown/gh-pages/shared/css/documentation.css" rel="stylesheet"></link><link href="https://raw.github.com/github/github-flavored-markdown/gh-pages/shared/css/pygments.css" rel="stylesheet"></link></head><body><!--~ Do not edit this derived file! See jboss-portal-quickstarts/src/main/freemarker/social-portlets/README.html.ftl ~-->
<h1><a id="socialportlets-social-portlets" class="anchor" href="#socialportlets-social-portlets"><span class="anchor-icon"></span></a>social-portlets: Social Portlets</h1>
<p>Author: Marek Posolda, Viliam Rockai<br/>
Level: Intermediate<br/>
Technologies: Portlet, JSP, OAuth, CDI<br/>
Summary: Portlets showing integration with Social networks<br/>
Target Product: JBoss Portal<br/>
Source: <a href="https://github.com/jboss-developer/jboss-portal-quickstarts.git">https://github.com/jboss-developer/jboss-portal-quickstarts.git</a></p>
<h2><a id="what-is-it" class="anchor" href="#what-is-it"><span class="anchor-icon"></span></a>What is it?</h2>
<p>This project demonstrates how to create social portlets in Red Hat JBoss Portal with usage of
Red Hat JBoss Portal API and JSP front-end. It contains:</p>
<ul>
<li>3 portlets for <a href="https://www.facebook.com">Facebook</a> integration, which are using <a href="https://developers.facebook.com/docs/reference/api/">Facebook Graph API</a> and leverages <a href="http://restfb.com/">RestFB library</a> for this purpose</li>
<li>3 portlets for <a href="https://plus.google.com/">Google+</a> integration, which are using <a href="https://developers.google.com/accounts/docs/OAuth2">Google OAuth2 API</a> and <a href="https://developers.google.com/+/api/latest/">Google+ API</a></li>
<li>1 portlet for <a href="https://twitter.com/">Twitter</a> integration, which is using Twitter API and leverages <a href="http://twitter4j.org/en/index.html">Twitter4j library</a> for this purpose</li>
</ul>
<p>Portlets require that Red Hat JBoss Portal integration with particular social network is enabled. You can see
chapter <a href="https://access.redhat.com/site/documentation/en-US/JBoss_Portal_Platform/6.2/html/Administration_and_Configuration_Guide/chap-OAuth_-_Authentication_with_Social_Network_accounts.html">OAuth - Authentication with social network accounts</a> in Red Hat JBoss Portal
reference guide for details.</p>
<p>Each portlet is using access token of current authenticated portal user and this access token is
used to call Social API operations. There is special portlet filter OAuthPortletFilter, which leverages
<a href="https://access.redhat.com/site/documentation/en-US/JBoss_Portal_Platform/6.2/html/Development_Guide/part-Portal_API.html">Portal API</a> to obtain informations about access token of current user. Filter saves this info
to CDI RequestContext object, which is used by particular portlet.</p>
<p>An introduction and some background information to this quickstart can be found in the following chapters
of Red Hat JBoss Portal Developer Guide:</p>
<ul>
<li><a href="https://access.redhat.com/site/documentation/en-US/JBoss_Portal_Platform/6.2/html/Development_Guide/sect-Starting_a_Portlet_Project.html">Starting a Portlet Project</a></li>
<li><a href="https://access.redhat.com/site/documentation/en-US/JBoss_Portal_Platform/6.2/html/Development_Guide/sect-Standard_Portlet_Development_JSR-286.html">Standard Portlet Development (JSR-286)</a></li>
<li><a href="https://access.redhat.com/site/documentation/en-US/JBoss_Portal_Platform/6.2/html/Development_Guide/part-Portal_API.html">Portal API</a></li>
</ul>
<p>Informations about configuration of OAuth authentication and integration with social networks could be found in the following
chapters of Red Hat JBoss Portal Reference Guide:</p>
<ul>
<li><a href="https://access.redhat.com/site/documentation/en-US/JBoss_Portal_Platform/6.2/html/Administration_and_Configuration_Guide/chap-OAuth_-_Authentication_with_Social_Network_accounts.html">OAuth - Authentication with social network accounts</a></li>
<li><a href="https://access.redhat.com/site/documentation/en-US/JBoss_Portal_Platform/6.2/html/Development_Guide/Facebook.html">Facebook</a></li>
<li><a href="https://access.redhat.com/site/documentation/en-US/JBoss_Portal_Platform/6.2/html/Development_Guide/Google.html">Google+</a></li>
<li><a href="https://access.redhat.com/site/documentation/en-US/JBoss_Portal_Platform/6.2/html/Development_Guide/Twitter.html">Twitter</a></li>
</ul>
<!--~ Included from gatein-portal-quickstarts-parent/src/main/freemarker/include/portlet-general.md.ftl ~-->
<!--~ Included from gatein-portal-quickstarts-parent/src/main/freemarker/include/system-requirements.md.ftl ~-->
<h2><a id="system-requirements" class="anchor" href="#system-requirements"><span class="anchor-icon"></span></a>System Requirements</h2>
<p>All you need to build this example project is Java 6.0 (Java SDK 1.6) or newer and Maven 3.0 or newer.</p>
<p>The project is designed to be deployed on Red Hat JBoss Portal 6.2 running on JBoss EAP.</p>
<!--~ Included from gatein-portal-quickstarts-parent/src/main/freemarker/include/configure-maven.md.ftl ~-->
<h2><a id="configure-maven" class="anchor" href="#configure-maven"><span class="anchor-icon"></span></a>Configure Maven</h2>
<p>You have two options how you can configure Maven: A. Use hosted Maven repository or B. Download & setup zipped Maven repository.</p>
<h3><a id="a-use-hosted-maven-repository" class="anchor" href="#a-use-hosted-maven-repository"><span class="anchor-icon"></span></a>A. Use hosted Maven repository</h3>
<p>This is the easier and thus recommended option. You need to configure the Maven user settings as follows:</p>
<ul>
<li><p>Look for the <code>settings.xml</code> file in the <code>${user.home}/.m2/</code> directory. For example:</p>
<div class="highlight"><pre><span class="n">For</span> <span class="n">Linux</span> <span class="n">or</span> <span class="n">Mac</span><span class="o">:</span> <span class="o">~/</span><span class="p">.</span><span class="n">m2</span><span class="o">/</span><span class="n">settings</span><span class="p">.</span><span class="n">xml</span>
<span class="n">For</span> <span class="n">Windows</span><span class="o">:</span> <span class="err">\</span><span class="n">Users</span><span class="err">\</span><span class="n">USER_NAME</span><span class="err">\</span><span class="p">.</span><span class="n">m2</span><span class="err">\</span><span class="n">settings</span><span class="p">.</span><span class="n">xml</span> <span class="n">or</span> <span class="err">\</span><span class="n">Documents</span> <span class="n">and</span> <span class="n">Settings</span><span class="err">\</span><span class="n">USER_NAME</span><span class="err">\</span><span class="p">.</span><span class="n">m2</span><span class="err">\</span><span class="n">settings</span><span class="p">.</span><span class="n">xml</span>
</pre></div></li>
<li><p>If you have an existing <code>settings.xml</code> file, modify it with the configuration information from the <code>settings-hosted-repo.xml</code>
file located in the root folder of Red Hat JBoss Portal quickstarts. This effectivelly results in
adding <code>http://maven.repository.redhat.com/techpreview/all</code> as <code><repository></code> and <code><pluginRepository></code> to your <code>settings.xml</code>.</p></li>
<li><p>If there is no <code>settings.xml</code> file, copy the <code>settings-hosted-repo.xml</code> file to the <code>.m2</code> directory for your
operating system and rename it to <code>settings.xml</code>.</p></li>
</ul>
<h3><a id="b-download-amp-setup-zipped-maven-repositories" class="anchor" href="#b-download-amp-setup-zipped-maven-repositories"><span class="anchor-icon"></span></a>B. Download & setup zipped Maven repositories</h3>
<ol>
<li><p>Download the following zipped Maven repositories from <a href="https://access.redhat.com/">Red Hat Customer Portal</a>,
Downloads > JBoss Enterprise Middleware:</p>
<ul>
<li>Red Hat JBoss Portal 6.2.0 Maven Repository</li>
<li>Red Hat JBoss Portal 6.1.1 Maven Repository</li>
<li>JBoss Portal Platform 6.1.0 Maven Repository</li>
<li>JBoss Enterprise Portal Platform (EPP) 6.0.0 Maven Repository</li>
<li>Web Framework Kit 2.4.0 Maven Repository</li>
<li>Web Framework Kit 2.3.0 Maven Repository</li>
<li>Web Framework Kit 2.2.0 Maven Repository</li>
<li>Web Framework Kit 2.1.0 Maven Repository</li>
<li>Web Framework Kit 2.0.0 Maven Repository</li>
<li>Application Platform 6.3.0 Maven Repository</li>
<li>Application Platform 6.2.0 Maven Repository</li>
<li>Application Platform 6.1.0 Maven Repository</li>
<li>Application Platform 6.0.1 Maven Repository</li>
<li>Application Platform 6.0.0 Maven Repository</li>
</ul>
<p>Unpack each of these files to a separate directory.</p></li>
<li><p>Modify the <code>settings-zipped-repos.xml</code> file located in the root directory of Red Hat JBoss Portal
quickstarts:</p>
<ul>
<li>For each zipped repository unpacked in the previous step, replace <code>/path/to/repo/</code> within <code>file:///path/to/repo/...</code>
with the fully qualified path of the directory where you unpacked the given zipped Maven repository in the previous
step.</li>
<li>Note that path to each repository needs tobe set twice: one within <code><repository></code> tag and one within
<code><pluginRepository></code> tag.</li>
<li><p>Be sure to use 3 forward slashes after <code>file:</code>. Two slashes are there for the protocol and one for the fully qualified
path. For example:</p>
<div class="highlight"><pre><span class="nl">file:</span><span class="c1">///home/joedoe/Quickstarts/jpp-6.2-quickstarts</span>
</pre></div></li>
</ul></li>
<li><p>Configure the Maven user settings.</p>
<ul>
<li><p>Look for the <code>settings.xml</code> file in the <code>${user.home}/.m2/</code> directory. For example:</p>
<div class="highlight"><pre><span class="n">For</span> <span class="n">Linux</span> <span class="n">or</span> <span class="n">Mac</span><span class="o">:</span> <span class="o">~/</span><span class="p">.</span><span class="n">m2</span><span class="o">/</span><span class="n">settings</span><span class="p">.</span><span class="n">xml</span>
<span class="n">For</span> <span class="n">Windows</span><span class="o">:</span> <span class="err">\</span><span class="n">Users</span><span class="err">\</span><span class="n">USER_NAME</span><span class="err">\</span><span class="p">.</span><span class="n">m2</span><span class="err">\</span><span class="n">settings</span><span class="p">.</span><span class="n">xml</span> <span class="n">or</span> <span class="err">\</span><span class="n">Documents</span> <span class="n">and</span> <span class="n">Settings</span><span class="err">\</span><span class="n">USER_NAME</span><span class="err">\</span><span class="p">.</span><span class="n">m2</span><span class="err">\</span><span class="n">settings</span><span class="p">.</span><span class="n">xml</span>
</pre></div></li>
<li><p>If you have an existing <code>settings.xml</code> file, modify it with the configuration information from the <code>example-settings.xml</code>
file.</p></li>
<li><p>If there is no <code>settings.xml</code> file, copy the modified <code>example-settings.xml</code> file to the <code>.m2</code> directory for your
operating system and rename it to <code>settings.xml</code>.</p></li>
</ul></li>
</ol>
<!--~ Included from gatein-portal-quickstarts-parent/src/main/freemarker/include/start-the-portal.md.ftl ~-->
<h2><a id="start-the-portal" class="anchor" href="#start-the-portal"><span class="anchor-icon"></span></a>Start the Portal</h2>
<ol>
<li>Open a command line and navigate to the root of the JBoss server directory.</li>
<li><p>The following shows the command line to start the server with the web profile:</p>
<div class="highlight"><pre><span class="n">For</span> <span class="n">Linux</span><span class="o">:</span> <span class="n">JBOSS_HOME</span><span class="o">/</span><span class="n">bin</span><span class="o">/</span><span class="n">standalone</span><span class="p">.</span><span class="n">sh</span>
<span class="n">For</span> <span class="n">Windows</span><span class="o">:</span> <span class="n">JBOSS_HOME</span><span class="err">\</span><span class="n">bin</span><span class="err">\</span><span class="n">standalone</span><span class="p">.</span><span class="n">bat</span>
</pre></div></li>
</ol>
<h2><a id="build-and-deploy-the-quickstart" class="anchor" href="#build-and-deploy-the-quickstart"><span class="anchor-icon"></span></a>Build and Deploy the Quickstart</h2>
<ol>
<li>Make sure you have started the Portal as described above.</li>
<li>Open a command line and navigate to the root directory of this quickstart.</li>
<li><p>Type this command to build and deploy the archive:</p>
<div class="highlight"><pre><span class="n">mvn</span> <span class="n">clean</span> <span class="n">package</span> <span class="n">jboss</span><span class="o">-</span><span class="n">as</span><span class="o">:</span><span class="n">deploy</span>
</pre></div>
<p>To deploy to other than default localhost:9999 JBoss instance, copy the following configuration
just after <code><artifactId>jboss-as-maven-plugin</artifactId></code> in the pom.xml file and adjust it to suit your needs.
<code>username</code> and <code>password</code> elements can be omitted sometimes, depending on your JBoss security settings.</p>
<div class="highlight"><pre><span class="nt"><configuration></span>
<span class="nt"><hostname></span>127.0.0.1<span class="nt"></hostname></span>
<span class="nt"><port></span>9999<span class="nt"></port></span>
<span class="nt"><username></span>admin<span class="nt"></username></span>
<span class="nt"><password></span>secret<span class="nt"></password></span>
<span class="nt"></configuration></span>
</pre></div>
<p>This will deploy <code>target/social-portlets.war</code> to the running instance of the portal.</p></li>
</ol>
<h2><a id="access-the-deployed-portlet" class="anchor" href="#access-the-deployed-portlet"><span class="anchor-icon"></span></a>Access the deployed Portlet</h2>
<p>To ensure that the example portlet has been deployed successfully, do the following:</p>
<ul>
<li>Point your web browser at the base URL of your portal (URL of a default local Red Hat JBoss Portal installation is
<a href="http://127.0.0.1:8080/portal/classic">http://127.0.0.1:8080/portal/classic</a>).</li>
<li>Sign in as root or other user with manager:/platform/administrators permissions.</li>
<li>Go to Top Menu > Group > Administration > Application Registry and hit Import Applications. After that, you should
see the newly imported Social Portlets under the Quickstarts Category.</li>
<li>Then you can add the example portlet to a page of your choice: either (a) to a new page or (b) to an existing page.
<ul>
<li>If you have chosen (a) to add the portlet to a new page:
<ul>
<li>Go to Top Menu > Group Editor > Add New Page</li>
<li>In the Page Creation Wizard, fill in:
<ul>
<li>Node Name: social-portlets</li>
<li>Display Name: Social Portlets</li>
</ul></li>
<li>Click Next</li>
<li>Leave Empty Layout as it is and hit Next</li>
<li>Drag-and-Drop Social Portlets from the Page Editor dialog to the middle of the Page Creation Wizard</li>
<li>Click the Diskette-like Finish button in the header of the Page Editor dialog and see the newly added portlet in action.</li>
</ul></li>
<li>If you have chosen (b) to add the portlet to an existing page:
<ul>
<li>Navigate to the page where you want to add the portlet and go to Top Menu > Group Editor > Edit Page</li>
<li>Drag-and-Drop Social Portlets from the Page Editor dialog to a place of your choice within the page.</li>
<li>Click the Diskette-like Finish button in the header of the Page Editor dialog and see the newly added portlet in action.</li>
</ul></li>
</ul></li>
</ul>
<h2><a id="undeploy-the-archive" class="anchor" href="#undeploy-the-archive"><span class="anchor-icon"></span></a>Undeploy the Archive</h2>
<ol>
<li>Make sure you have started the JBoss Server as described above.</li>
<li>Open a command line and navigate to the root directory of this quickstart.</li>
<li><p>When you are finished testing, type this command to undeploy the archive:</p>
<div class="highlight"><pre><span class="n">mvn</span> <span class="n">jboss</span><span class="o">-</span><span class="n">as</span><span class="o">:</span><span class="n">undeploy</span>
</pre></div></li>
</ol>
<h2><a id="use-jboss-developer-studio-or-eclipse-with-jboss-tools-to-run-this-quickstart" class="anchor" href="#use-jboss-developer-studio-or-eclipse-with-jboss-tools-to-run-this-quickstart"><span class="anchor-icon"></span></a>Use JBoss Developer Studio or Eclipse with JBoss Tools to Run this Quickstart</h2>
<p>You can also deploy the quickstarts from Eclipse using JBoss Tools. For more information on how to set up Maven and JBoss Tools,
refer to the
<a href="https://access.redhat.com/knowledge/docs/JBoss_Enterprise_Application_Platform/">JBoss Enterprise Application Platform 6 Development Guide</a>
or <a href="http://www.jboss.org/jdf/quickstarts/jboss-as-quickstart/guide/Introduction/" title="Get Started Developing Applications">Get Started Developing Applications</a>.</p>
<!--~ Included from gatein-portal-quickstarts-parent/src/main/freemarker/include/debug.md.ftl ~-->
<h2><a id="debug-the-application" class="anchor" href="#debug-the-application"><span class="anchor-icon"></span></a>Debug the Application</h2>
<p>If you want to debug the source code or look at the Javadocs of any library in the project, run either of the following
commands to pull them into your local repository. The IDE should then detect them.</p>
<div class="highlight"><pre><span class="n">mvn</span> <span class="n">dependency</span><span class="o">:</span><span class="n">sources</span>
<span class="n">mvn</span> <span class="n">dependency</span><span class="o">:</span><span class="n">resolve</span> <span class="o">-</span><span class="n">Dclassifier</span><span class="o">=</span><span class="n">javadoc</span>
</pre></div>
<!--~ Included from gatein-portal-quickstarts-parent/src/main/freemarker/include/feedback.md.ftl ~-->
<h2><a id="feedback" class="anchor" href="#feedback"><span class="anchor-icon"></span></a>Feedback</h2>
<p>Please post feedback on this quickstart or Red Hat JBoss Portal on <a href="https://access.redhat.com/groups/jboss-enterprise-middleware">Online User Group</a>.</p>
</body></html>