livelink wcm server - universit¤t leipzig

44
Livelink WCM Server Programming Guide for the WCM Lightweight API This manual describes the Lightweight Java programming interface of Livelink WCM Server, which allows external programs to use the functionality of the WCM servers with efficient resource usage. WM090700-PLA-EN-1 Great Minds Working Together

Upload: others

Post on 12-Sep-2021

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Livelink WCM Server - Universit¤t Leipzig

Livelink WCM Server

Programming Guide for the WCM Lightweight API

This manual describes the Lightweight Java programming interface of Livelink WCM Server, which allows external programs to use the functionality of the WCM servers with efficient resource usage.

WM090700-PLA-EN-1

Great Minds Working Together

Page 2: Livelink WCM Server - Universit¤t Leipzig

Livelink WCM Server Programming Guide for the WCM Lightweight API WM090700-PLA-EN-1 Rev.: 2007-Mar-08

Copyright © 2007 by Open Text Corporation

The copyright to these materials and any accompanying software is owned, without reservation, by Open Text Corporation. These materials and any accompanying software may not be copied in whole or part without the express, written permission of Open Text Corporation. Open Text Corporation is the owner of the trademarks Open Text, 'Great Minds Working Together', Livelink, and MeetingZone among others. This list is not exhaustive. All other products or company names are used for identification purposes only, and are trademarks of their respective owners. All rights reserved. Open Text Corporation provides certain warranties and limitations in connection with the software that this document describes. For information about these warranties and limitations, refer to the license agreement entered into between the licensee and Open Text Corporation.

Adobe is a trademark of Adobe Systems Incorporated. Lotus and Lotus Notes are registered trademarks of Lotus Development Corporation. Domino is a trademark of Lotus Development Corporation. Microsoft and Microsoft SQL are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. Oracle is a registered trademark of Oracle Corporation. Netscape and the Netscape N and Ship's Wheel logos are registered trademarks of Netscape Communications Corporation in the U.S. and other countries.

Contacting Us Open Text Corporation Corporate Headquarter 275 Frank Tompa Drive, Waterloo, Ontario, Canada N2L 0A1 +1 (519) 888-7111

If you subscribe to our Customer Assistance Program or would like more information about the support program, write to Open Text Corporation's Customer Support at [email protected] or telephone +1 (800) 540-7292 or +1 (519) 888-9933. Our support hours are Monday through Friday, 8:30 a.m. to 8 p.m. (EST).

If you have comments or suggestions regarding this documentation, write to the Open Text Corporation Publications Group at [email protected]

For more information about Open Text Corporation's products and services, visit our home page at http://www.opentext.com.

© 2007 IXOS SOFTWARE AG

Werner-v.-Siemens-Ring 20 85630 Grasbrunn, Germany

Tel.: +49 (89) 4629-0 Fax: +49 (89) 4629-1199 eMail: [email protected] Internet: http://www.ixos.com

All rights reserved, including those regarding reproduction, copying or other use or communication of the contents of this document or parts thereof. No part of this publication may be reproduced, transmitted to third parties, processed using electronic retrieval systems, copied, distributed or used for public demonstration in any form without the written consent of IXOS SOFTWARE AG. We reserve the right to update or modify the contents. Any and all information that appears within illustrations of screenshots is provided coincidentally to better demonstrate the functioning of the software. IXOS SOFTWARE AG hereby declares that this information reflects no statistics of nor has any validity for any existing company. This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/)

Page 3: Livelink WCM Server - Universit¤t Leipzig

and software developed by the Apache Software Foundation (http://www.apache.org/).

Trademarks IXOS: IXOS SOFTWARE AG.

SAP®, R/3® and SAP ArchiveLink® are registered trademarks of SAP AG.

Microsoft®, Microsoft Windows NT® and the names of further Microsoft products are registered trademarks of Microsoft Corporation.

Acrobat Reader Copyright © 1987 Adobe Systems Incorporated. All rights reserved. Adobe and Acrobat are trademarks of Adobe Systems Incorporated which may be registered in certain jurisdictions.

Siebel® is a registered trademark by Siebel Systems, Inc.

Other product names are used only to identify the products and they may be registered trademarks of the relevant manufac-turers.

Page 4: Livelink WCM Server - Universit¤t Leipzig
Page 5: Livelink WCM Server - Universit¤t Leipzig

WM090700-PLA-EN-1 Livelink WCM Server 5

Table of Contents

1 Introduction ............................................................................... 7 1.1 About this guide ....................................................................................... 8 1.2 Overview of documentation for Livelink WCM Server ............................. 9 1.3 Conventions ........................................................................................... 10 1.4 Terminology ........................................................................................... 12 1.5 Contact information ................................................................................ 12

2 Installation of the WCM Lightweight API ............................... 13 2.1 Installation of the WCM Lightweight API on a Livelink WCM Server..... 13 2.2 Installation of the WCM Lightweight API on a client .............................. 16

3 Application examples.............................................................. 23 3.1 Desktop application example ................................................................. 23 3.2 Web application example....................................................................... 28

4 Appendix: Tag Library ............................................................ 33 4.1 checkLogin ............................................................................................. 33 4.2 getSessionManager ............................................................................... 34 4.3 getSession ............................................................................................. 35 4.4 getObjectManager.................................................................................. 35 4.5 getObject................................................................................................ 36 4.6 logout ..................................................................................................... 37 4.7 searchMetadata ..................................................................................... 37 4.8 searchCollection..................................................................................... 39 4.9 sort ......................................................................................................... 40

IX Index......................................................................................... 43

Page 6: Livelink WCM Server - Universit¤t Leipzig
Page 7: Livelink WCM Server - Universit¤t Leipzig

WM090700-PLA-EN-1 Livelink WCM Server 7

Chapter 1 Introduction

Functionality of this API

The WCM Lightweight API provides remote access to services of Livelink Web Content Management Server™ (Livelink WCM Server for short) via a Java 5-based programming interface. These services include for example the authentication of users and the administration of website content. Using the WCM Lightweight API classes and interfaces, you can access the WCM-managed content and use it in the context of your own software development outside the Java virtual machine of a Livelink WCM Server, e.g. to implement an Eclipse plugin for WCM-managed content. This API allows you to:

• develop Web applications which run outside the Web application or Java virtual machine of the Livelink WCM Server.

• develop “small” Web applications which need only few resources from the Web server.

• use the Web application in failover or load balancing scenarios.

The central functions of Livelink WCM Server that you may access via the WCM Lightweight API include:

• object management, e.g. reading, adding, editing, and deleting WCM objects

• authentication

Access to the remote services of the WCM Lightweight API is provided by a server agent, which runs in a WCM server.

Page 8: Livelink WCM Server - Universit¤t Leipzig

Chapter 1 Introduction

8 Livelink WCM Server WM090700-PLA-EN-1

Caution Incorrect use of the programming interface described in this manual may lead to errors in the WCM system including system crashes and data loss. Incorrect programming can also cause problems related to performance and system resources. For this reason it is essential to test the developed software in terms of correctness, stability, robustness, and performance before putting it to productive operation.

Open Text cannot assume any liability for the correct functionality of the developed software. Open Text Global Services can help you plan and implement solutions. This may help you avoid problems right from the start.

Differences to other APIs

The WCM Lightweight API offers functionality similar to the Remote/Java API, but requires much less resources, i.e. it is a lightweight API. The WCM Lightweight API offers a cache for the metadata of WCM objects which strongly reduces the number of RMI calls (RMI = remote method invocation). Furthermore, the WCM objects can be read directly from the database by the client application which is much faster compared to reading via RMI. Compared to the Portal Manager API, fewer resources are required because Web applications can run outside the Livelink WCM Server. The advantages of the WCM Lightweight API are as follows:

• The implemented cache requires much less main memory than the cache used by the Livelink WCM Server.

• The number of Java classes is significantly smaller.

• The load of the Livelink WCM Server is strongly reduced because the WCM Lightweight API (default configuration) reads the WCM objects directly from the database, therefore fewer JDBC pools are required

• The WCM system is more stable, because the actual applications run outside the Livelink WCM Server.

The WCM Lightweight API uses the new language features of Java 5 (generics and enumerations).

1.1 About this guide What this document describes

This manual describes the Lightweight Java programming interface of Livelink WCM Server, which allows external programs to use the functionality of the WCM servers with efficient resource usage.

Note: For detailed information about installation requirements and supported software versions, refer to the Livelink WCM Server Release Notes, which are available at the Open Text Knowledge Center (https://knowledge.opentext.com/knowledge).

Page 9: Livelink WCM Server - Universit¤t Leipzig

1.2 Overview of documentation for Livelink WCM Server

WM090700-PLA-EN-1 Programming Guide for the WCM Lightweight API 9

Target group This documentation is designed for software developers with the necessary knowledge of the programming language Java and the functionality of Livelink WCM Server.

Note: The individual classes, interfaces, and methods of the WCM Lightweight API are only briefly described here. Please refer to the online documentation (Javadoc) for complete and detailed descriptions. The Javadoc documentation is located on the WCM CD in the directory wcmapi\doc\api.

Structure of the guide

The following list gives a short overview of this documentation:

• Chapter “Installation of the WCM Lightweight API” on page 13 describes the installation of the WCM Lightweight API on a Livelink WCM Server and on a client.

• Chapter “Application examples” on page 23 describes examples for creating a desktop and a Web application.

• Chapter “Appendix: Tag Library” on page 33 contains descriptions of all available tags for the WCM Lightweight API.

1.2 Overview of documentation for Livelink WCM Server

Product documentation

The following documentation is available for Livelink WCM Server:

• Livelink WCM Server - Installation Guide (WM-IGD) – This manual describes how to install Livelink WCM Server. It also shows — based on examples — how to configure RDBMS, LDAP directory servers, web servers, and application servers for use with Livelink WCM Server.

• Livelink WCM Server - Administrator Manual (WM-AGD) – This manual describes how to configure, administer, and monitor your WCM system, i.e. manage servers, websites, deployment systems, etc.

• Livelink WCM Server - Content client User Manual (WMCC-GGD) – This documentation describes how to use the Content client and InSite Editing for editing the contents of websites managed with Livelink WCM Server.

• Livelink WCM Server - Enterprise Server Integration Manual (WM-CLL) – This manual describes how to integrate Livelink WCM Server and Livelink ECM - Enterprise Server in order to use the Enterprise Server user administration for the WCM system, publish Enterprise Server items on WCM-managed websites, and use the Enterprise Server search for WCM-managed websites.

• Livelink WCM Server — Search Server Connector for Lucene Manual – This manual describes the concepts and administration of Lucene Search servers.

• Livelink WCM Server - Programming Guide for the WCM Java API (WM-PJA) – This manual describes the Java programming interface of Livelink WCM

Page 10: Livelink WCM Server - Universit¤t Leipzig

Chapter 1 Introduction

10 Livelink WCM Server WM090700-PLA-EN-1

Server, which allows external programs to use the functionality of the WCM servers.

• Livelink WCM Server - Programming Guide for the WCM Lightweight API (WM-PLA) – This manual describes the Lightweight Java programming interface of Livelink WCM Server, which allows external programs to use the functionality of the WCM servers with efficient resource usage.

• Online help – Online help is available for using and configuring the individual clients of Livelink WCM Server.

Release Notes The Release Notes describe the following aspects in detail: • The software supported by the product

• Requirements

• Restrictions

• Important dependencies

• Last-minute changes to the documentation

• Identification codes of the current documentation

The Release Notes are continually updated. The latest version of the Livelink WCM Server Release Notes is available in the Open Text Knowledge Center (https://knowledge.opentext.com/knowledge).

1.3 Conventions Read the following conventions before you use this documentation.

Typography In general, this product documentation uses the following typographical conventions:

• New terms This format is used to introduce new terms, emphasize particular terms, concepts, long product names, and to refer to other documentation.

• User interface This format is used for elements of the graphical user interface (GUI), such as buttons, names of icons, menu items, names of dialog boxes and fields.

• Filename, command, sample data This format is used for filenames, paths, URLs and commands in the command line. It is also used for example data, text to be entered in text boxes, and other literals.

Note: If a guide provides command line examples, these examples may contain special or hidden characters in the PDF version of the guide (for technical reasons). If you want to copy commands to your application or command line, use the HTML version of the guide.

Page 11: Livelink WCM Server - Universit¤t Leipzig

1.3 Conventions

WM090700-PLA-EN-1 Programming Guide for the WCM Lightweight API 11

• Key names Key names appear in ALL CAPS, for example: Press CTRL+V.

• <Variable name>The brackets < > are used to denote a variable or placeholder. Enter the correct value for your situation, for example: Replace <server_name> with the name of the relevant server, e.g. serv01.

• Hyperlink and Weblink (http://www.opentext.com)These formats are used for hyperlinks. In all document formats, these are active references to other locations in the documentation (hyperlink) and on the Internet (Weblink), providing further information on the same subject or a related subject. Click the link to move to the respective target page. (Note: The hyperlink above points to itself, and will therefore produce no result).

Tip: Tips offer extra information that may make your work more efficient, or show alternative ways of performing a task.

Note: Notes provide additional useful information, help you avoid problems and clear up misunderstandings.

Important

Important information is identified in this way. If you ignore such information, you may encounter major problems.

Caution Cautions contain very important information that, if ignored, may cause irreversible problems. Read this information carefully and follow all instructions!

Cross-references

The documentation uses different types of cross-references:

• Internal cross-references Clicking on the colored part of a cross-reference takes you directly to the target of the reference. This applies to cross-references in the index and in the table of contents.

• External cross-references in PDF documents In PDF documents, external cross-references are references to other manuals. For technical reasons, these external cross-references often do not refer to specific chapters but to a manual in general.

Page 12: Livelink WCM Server - Universit¤t Leipzig

Chapter 1 Introduction

12 Livelink WCM Server WM090700-PLA-EN-1

1.4 Terminology In this documentation, all terms relating to Livelink ECM - Enterprise Server start with Enterprise Server to differentiate them from other Open Text products and to keep them short. Examples are Enterprise Server item, Enterprise Server users, or Enterprise Server permission.

In the Livelink ECM - Enterprise Server documentation, these terms are referred to as Livelink items, Livelink users, or Livelink permissions, for example.

1.5 Contact information There are several ways to contact Open Text:

Open Text Online

Open Text Online is a unique access point for the information provided by Open Text. You can access Open Text Online via the Internet at http://online.opentext.com/.

Information and access to resources are organized according to the following roles:

• Partners

• Business Users

• Administrators/Developers

Open Text Online offers access to the following information sources:

• Open Text Knowledge Center

• Firstlook server

• Expert Service Center

Open Text Customer

Support

If you require additional help with technical problems, contact Open Text Customer Support. You can find the contact information for your region at http://www.opentext.com/services/support.html.

Feedback on the documentation

If you have any comments, questions, or suggestions to improve the documentation, you can contact us by e-mail at [email protected].

Page 13: Livelink WCM Server - Universit¤t Leipzig

WM090700-PLA-EN-1 Livelink WCM Server 13

Chapter 2 Installation of the WCM Lightweight API

2.1 Installation of the WCM Lightweight API on a Livelink WCM Server

2.1.1 Installing the library

To install the library of the WCM Lightweight API on a Livelink WCM Server

1. Copy the wcmapiserver.jar file from the wcmapi/lib directory on the WCM CD to the <installation directory>/external_lib directory on the Livelink WCM Server where you want to create the agent for the WCM Lightweight API.

2. If the Livelink WCM Server runs as a Web application in the Web server, copy the wcmapiserver.jar library to the WEB-INF/lib directory of the Web application.

3. Restart the Livelink WCM Server using Java 5 or higher.

2.1.2 Creating an agent

To create a new agent in the Admin client

1. Start the Admin client (see Section 8 "Working with the Admin client" in Livelink WCM Server - Administrator Manual (WM-AGD))

2. Select Configuration ⇒ Server agents ⇒ New server agent.

3. Create the server agent with the following attributes:

• name: arbitrary, for example WcmApiServiceAgent

• class name: com.opentext.wcm.impl.server.WcmApiServiceAgent

Page 14: Livelink WCM Server - Universit¤t Leipzig

Chapter 2 Installation of the WCM Lightweight API

14 Livelink WCM Server WM090700-PLA-EN-1

2.1.3 Configuring an agent (optional) The agent you created supports the following configuration parameters. The default values fit in most cases.

Parameter Description Default value

max-clients Maximum number of connections to the agent. 10

max-invalid-oids Maximum number of changed OIDs the agent memorizes in the main memory to inform a client about changes. If the maximum number is ex-ceeded, the whole cache on the client will be re-initialized, i.e. the cache will be cleared.

1000

max-filter-cache Maximum number of filter expressions the agent memorizes in the main memory.

1000

delay-refresh-time The update interval indicates how often clients are informed about changes. The interval is given in milliseconds.

60000

2.1.4 Assigning an agent To start the agent, you must assign it to the Livelink WCM Server, for example via: Select Configuration ⇒ Server agents ⇒ WcmApiServiceAgent ⇒ Servers ⇒Assign server.

If you want to use the WCM Lightweight API also to modify WCM objects, Open Text recommends to start the agent on the master Content server or on another Content server which is configured as a proxy Content server for the website (Edit view). Every client must be able to reach the Livelink WCM Server to which the agent is assigned via the RMI port (default 1099).

2.1.5 Starting an agent Start the agent as follows to make the WCM Lightweight API available:

1. Select System administration ⇒ Active Servers ⇒ <Server where agent runs>⇒ Agents.

2. Right-click WcmApiServiceAgent.

3. Select Start agent from the context menu.

The agent uses the RMI port of the assigned Livelink WCM Server. The default port is 1099.

Notes:

• If you want to change the default port, proceed as follows:

Page 15: Livelink WCM Server - Universit¤t Leipzig

2.1 Installation of the WCM Lightweight API on a Livelink WCM Server

WM090700-PLA-EN-1 Programming Guide for the WCM Lightweight API 15

1. Select Configuration ⇒ Servers ⇒ <Server where agent runs>.

2. Modify the value in the Remote API port field.

3. Click Apply to save your changes.

• It is not required to activate RMI for the Livelink WCM Server.

2.1.6 Activating logging The WCM Lightweight API uses the logging mechanism of Java 5 (package java.-util.logging). The following table gives an overview of the used logger instances of the agent.

Log name Function

com.opentext.wcmapi.server.action Logs the execution of actions on the Livelink WCM Server

com.opentext.wcmapi.server.authorisation Logs the authentication on the Livelink WCM Server

com.opentext.wcmapi.server.connect Logs connection establishment/connection termination and the state model of the cli-ents on the Livelink WCM Server

com.opentext.wcmapi.server.exception Logs exception processing on the Livelink WCM Server

com.opentext.wcmapi.server.refresh Logs the activities of the notification service regarding modifications of WCM objects on the Livelink WCM Server

com.opentext.wcmapi.server.search Logs the activities of search for metadata or collections on the Livelink WCM Server

Alternatively, you can view further reporting information in the WcmApiServiceAgent report in the Admin client. To view this report in the Admin client, select System administration ⇒ Active Servers ⇒ <server on which agent runs>⇒ Reports⇒ WcmApiServiceAgent-<X> (where X indicates the number of restarts). For example, the report lists how many clients are connected to the agent.

Page 16: Livelink WCM Server - Universit¤t Leipzig

Chapter 2 Installation of the WCM Lightweight API

16 Livelink WCM Server WM090700-PLA-EN-1

2.2 Installation of the WCM Lightweight API on a client

2.2.1 Installing the library

To install the library of the WCM Lightweight API on a client

Note: The installation of the library requires that the client uses Java 5 or higher.

1. Copy the wcmapi.jar file from the wcmapi/lib directory on the WCM CD to the class path of the client application.

2. Copy the JDBC driver classes of the respective database manufacturer to the class path of the client application.

This is necessary because the standard configuration of the WCM Lightweight API reads the WCM objects directly from the database.

To compile projects, use the wcmapi_api.jar file from the wcmapi/lib directory on the WCM CD. This file only contains the public interfaces and classes. For detailed information, refer to documentation in the wcmapi/doc directory on the WCM CD.

2.2.2 Configuration on the client You can configure the following aspects of the WCM Lightweight API on the client:

• Connection establishment

• Maximum size of search results

• Cache size and lifetime

A WCM Lightweight API configuration is represented by an object of the com.-opentext.wcm.session.Configuration class. This class contains methods for setting and reading the configuration properties. Furthermore, this class offers a constructor with an object of the java.util.Properties class. The property names correspond to the method names according to the JavaBeans naming convention. For example, a method getPropertyName() corresponds to the propertyName property. The following table lists the configuration parameters of the WCM Lightweight API:

Page 17: Livelink WCM Server - Universit¤t Leipzig

2.2 Installation of the WCM Lightweight API on a client

WM090700-PLA-EN-1 Programming Guide for the WCM Lightweight API 17

Parameter Description Default value

hostname Host name of the Livelink WCM Server where the WCM Lightweight API agent runs

localhost

rmiPort Port number of the RMI port on the Livelink WCM Server. The client must be able to reach the computer of the Livelink WCM Server on this port.

1099

wcmServerName Name of the Livelink WCM Server where the agent runs.

Master_Content

useDB Indicates whether the meta-data of WCM objects are di-rectly read from the data-base (for performance rea-sons). Possible values: true (read from database), false (read using RMI services)

true

connectionPoolSize Number of database con-nections which are kept open for re-use1.

10

connectionPoolTimeout Maximum waiting time (given in milliseconds) until a database connection is available again if all other connections are currently busy.

5000

maxObjectCollectionSize Maximum number of search results.

1000

metadataCacheSize Maximum number of cache entries for metadata of a WCM object which are kept in the client's main memory. The caching strategy “Least recently used” is applied.

5000

metadataCacheTTL Maximum life time (given in milliseconds) of a cache entry for the metadata of a WCM object. If the cache entry is older than this life time, the entry will be “pre-ferred” if entries have to be removed.

0

Page 18: Livelink WCM Server - Universit¤t Leipzig

Chapter 2 Installation of the WCM Lightweight API

18 Livelink WCM Server WM090700-PLA-EN-1

Parameter Description Default value

metadataCacheTimeout Maximum time (given in milliseconds) a thread has to wait for obtaining read ac-cess for a WCM object if two or more threads want to ac-cess the same object. Obtain-ing read access fails if the thread which is currently reading the object, does not finish reading within this waiting time.

5000

refreshUrl URL to be called for cache refresh by Livelink WCM Server when modifying WCM objects. By default, there is no automatic re-fresh.

-

Notes: 1. A small number of database connections needs fewer database resources but reduces performance

for concurrent database access. In turn, a higher number of database connections increases per-formance for concurrent database access but requires more database resources.

In most cases you have to change at least the parameters hostname and wcmServerName.

You can refine some settings, i.e. you can define different configurations for each website and each view (EDIT, QA, PROD). The cache configuration can be different for each view, whereas the view parameter is optional. You can refine the following settings per website or view:

website.<websiteName>.connectionPoolSize website.<websiteName>.connectionPoolTimeout website.<websiteName>.<view>.metadataCacheSize website.<websiteName>.<view>.metadataCacheTTL website.<websiteName>.<view>.metadataCacheTimeout

Example 2-1: Example for the cache configuration of website called “intranet”

# all websites : maximum of 1000 cache entries: metadataCacheSize = 1000 # intranet website : maximum of 5000 cache entries: website.intranet.metadataCacheSize = 5000 # intranet Website Produktion : maximum of 40000 cache entries: website.intranet.PROD.metadataCacheSize = 40000

Page 19: Livelink WCM Server - Universit¤t Leipzig

2.2 Installation of the WCM Lightweight API on a client

WM090700-PLA-EN-1 Programming Guide for the WCM Lightweight API 19

2.2.3 Configuring desktop applications In this guide, desktop application means a Java application which runs in the operating system of the user (e.g. on Windows), i.e. it is not a Web application which runs on a Web server.

Establishing connections

1. Create an object of the class com.opentext.wcm.session.Configuration.

2. Use the com.opentext.wcm.session.WcmSessionManagerFactory class to connect to the Livelink WCM Server where the agent runs, see “Sample class for configuring a desktop application” on page 19.

As a result, an object of the com.opentext.wcm.session.WcmSessionManager interface is returned. This object offers all services of the WCM Lightweight API.

Note: Create this object only once in the Java application (as singleton pattern), because this instance saves status information (for example the cache instances for the metadata of WCM objects and the database connections).

Note: If the WcmSessionManager is not used any more, call the release method to release all used resources.

Example 2-2: Sample class for configuring a desktop application public class Example extends JFrame {

private final WcmSessionManager sm;

public Example() {

// create configuration Configuration conf = new Configuration("wcmserver.example.com", 1099, "Master_Content"); // connect to WCM API on server sm = WcmSessionManagerFactory.getInstance().newWcmSessionManager(conf); // clean up resources on close (disconnect) addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) {

sm.release(true); System.exit(0); }}); }

public static void main(String[] args) {

new Example().setVisible(true); }}

Page 20: Livelink WCM Server - Universit¤t Leipzig

Chapter 2 Installation of the WCM Lightweight API

20 Livelink WCM Server WM090700-PLA-EN-1

Refreshing the cache

To refresh the cache, call the refreshWebsiteCache method of the WcmSessionManager interface.

Refreshing user logins

It can be necessary to refresh the login of a user on the Livelink WCM Server. Because there is no communication to the Livelink WCM Server via RMI during pure read access, the logged-in user would be logged out after a certain period of time (normally after 90 minutes).

You can refresh the login of a user on the Livelink WCM Server by calling the touch method for the WcmSession instance. The WcmSession instance represents an authenticated user.

2.2.4 Configuring Web applications

Establishing connections

1. Configure a listener in the web.xml file. This listener establishes or terminates the connection automatically when the Web application is started or stopped. Create a web.xml file like the following example:

<web-app version="2.4"> <listener> <listener-class>com.opentext.wcm.web.servlet.BootListener</listener-class> </listener> </web-app>

The listener will invoke the boot method of the com.opentext.wcm.web.servlet.SessionBean class to establish the connection using the default configuration (see step 2). If you do not want to use the listener you can also invoke this method manually.

The boot method creates implicitly an instance of the com.opentext.wcm.web.servlet.SessionBean class and stores it (as singleton pattern) in the application context of the Web application.

2. Configure the connection.

The easiest way to configure the connection is:

a. Create a file named wcmapi.properties in the WEB-INF directory of the Web application.

b. Add the following lines to the wcmapi.properties file, for example with these values:

hostname=wcmserver.example.com wcmServerName=Master_Content rmiPort=1099

Page 21: Livelink WCM Server - Universit¤t Leipzig

2.2 Installation of the WCM Lightweight API on a client

WM090700-PLA-EN-1 Programming Guide for the WCM Lightweight API 21

Alternatively, you can use one of the following ways to configure the connection:

Via <context> parameters in the web.xml file You must specify the parameters in the com.opentext.wcm.-web.<configParameter> format, where the configuration parameters must follow the same naming conventions as in a .properties file. The <context>parameters are only used if at least the hostname parameter is configured.

Example:

<context-param> <param-name>com.opentext.wcm.web.hostname</param-name> <param-value>wcmserver.example.com</param-value> </context-param>

If the host name is not defined as <context> parameter, the boot process searches the /META-INF/wcmapi.properties resource in the class path.

Via a .properties file Specify a .properties file containing the configuration data as <context>parameters. The com.opentext.wcm.web.CONFIG_FILE parameter must contain the path of the .properties file. The path looks like this:

• The path must start with / and is relative to the Web application.

• The default value of the path is /WEB-INF/wcmapi.properties, i.e. this file is used if no other configuration file is specified

Example:

<context-param> <param-name>com.opentext.wcm.web.CONFIG_FILE</param-name> <param-value>/WEB-INF/example.properties</param-value> </context-param>

Refreshing the cache

1. Configure a servlet to be called by the agent if any WCM object has changed in a website. Perform this configuration in the web.xml file as follows:

<web-app version="2.4"> ... </listener> <servlet> <servlet-name>wcmrefresh</servlet-name> <servlet-class>com.opentext.wcm.web.servlet.RefreshServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>wcmrefresh</servlet-name> <url-pattern>/wcmrefresh</url-pattern> </servlet-mapping> ... </web-app>

Page 22: Livelink WCM Server - Universit¤t Leipzig

Chapter 2 Installation of the WCM Lightweight API

22 Livelink WCM Server WM090700-PLA-EN-1

2. Configure a refresh URL for the agent by adding the following entry in the wcmapi.properties file:

refreshUrl=http://<hostname>/<webappname>:<port>/wcmrefresh

Refreshing user logins

It can be necessary to refresh the login of a user on the Livelink WCM Server. Because there is no communication to the Livelink WCM Server via RMI during pure read access, the logged-in user would be logged out after a certain period of time (normally after 90 minutes).

Configuring a filter

You can configure a filter which refreshes the login of a user on the Livelink WCM Server after a certain interval. The TouchFilter refreshes the user context in the Livelink WCM Server every 30 minutes. You can change the refresh interval by modifying the touch-interval parameter of the filter. Configure the filter in the web.xml file as follows: <web-app version="2.4"> <filter> <filter-name>TouchFilter</filter-name> <filter-class>com.opentext.wcm.web.servlet.TouchFilter</filter-class> </filter> <filter-mapping> <filter-name>TouchFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener>... </web-app>

2.2.5 Activating logging The following table gives an overview of the used logger instances in a client application.

Log name Function

com.opentext.wcmapi.db Logs the execution of database operations. The logger is also used on the Livelink WCM Server of the agent if metadata is read via RMI.

com.opentext.wcmapi.session Logs connection establishment/connection termination on the client and cache refresh-ing.

com.opentext.wcmapi.web Logs the Web layer objects of the WCM Lightweight API, i.e. servlets, filters, lis-tener, and the SessionBean class.

For the analysis of performance and resource usage, you can retrieve report information about the status of the WCM Lightweight API. Use the getReport method of the WcmSessionManager interface to obtain the status.

Page 23: Livelink WCM Server - Universit¤t Leipzig

WM090700-PLA-EN-1 Livelink WCM Server 23

Chapter 3 Application examples

3.1 Desktop application example

3.1.1 Example structure This example shows the implementation of a simple application which can read, search, and add documents via the WCM Lightweight API. The following list gives a short overview of this section:

• Main method of the sample class. The class is expanded by the required methods in the further sections.

• Implementation of connection establishment from client to server

• Log in as a user to the Livelink WCM Server. After successful login, the user can access the content of the website. In this example, the children of a topic are read.

• Searching for metadata in a website

• Adding documents to a website

• Logging out, connection termination and program termination

3.1.2 Main method The main method performs the following tasks:

• Creates an instance of the sample class

• Establishes the connection to the Livelink WCM Server

• Executes the respective action (displaying, searching, or adding documents)

• Logs out the user

The connection is terminated in the finally block, because an exception may be thrown before. In the WCM Lightweight API only exceptions are thrown which inherit from the WcmException class.

Note: The WcmException class represents a RuntimeException. Therefore, it is not necessary to catch the exception or to specify it in the declaration of methods.

Page 24: Livelink WCM Server - Universit¤t Leipzig

Chapter 3 Application examples

24 Livelink WCM Server WM090700-PLA-EN-1

public class InvoiceDemo {

public static void main(String[] args) {

String action = (args.length>0) ? args[0] : ""; if (args.length<5 || ("add".equals(action)||"search".equals(action)) && args.length<6 || !"show".equals(action) && "add".equals(action) && "search".equals(action)) {

System.out.println("Usage: java InvoiceDemo"); System.out.println(" show <usrID> <pwd> <deployment> <topic>"); System.out.println(" search <usrID> <pwd> <deployment> <topic> <title>"); System.out.println(" add <usrID> <pwd> <deployment> <topic> <fileName>"); System.exit(-1); }

InvoiceDemo invoicedemo = new InvoiceDemo(); try {

invoicedemo.connect(); invoicedemo.login(args[1],args[2]); if ("show".equals(action)) {

invoicedemo.showInvoices(args[3],args[4]); }

else if ("search".equals(action)) {

invoicedemo.searchInvoices(args[3],args[4],args[5]); }

else // add {

invoicedemo.addInvoice(args[3],args[4], new File(args[5])); }

invoicedemo.logout(); }

catch (WcmException wcmex) {

System.err.println("Failed:"+wcmex.getMessage()); }

finally {

invoicedemo.disconnect(); }

}}

3.1.3 Establishing the Livelink WCM Server connection A connection of the WCM Lightweight API to the Livelink WCM Server is represented by an object of the WcmSessionManager interface. The WcmSessionManagerFactory class creates the connection. The Configuration class is used to configure the connection.

In this example, a larger cache is used and direct database access is not permitted.

private WcmSessionManager wcmsessionmanager; public void connect() {

Configuration conf = new Configuration("wcmserver.example.com", 1099, "Master_Content"); conf.setMetadataCacheSize("intranet", View.EDIT, 10000); conf.setUseDB(false); // read WCM objects using RMI wcmsessionmanager = WcmSessionManagerFactory.getInstance().newWcmSessionManager(conf);

Page 25: Livelink WCM Server - Universit¤t Leipzig

3.1 Desktop application example

WM090700-PLA-EN-1 Programming Guide for the WCM Lightweight API 25

}

3.1.4 Authentication Use the login method of the WcmSessionManager to authenticate a user. The login method allows you to specify a session ID (the session ID of an HTTP session, for example). In this example, the session ID is generated automatically.

A logged-in user is represented by an instance of the WcmSession interface. All accesses via this interface are personalized, i.e. the user receives only the information for which the user has permissions (for example, a list of websites to which the user is directly or indirectly assigned to).

private WcmSession wcmsession; public void login(String usrID, String pwd) {

wcmsession = wcmsessionmanager.login( null, /* session ID : will be generated automatically */ usrID, pwd); }

3.1.5 Reading WCM objects WCM objects are accessed via an instance of the WcmObjectManager interface. This instance is returned by the getObjectManager method of the Wcmsession interface. It provides personalized access, i.e. only WCM objects can be read for which the logged-in user has read permission. You can identify the WcmObjectManager via a deployment system or a website name and a website view.

The get method returns a WCM object which is represented by the WcmObject interface. The result is null if the user has no read permission or if the OID does not exist in the website. The WcmObject interface is personalized and memorizes by which WcmObjectManager it was read.

The WCM Lightweight API offers two extensions of the WcmObject interface:

• Topic

• Template

Additional properties are available via type conversion (retrieval of topic's children, for example)

private Topic getTopic(String deployment, String topicOID) {

WcmObjectManager om = wcmsession.getObjectManager(deployment); WcmObject topic = om.get(topicOID); if (topic==null || !topic.getObjectType().isTopic()) {

// no permission or does not exist or is not a topic; System.err.println("topic OID cannot be used!"); return null; }

// cast to Topic interface for more functionality (e.g. getChildren()) return (Topic)topic; }

Page 26: Livelink WCM Server - Universit¤t Leipzig

Chapter 3 Application examples

26 Livelink WCM Server WM090700-PLA-EN-1

The following method reads all children of a topic and writes the title and the URL of the WCM object to the console. The URL is derived from the deployment system used by the WcmObjectManager.

public void showInvoices(String deploymentSystemName, String topicOID) {

Topic topic = getTopic(deploymentSystemName, topicOID); if (topic!=null) {

for (WcmObject child : topic.getChildren()) {

System.out.println("Invoice '"+child.getTitle()+"' ("+child.getUrl()+")"); }

}}

3.1.6 Searching WCM objects The searchInvoices method in this example searches for WCM objects with certain titles. The method searches only WCM objects below a certain topic. The search term for the metadata search has to be specified using the syntax for filter expressions. You can figure out this term via the filter dialog in the Content Client. For the metadata search, the searchInvoices method creates an object of the MetadataQuery class. You can refine the query (maximum number of hits and start OID, for example) via specifying attributes for the query object. The search is executed via the search method of the WcmObjectManager interface.

To search in collections, use the CollectionQuery class.

The result consists of a list of objects which implement the Hit interface.

public void searchInvoices(String deployment, String topicOID, String title) {

Topic topic = getTopic(deployment, topicOID); if (topic!=null) {

MetadataQuery query = new MetadataQuery("title .contains. '"+title+"'"); query.setStartOID(topic.getOID()); List<Hit> hitlist = topic.getObjectManager().search(query); for (Hit hit : hitlist) {

System.out.println("Found invoice '"+hit.getObject().getTitle()+"'"); }

}}

3.1.7 Creating WCM objects The following addInvoice method demonstrates the execution of actions using the WCM Lightweight API. An action is represented by the abstract class called Action.The actions offered by the WCM Lightweight API extend this class. Examples:

• The SubmitAction class is used for submitting a WCM object.

• Use the ChangeAction class to change metadata.

In this example, the CreateAction class is used for creating a new WCM object.

Page 27: Livelink WCM Server - Universit¤t Leipzig

3.1 Desktop application example

WM090700-PLA-EN-1 Programming Guide for the WCM Lightweight API 27

To create the WCM object with content

1. To create a new WCM object, you must first create a new instance with the newObjectInstance method in the WcmObject interface.

• To create this instance, you must specify a title, topic, and the object type (lines 8 to 11 in listing below, invoice-"+System.currentTimeMillis(),topic and etcType in this example).

Some metadata is set before the instance is actually created via the execute method (see lines 12 and 19 in the listing below). After the execution of an action, the modified values are immediately available. The instance can be used in further actions.

2. Pass an InputStream object to the constructor (line 17 in listing below ). An action is executed via the execute method of the WcmObject interface.

In this example, metadata of the newly created WCM object is modified, then the new OID and the new metadata value are displayed.

1 public void addInvoice(String deploymentSystemName, String topicOID, File file) 2 {3 Topic topic = getTopic(deploymentSystemName, topicOID);

4 if (topic!=null) 5 {6 WcmObjectManager om = topic.getObjectManager();

7 WcmObjectType etcType = om.getObjectType("ETC"); 8 WcmObject invoice = om.newObjectInstance( 9 "invoice-"+System.currentTimeMillis(), 10 topic, 11 etcType); 12 invoice.setTargetGroup("invoice"); 13 InputStream is = null; 14 try 15 {16 is = new BufferedInputStream(new FileInputStream(file)); 17 CreateAction action = new CreateAction(is); 18 invoice.execute(action); 19 invoice.setDescription("Created by InvoiceDemo"); 20 invoice.execute(new ChangeAction()); 21 System.out.println(invoice.getOID()+" "+invoice.getDescription()); 22 }23 catch (IOException iox) 24 {25 iox.printStackTrace(); 26 }27 finally 28 {29 try { if (is!=null) is.close(); } catch (IOException iox) { /* ignored */ } 30 }31 }32 }

Page 28: Livelink WCM Server - Universit¤t Leipzig

Chapter 3 Application examples

28 Livelink WCM Server WM090700-PLA-EN-1

3.1.8 Logging out and disconnecting At program termination, the program releases all resources:

1. Log out the user via the logout method of the Wcmsession interface.

2. Terminate the connection via the release method of the WcmSessionManager interface. To log out all users from the Livelink WCM Server which were logged in by the WcmSessionManager, specify true as value for the boolean parameter (see line 8 in the following listing).

1 public void logout() 2 {3 wcmsession.logout();

4 }56 public void disconnect()

7 {8 if (wcmsessionmanager!=null) wcmsessionmanager.release(true);

9 }

3.2 Web application example

3.2.1 Example structure This example implements a Web application that shows documents in a navigation via the Web interface of the WCM Lightweight API. The Web interface is based on a tag library (wcmapi.tld), which is located under META-INF within the wcmapi.jar file.

After login with user ID and password, the navigation page opens. You can navigate via hyperlinks for topic objects or via a breadcrumb navigation which displays the path from the root object to the current object. If your current object is a document, you can switch to a detailed view which displays selected metadata. In this example, JSP scriptlets are not used, instead the JSTL (Java Standard Tag Library) Version 1.1 is used.

The following list gives a short overview of this section:

• “Configuring the Web application” on page 29: Configuring the connection to the Livelink WCM Server

• “Logging in and out” on page 30: Implementing the session authentication and logging in and out.

• “Building the navigation” on page 30: Building a breadcrumb navigation and creating hyperlinks for topic objects for navigating through the website.

• “Displaying metadata” on page 31: Displaying metadata of a WCM object with the details.jsp page.

Page 29: Livelink WCM Server - Universit¤t Leipzig

3.2 Web application example

WM090700-PLA-EN-1 Programming Guide for the WCM Lightweight API 29

3.2.2 Configuring the Web application This application example uses the following components:

• Web server: Tomcat 5.5 with JSP 2.0

The example uses the following application, deployment system, and library:

• Name of the Web application: invoice, port: 8080

• Name of the deployment system: intranet_edit. This deployment system is used to deliver the WCM objects.

• Library: <WCM CD>/wcmapi/lib/wcmapi.jar must be copied to the WEB-INF/lib directory of the Web application.

For performance reasons, the WCM objects are directly read from the database. Perform the following steps to achieve that and to configure the connection to the WCM server:

1. Copy the JDBC driver classes used by the Livelink WCM Server to the WEB-INF/lib directory of the Web application from the following directory on the WCM CD:

• Oracle: lib/external/ojdbc.jar

• SQL Server 2005: lib/external/sqljdbc.jar

2. Configure the connection data to the Livelink WCM Server:

a. In the WEB-INF directory of the Web application, create the wcmapi.properties file.

b. Enter the following connection data in the wcmapi.properties file and adapt the host name (wcmserver.example.com) to your environment.

hostname=wcmserver.example.com wcmServerName=Master_Content rmiPort=1099 refreshUrl=http://wcmserver.example.com:8080/invoice/wcmrefresh

c. Enter the following settings in the web.xml file in the WEB-INF directory to:

• connect automatically to the Livelink WCM Server when the Web application starts

• refresh the metadata cache automatically

<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4"> <listener> <listener-class>com.opentext.wcm.web.servlet.BootListener</listener-class> </listener> <servlet> <servlet-name>wcmrefresh</servlet-name> <servlet-class>com.opentext.wcm.web.servlet.RefreshServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>wcmrefresh</servlet-name>

Page 30: Livelink WCM Server - Universit¤t Leipzig

Chapter 3 Application examples

30 Livelink WCM Server WM090700-PLA-EN-1

<url-pattern>/wcmrefresh</url-pattern> </servlet-mapping> </web-app>

3.2.3 Logging in and out The application starting page is stored in the index.jsp file. This page checks whether the current HTTP session is authenticated. If the HTTP session is authenticated, the request is forwarded to the navigation page, otherwise the request is forwarded to the login page.

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="wcm" uri="http://www.opentext.com/wcm/wcmapi" %> <wcm:checkLogin var="ok" userId="${param.userId}" password="${param.password}" /> <c:if test="${!ok}"> <jsp:forward page="/loginform.html"/> </c:if> <jsp:forward page="/navigation.jsp"/>

The login form loginform.html page sends the user ID and password to the index.jsp page. The checkLogin tag performs the login.

<html> <head></head> <body> <form action="index.jsp" method="post"> UserId : <input type="text" name="userId" /></br> Password : <input type="password" name="password" /></br> <input type="submit" value="Login" /></br> </form> </body> </html>

The logout.jsp page serves for logging out the user of the current HTTP session.

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="wcm" uri="http://www.opentext.com/wcm/wcmapi" %> <wcm:logout /> <c:redirect url="/index.jsp" />

3.2.4 Building the navigation The navigation.jsp page implements a simple navigation. This page contains the following elements and functions:

• Button for logging out

• Reading the WCM object which is identified by the request parameter oid.

• Building the breadcrumb navigation which shows the topics from the root object down to the current object. If the OID does not refer to a topic, the parent topic will be identified. Then all children of the topic will be displayed.

Page 31: Livelink WCM Server - Universit¤t Leipzig

3.2 Web application example

WM090700-PLA-EN-1 Programming Guide for the WCM Lightweight API 31

• For topics, a hyperlink is created to visit the topic (line 40 in the following listing). For all other object types, the details view page (details.jsp) will be opened.

1 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 <%@ taglib prefix="wcm" uri="http://www.opentext.com/wcm/wcmapi" %> 34 <html>

5 <head></head> 6 <body> 78 <%-- log out button --%>

910 <p><form action="logout.jsp"><input type="submit" value="Logout" /></form></p> 11 12 <%-- get WCM object --%> 13 14 <c:set var="oid" value="${param.oid}" /> 15 <c:if test="${empty oid}"> 16 <c:set var="oid" value="1" /> 17 </c:if> 18 <wcm:getObject var="wcmobject" deployment="intranet_edit" oid="${oid}" /> 19 20 <%-- show trail --%> 21 22 <c:forEach var="trail" items="${wcmobject.trail}"> 23 <a href="navigation.jsp?oid=${trail.OID}">${trail.title}</a>&nbsp; 24 </c:forEach> 25 26 27 <%-- get topic --%> 28 29 <c:if test="${!wcmobject.objectType.topic}"> 30 <c:set var="wcmobject" value="${wcmobject.parent}" /> 31 </c:if> 32 33 <%-- show children --%> 34 35 <ul> 36 <c:forEach var="child" items="${wcmobject.children}"> 37 <li> 38 <c:choose> 39 <c:when test="${child.objectType.topic}"> 40 <a href="navigation.jsp?oid=${child.OID}">${child.title}</a> 41 </c:when> 42 <c:otherwise> 43 ${child.title} <a href="details.jsp?oid=${child.OID}">Details</a> 44 </c:otherwise> 45 </c:choose> 46 </li> 47 </c:forEach> 48 </ul> 49 50 </body> 51 </html>

Page 32: Livelink WCM Server - Universit¤t Leipzig

Chapter 3 Application examples

32 Livelink WCM Server WM090700-PLA-EN-1

3.2.5 Displaying metadata The details.jsp page shows the metadata of a WCM object. The OID is extracted from the request parameter. The page displays 6 rows with the following content:

• First row: icon for the object type

• Second row: title

• Third row: user who modified the object the last time

• Fourth row: date of last change

• Fifth row: version number of the object

• Sixth row: hyperlink that points to the object content

1 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 3 <%@ taglib prefix="wcm" uri="http://www.opentext.com/wcm/wcmapi" %> 45 <html>

6 <head></head> 7 <body> 8

9 <wcm:getObject var="wcmobject" deployment="intranet_edit" oid="${param.oid}" /> 10 11 <table> 12 13 <tr> 14 <td>Type</td> 15 <td><img src="${wcmobject.objectTypeIconUrl}" title="${wcmobject.objectType.name}" /></td> 16 </tr> 17 18 <tr> 19 <td>Title</td> 20 <td>${wcmobject.title}</td> 21 </tr> 22 23 <tr> 24 <td>Modified By</td> 25 <td>${wcmobject.modifiedBy}</td> 26 </tr> 27 28 <tr> 29 <td>Modify Date</td> 30 <td><fmt:formatDate type="both" value="${wcmobject.modifiedDate}" /></td> 31 </tr> 32 33 <tr> 34 <td>Version</td> 35 <td>${wcmobject.versionId}</td> 36 </tr> 37 38 <tr> 39 <td>URL</td> 40 <td><a href="${wcmobject.url}">Show</a></td> 41 </tr> 42 43 </table> 44 </body> 45 </html>

Page 33: Livelink WCM Server - Universit¤t Leipzig

WM090700-PLA-EN-1 Livelink WCM Server 33

Chapter 4 Appendix: Tag Library

This chapter describes all available tags of the WCM Lightweight API Tag Library. The tags implement standard functions to display content from the Livelink WCM Server on JSP pages. In the examples, the expression language from JSP 2.0 and JSTL 1.1 is used.

The TLD (Tag Library Descriptor) file is contained in the wcmapi.jar file (/META-INF/wcmapi.tld). You can use the tag library via the http://www.opentext.com/wcm/wcmapi URI.

4.1 checkLogin Description

The checkLogin tag checks whether the current HTTP session was authenticated against the Livelink WCM Server. You can store the result in the <var> variable. If the login fails, an exception is thrown. The tag has the following parameters:

Parameter Description

userId (optional) User ID of user to be logged in

password (op-tional)

Password of user to be logged in

var After the execution, the <var> variable contains the result of the login, i.e. whether the login was successful.

scope The parameter corresponds to the JSP standard. If the scope parameter is not specified, page is used as default value.

Syntax

<wcm:checkLogin [userId="<userId>"] [password="<password>"] [var="<var>"] [scope="request|page|session|application"] />

Page 34: Livelink WCM Server - Universit¤t Leipzig

Chapter 4 Appendix: Tag Library

34 Livelink WCM Server WM090700-PLA-EN-1

Example

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="wcm" uri="http://www.opentext.com/wcm/wcmapi" %> <c:catch var="wcmex"> <wcm:checkLogin var="ok" userId="${param.userId}" password="${param.password}" /> <c:if test="${!ok}"> <p>Session not authenticated!</p> </c:if> </c:catch> <c:if test="${!empty wcmex}"> <p>Login failed : ${wcmex.message}</p> </c:if>

4.2 getSessionManager Description

The getSessionManager tag returns the WcmSessionManager instance in the <var> variable.

Parameter Description

var After the execution, the <var> variable contains the WcmSessionManager instance.

scope The parameter corresponds to the JSP standard. If the scope parameter is not specified, page is used as default value.

Syntax

<wcm:getSessionManager var="<var>" [scope="request|page|session|application"] />

Example

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="wcm" uri="http://www.opentext.com/wcm/wcmapi" %> <wcm:getSessionManager var="wcmsessionmanager" /> <pre> <c:forEach var="line" items="${wcmsessionmanager.report}"> ${line} </c:forEach> </pre>

Page 35: Livelink WCM Server - Universit¤t Leipzig

4.3 getSession

WM090700-PLA-EN-1 Programming Guide for the WCM Lightweight API 35

4.3 getSession Description

The getSession tag returns the WCM session of the current HTTP session. For unauthenticated users, a WcmSession instance of the World group is returned. The tag has the following parameters:

Parameter Description

var After the execution, the WcmSession interface is stored in the <var>variable.

scope The parameter corresponds to the JSP standard. If the scope parameter is not specified, page is used as default value.

Syntax

<wcm:getSession var="<var>" [scope="request|page|session|application"] />

Example

<%@ taglib prefix="wcm" uri="http://www.opentext.com/wcm/wcmapi" %> <wcm:getSession var="wcmsession" /> <p>Logged in as ${wcmsession.userProfile.commonName}</p>

4.4 getObjectManager Description

The getObjectManager tag returns the object manager for a website or a deployment system. You must either specify the <website> parameter or the <deployment> parameter. If the <website> parameter is used, you can specify the view. The tag has the following parameters:

Parameter Description

deployment Name of a deployment system within a website.

website Name of a website. This parameter is required if the <deployment>parameter is not specified.

view The view on the website. This parameter applies only if the <website> parameter is specified. If the <view> parameter is missing, the view of the connected Livelink WCM Server for the website is used.

var After the execution, the <var> variable contains a WcmObjectManager instance.

scope The parameter corresponds to the JSP standard. If the scope parameter is not specified, page is used as default value.

Page 36: Livelink WCM Server - Universit¤t Leipzig

Chapter 4 Appendix: Tag Library

36 Livelink WCM Server WM090700-PLA-EN-1

Syntax

<wcm:getObjectManager [deployment="<deployment>"] [website="<website>"] [view="EDIT|QA|PROD"] var="<var>" [scope="request|page|session|application"] />

Example

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="wcm" uri="http://www.opentext.com/wcm/wcmapi" %> <wcm:getObjectManager deployment="intranet_edit" var="wcmobjectmananger" /> <ul> <c:forEach items="${wcmobjectmananger.objectTypes}" var="type"> <li>${type.name}</li> </c:forEach> </ul>

4.5 getObject Description

The getObject tag returns a WCM object for an OID in a website. The OID is set via the <oid> parameter. You must either specify the <website> parameter or the <deployment> parameter. If the <website> parameter is used, you can specify the view. The tag has the following parameters:

Parameter Description

oid OID of a WCM object.

deployment Name of a deployment system within a website.

website Name of a website. This parameter is required if the <deployment>parameter is not specified.

view The view on the website. This parameter applies only if the <website> parameter is specified. If the <view> parameter is missing, the view of the connected Livelink WCM Server for the website is used.

var After the execution, the <var> variable contains a WcmObject in-stance.

scope The parameter corresponds to the JSP standard. If the scope parameter is not specified, page is used as default value.

Page 37: Livelink WCM Server - Universit¤t Leipzig

4.6 logout

WM090700-PLA-EN-1 Programming Guide for the WCM Lightweight API 37

Syntax

<wcm:getObject oid="<oid>" [deployment="<deployment>"] [website="<website>"] [view="EDIT|QA|PROD"] var="<var>" [scope="request|page|session|application"] />

Example

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="wcm" uri="http://www.opentext.com/wcm/wcmapi" %> <wcm:getObject oid="1492" deployment="intranet_edit" var="wcmobj" /> <p>Title: ${wcmobj.title} URL: ${wcmobj.url}</p>

4.6 logout Description

The logout tag logs out the WCM user from the current HTTP session.

Syntax

<wcm:logout />

Example

<%@ taglib prefix="wcm" uri="http://www.opentext.com/wcm/wcmapi" %> <wcm:logout /> <wcm:getSession var="wcmsession" /> <p>Logged In: ${wcmsession.loggedIn}</p>

4.7 searchMetadata Description

The searchMetadata tag returns a hit list for the metadata search in a website.

You must either specify the <website> parameter or the <deployment>parameter. If the <website> parameter is used, you can specify the view. The tag has the following parameters:

Page 38: Livelink WCM Server - Universit¤t Leipzig

Chapter 4 Appendix: Tag Library

38 Livelink WCM Server WM090700-PLA-EN-1

Parameter Description

query Contains the search term. The syntax corresponds to the text repre-sentation of a search in the Content Client.

startOID OID where you want to start your search.

sortAttribute Name of the attribute you want to use for sorting the search result.

sortDirection Sorting direction: ascending or descending.

maxHits (optional) To reduce the maximum number of hits.

deployment Name of a deployment system within a website.

website Name of a website. This parameter is required if the <deployment>parameter is not specified.

view The view on the website. This parameter applies only if the <website> parameter is specified. If the <view> parameter is missing, the view of the connected Livelink WCM Server for the website is used.

var After the execution, the <var> variable contains a list of Hit in-stances.

scope If the scope parameter is not specified, page is used as default value.

Syntax

<wcm:searchMetadata query="<query>" [startOID=<oid>] [sortAttribute="<attribute>"] [sortDirection="ASCENDING|DESCENDING"] [maxHits="<number>"] [deployment="<deployment>"] [website="<website>"] [view="EDIT|QA|PROD"] var="<var>" [scope="request|page|session|application"] />

Example

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="wcm" uri="http://www.opentext.com/wcm/wcmapi" %> <wcm:searchMetadata query="title .contains. 'invoice'" deployment="intranet_edit" var="hitlist" /> <ul> <c:forEach items="${hitlist}" var="hit"> <li><a href="${hit.objectURL}">${hit.object.title}</a></li> </c:forEach> </ul>

Page 39: Livelink WCM Server - Universit¤t Leipzig

4.8 searchCollection

WM090700-PLA-EN-1 Programming Guide for the WCM Lightweight API 39

4.8 searchCollection Description

The searchCollection tag returns a hit list for searching in a website via an index server (Lucene, for example). The tag has the following parameters:

Parameter Description

collection To set the name of the collection.

query Contains the search term. The syntax depends on the index server.

maxHits (optional) To reduce the maximum number of hits.

deployment Name of a deployment system within a website.

website Name of a website. This parameter is required if the <deployment>parameter is not specified.

view The view on the website. This parameter applies only if the <website> parameter is specified. If the <view> parameter is missing, the view of the connected Livelink WCM Server for the website is used.

var After the execution, the <var> variable contains a list of Hit in-stances.

scope The parameter corresponds to the JSP standard. If the scope parameter is not specified, page is used as default value.

Syntax

<wcm:searchCollection query="<query>" collection="<collection>" [maxHits="<number>"] [deployment="<deployment>"] [website="<website>"] [view="EDIT|QA|PROD"] var="<var>" [scope="request|page|session|application"] />

Example

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="wcm" uri="http://www.opentext.com/wcm/wcmapi" %> <wcm:searchCollection query="invoice" collection="intranet_collection" deployment="intranet_edit" var="hitlist" /> <ul> <c:forEach items="${hitlist}" var="hit"> <li><a href="${hit.objectURL}">${hit.object.title}</a> (score:${hit.score})</li> </c:forEach>

Page 40: Livelink WCM Server - Universit¤t Leipzig

Chapter 4 Appendix: Tag Library

40 Livelink WCM Server WM090700-PLA-EN-1

</ul>

4.9 sort Description

The sort tag sorts a list of objects by the <attribute> parameter. The tag has the following parameters:

Parameter Description

attribute Attribute that sorts the search result.

var Name of the list object you want to sort. After the execution, the list object is sorted.

scope The parameter corresponds to the JSP standard. If the scope parameter is not specified, page is used as default value.

The objects to be sorted must fulfill the naming convention for Java Beans because the BeanComparator class is used for sorting.

Syntax

<wcm:sort attribute="<attribute>" direction="ASCENDING|DESCENDING" var="<var>" [scope="request|page|session|application"] />

Example

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="wcm" uri="http://www.opentext.com/wcm/wcmapi" %> <wcm:sort attribute="title" direction="DESCENDING" var="hitlist" /> <c:forEach items="${hitlist}" var="hit"> <li>${hit.object.title}</li> </c:forEach> </ul>

Page 41: Livelink WCM Server - Universit¤t Leipzig
Page 42: Livelink WCM Server - Universit¤t Leipzig
Page 43: Livelink WCM Server - Universit¤t Leipzig

WM090700-PLA-EN-1 Livelink WCM Server 43

Index

AAction class 26 agent 13

assigning to the Livelink WCM Server 14 configuring 13 creating 13 starting 14

BBeanComparator class 40

Ccache

refreshing (desktop applications) 19 refreshing (Web applications) 20

ChangeAction class 26 class

Action 26 BeanComparator 40 ChangeAction 26 CollectionQuery 26 com.opentext.wcm.session.Configuration 19, 16

com.opentext.wcm.session.-WcmSessionManagerFactory 19

com.opentext.wcm.web.servlet.-SessionBean 20

CreateAction 26 MetadataQuery 26 SessionBean 22 SubmitAction 26 WcmException 23

CollectionQuery class 26 com.opentext.wcm.session.Configuration class 19, 16

com.opentext.wcm.session.-WcmSessionManagerFactory class 19

com.opentext.wcm.web.servlet.-SessionBean class 20

connections establishing (desktop applications) 19 establishing (Web applications) 20

Contact information 12 Conventions

Conventions in this documentation 10 CreateAction class 26

Ddesktop applications

configuration 19 establishing connections 19

disconnecting from Livelink WCM Server 27

Documentation general 8

documentation for Livelink WCM Server 9

FFeedback 12 filter

configuring (Web applications) 22

Llibrary

installing 13 installing on a client 16

Livelink terms 12 logging

activating on client 22 activating on Livelink WCM Server 15 logger instances 15

logging in 30 logging out 30, 27

Page 44: Livelink WCM Server - Universit¤t Leipzig

Index

44 Livelink WCM Server WM090700-PLA-EN-1

Mmetadata

displaying 31 MetadataQuery class 26

Nnavigation

building 30

OOpen Text Online 12 overview of documentation 9

Rrelated documentation 9Release Notes 10

SSessionBean class 22 sorting objects 40 SubmitAction class 26 Support 12

TTarget group 8terminology 12 Typography 10

Uuser logins

refreshing (desktop applications) 19 refreshing (Web applications) 20

WWCM Lightweight API

configuration on the client 16 configuration parameters (client) 16

WCM objects creating 26

WcmException class 23 Web application

configuring 29 Web applications

configuration 20 establishing connections 20

wording 12