Skip to main content link. Accesskey S
  • HCL Logo
  • HCL Connections On-Premise Wiki
  • THIS WIKI IS READ-ONLY.
  • HCL Forums and Blogs
  • Home
  • API Documentation
Search
Community Articles > Connections SDK articles > Getting Started as a Java Developer
  • Share Show Menu▼

Recent articles by this author

Getting Started as a JavaScript Developer

The SDK comes with JavaScript APIs to easily access Connections Cloud.

Getting Started as a Java Developer

The SDK comes with Java APIs to easily access Connections Social.
Community articleGetting Started as a Java Developer
Added by ~Dexter Zenjipylitader | Edited by ~Dexter Zenjipylitader on October 28, 2014 | Version 19
  • Actions Show Menu▼
expanded Abstract
collapsed Abstract
The SDK comes with Java APIs to easily access Connections Social.
ShowTable of Contents
HideTable of Contents
  • 1 Introduction
  • 2 Watch a Video with Sample Snippets
  • 3 Prepare your Environment
  • 4 Code your first app
  • 5 Learn More

Introduction

The SDK comes with Java APIs to easily access IBM Connections Cloud. Watch this video for a short overview of the SDK.

Note: This article is reproduced from the original version published on the IBM Social Business website.


Watch a Video with Sample Snippets

Watch this video (at 2m30s) to see some simple JSP samples.



Prepare your Environment

In order to use the SDK within your applications, you need to download and install the SDK.

Download the latest SDK

There are simple Java snippets that can be run from an Eclipse IDE. The complete Eclipse workspace with the samples and a local Tomcat server comes with the SDK which can easily be used in Eclipse IDEs.


Code your first app

Build a Hello World web application using Eclipse and Tomcat 7.0

1. Click File > New > Dynamic Web Project.

Specify the project name as social.helloworld-web.

Click Finish.


New Dynamic Web Project dialog 1


New Dynamic Web Project dialog 2

2. Right-click social.helloworld-web and create a new folder named lib.
Add the following SDK dependency .jar files to the lib folder (available from one of the existing sample WAR files).


apache-mime4j-0.6.jar
com.ibm.commons-1.0.0.jar
com.ibm.commons.runtime-1.0.0.jar
com.ibm.commons.xml-1.0.0.jar
com.ibm.sbt.core-1.0.0.jar
com.ibm.sbt.playground-1.0.0.jar
commons-codec-1.3.jar
commons-logging-1.1.1.jar
httpclient-4.0.1.jar
httpcore-4.0.1.jar
httpmime-4.0.1.jar
commons-fileupload-1.2.2.jar
commons-io-2.4.jar


They appear in the file system.

sbt.helloworld.libs

3. To update the build path and deployment assembly properties of social.helloworld-web, right-click social.helloworld-web and select properties.

A. Select Java Build Path > Add Jars and add all SDK .jar files from the lib folder.

B. Select Deployment Assembly > Add > Java Build Path Entries and select all SDK .jar files.

C. Click Apply and OK.


Java Build Path dialog


Web Deployment Assembly dialog

4. Click File > New > Servlet to create a new servlet for toolkit services. Provide the following information:
  • Use the existing servlet class: com.ibm.sbt.service.core.servlet.ServiceServlet
  • Name: ServiceServlet
  • Description: The service servlet handles requests from the toolkit to access external resources.
  • URL mappings: /service/*

Create Servlet dialog

5. Click File > New > Servlet to create a new servlet for initializing the toolkit JavaScript library.
  • Use the existing servlet class: com.ibm.sbt.jslibrary.servlet.LibraryServlet
  • Name: LibraryServlet
  • Description: This servlet initializes the specified JavaScript library for use by the Connections Cloud SDK.
  • URL Patterns: /library/*
6. Click File > New > Filter to create a new filter for creating the toolkit application and context objects. Provide the following information:
  • Use the existing filter class: com.ibm.sbt.util.SBTFilter
  • Description: This filter is responsible for creating the toolkit application and context objects for every servlet within this web application.
  • URL Patterns: /*
7. Add the following lines to web.xml.
<resource-ref>
<description>Reference to a URL resource which points to the configuration properties for the Social Business Toolkit.</description>
<res-ref-name>url/ibmsbt-sbtproperties</res-ref-name>
<res-type>java.net.URL</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>


8. Create the file managed-beans.xml in the WebContent\WEB-INF folder.

9. Copy sbt.properties from sbtsdk\config and place it in tomcat-config. This file needs to be customized, for example, with the URL to IBM Connections.

sbt

10. Create a new .jsp file named ViewMyConnectionsFiles.jsp.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.ibm.sbt.services.client.connections.files.model.FileRequestParams"%>
<%@page import="java.util.HashMap"%>
<%@page import="com.ibm.sbt.services.client.connections.files.FileService"%>
<%@page import="com.ibm.sbt.services.client.connections.files.model.FileEntry"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Map"%>
<%@page import="com.ibm.commons.runtime.Application"%>
<%@page import="com.ibm.commons.runtime.Context"%>  
<html>
  <head><title>My Files</title></head>
  <body>
    <div id="content">
    <%
      try {
        FileService fileService = new FileService();
        List<FileEntry> files = fileService.getPublicFiles(null);
        if(files != null && ! files.isEmpty()) {
          for (Iterator iterator = files.iterator(); iterator.hasNext();) {
            FileEntry file = (FileEntry)iterator.next();
            out.println("<a href=\"" + file.getDownloadLink() + "\"> " + file.getLabel() + "</a><br/>" );
          }
        } else {
          out.println("No Results");
        }
      } catch (Throwable e) {} 
    %>
  </div>
</body> 
</html>
11. Right-click the .jsp file and select Run as > Run on Server for the configured server.
Click Finish.
Run on Server menu

Learn More

To find out what functionality the SDK provides read the Java API documentation. There are articles how to install and configure the SDK. Additionally there is a tutorial and a webinar to learn how to create a J2EE application from scratch.


  • Actions Show Menu▼


expanded Attachments (0)
collapsed Attachments (0)
Edit the article to add or modify attachments.
expanded Versions (1)
collapsed Versions (1)
Version Comparison     
VersionDateChanged by              Summary of changes
This version (19)Oct 28, 2014, 12:42:59 PM~Dexter Zenjipylitader  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedAbout
  • HCL Software
  • HCL Digital Solutions community
  • HCL Software support
  • BlogsDigital Solutions blog
  • Community LinkHCL Software forums and blogs
  • About HCL Software
  • Privacy
  • Accessibility