Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide...

94
Americas Headquarters Cisco Systems, Inc. 170 West Tasman Drive San Jose, CA 95134-1706 USA http://www.cisco.com Tel: 408 526-4000 800 553-NETS (6387) Fax: 408 527-0883 Cisco SCMS Subscriber Manager Java API Programmer Guide Release 3.7.x September 20, 2011 Text Part Number: OL-24191-02

Transcript of Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide...

Page 1: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Cisco SCMS Subscriber Manager Java API Programmer GuideRelease 3.7.x September 20, 2011

Americas HeadquartersCisco Systems, Inc.170 West Tasman DriveSan Jose, CA 95134-1706 USAhttp://www.cisco.comTel: 408 526-4000

800 553-NETS (6387)Fax: 408 527-0883

Text Part Number: OL-24191-02

Page 2: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

THE SPECIFICATIONS AND INFORMATION REGARDING THE PRODUCTS IN THIS MANUAL ARE SUBJECT TO CHANGE WITHOUT NOTICE. ALL STATEMENTS, INFORMATION, AND RECOMMENDATIONS IN THIS MANUAL ARE BELIEVED TO BE ACCURATE BUT ARE PRESENTED WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. USERS MUST TAKE FULL RESPONSIBILITY FOR THEIR APPLICATION OF ANY PRODUCTS.

THE SOFTWARE LICENSE AND LIMITED WARRANTY FOR THE ACCOMPANYING PRODUCT ARE SET FORTH IN THE INFORMATION PACKET THAT SHIPPED WITH THE PRODUCT AND ARE INCORPORATED HEREIN BY THIS REFERENCE. IF YOU ARE UNABLE TO LOCATE THE SOFTWARE LICENSE OR LIMITED WARRANTY, CONTACT YOUR CISCO REPRESENTATIVE FOR A COPY.

The Cisco implementation of TCP header compression is an adaptation of a program developed by the University of California, Berkeley (UCB) as part of UCB’s public domain version of the UNIX operating system. All rights reserved. Copyright © 1981, Regents of the University of California.

NOTWITHSTANDING ANY OTHER WARRANTY HEREIN, ALL DOCUMENT FILES AND SOFTWARE OF THESE SUPPLIERS ARE PROVIDED “AS IS” WITH ALL FAULTS. CISCO AND THE ABOVE-NAMED SUPPLIERS DISCLAIM ALL WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THOSE OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OR ARISING FROM A COURSE OF DEALING, USAGE, OR TRADE PRACTICE.

IN NO EVENT SHALL CISCO OR ITS SUPPLIERS BE LIABLE FOR ANY INDIRECT, SPECIAL, CONSEQUENTIAL, OR INCIDENTAL DAMAGES, INCLUDING, WITHOUT LIMITATION, LOST PROFITS OR LOSS OR DAMAGE TO DATA ARISING OUT OF THE USE OR INABILITY TO USE THIS MANUAL, EVEN IF CISCO OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

Cisco and the Cisco Logo are trademarks of Cisco Systems, Inc. and/or its affiliates in the U.S. and other countries. A listing of Cisco's trademarks can be found at www.cisco.com/go/trademarks. Third party trademarks mentioned are the property of their respective owners. The use of the word partner does not imply a partnership relationship between Cisco and any other company. (1005R)

Any Internet Protocol (IP) addresses and phone numbers used in this document are not intended to be actual addresses and phone numbers. Any examples, command display output, network topology diagrams, and other figures included in the document are shown for illustrative purposes only. Any use of actual IP addresses or phone numbers in illustrative content is unintentional and coincidental.

Cisco SCMS SM Java API Programmer Guide © 2011 Cisco Systems, Inc. All rights reserved.

Page 3: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

OL-24191-02

C O N T E N T S

About this Guide ix

Introduction ix

Document Revision History x

Organization xi

Related Documentation xi

Conventions xii

Obtaining Documentation and Submitting a Service Request xiii

C H A P T E R 1 Getting Started 1-1

Introduction 1-1

The Java API 1-2

Introduction 1-2

Platforms 1-2

Package Content 1-2

Installing the Java API 1-4

Subscriber Manager Setup 1-4

Installing on a UNIX Platform 1-4

Installing on a Windows Platform 1-4

Compiling and Running a Program That Uses the API 1-5

C H A P T E R 2 General API Concepts 2-1

Introduction 2-1

Blocking API and the Nonblocking API 2-2

Blocking API 2-2

Nonblocking API 2-2

API Initialization 2-3

API Construction 2-3

Constructor that Accepts a LEG Name 2-3

Blocking API—Example 2-3

Setup Operations 2-3

Blocking API Setup 2-4

Nonblocking API Setup 2-4

Connecting to the Subscriber Manager 2-4

iCisco SCMS SM Java API Programmer Guide

Page 4: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Contents

API Finalization 2-5

Subscriber Name Format 2-5

Network ID Mappings 2-6

Specifying IP Address Mapping 2-6

Specifying IP Range Mapping 2-7

Specifying Private IP Address or Private IP Range over VPN Mapping 2-7

Specifying VLAN Tag Mapping 2-7

Subscriber Domains 2-8

Subscriber Properties 2-8

Custom Properties 2-9

DisconnectListener Interface 2-9

DisconnectListener Interface Example 2-9

Exceptions 2-10

Practical Tips 2-10

C H A P T E R 3 Blocking API 3-1

Introduction 3-1

Multithreading Support 3-2

ReplyTimeout and OperationTimeout Exception 3-3

Subscriber Manager Blocking API Methods 3-4

login 3-5

Syntax 3-5

Description 3-5

Parameters 3-5

RPC Exception Error Codes 3-6

Return Value 3-6

Examples 3-6

logoutByName 3-7

Syntax 3-8

Description 3-8

Parameters 3-8

Return Value 3-8

RPC Exception Error Codes 3-8

Examples 3-9

logoutByNameFromDomain 3-10

Syntax 3-10

Description 3-10

Parameters 3-10

iiCisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 5: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Contents

Return Value 3-10

RPC Exception Error Codes 3-11

Example 3-11

logoutByMapping 3-11

Syntax 3-11

Description 3-12

Parameters 3-12

Return Value 3-12

RPC Exception Error Codes 3-12

Example 3-12

loginCable 3-13

Syntax 3-13

Description 3-13

Parameters 3-13

Return Value 3-14

RPC Exception Error Codes 3-14

Examples 3-14

logoutCable 3-15

Syntax 3-15

Description 3-15

Parameters 3-15

Return Value 3-15

RPC Exception Error Codes 3-15

Example 3-15

addSubscriber 3-16

Syntax 3-16

Description 3-16

Example 3-17

Parameters 3-17

Return Value 3-17

RPC Exception Error Codes 3-17

Examples 3-18

removeSubscriber 3-18

Syntax 3-18

Description 3-18

Parameters 3-18

Return Value 3-18

RPC Exception Error Codes 3-19

Example 3-19

removeAllSubscribers 3-19

iiiCisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 6: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Contents

Syntax 3-19

Description 3-19

Return Value 3-19

RPC Exception Error Codes 3-19

getNumberOfSubscribers 3-20

Syntax 3-20

Description 3-20

Return Value 3-20

RPC Exception Error Codes 3-20

getNumberOfSubscribersInDomain 3-20

Syntax 3-20

Description 3-21

Parameters 3-21

Return Value 3-21

RPC Exception Error Codes 3-21

getSubscriber 3-21

Syntax 3-21

Description 3-21

Parameters 3-22

Return Value 3-22

RPC Exception Error Codes 3-22

Example 3-22

subscriberExists 3-23

Syntax 3-23

Description 3-23

Parameters 3-23

Return Value 3-23

RPC Exception Error Codes 3-23

subscriberLoggedIn 3-23

Syntax 3-24

Description 3-24

Parameters 3-24

Return Value 3-24

RPC Exception Error Codes 3-24

getSubscriberNameByMapping 3-24

Syntax 3-25

Description 3-25

Parameters 3-25

Return Value 3-25

RPC Exception Error Codes 3-25

ivCisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 7: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Contents

getSubscriberNames (all) 3-26

Syntax 3-26

Description 3-26

Parameters 3-26

Return Value 3-26

RPC Exception Error Codes 3-27

Example 3-27

getSubscriberNames (filter by property) 3-27

Syntax 3-27

Description 3-28

Parameters 3-28

Return Value 3-28

RPC Exception Error Codes 3-28

getSubscriberNamesInDomain 3-28

Syntax 3-29

Description 3-29

Parameters 3-29

Return Value 3-29

RPC Exception Error Codes 3-29

getSubscriberNamesWithPrefix 3-29

Syntax 3-30

Description 3-30

Parameters 3-30

Return Value 3-30

RPC Exception Error Codes 3-30

getSubscriberNamesWithSuffix 3-30

Syntax 3-31

Description 3-31

Parameters 3-31

Return Value 3-31

RPC Exception Error Codes 3-31

getDomains 3-31

Syntax 3-32

Description 3-32

Return Value 3-32

RPC Exception Error Codes 3-32

setPropertiesToDefault 3-32

Syntax 3-32

Description 3-32

Parameters 3-33

vCisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 8: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Contents

Return Value 3-33

RPC Exception Error Codes 3-33

removeCustomProperties 3-33

Syntax 3-33

Description 3-33

Parameters 3-34

Return Value 3-34

RPC Exception Error Codes 3-34

Quota Manager Blocking API Methods 3-35

addSubscriberQuota 3-35

Syntax 3-35

Description 3-35

Parameters 3-35

RPC Exception Error Codes 3-36

setSubscriberQuota 3-36

Syntax 3-36

Description 3-36

Parameters 3-36

RPC Exception Error Codes 3-37

replenishSubscriberQuota 3-37

Syntax 3-37

Description 3-37

Parameters 3-37

RPC Exception Error Codes 3-37

getSubscriberQuotaInformation 3-38

Syntax 3-38

Description 3-38

Parameters 3-38

Return Value 3-38

RPC Exception Error Codes 3-39

getSubscriberQuotaProfileId 3-39

Syntax 3-39

Description 3-40

Parameters 3-40

Return Value 3-40

RPC Exception Error Codes 3-40

getBreachedSubscriberNames 3-40

Syntax 3-40

Description 3-40

Parameters 3-41

viCisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 9: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Contents

Return Value 3-41

RPC Exception Error Codes 3-41

getPenaltySubscriberNames 3-41

Syntax 3-41

Description 3-41

Parameters 3-41

Return Value 3-42

RPC Exception Error Codes 3-42

Blocking API Code Examples 3-43

Getting Number of Subscribers 3-43

Adding a Subscriber, Printing Information, and Removing a Subscriber 3-44

Getting Subscriber Quota Information 3-45

C H A P T E R 4 Nonblocking API 4-1

Introduction 4-1

Reliability Support 4-2

Reliable Mode 4-2

Nonreliable Mode 4-2

Autoreconnect Support 4-3

Multithreading Support 4-3

ResultHandler Interface 4-4

ResultHandler Interface Example 4-4

Nonblocking API Construction 4-6

Nonblocking API Syntax 4-6

Nonblocking API Arguments 4-6

Nonblocking API Examples 4-6

Nonblocking API Initialization 4-8

Nonblocking API Initialization Syntax 4-8

Nonblocking API Initialization Parameters 4-8

Nonblocking API Initialization Example 4-8

Nonblocking API Methods 4-9

login 4-9

Syntax 4-9

logoutByName 4-10

Syntax 4-10

logoutByNameFromDomain 4-10

Syntax 4-10

logoutByMapping 4-10

Syntax 4-10

viiCisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 10: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Contents

loginCable 4-10

Syntax 4-11

logoutCable 4-11

Syntax 4-11

Nonblocking API Code Examples 4-12

Login and Logout 4-12

A P P E N D I X A List of Error Codes A-1

Introduction A-1

List of Error Codes A-1

viiiCisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 11: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

About this Guide

Revised: September 20, 2011, OL-24191-02

IntroductionThis document describes the Cisco Service Control Management Suite (SCMS) Subscriber Manager (SM) Java API.

You use the SCMS SM Java API to update, query, and configure the Subscriber Manager. The API has of two parts, which you can use separately or together without restriction:

1. Subscriber Manager Nonblocking Java API—High-performance API with low visibility to errors and other operation results. Supports automatic integrations with operations support (OSS) systems and authentication, authorization, and accounting (AAA) systems.

2. Subscriber Manager Blocking Java API—Supports user-interface applications for accessing and managing the Subscriber Manager.

Note A set of APIs with the same functionality is also available for the C/C++ environment.

This document is for networking or computer technicians who are responsible for configuring the Subscriber Manager. It is also intended for operators who manage Cisco Service Control Engine (SCE) platforms.

ixCisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 12: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

About this Guide

Document Revision HistoryTable 1 lists the changes made to this document since it was first released.

Table 1 Document Revision History

RevisionCisco Service Control Release and Date Change Summary

OL-24191-02 September 20, 2011 Improved the quality of the user documentation by adding customer and internal feedback.

OL-24191-01 Release 3.7.x June 13, 2011

Initial document release.

xCisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 13: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

About this Guide

OrganizationTable 2 lists the major sections of this document.

Related DocumentationUse this document in conjunction with all the SCMS Subscriber Manager user, API, and reference guides.

Table 2 Document Organization

Section Title Description

1 Getting Started Describes the platforms on which you can use the Java API. This chapter also describes how to install, compile, and run the Java API component.

2 General API Concepts Describes various concepts that pertain to working with the Subscriber Manager Java API.

3 Blocking API Describes the features and operation of the blocking API and provides code examples.

4 Nonblocking API Describes the features and operation of the nonblocking API and provides code examples.

A List of Error Codes Lists error codes that are used in the Java API.

xiCisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 14: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

About this Guide

ConventionsTable 3 lists the conventions used in this document.

Note Means reader take note.

Tip Means the following information will help you solve a problem.

Caution Means reader be careful. In this situation, you might perform an action that could result in equipment damage or loss of data.

Timesaver Means the described action saves time. You can save time by performing the action described in the paragraph.

Warning Means reader be warned. In this situation, you might perform an action that could result in bodily injury.

Table 3 Conventions

Convention Indication

bold font Commands and keywords and user-entered text appear in bold font.

italic font Document titles, new or emphasized terms, and arguments for which you supply values are in italic font.

[ ] Elements in square brackets are optional.

{x | y | z } Required alternative keywords are grouped in braces and separated by vertical bars.

[ x | y | z ] Optional alternative keywords are grouped in brackets and separated by vertical bars.

string A nonquoted set of characters. Do not use quotation marks around the string or the string will include the quotation marks.

courier font Terminal sessions and information the system displays appear in courier font.

< > Nonprinting characters such as passwords are in angle brackets.

[ ] Default responses to system prompts are in square brackets.

!, # An exclamation point (!) or a pound sign (#) at the beginning of a line of code indicates a comment line.

xiiCisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 15: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

About this Guide

Obtaining Documentation and Submitting a Service RequestFor information on obtaining documentation, submitting a service request, and gathering additional information, see the monthly What’s New in Cisco Product Documentation, which also lists all new and revised Cisco technical documentation, at:

http://www.cisco.com/en/US/docs/general/whatsnew/whatsnew.html

Subscribe to What’s New in Cisco Product Documentation as a Really Simple Syndication (RSS) feed and set content to be delivered directly to your desktop using a reader application. The RSS feeds are a free service and Cisco currently supports RSS version 2.0.

xiiiCisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 16: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

About this Guide

xivCisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 17: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

OL-24191-02

C H A P T E R 1

Getting Started

Revised: September 20, 2011, OL-24191-02

IntroductionThis chapter identifies the platforms on which you can use the Java API. The chapter also describes how to install, compile, and run the API.

This chapter consists of the following sections:

• The Java API, page 1-2

• Installing the Java API, page 1-4

• Compiling and Running a Program That Uses the API, page 1-5

1-1Cisco SCMS SM Java API Programmer Guide

Page 18: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 1 Getting Started The Java API

The Java APIThe following sections provide information about the Java API:

• Introduction, page 1-2

• Platforms, page 1-2

• Package Content, page 1-2

Introduction The Java API enables you to update, query, and configure the Service Control Management Suite (SCMS) Subscriber Manager. The API has two parts, which you can use separately or together without restriction.

• Subscriber Manager Nonblocking Java API—High-performance API with low visibility to errors and other operation results. This API supports automatic integrations with OSS/AAA systems.

• Subscriber Manager Blocking Java API—Supports user-interface applications that enable you to access and manage the Subscriber Manager.

Platforms The Subscriber Manager Java API was developed and tested on a Windows platform, but it is operable on any platform that supports Java Version 5.0.

Package Content For brevity, <installdir> refers to the installation directory, sm-java-api-vvv.bb.

The <installdir>/javadoc folder contains the API JAVADOC documentation.

The <installdir>lib folder contains the smapi.jar file, which is the API executable. It also contains additional JAR files that are required to operate the API.

Table 1-1 provides the layout of the installation directory.

Table 1-1 Layout of Installation Directory

Path Name Description

<installdir> — —

— README API readme file

<installdir>/javadoc — —

— index.html Index of all API specifications

— (API specification files, and so on.)

API specification documents

<installdir>/lib — —

— smapi.jar Subscriber Manager API executable

1-2Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 19: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 1 Getting Started Package Content

— asn1rt.jar Utility jar used by the API

— jdmkrt.jar Utility jar used by the API

— log4j.jar Utility jar used by the API

— log4j.properties Property file needed for the API logging functionalities

— xerces.jar Utility jar used by the API

— jce-jdk13-133.jar Provides an implementation of the Java Cryptography Extension API

Table 1-1 Layout of Installation Directory (continued)

Path Name Description

1-3Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 20: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 1 Getting Started Installing the Java API

Installing the Java API The Java API is part of the SCMS Subscriber Manager Login Event Generator (LEG) distribution file and is located in the SM_API directory.

The Java Subscriber Manager API is packaged in a UNIX tar file. The API is compiled with log4j 1.2. You can extract the Java Subscriber Manager API by using the UNIX tar utility or most Windows compression utilities:

• Subscriber Manager Setup, page 1-4

• Installing on a UNIX Platform, page 1-4

• Installing on a Windows Platform, page 1-4

Subscriber Manager Setup The API connects to the Proprietary Remote Procedure Call (PRPC) server on the Subscriber Manager. To enable the API to operate, the following conditions must be met:

• The Subscriber Manager must be operating, and reachable from the machine that hosts the API.

• The PRPC server must be started.

The PRPC server is a proprietary RPC protocol designed by Cisco. For more information about the PRPC server, see Cisco Service Control Management Suite Subscriber Manager User Guide.

Installing on a UNIX Platform

Note The abbreviations vvv and bb represent the Subscriber Manager Java API version and build number.

To install SCMS Subscriber Manager Java API

Step 1 Extract the SCMS SM LEG distribution file.

Step 2 Locate the Java Subscriber Manager API distribution tar, sm-java-api-dist.tar.

Step 3 Extract the Java Subscriber Manager API distribution tar and obtain sm-java-api-vvv.bb.tar.

#>tar -xvf sm-java-api-dist.tar

Step 4 Extract the Java Subscriber Manager API package tar.

#>tar -xvf sm-java-api-vvv.bb.tar

Installing on a Windows Platform Use a zip extractor (such as WinZip).

1-4Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 21: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 1 Getting Started Compiling and Running a Program That Uses the API

Compiling and Running a Program That Uses the APITo compile and run a program that uses the Subscriber Manager Java API, smapi.jar must be in the CLASSPATH.

For example, if the program source is in SMApiProgram.java, use the following command to compile the program:

#>javac -classpath smapi.jar SMApiProgram.java

After compiling the program, use the following command to run the program:

#>java -cp .;<installdir>/lib/smapi.jar SMApiProgram

1-5Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 22: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 1 Getting Started Compiling and Running a Program That Uses the API

1-6Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 23: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

OL-24191-02

C H A P T E R 2

General API Concepts

Revised: September 20, 2011, OL-24191-02

IntroductionThis chapter describes the concepts that pertain to working with the Subscriber Manager (SM) Java API.

This chapter consists of the following sections:

• Blocking API and the Nonblocking API, page 2-2

• API Initialization, page 2-3

• API Finalization, page 2-5

• Subscriber Name Format, page 2-5

• Network ID Mappings, page 2-6

• Subscriber Domains, page 2-8

• Subscriber Properties, page 2-8

• Custom Properties, page 2-9

• DisconnectListener Interface, page 2-9

• Exceptions, page 2-10

• Practical Tips, page 2-10

2-1Cisco SCMS SM Java API Programmer Guide

Page 24: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 2 General API Concepts Blocking API and the Nonblocking API

Blocking API and the Nonblocking APIThis section describes the differences between the Blocking API and the Nonblocking API.

• Blocking API, page 2-2

• Nonblocking API, page 2-2

Blocking API In a Blocking API operation, which is the most common, every method returns after its operation is performed.

The Subscriber Manager Blocking Java API provides a wide range of operations. It contains most of the functionality of the Nonblocking API and many functions that the Nonblocking API does not provide. The Blocking API does not support reliability and autoreconnect functionality.

Nonblocking API In a Nonblocking Java API operation, every method returns immediately, even before the completion of its operation. The operation results are either returned to an observer object (listener) or not returned at all.

The Nonblocking API method is preferred when the operation is lengthy and involves I/O. When the operation is performed in a separate thread, the calling program can continue performing other tasks, which improves the overall system performance.

The Subscriber Manager Nonblocking Java API contains a small number of nonblocking operations. The API supports the retrieval of operation results by using a result listener.

The Subscriber Manager Nonblocking Java API supports two modes—reliable and nonreliable. For more information about the reliability modes, see the “Reliability Support” section on page 4-2.

2-2Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 25: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 2 General API Concepts API Initialization

API Initialization To initialize the API, you must complete three tasks:

• Construct the API by using one of its constructors. For details, see the “API Construction” section on page 2-3.

• Perform the API-specific setup operations. For details, see the “Setup Operations” section on page 2-3.

• Connect the API to the Subscriber Manager. For details, see the “Connecting to the Subscriber Manager” section on page 2-4.

API Construction Blocking and Nonblocking APIs have two constructors:

• An Empty constructor

• A Constructor that accepts a Login Event Generator (LEG) name as a parameter.

Constructor that Accepts a LEG Name

Set the LEG name if you intend to turn on the Subscriber Manager LEG failure processing options in the Subscriber Manager. For more information about the LEG software components and SM-LEG failure handling, see the Cisco Service Control Management Suite Subscriber Manager User Guide.

The Subscriber Manager uses the LEG name when recovering from a connection failure. A constant string that identifies the API is appended to the LEG name as follows:

• For blocking API—.B.SM-API.J

• For nonblocking API—.NB.SM-API.J

Blocking API—Example

If the provided LEG name is my-leg.10.1.12.45-version-1.0, the actual LEG name is my-leg.10.1.12.45-version-1.0.B.SM-API.J.

If no name is set, the LEG uses the hostname of the machine as the prefix of the name.

Additional constructors are available for the Nonblocking API. For more information, see the “Nonblocking API Construction” section on page 4-6.

Setup Operations The setup operations differ for the two APIs. Both APIs support setting a disconnect listener, which is described in detail in the “DisconnectListener Interface” section on page 2-9.

• Blocking API Setup, page 2-4

• Nonblocking API Setup, page 2-4

2-3Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 26: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 2 General API Concepts Connecting to the Subscriber Manager

Blocking API Setup

To set up the Blocking API, you must set an operation timeout value. For more information, see Chapter 3, “Blocking API”.

Nonblocking API Setup

To set up the Nonblocking API, you must set a disconnect listener. For more details, see Chapter 4, “Nonblocking API”.

Connecting to the Subscriber Manager To connect to the Subscriber Manager, use one of the following connect methods.

• Use the following method to connect to the Subscriber Manager by using the default remote procedure call (RPC) TCP port (14374):

connect(String host)

• Use the following method to allow the caller to set the TCP port to which the API connects:

connect(String host, int port)

For both methods, the host parameter can be either an IP address or a reachable hostname.

At any time during the API operation, you can check if the API is connected by using the isConnected method.

2-4Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 27: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 2 General API Concepts API Finalization

API FinalizationTo free the resources of both the server and the client, use the disconnect method.

Use a finally statement in your main class, as follows:

public static void main(String [] args) throws Exception { SMNonBlockingApi smnbapi = new SMNonBlockingApi(); try { ... } finally { smnbapi.disconnect(); }}

Subscriber Name FormatMost methods of both APIs require the subscriber name as an input parameter.

A subscriber name can contain up to 64 characters. You can use all printable characters with an ASCII code between 32 and 126 (inclusive), except for 34 ("), 39 ('), and 96 (`).

2-5Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 28: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 2 General API Concepts Network ID Mappings

Network ID MappingsA network ID mapping is a network identifier that the Service Control Engine (SCE) device can map to a specific subscriber record. A typical example of a network ID mapping (or simply, mapping) is an IP address. Currently, the Cisco Service Control solution supports IP address, IP range, private IP address over VPN, private IP range over VPN, and VLAN mappings.

Both Blocking and Nonblocking APIs contain operations that accept mappings as a parameter, such as the following:

• The addSubscriber operation (Blocking API)

• The login method (Blocking or Nonblocking API)

When passing mappings to an API method, the caller is requested to provide two parameters:

• The java.lang.String mapping identifier or array of mapping types

• The short mapping type or array of mapping types

When passing arrays, the mappingTypes array must contain either the same number of elements as the mappings array or a single element. If the mappingTypes array contains a single element, all mappings have the same type, specified by this single element.

The API supports the following subscriber mapping types:

• IP addresses or IP ranges

• Private IP addresses or private IP ranges over VPN

• VLAN tags

For additional information, see the Cisco Service Control Management Suite Subscriber Manager User Guide.

Specifying IP Address Mapping The string format of an IP address is the commonly used decimal notation:

IP-Address=[0-255].[0-255].[0-255].[0-255]

Example:

• 216.109.118.66

Mapping type of an IP address is provided in the com.pcube.management.api.SMApiConstants interface:

– com.pcube.management.api.SMApiConstants.MAPPING_TYPE_IP specifies a single IP mapping that matches the mapping identifier with the same index in the mapping identifier array.

– com.pcube.management.api.SMApiConstants.ALL_IP_MAPPINGS specifies that all the entries in the mapping identifiers array are IP mappings.

2-6Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 29: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 2 General API Concepts Specifying IP Range Mapping

Specifying IP Range Mapping The string format of an IP range is an IP address in decimal notation and a decimal specifying the number of 1s in a bit mask:

IP-Range=[0-255].[0-255].[0-255].[0-255]/[0-32]

Examples:

• 10.1.1.10/32 is an IP range with a complete mask, that is, a regular IP address.

• 10.1.1.0/24 is an IP range with a 24-bit mask, that is, all the addresses ranging between 10.1.1.0 and 10.1.1.255.

Note The mapping type of an IP range is identical to the mapping type of the IP address.

Specifying Private IP Address or Private IP Range over VPN MappingThe string format of an IP address and an IP range are described in the “Specifying IP Address Mapping” section on page 2-6 and in the “Specifying IP Range Mapping” section on page 2-7. When the network ID mapping uses an IP address or range over VPN, the string format includes the VPN name.

Examples:

• 10.1.1.10@VPN1 is an IP address over the VPN named VPN1.

• 10.1.1.0/24@VPN2 is an IP range with a 24-bit mask, that is, all of the addresses in the range from 10.1.1.0 to 10.1.1.255 over the VPN named VPN2.

Note The mapping type of an IP address or IP range over VPN is identical to the mapping type of the IP address.

Specifying VLAN Tag Mapping The string format for VLAN tag mapping is VLAN-tag = 0 to 4095.

The value is a decimal in the specified range.

The com.pcube.management.api.SMApiConstants interface also provides the mapping type:

• com.pcube.management.api.SMApiConstants.MAPPING_TYPE_VPN specifies a single VLAN mapping that matches the mapping identifier with the same index in the mapping identifier array.

• com.pcube.management.api.SMApiConstants.ALL_VPN_MAPPINGS specifies that all the entries in the mapping identifiers array are VLAN mappings.

Note The SMApiConstants.TYPE_VLAN and SMApiConstants.ALL_VLAN_MAPPINGS constants are deprecated. You should use the SMApiConstants.TYPE_VPN and SMApiConstants.ALL_VPN_MAPPINGS constants instead.

2-7Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 30: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 2 General API Concepts Subscriber Domains

Subscriber DomainsThe Cisco Service Control Management Suite Subscriber Manager User Guide defines the domain concept. Briefly, a domain identifies for the Subscriber Manager the SCE devices to which it updates subscriber records.

A domain name is a type of String. During system installation, the network administrator determines the system domain names, which, therefore, vary between installations. The APIs include methods that specify the domain to which a subscriber belongs. The APIs also provide methods that enable queries about system domain names. If an API operation specifies a domain name that does not exist in the Subscriber Manager domain repository, it is considered an error and RpcErrorException is returned.

The Subscriber Manager automatic domain roaming feature enables you to move subscribers between domains by calling the login method for a subscriber with an updated domain parameter as described in the “login” section on page 3-5.

Note Automatic domain roaming is not backward compatible with previous versions of the Subscriber Manager API. Previous versions did not permit changing the domain of the subscriber.

Subscriber PropertiesSeveral operations manipulate subscriber properties. A subscriber property is a key/value pair that affects the way the Cisco SCE analyzes and reacts to network traffic generated by the subscriber.

For information about properties, see the Cisco Service Control Management Suite Subscriber Manager User Guide and the Cisco Service Control Application for Broadband User Guide. The latter provides application-specific information; it lists the subscriber properties that exist in the application running on your system, the allowed value set, and the significance of each property value.

To format subscriber properties for Java API operations, use the String arrays propertyKeys and propertyValues.

Note The arrays must be of the same length, and NULL entries are forbidden. Each key in the keys array has a matching entry in the values array; the value for propertyKeys[j] resides in propertyValues[j]. The mapping type of an IP range is identical to the mapping type of the IP address.

Example:

If the property keys array is {"packageId","monitor"} and the property values array is {"5","1"}, the properties are packageId=5, monitor=1.

2-8Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 31: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 2 General API Concepts Custom Properties

Custom PropertiesSome operations manipulate custom properties. Custom properties are similar to subscriber properties, but do not affect how the SCE analyzes and manipulates the subscriber traffic. The application management modules use custom properties to store additional information for each subscriber.

To format custom properties, use the String arrays customPropertyKeys and customPropertyValues. This formatting is the same as in the subscriber properties formatting described in the “Subscriber Properties” section on page 2-8.

DisconnectListener InterfaceBoth APIs (Blocking and Nonblocking) enable you to set a disconnect listener. The disconnect listener is an interface with a single method:

public interface DisconnectListener { /** * called when the connection with the server is down. */ public void connectionIsDown();}

Implement this interface to be notified when the API is disconnected from the Subscriber Manager.

To set a disconnect listener, use the setDisconnectListener method.

DisconnectListener Interface ExampleThe following example is a basic implementation of a disconnect listener that prints a message to stdout and exits:

import com.pcube.management.framework.rpc.DisconnectListener;

public class MyDisconnectListener implements DisconnectListener {

public void connectionIsDown(){ System.out.println("Message: connection is down."); System.exit(0); }}

2-9Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 32: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 2 General API Concepts Exceptions

ExceptionsThe same Java class, com.pcube.management.framework.rpc.RpcErrorException, provides all of the functional errors of the Subscriber Manager Java API. This is contrary to the normal Java usage. This approach was chosen because of the cross-language nature of the Subscriber Manager API. It enables all Subscriber Manager API implementations (Java, C, and C++) to appear similar.

Each exception provides the following information:

• Unique error code (long)

• Informative message (java.lang.String)

• Server-side stack trace (java.lang.String)

The error code can be interpreted by using com.pcube.management.api.SMApiConstants. See Appendix A, “List of Error Codes” for details about error codes and their significance.

Note Several types of errors can occur only if you use the Blocking API. These are operational errors that are related to operation-timeout handling. These errors are described in Chapter 3, “Blocking API.”

Practical TipsWhen implementing the code that integrates the API with your application, consider the following practical tips:

• Connect to the Subscriber Manager once and maintain an open API connection to the Subscriber Manager at all times, using the API many times. Establishing a connection is a timely procedure, which allocates resources on the Subscriber Manager side and the API client side.

• Share the API connection between your threads. It is best to have one connection per LEG. Multiple connections require more resources on the Subscriber Manager side and client side.

• Do not implement synchronization of the calls to the API. The client automatically synchronizes calls to the API.

• Place the API clients (LEGs) in the same order as the Subscriber Manager machine processor number.

• If the LEG application has bursts of login operations, enlarge the internal buffer size accordingly to hold these bursts (Nonblocking API).

• During the integration, set the Subscriber Manager logon_logging_enabled configuration parameter to enable viewing the API operations in the Subscriber Manager log. Setting this parameter enables you to troubleshoot the integration, if any problems arise.

• Use the debug mode for the LEG application that logs the return values of the nonblocking operations.

• Use the automatic reconnect feature to improve the resiliency of the connection to the Subscriber Manager.

• In cluster setups, connect the API by using the virtual IP address of the cluster and not the management IP address of one of the machines.

2-10Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 33: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

OL-24191-02

C H A P T E R 3

Blocking API

Revised: September 20, 2011, OL-24191-02

IntroductionThis chapter introduces the Reply Timeout, a feature unique to the Blocking API.

The chapter also lists all the operations of the Blocking API, and provides code examples.

Note If you need to develop only an automatic integration, skip this chapter and go directly to Chapter 4, “Nonblocking API.”

This chapter consists of the following sections:

• Multithreading Support, page 3-2

• ReplyTimeout and OperationTimeout Exception, page 3-3

• Subscriber Manager Blocking API Methods, page 3-4

• Quota Manager Blocking API Methods, page 3-35

• Blocking API Code Examples, page 3-43

3-1Cisco SCMS SM Java API Programmer Guide

Page 34: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API Multithreading Support

Multithreading SupportThe Blocking API supports an unlimited number of threads calling its methods simultaneously.

Note In a multithreaded scenario for the Blocking API, the order of invocation is not guaranteed.

Example:

Thread-0 calls operation-0 at time-0, and thread-1 calls operation-1 at time-1, where time-1 is later than time-0. In this example, it is possible that operation-1 might be performed before operation-0, as shown in Figure 3-1 (the vertical scale is time):

Figure 3-1 Multithreading Support

The Subscriber Manager (SM) allocates five threads to manage each API instance. Develop a multithreaded application that uses the API with several threads in the order of the five threads. Implementing with more threads might result in longer delays for the calling threads.

1571

10

Thread 0 :

op-0 : operation

op-1 : operation

op-1 : result

op-0 : result

Thread 1 : SM Blocking API :

3-2Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 35: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API ReplyTimeout and OperationTimeout Exception

ReplyTimeout and OperationTimeout ExceptionA blocking operation returns only when the operation result is retrieved from the Subscriber Manager. If a networking malfunction or other error prevents the operation result from being retrieved, the caller waits indefinitely. The Subscriber Manager API provides a means of working around this situation.

The reply timeout feature (the setReplyTimeout method) enables the caller to set a timeout. It will generate com.pcube.management.framework.rpc.OperationTimeoutException when a reply does not return within the timeout period.

Calling the setReplyTimeout method with a long value sets a reply timeout. The reply timeout is interpreted in milliseconds. A zero value indicates that the operation should wait (freeze, stop responding) until a result arrives—or indefinitely, if no result arrives.

There is an alternative way to release a method call that is blocking the caller, who is waiting for a result to arrive. Call the interrupt method of the calling thread; java.lang.InterruptedException will then be returned to the caller.

3-3Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 36: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API Subscriber Manager Blocking API Methods

Subscriber Manager Blocking API MethodsThis section lists the methods of the Subscriber Manager Blocking API. The description of each method includes its syntax, input parameters, and return values.

The Blocking API is a superset of the Nonblocking API. Except for differences in return values and result handling, identical operations in both APIs have the same functions and syntax structure. All the methods generate java.lang.IllegalStateException when called before the API establishes a connection with the Subscriber Manager.

The Blocking API methods are classified as follows:

• Dynamic IP and property allocation—Use the following methods to integrate the Subscriber Manager API with an authentication, authorization, and accounting (AAA) system. These methods are not designed to add or remove subscribers from the database. Instead, they modify dynamic parameters (such as IP addresses) of the existing subscribers:

– login, page 3-5

– logoutByName, page 3-7

– logoutByNameFromDomain, page 3-10

– logoutByMapping, page 3-11

– loginCable, page 3-13

– logoutCable, page 3-15

• Static or Manual Subscriber configuration—Use the following methods for a GUI:

– addSubscriber, page 3-16

– removeSubscriber, page 3-18

– removeAllSubscribers, page 3-19

– setPropertiesToDefault, page 3-32

– removeCustomProperties, page 3-33

• Use the following methods for simple read-only operations, performed independently in the subscriber awareness mode:

– getNumberOfSubscribers, page 3-20

– getNumberOfSubscribersInDomain, page 3-20

– getSubscriber, page 3-21

– subscriberExists, page 3-23

– subscriberLoggedIn, page 3-23

– getSubscriberNameByMapping, page 3-24

– getSubscriberNames (all), page 3-26

– getSubscriberNames (filter by property), page 3-27

– getSubscriberNamesInDomain, page 3-28

– getSubscriberNamesWithPrefix, page 3-29

– getSubscriberNamesWithSuffix, page 3-30

– getDomains, page 3-31

3-4Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 37: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API login

You can mix methods from different categories in a single application. The classification is presented only for clarity.

loginThe following sections provide information about the login operation:

• Syntax, page 3-5

• Description, page 3-5

• Parameters, page 3-5

• RPC Exception Error Codes, page 3-6

• Return Value, page 3-6

• Examples, page 3-6

Syntax

The login syntax is as follows:

public void login(String subscriberName, String[] mappings, short[] mappingTypes, String[] propertyKeys, String[] propertyValues, String domain, boolean isMappingAdditive, int autoLogoutTime)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The login method adds or modifies a domain, mappings, and possibly properties of a subscriber that already exists in the Subscriber Manager database. The login method can be called with partial data; for example, it might provide mappings or properties only, and put NULL ++++ in the unchanged fields.

If another subscriber with the same (or conflicting) mappings already exists in the same domain, the conflicting mappings are removed from the other subscriber and assigned to the new subscriber.

If the subscriber does not exist in the Subscriber Manager database, the login method creates it with the data provided.

Parameters

The parameters of the login method are as follows:

• subscriberName—See the description of subscriber name formatting in the “Subscriber Name Format” section on page 2-5.

• mappings—See the description of mappings and mapping types in the “Network ID Mappings” section on page 2-6. If no mappings are specified, and the isMappingAdditive parameter is TRUE, the previous mappings are retained. If no such mappings exist, the operation fails.

• mappingTypes—See the description of mappings and mapping types in the “Network ID Mappings” section on page 2-6.

3-5Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 38: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API login

• propertyKeys—See the description of property keys in the “Subscriber Properties” section on page 2-8.

• propertyValues—See the description of property values in the “Subscriber Properties” section on page 2-8.

• domain—See the description of subscriber domains in the “Subscriber Domains” section on page 2-8.

If domain is NULL, but the subscriber already has a domain, the existing domain is retained.

If the domain is different from the domain that was previously assigned to the subscriber, the subscriber is removed automatically from the Cisco SCEs of the previous domain and moved to the SCEs of the new domain.

• isMappingAdditive

– TRUE—Adds the mappings provided by this call to the subscriber record.

– FALSE—Overrides the mappings provided by this call with mappings that already exist in the subscriber record.

• autoLogoutTime—Applies only to the mappings provided as arguments to this method.

– Positive value (N)—Automatically logs out the mappings (similar to calling a logout method) after N seconds.

– 0 value—Maintains the current expiration time for the given mappings.

– Negative value—Disables any expiration time set for the given mappings.

RPC Exception Error Codes

The following list presents the error codes the login method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE_BAD_SUBSCRIBER_MAPPING

• ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION

• ERROR_CODE_DATABASE_EXCEPTION

• ERROR_CODE_UNKNOWN

This error can be caused by the following parameter settings:

– NULL value for the domain parameter for the subscriber that does not exist or does not have a domain

– Invalid values for the propertyValues parameter

For a description of error codes, see Appendix A, “List of Error Codes”.

Return Value

None.

Examples

To add the IP address 192.168.12.5 to an existing subscriber named alpha without affecting existing mappings:

login(

3-6Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 39: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API logoutByName

"alpha", // subscriber name new String[]{"192.168.12.5"}, SMApiConstants.ALL_IP_MAPPINGS, null, null, "subscribers", // domain true, // isMappingAdditive is true -1); // autoLogoutTime set to infinite

To add the IP address 192.168.12.5 overriding previous mappings:

login( "alpha", // subscriber name new String[]{"192.168.12.5"}, SMApiConstants.ALL_IP_MAPPINGS, null, null, "subscribers", // domain false, // isMappingAdditive is false -1); // autoLogoutTime set to infinite

To extend the auto logout time of 192.168.12.5, which was previously assigned to alpha:

login( "alpha", //the previously assigned IP new String[]{"192.168.12.5"}, SMApiConstants.ALL_IP_MAPPINGS, null, null, "subscribers", // domain false, // isMappingAdditive 300); // autoLogoutTime set to 300 seconds

To modify a dynamic property of alpha (for example, package ID):

login( "alpha", null, null, new String[]{"packageId"}, // property key new String[]{"10"}, // property value "subscribers", // domain false, -1);

To add the IP address 192.168.12.5 to an existing subscriber named alpha without affecting existing mappings and to modify a dynamic property of alpha (for example, package ID):

login( "alpha", new String[]{"192.168.12.5"}, SMApiConstants.ALL_IP_MAPPINGS, new String[]{"packageId"}, // property key new String[]{"10"}, // property value "subscribers", // domain true, // isMappingAdditive is set to true -1);

logoutByNameThe following sections provide information about the logoutByName operation:

• Syntax, page 3-8

• Description, page 3-8

• Parameters, page 3-8

• Return Value, page 3-8

3-7Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 40: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API logoutByName

• RPC Exception Error Codes, page 3-8

• Examples, page 3-9

Syntax

The logoutByName syntax is as follows:

public boolean logoutByName(String subscriberName, String[] mappings, short[] mappingTypes)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The logoutByName method locates the subscriber in the database and removes mappings from it. If the subscriber does not exist, the logoutByName operation does not do anything.

Parameters

The parameters of the logoutByName method are as follows:

• subscriberName—See the description of subscriber name formatting in the “Subscriber Name Format” section on page 2-5.

• mappings—See the description of mappings in the “Network ID Mappings” section on page 2-6. If no mappings are specified, all subscriber mappings are removed.

• mappingTypes—See the description of mapping types in the “Network ID Mappings” section on page 2-6.

Return Value

• TRUE—If the subscriber was found and the subscriber mappings were removed from the subscriber database

• FALSE—If the subscriber was not found in the subscriber database

RPC Exception Error Codes

The following list presents the error codes the logoutByName method might return:

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE _BAD_SUBSCRIBER_MAPPING

• ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION

• ERROR_CODE_DOMAIN_NOT_FOUND

• ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

3-8Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 41: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API logoutByName

Examples

To remove IP address 192.168.12.5 of subscriber alpha:

boolean isExist = logoutByName( "alpha", new String[]{"192.168.12.5"}, SMApiConstants.ALL_IP_MAPPINGS);

To remove all IP addresses of subscriber alpha:

boolean isExist = logoutByName("alpha", null, null);

3-9Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 42: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API logoutByNameFromDomain

logoutByNameFromDomainThe following sections provide information about the logoutByNameFromDomain operation:

• Syntax, page 3-10

• Description, page 3-10

• Parameters, page 3-10

• Return Value, page 3-10

• RPC Exception Error Codes, page 3-11

• Example, page 3-11

Syntax

The logoutByNameFromDomain syntax is as follows:

public boolean logoutByNameFromDomain(String subscriberName, String[] mappings, short[] mappingTypes, String domain)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The logoutByNameFromDomain similar to logoutByName, but this method also enables the caller to provide the name of the domain to which the subscriber belongs. When the subscriber domain is known, use this method to improve performance.

Parameters

The parameters of the logoutByNameFromDomain method are as follows:

• subscriberName—See the description of subscriber name formatting in the “Subscriber Name Format” section on page 2-5.

• mappings—See the description of mappings in the “Network ID Mappings” section on page 2-6. If no mappings are specified, all subscriber mappings are removed.

• mappingTypes—See the description of mapping types in the “Network ID Mappings” section on page 2-6.

• domain—See the description of subscriber domains in the “Subscriber Domains” section on page 2-8.

The operation fails if either of the following conditions exists:

• Domain is null, but the subscriber exists in the database and belongs to a domain.

• Domain specified is incorrect.

Return Value

• TRUE—If the subscriber was found and removed from the subscriber database

• FALSE—If the subscriber was not found in the subscriber database

3-10Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 43: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API logoutByMapping

RPC Exception Error Codes

The following list presents error codes the logoutByNameFromDomain method might return:

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE _BAD_SUBSCRIBER_MAPPING

• ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION

• ERROR_CODE_DOMAIN_NOT_FOUND

• ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

Example

To remove IP address 192.168.12.5 of subscriber alpha from domain subscribers:

boolean isExist = logoutByNameFromDomain( "alpha", new String[]{"192.168.12.5"}, SMApiConstants.ALL_IP_MAPPINGS, "subscribers");boolean isExist = logoutByNameFromDomain( "alpha", null, null, "subscribers");

logoutByMappingThe following sections provide information about the logoutByMapping operation:

• Syntax, page 3-11

• Description, page 3-12

• Parameters, page 3-12

• Return Value, page 3-12

• RPC Exception Error Codes, page 3-12

• Example, page 3-12

Syntax

The logoutByMapping syntax is as follows:

public boolean logoutByMapping(String mapping, short mappingType, String domain)throws InterruptedException, OperationTimeoutException, RpcErrorException

3-11Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 44: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API logoutByMapping

Description

The logoutByMapping locates a subscriber based on domain and mapping, and removes the mapping (the subscriber stays in the database).

Parameters

The parameters of the logoutByMapping method are as follows:

• mapping—See the description of mappings in the “Network ID Mappings” section on page 2-6.

• mappingType—See the description of mapping types in the “Network ID Mappings” section on page 2-6.

• domain—See the description of the logoutByNameFromDomain operation in the “Parameters” section on page 3-10.

Return Value

• TRUE—If the subscriber was found and removed from the subscriber database.

• FALSE—If the subscriber was not found in the subscriber database.

RPC Exception Error Codes

The following list presents error codes the logoutByMapping method might return:

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE _BAD_SUBSCRIBER_MAPPING

• ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION

• ERROR_CODE_DOMAIN_NOT_FOUND

• ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

Example

To remove IP address 192.168.12.5 from domain subscribers:

boolean isExist = logoutByMapping( "192.168.12.5", SMApiConstants. MAPPING_TYPE_IP, "subscribers");

3-12Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 45: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API loginCable

loginCableThe following sections provide information about the loginCable operation:

• Syntax, page 3-13

• Description, page 3-13

• Parameters, page 3-13

• Return Value, page 3-14

• RPC Exception Error Codes, page 3-14

• Examples, page 3-14

Syntax

The loginCable syntax is as follows:

public void loginCable(String CPE, String CM, String IP, int lease, String domain, String[] propertyKeys, String[] propertyValues)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The loginCable method is an operation adapted for the cable environment; it calls the cable support module in the Subscriber Manager. This method is designed to log in the customer premise equipment (CPE) and content managers to the Subscriber Manager. To log in a CPE, specify its cable modem (CM) MAC in the CM argument and the CPE MAC in the CPE argument. To log in a cable modem, specify the cable modem MAC address in both CPE and CM arguments. Note that the login of a CPE whose CM does not exist in the Subscriber Manager database is ignored—the CM has to exist in the database, either by import or by a CM login operation. For additional information, see the CPE as Subscriber in Cable Environment chapter of Cisco Service Control Management Suite Subscriber Manager User Guide.

Note The name of the CPE in the Subscriber Manager database is the concatenation of the CPE and CM values with two underscore characters (“_”) between them. The caller must ensure that the lengths of CPE and CM add up to no more than 38 characters.

Parameters

The parameters of the loginCable method are as follows:

• CPE—Unique identifier of the CPE (usually a MAC address)

• CM—Unique identifier of the cable modem (usually a MAC address)

• IP—CPE IP address

• lease—CPE lease time

• domain—See the description of the subscriber domains in the “Subscriber Domains” section on page 2-8. The domain is usually cable modem termination system (CMTS) IP.

3-13Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 46: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API loginCable

Note Domain aliases must be set on the Subscriber Manager so that the cable modem termination system (CMTS) IP is correctly interpreted as a domain name. For information about configuring aliases, see the Default Domains Configuration section of Cisco SCMS Subscriber Manager User Guide.

• propertyKeys—See the description of property keys in the “Subscriber Properties” section on page 2-8.

If the CPE is provided with partial or no application properties, the values for the missing application properties are copied from the application properties of the cable modem to which this CPE belongs. Each cable modem application property thus serves as a default for the CPE with which it is associated.

• propertyValues—See the description of property values in the “Subscriber Properties” section on page 2-8.

Return Value

None.

RPC Exception Error Codes

None.

Examples

To add the IP address 192.168.12.5 to a cable modem called CM1 with two hours lease time:

loginCable( "CM1", "CM1", "192.168.12.5", 7200, // lease time in seconds "subscribers", null, null);

To add the IP address 192.168.12.50 to a CPE called CPE1, which is behind CM1 with lease time of one hour:

loginCable( "CPE1", "CM1", "192.168.12.50", 3600, // lease time in seconds "subscribers", null, null);

3-14Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 47: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API logoutCable

logoutCableThe following sections provide information about the logoutCable operation:

• Syntax, page 3-15

• Description, page 3-15

• Parameters, page 3-15

• Return Value, page 3-15

• RPC Exception Error Codes, page 3-15

• Example, page 3-15

Syntax

The logoutCable syntax is as follows:

public boolean logoutCable(String CPE, String CM, String IP, String domain)

Description

The logoutCable method indicates to the Subscriber Manager cable support module that a logout event has happened.

Parameters

The parameters of the logoutCable method are as follows:

• CPE—See the description in the “Parameters” section on page 3-13.

• CM—See the description in the “Parameters” section on page 3-13.

• IP—See the description in the “Parameters” section on page 3-13.

• domain—See the description in the “Parameters” section on page 3-13.

Return Value

• TRUE—If the CPE was found and removed from the subscriber database

• FALSE—If the CPE was not found in the subscriber database

RPC Exception Error Codes

None.

Example

To remove the IP address 192.168.12.5 from CPE1, which is associated with CM1:

boolean isExist = logoutCable( "CPE1",

3-15Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 48: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API addSubscriber

"CM1", "192.168.12.5", "subscribers");

addSubscriberThe following sections provide information about the addSubscriber operation:

• Syntax, page 3-16

• Description, page 3-16

• Example, page 3-17

• Parameters, page 3-17

• Return Value, page 3-17

• RPC Exception Error Codes, page 3-17

• Examples, page 3-18

Syntax

The addSubscriber syntax is as follows:

public void addSubscriber(String subscriberName, String[] mappings, short[] mappingTypes, String[] propertyKeys, String[] propertyValues, String[] customPropertyKeys, String[] customPropertyValues, String domain)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The addSubscriber method creates a new subscriber record according to the method parameters and adds the record to the Subscriber Manager database.

When adding a new subscriber name, if the name already exists in Subscriber Manager database, the first instance of the name is removed before the new one is added. In contrast to login method, which modifies fields and leaves unspecified fields unchanged, the addSubscriber method sets the subscriber exactly as specified by the parameters passed to it.

Note Use the call login method for existing subscribers, instead of the addSubscriber command. You should set dynamic mappings and properties by using the login command. Set static mappings and properties the first time the subscriber is created by using the addSubscriber command.

Note With the addSubscriber command, the autologout feature is always disabled. To enable autologout, use the login command.

3-16Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 49: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API addSubscriber

Example

Subscriber AB, already set up in the subscriber database, has a single IP mapping (IP1).

If an addSubscriber operation for AB is called with no mappings specified (NULL in both the mappings and mappingTypes fields), AB is left with no mappings.

However, calling the login operation with these NULL-value parameters does not change the subscriber mappings of AB; AB retains its previous IP mapping of IP1.

Parameters

The parameters of the addSubscriber method are as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

• mappings—See the description in the “Network ID Mappings” section on page 2-6.

• mappingTypes—See the description of mapping types in the “Network ID Mappings” section on page 2-6.

• propertyKeys—See the description of property keys in the “Subscriber Properties” section on page 2-8.

• propertyValues—See the description of property values in the “Subscriber Properties” section on page 2-8.

• customPropertyKeys—See the description of custom property keys in the “Custom Properties” section on page 2-9.

• customPropertyValues—See the description of custom property values in the “Custom Properties” section on page 2-9.

• domain—See the description of subscriber domains in the “Subscriber Domains” section on page 2-8.

A NULL value indicates that the subscriber has no domain. If domain is NULL, but the subscriber already has a domain, the existing domain is retained.

Return Value

None.

RPC Exception Error Codes

The following list presents error codes that the addSubscriber method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _BAD_SUBSCRIBER_MAPPING

• ERROR_CODE_DOMAIN_NOT_FOUND

• ERROR_CODE_SUBSCRIBER_ALREADY_EXISTS

• ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION

• ERROR_CODE_UNKNOWN

This error code might indicate invalid values that were supplied for the propertyValues parameter.

• ERROR_CODE_DATABASE_EXCEPTION

3-17Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 50: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API removeSubscriber

For a description of error codes, see Appendix A, “List of Error Codes”.

Examples

The following example code adds a new subscriber, alpha, with some custom properties:

addSubscriber("alpha", null, null, // dynamic mappings will be set by login null, null // dynamic properties will be set by login new String[]{ // custom property keys "work phone", "home phone"}, new String[]{ // custom property values "6543212" "5059927"}, "subscribers"); // default domain

removeSubscriberThe following sections provide information about the removeSubscriber operation:

• Syntax, page 3-18

• Description, page 3-18

• Parameters, page 3-18

• Return Value, page 3-18

• RPC Exception Error Codes, page 3-19

• Example, page 3-19

Syntax

The removeSubscriber syntax is as follows:

public boolean removeSubscriber(String subscriberName) throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The removeSubscriber method removes a subscriber completely from the Subscriber Manager database.

Parameters

The only parameter of the removeSubscriber method is as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

Return Value

• TRUE—If the subscriber was found in the database and successfully removed.

• FALSE—If the conditions for TRUE were not met; in other words, the subscriber was not found in the database, or the subscriber was found but was not successfully removed.

3-18Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 51: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API removeAllSubscribers

RPC Exception Error Codes

The following list presents error codes that the removeSubscriber method method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

Example

The following example code removes subscriber alpha entirely from the database:

boolean isExist = removeSubscriber("alpha");

removeAllSubscribersThe following sections provide information about the removeAllSubscribers operation:

• Syntax, page 3-19

• Description, page 3-19

• Return Value, page 3-19

• RPC Exception Error Codes, page 3-19

Syntax

The removeAllSubscribers syntax is as follows:

public void removeAllSubscribers() throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The removeAllSubscribers method removes all subscribers from the Subscriber Manager, leaving the database with no subscribers.

Note This method might take time to execute. To avoid operation timeout exceptions, set a high operation timeout (up to 5 minutes) before calling this method.

Return Value

None.

RPC Exception Error Codes

None.

3-19Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 52: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API getNumberOfSubscribers

getNumberOfSubscribersThe following sections provide information about the getNumberOfSubscribers operation:

• Syntax, page 3-20

• Description, page 3-20

• Return Value, page 3-20

• RPC Exception Error Codes, page 3-20

Syntax

The getNumberOfSubscribers syntax is as follows:

public int getNumberOfSubscribers() throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getNumberOfSubscribers method retrieves the total number of subscribers in the Subscriber Manager database.

Return Value

The number of subscribers in the Subscriber Manager.

RPC Exception Error Codes

None.

getNumberOfSubscribersInDomainThe following sections provide information about the getNumberOfSubscribersInDomain operation:

• Syntax, page 3-20

• Description, page 3-21

• Parameters, page 3-21

• Return Value, page 3-21

• RPC Exception Error Codes, page 3-21

Syntax

The getNumberOfSubscribersInDomain syntax is as follows:

public int getNumberOfSubscribersInDomain(String domain) throws InterruptedException, OperationTimeoutException, RpcErrorException

3-20Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 53: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API getSubscriber

Description

The getNumberOfSubscribersInDomain method retrieves the number of subscribers in a subscriber domain.

Parameters

The only parameter of the getNumberOfSubscribersInDomain method is as follows:

• domain—Name of a subscriber domain that exists in the Subscriber Manager domain repository.

Return Value

The number of subscribers in the provided domain.

RPC Exception Error Codes

The following list presents the error codes that the getNumberOfSubscribersInDomain method might return:

• ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN

• ERROR_CODE _DOMAIN_NOT_FOUND

For a description of error codes, see Appendix A, “List of Error Codes”.

getSubscriberThe following sections provide information about the getSubscriber operation:

• Syntax, page 3-21

• Description, page 3-21

• Parameters, page 3-22

• Return Value, page 3-22

• RPC Exception Error Codes, page 3-22

• Example, page 3-22

Syntax

The getSubscriber syntax is as follows:

public Object[] getSubscriber(String subscriberName) throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriber method retrieves a subscriber record. Each field is formatted as an integer, string, or string array.

If the subscriber does not exist in the Subscriber Manager database, the operation returns an exception.

3-21Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 54: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API getSubscriber

Parameters

The only parameter of the getSubscriber method is as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

Return Value

An object array with nine elements. Table 3-1 lists the index values and descriptions. No array element has a NULL value.

RPC Exception Error Codes

The following list presents error codes that the getSubscriber method method might return:

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

Example

The following example code retrieves the subscriber record of alpha:

Object[] subRecord = getSubscriber("alpha"); String[] mappings = (String[])subRecord[1] short[] mappingTypes = {short[])subRecord[2]; String domainName = (String)subRecord[3]; String[] propertyNames = (String[])subRecord[4]; String[] propertyValues = (String[])subRecord[5]; String[] customPropertyName = (String[])subRecord[6]; String[] customPropertyValues = (String[])subRecord[7]; long[] autoLogoutTime = (long[])subRecord[8];

Table 3-1 Indexes and Descriptions

Index Value Description

Index 0 Subscriber name (java.lang.String)

Index 1 Array of mappings (java.lang.String[])

Index 2 Array of mapping types (short[])

Index 3 Domain name (java.lang.String)

Index 4 Array of property names (java.lang.String[])

Index 5 Array of property values (java.lang.String[])

Index 6 Array of custom property names (java.lang.String[])

Index 7 Array of custom property values (java.lang.String[])

Index 8 Autologout time, in seconds from the present time, or -1 if not set (long[])

3-22Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 55: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API subscriberExists

subscriberExistsThe following sections provide information about the subscriberExists operation:

• Syntax, page 3-23

• Description, page 3-23

• Parameters, page 3-23

• Return Value, page 3-23

• RPC Exception Error Codes, page 3-23

Syntax

The subscriberExists syntax is as follows:

public boolean subscriberExists(String subscriberName) throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The subscriberExists method verifies that a subscriber exists in the Subscriber Manager database.

Parameters

The only parameter of the subscriberExists method is as follows:

subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

Return Value

• TRUE—If the subscriber was found in the Subscriber Manager database.

• FALSE—If the subscriber was not found.

RPC Exception Error Codes

None.

subscriberLoggedInThe following sections provide information about the subscriberLoggedIn operation:

• Syntax, page 3-24

• Description, page 3-24

• Parameters, page 3-24

• Return Value, page 3-24

• RPC Exception Error Codes, page 3-24

3-23Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 56: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API getSubscriberNameByMapping

Syntax

The subscriberLoggedIn syntax is as follows:

public boolean subscriberLoggedIn(String subscriberName) throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The subscriberLoggedIn method checks whether a subscriber that already exists in the Subscriber Manager database is logged in, that is, if the subscriber also exists in an SCE database.

When the Subscriber Manager is configured to work in Pull mode, a TRUE value returned by this method does not guarantee that the subscriber actually exists in an SCE database; but rather, the subscriber is available to be pulled by an SCE if needed.

If the subscriber does not exist in the Subscriber Manager database, an exception is generated.

Parameters

The only parameter of the subscriberLoggedIn method is as follows:

subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

Return Value

• TRUE—If the subscriber is logged in.

• FALSE—If the subscriber is not logged in.

RPC Exception Error Codes

The following list presents error codes that the subscriberLoggedIn method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

getSubscriberNameByMappingThe following sections provide information about the getSubscriberNameByMapping operation:

• Syntax, page 3-25

• Description, page 3-25

• Parameters, page 3-25

• Return Value, page 3-25

• RPC Exception Error Codes, page 3-25

3-24Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 57: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API getSubscriberNameByMapping

Syntax

The getSubscriberNameByMapping syntax is as follows:

public String getSubscriberNameByMapping(String mapping, short mappingType, String domain)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriberNameByMapping method finds a subscriber name according to a mapping and a domain.

Parameters

The parameters of the getSubscriberNameByMapping method are as follows:

• mapping—See the description of mappings in the “Network ID Mappings” section on page 2-6.

• mappingType—See the description of mapping types in the “Network ID Mappings” section on page 2-6.

• domain—Name of the domain to which the subscriber belongs. The operation fails if either of the following conditions exists:

– Domain is NULL, but the subscriber exists in the database and belongs to a domain.

– The specified domain is incorrect.

Return Value

• Subscriber name—If a subscriber record was found.

• NULL—If no subscriber record was found.

RPC Exception Error Codes

The following list presents error codes that the getSubscriberNameByMapping method might return:

• ERROR_CODE_DOMAIN_NOT_FOUND

• ERROR_CODE _BAD_SUBSCRIBER_MAPPING

• ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

3-25Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 58: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API getSubscriberNames (all)

getSubscriberNames (all)The following sections provide information about the getSubscriberNames (all) operation:

• Syntax, page 3-26

• Description, page 3-26

• Parameters, page 3-26

• Return Value, page 3-26

• RPC Exception Error Codes, page 3-27

• Example, page 3-27

Syntax

The getSubscriberNames (all) syntax is as follows:

public String[] getSubscriberNames(String lastBulkEnd, int numOfSubscribers)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriberNames (all) method retrieves a bulk of subscriber names from the Subscriber Manager database, starting with lastBulkEnd followed by numOfSubscribers (in alphabetical order).

If lastBulkEnd is NULL, the first subscriber name (alphabetically) that exists in the Subscriber Manager database is retrieved.

Note There is no guarantee that the total number of subscribers (in all the bulks) will equal the value returned from getNumOfSubscribers at any time. The values might differ if some subscribers are added or removed when the bulks are being retrieved.

Parameters

The parameters of the getSubscriberNames (all) method are as follows:

• lastBulkEnd—The last subscriber name from the last bulk. Use NULL to start with the first (alphabetic) subscriber.

• numOfSubscribers—The limit on the number of subscribers that is returned. If this value is higher than the Subscriber Manager limit (1000), the operation uses the Subscriber Manager limit.

Note Do not provide a value of more than 500 subscribers.

Return Value

An array of subscriber names, alphabetically ordered.

The getSubscriberNames (all) method returns as many subscribers as are found in the Subscriber Manager database, starting at the requested subscriber. The array size is limited by the smaller of these values—numOfSubscribers or the Subscriber Manager limit (1000).

3-26Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 59: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API getSubscriberNames (filter by property)

RPC Exception Error Codes

The following list presents error codes that the getSubscriberNames (all) method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

Example

The following example code returns an array of subscriber names:

boolean hasMoreSubscribers;String lastBulkEnd = null;int bulkSize = 100;

do { String[] subscribers = smApi.getSubscriberNames(lastBulkEnd, bulkSize);

hasMoreSubscribers = false; if (subscribers != null) { for (int i = 0; i < subscribers.length; i++) { // do something with subscribers[i] } if (subscribers.length == bulkSize) { hasMoreSubscribers = true; lastBulkEnd = subscribers[bulkSize - 1]; } }} while (hasMoreSubscribers);

getSubscriberNames (filter by property)The following sections provide information about the getSubscriberNames (filter by property) operation:

• Syntax, page 3-27

• Description, page 3-28

• Parameters, page 3-28

• Return Value, page 3-28

• RPC Exception Error Codes, page 3-28

Syntax

The getSubscriberNames (filter by property) method syntax is as follows:

public String[] getSubscriberNames(String lastBulkEnd,String propertyName,String propertyValue,int numOfSubscribers)throws InterruptedException, OperationTimeoutException, RpcErrorException

3-27Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 60: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API getSubscriberNamesInDomain

Description

The getSubscriberNames (filter by property) method retrieves a bulk of subscriber names from the Subscriber Manager database, starting with lastBulkEnd followed by numOfSubscribers (in alphabetical order), and based on the property name and property value.

If lastBulkEnd is NULL, the first subscriber name (alphabetically) that exists in the Subscriber Manager database is retrieved.

Note There is no guarantee that the total number of subscribers (in all the bulks) will equal the value returned from getNumOfSubscribers at any time. The values might differ if some subscribers are added or removed when the bulks are being retrieved.

Parameters

The parameters of the getSubscriberNames (filter by property) method are as follows:

• lastBulkEnd—The last subscriber name from the last bulk. Use NULL to start with the first (alphabetic) subscriber.

• propertyName—The property name of the string type used to filter subscriber names.

• propertyValue—The property value of the string type used to filter subscriber names.

• numOfSubscribers—The limit on the number of subscribers that is returned. If this value is higher than the Subscriber Manager limit (1000), the operation uses the Subscriber Manager limit.

Note Do not provide a value of more than 500 subscribers.

Return Value

An array of alphabetically ordered subscriber names that matches the property name and its given value. The method returns as many subscribers as are found in the Subscriber Manager database, starting at the requested subscriber. The array size is limited by the smaller of these values—numOfSubscribers or the Subscriber Manager limit (1000).

RPC Exception Error Codes

The following list presents error codes that the getSubscriberNames (filter by property) method might return:

• ERROR_CODE_DATABASE_EXCEPTION

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

For a description of error codes, see Appendix A, “List of Error Codes”.

getSubscriberNamesInDomainThe following sections provide information about the getSubscriberNamesInDomain operation:

• Syntax, page 3-29

3-28Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 61: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API getSubscriberNamesWithPrefix

• Description, page 3-29

• Parameters, page 3-29

• Return Value, page 3-29

• RPC Exception Error Codes, page 3-29

Syntax

The getSubscriberNamesInDomain syntax is as follows:

public String[] getSubscriberNamesInDomain(String lastBulkEnd, int numOfSubscribers, String domain)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriberNamesInDomain method retrieves subscribers in the Subscriber Manager database that are associated with the specified domain.

The semantics of this operation are the same as that of the getSubscriberNames operation described in the “getSubscriberNames (all)” section on page 3-26.

Parameters

The parameters of the getSubscriberNamesInDomain method are as follows:

• lastBulkEnd—See the description in the “Parameters” section on page 3-26.

• numOfSubscribers—See description in the “Parameters” section on page 3-26.

• domain—The name of a subscriber domain that exists in the Subscriber Manager domain repository.

Return Value

An alphabetically ordered array of subscriber names that belong to the domain provided.

See the “Return Value” section on page 3-26 (the getSubscriberNames (all) operation).

RPC Exception Error Codes

The following list presents the error codes that the getSubscriberNamesInDomain method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _DOMAIN_NOT_FOUND

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

getSubscriberNamesWithPrefixThe following sections provide information about the getSubscriberNamesWithPrefix operation:

• Syntax, page 3-30

3-29Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 62: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API getSubscriberNamesWithSuffix

• Description, page 3-30

• Parameters, page 3-30

• Return Value, page 3-30

• RPC Exception Error Codes, page 3-30

Syntax

The getSubscriberNamesWithPrefix syntax is as follows:

public String[] getSubscriberNamesWithPrefix(String lastBulkEnd, int numOfSubscribers, String prefix)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriberNamesWithPrefix method retrieves subscribers in the Subscriber Manager database whose name begins with a specified prefix.

The semantics of this operation are the same as that of the getSubscriberNames operation described in the “getSubscriberNames (all)” section on page 3-26.

Parameters

The parameters of the getSubscriberNamesWithPrefix method are as follows:

• lastBulkEnd—See the description in the “Parameters” section on page 3-26.

• numOfSubscribers—See the description in the “Parameters” section on page 3-26.

• prefix—Case-sensitive string that marks the prefix of the required subscriber names.

Return Value

An alphabetically ordered array of subscriber names that begin with the required prefix.

See, the “Return Value” section on page 3-26.

RPC Exception Error Codes

The following list presents error codes that the getSubscriberNamesWithPrefix method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

getSubscriberNamesWithSuffixThe following sections provide information about the getSubscriberNamesWithSuffix operation:

• Syntax, page 3-31

• Description, page 3-31

3-30Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 63: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API getDomains

• Parameters, page 3-31

• Return Value, page 3-31

• RPC Exception Error Codes, page 3-31

Syntax

The getSubscriberNamesWithSuffix syntax is as follows:

public String[] getSubscriberNamesWithSuffix(String lastBulkEnd, int numOfSubscribers, String suffix)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriberNamesWithSuffix method retrieves subscribers in the Subscriber Manager database whose names end with the specified suffix.

The semantics of this operation are the same as that of the getSubscriberNames (all) operation described in the “getSubscriberNames (all)” section on page 3-26.

Parameters

The parameters of the getSubscriberNamesWithSuffix method are as follows:

• lastBulkEnd—See the description in the “Parameters” section on page 3-26.

• numOfSubscribers—See the description in the “Parameters” section on page 3-26.

• suffix—Case-sensitive string that represents the suffix of the required subscriber names.

Return Value

An alphabetically ordered array of subscriber names that end with the required suffix.

See, the “Return Value” section on page 3-26 (the getSubscriberNames (all) operation).

RPC Exception Error Codes

The following list presents error codes that the getSubscriberNamesWithSuffix method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

getDomainsThe following sections provide information about the getDomains operation:

• Syntax, page 3-32

• Description, page 3-32

• Return Value, page 3-32

3-31Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 64: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API setPropertiesToDefault

• RPC Exception Error Codes, page 3-32

Syntax

The getDomains syntax is as follows:

public String[] getDomains() throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getDomains method provides the list of current subscriber domains in the Subscriber Manager domain repository.

Return Value

A complete list of subscriber domain names in the Subscriber Manager.

RPC Exception Error Codes

None.

setPropertiesToDefaultThe following sections provide information about the setPropertiesToDefault operation:

• Syntax, page 3-32

• Description, page 3-32

• Parameters, page 3-33

• Return Value, page 3-33

• RPC Exception Error Codes, page 3-33

Syntax

The setPropertiesToDefault syntax is as follows:

public void setPropertiesToDefault(String subscriberName, String[] properties)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The setPropertiesToDefault method resets the specified application properties of a subscriber. If an application is installed, the relevant application properties are set to the default values of the properties according to the currently loaded application information. If an application is not installed, the operation returns java.lang.IllegalStateException.

3-32Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 65: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API removeCustomProperties

Parameters

The parameters of the setPropertiesToDefault method are as follows:

• subscriberName—See the description of subscriber name formatting in the “Subscriber Name Format” section on page 2-5.

• properties—See the description of property keys and values in the “Subscriber Properties” section on page 2-8.

Return Value

None.

RPC Exception Error Codes

The following list presents error codes that the setPropertiesToDefault method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _BAD_SUBSCRIBER_MAPPING

• ERROR_CODE_DOMAIN_NOT_FOUND

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

removeCustomPropertiesThe following sections provide information about the removeCustomProperties operation:

• Syntax, page 3-33

• Description, page 3-33

• Parameters, page 3-34

• Return Value, page 3-34

• RPC Exception Error Codes, page 3-34

Syntax

The removeCustomProperties syntax is as follows:

public void removeCustomProperties(String subscriberName, String[] customProperties)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The removeCustomProperties method resets the specified custom properties of a subscriber.

3-33Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 66: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API removeCustomProperties

Parameters

The parameters of the removeCustomProperties method are as follows:

• subscriberName—See the description of subscriber name formatting in the “Subscriber Name Format” section on page 2-5.

• CustomProperties—See the description of custom property keys and values in the “Custom Properties” section on page 2-9.

Return Value

None.

RPC Exception Error Codes

The following list presents error codes that the removeCustomProperties method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

3-34Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 67: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API Quota Manager Blocking API Methods

Quota Manager Blocking API MethodsThis section lists the methods of the Quota Manager (QM) Blocking API. The description of each method includes the syntax, input parameters, and return values.

• Use the following methods for static or manual subscriber quota configuration:

– addSubscriberQuota, page 3-35

– setSubscriberQuota, page 3-36

– replenishSubscriberQuota, page 3-37

• Use the following methods for basic read-only operations:

– getSubscriberQuotaInformation, page 3-38

– getSubscriberQuotaProfileId, page 3-39

– getBreachedSubscriberNames, page 3-40

– getPenaltySubscriberNames, page 3-41

addSubscriberQuotaThe following sections provide information about the addSubscriberQuota operation:

• Syntax, page 3-35

• Description, page 3-35

• Parameters, page 3-35

• RPC Exception Error Codes, page 3-36

Syntax

The addSubscriberQuota syntax is as follows:

public void addSubscriberQuota(String subscriberName,int bucketId,long bucketSize)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The addSubscriberQuota method adds the quota for the given bucket ID of a subscriber.

Parameters

The parameters of the addSubscriberQuota method are as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

• bucketId—An integer value for the bucket ID to add.

• bucketSize—A long value for the bucket size to add.

3-35Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 68: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API setSubscriberQuota

RPC Exception Error Codes

The following list presents error codes that the addSubscriberQuota method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _DATABASE_EXCEPTION

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_NO_QUOTA_INFO_FOR_SUBSCRIBER

• ERROR_CODE_INVALID_BUCKETID

• ERROR_CODE_INVALID_BUCKETSIZE

setSubscriberQuotaThe following sections provide information about the setSubscriberQuota operation:

• Syntax, page 3-36

• Description, page 3-36

• Parameters, page 3-36

• RPC Exception Error Codes, page 3-37

Syntax

The setSubscriberQuota syntax is as follows:

public void setSubscriberQuota(String subscriberName,int bucketId,long bucketSize)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The setSubscriberQuota method updates the quota for the given bucket ID of a subscriber.

Parameters

The parameters of the setSubscriberQuota method are as follows:

• subscriberName—See the description for the subscriber name format in the “Subscriber Name Format” section on page 2-5.

• bucketId—An integer value of the bucket ID to update.

• bucketSize—A long value of the bucket size to update.

3-36Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 69: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API replenishSubscriberQuota

RPC Exception Error Codes

The following list presents error codes that the setSubscriberQuota method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _DATABASE_EXCEPTION

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_NO_QUOTA_INFO_FOR_SUBSCRIBER

• ERROR_CODE_INVALID_BUCKETID

• ERROR_CODE_INVALID_BUCKETSIZE

replenishSubscriberQuotaThe following sections provide information about the replenishSubscriberQuota operation:

• Syntax, page 3-37

• Description, page 3-37

• Parameters, page 3-37

• RPC Exception Error Codes, page 3-37

Syntax

The replenishSubscriberQuota syntax is as follows:

public void replenishSubscriberQuota(String subscriberName)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The replenishSubscriberQuota method replenishes the quota for the given subscriber.

Parameters

The only parameter of the replenishSubscriberQuota method is as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

RPC Exception Error Codes

The following list presents error codes that the replenishSubscriberQuota method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _DATABASE_EXCEPTION

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_NO_QUOTA_INFO_FOR_SUBSCRIBER

• ERROR_REPLENISH_FAILED

3-37Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 70: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API getSubscriberQuotaInformation

getSubscriberQuotaInformationThe following sections provide information about the getSubscriberQuotaInformation operation:

• Syntax, page 3-38

• Description, page 3-38

• Parameters, page 3-38

• Return Value, page 3-38

• RPC Exception Error Codes, page 3-39

Syntax

The getSubscriberQuotaInformation syntax is as follows:

public Object[] getSubscriberQuotaInformation(String subscriberName)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriberQuotaInformation method gets a bulk of quota information for a specified subscriber.

Parameters

The only parameter of the getSubscriberQuotaInformation method is as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

Return Value

An object array with five elements. Table 3-2 lists the index values and descriptions. None of the array elements have a NULL value.

Table 3-2 Indexes and Descriptions

Index Value Description

Index 0 Package ID (java.lang.String)

Index 1 Last replenish time (java.lang.String)

Index 2 Last SCE that consumed quota (java.lang.String)

3-38Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 71: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API getSubscriberQuotaProfileId

RPC Exception Error Codes

The following list presents error codes that the getSubscriberQuotaInformation method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _DATABASE_EXCEPTION

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_NO_QUOTA_INFO_FOR_SUBSCRIBER

getSubscriberQuotaProfileIdThe following sections provide information about the getSubscriberQuotaProfileId operation:

• Syntax, page 3-39

• Description, page 3-40

• Parameters, page 3-40

• Return Value, page 3-40

• RPC Exception Error Codes, page 3-40

Syntax

The getSubscriberQuotaProfileId syntax is as follows:

public int getSubscriberQuotaProfileId(String subscriberName)throws InterruptedException, OperationTimeoutException, RpcErrorException

Index 3 Aggregation period end (java.lang.String)

Index 4 Quota buckets (java.lang.Object[][])

Bucket 1:

[0][0]=500 (quota size)

[0][1]=500 (remaining quota)

[0][2]=50 (last quota reported by SCE)

[0][3]=time not set (penalty start)

[0][4]=time not set (next penalty monitor)

Bucket 2:

[1][0]=500 (quota size)

[1][1]=500 (remaining quota)

[1][2]=50 (last quota reported by SCE)

[1][3]=time not set (penalty start)

[1][4]=time not set (next penalty monitor)

Table 3-2 Indexes and Descriptions (continued)

Index Value Description

3-39Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 72: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API getBreachedSubscriberNames

Description

The getSubscriberQuotaProfileId method returns the quota profile ID for the specified subscriber.

Parameters

The only parameter of the getSubscriberQuotaProfileId method is as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

Return Value

Quota profile ID.

RPC Exception Error Codes

The following list presents error codes that the getSubscriberQuotaProfileId method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _DATABASE_EXCEPTION

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_SUBSCRIBER_NOT_ASSIGNED_PROFILE

getBreachedSubscriberNamesThe following sections provide information about the getBreachedSubscriberNames operation:

• Syntax, page 3-40

• Description, page 3-40

• Parameters, page 3-41

• Return Value, page 3-41

• RPC Exception Error Codes, page 3-41

Syntax

The getBreachedSubscriberNames syntax is as follows:

public String[] getBreachedSubscriberNames(String lastBulkEnd,int numOfSubscribers)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getBreachedSubscriberNames method retrieves the breached subscriber names.

3-40Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 73: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API getPenaltySubscriberNames

Parameters

The parameters of the getBreachedSubscriberNames method are as follows:

• lastBulkEnd—The last subscriber name from the last bulk. Use NULL to start with the first (alphabetic) subscriber.

• numOfSubscribers—The limit on the number of subscribers that will be returned. If this value is higher than the Subscriber Manager limit (1000), the operation uses the Subscriber Manager limit.

Return Value

An array of alphabetically ordered subscriber names that belong to a breached state. This method returns all the subscribers found in the Subscriber Manager database starting with the requested subscriber. The array size is limited by the smaller of these values—numOfSubscribers or the Subscriber Manager limit (1000).

RPC Exception Error Codes

The getBreachedSubscriberNames method might return the ERROR_CODE _DATABASE_EXCEPTION error code.

getPenaltySubscriberNamesThe following sections provide information about the getPenaltySubscriberNames operation:

• Syntax, page 3-41

• Description, page 3-41

• Parameters, page 3-41

• Return Value, page 3-42

• RPC Exception Error Codes, page 3-42

Syntax

The getPenaltySubscriberNames syntax is as follows:

public String[] getPenaltySubscriberNames(String lastBulkEnd,int numOfSubscribers)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getPenaltySubscriberNames method retrieves the subscriber names in a penalty state.

Parameters

The parameters of the getPenaltySubscriberNames method are as follows:

• lastBulkEnd—The last subscriber name from the last bulk. Use NULL to start with the first (alphabetic) subscriber.

3-41Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 74: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API getPenaltySubscriberNames

• numOfSubscribers—The limit on the number of subscribers that will be returned. If this value is higher than the Subscriber Manager limit (1000), the operation uses the Subscriber Manager limit.

Return Value

An array of alphabetically ordered subscriber names that belong to a penalty state. This method returns all the subscribers found in the Subscriber Manager database starting with the requested subscriber. The array size is limited by the smaller of these values—numOfSubscribers or the Subscriber Manager limit (1000).

RPC Exception Error Codes

The getPenaltySubscriberNames method might return the ERROR_CODE _DATABASE_EXCEPTION error code.

3-42Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 75: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API Blocking API Code Examples

Blocking API Code ExamplesThis section includes the following code examples:

• Getting Number of Subscribers, page 3-43

• Adding a Subscriber, Printing Information, and Removing a Subscriber, page 3-44

• Getting Subscriber Quota Information, page 3-45

Getting Number of Subscribers The following example prints to stdout the total number of subscribers in the Subscriber Manager database and the number of subscribers in each subscriber domain:

package blocking;

import com.pcube.management.api.SMBlockingApi;

public class PrintInfo { public static void main (String args[]) throws Exception { SMBlockingApi bapi = new SMBlockingApi(); try { //initiation bapi.setReplyTimeout(300000); //set timeout for 5 minutes bapi.connect(args[0]); // connect to the SM

//operations String[] domains=bapi.getDomains(); int totalSubscribers=bapi.getNumberOfSubscribers(); System.out.println( "number of susbcribers in the database:\t\t "+ totalSubscribers); for (int i=0; i<domains.length; i++) { int numberOfSusbcribersInDomain= bapi.getNumberOfSubscribersInDomain(domains[i]); System.out.println( "number of susbcribers domain "+domains[i]+ ":\t\t "+numberOfSusbcribersInDomain); } } finally { //finalization bapi.disconnect(); } }}

3-43Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 76: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API Adding a Subscriber, Printing Information, and Removing a Subscriber

Adding a Subscriber, Printing Information, and Removing a Subscriber The following program adds a subscriber to the subscriber database. It then gets its information and prints it to stdout. Finally, the program removes the subscriber from the subscriber database:

package blocking;

import com.pcube.management.api.SMBlockingApi;import com.pcube.management.api.SMApiConstants;

public class AddPrintRemove { public static void main (String args[]) throws Exception { checkArguments(args); SMBlockingApi bapi = new SMBlockingApi(); try { //initiation bapi.setReplyTimeout(10000); //set timeout for 10 seconds bapi.connect(args[0]); // connect to the SM //add subscriber System.out.println("+ adding subscriber to SM"); bapi.addSubscriber( args[1], //name new String[]{args[2]}, //mapping SMApiConstants.ALL_IP_MAPPINGS, new String[]{args[3]}, //property key new String[]{args[4]}, //property value new String[]{"custom-key"}, //custom property key new String[]{"10"}, //custom property value args[5]); //domain //Print subscriber System.out.println("+ Printing subscriber"); Object[] subfields = bapi.getSubscriber(args[1]); System.out.println("\tname:\t\t"+subfields[0]); System.out.println("\tmapping:\t"+ ((String[])subfields[1])[0]); System.out.println("\tdomain:\t\t"+subfields[3]); System.out.println("\tautologout:\t"+subfields[8]); //Remove subscriber System.out.println("+ removing subscriber from SM"); bapi.removeSubscriber(args[1]); } finally { //finalization bapi.disconnect(); } }

static void checkArguments(String[] args) throws Exception{ if (args.length != 6) { System.err.println( "usage: java AddPrintRemove <SM-address>"+ " <subscriber-name> <IP mapping> <property-key>"+ " <property-value> <domain>"); System.exit(1); } }}

3-44Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 77: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API Getting Subscriber Quota Information

Getting Subscriber Quota InformationThe following example gets subscriber quota information, sets subscriber quota, and lists subscribers in the breached state:

package blocking;

import com.pcube.management.api.QuotaManagerApi;public class PrintQuotaInfo {

/** * @param args * @throws Exception */

public static void main(String[] args) throws Exception {QuotaManagerApi qmapi = new QuotaManagerApi();checkArguments(args);String smIP=args[0];//initiation

try{

qmapi .setReplyTimeout(300000); //set timeout for 5 minutesqmapi .connect(smIP); // connect to the SM

//operations//getSubscriberQuotaInformationObject []subQuotaInfo = qmapi.getSubscriberQuotaInformation(args[1]);

for(int i=0;i<subQuotaInfo.length;i++){ System.out.println(subQuotaInfo[i]); } //getSubscriberQuotaProfileId int profileID = qmapi.getSubscriberQuotaProfileId(args[1]);

System.out.println(profileID); //addSubscriberQuota qmapi.addSubscriberQuota(args[1], 1,300); subQuotaInfo = qmapi.getSubscriberQuotaInformation(args[1]); for(int i=0;i<subQuotaInfo.length;i++){ System.out.println(subQuotaInfo[i]); } //setSubscriberQuota qmapi.setSubscriberQuota(args[1], 1,300); subQuotaInfo = qmapi.getSubscriberQuotaInformation(args[1]); for(int i=0;i<subQuotaInfo.length;i++){ System.out.println(subQuotaInfo[i]); } //getBreachedSubscriberNames String []breachSubsNames=qmapi.getBreachedSubscriberNames(null, 10); for(int i=0;i<breachSubsNames.length;i++){ System.out.println(breachSubsNames[i]); }

}finally{//finaliztionqmapi.disconnect();

}}static void checkArguments(String[] args) throws Exception{

if (args.length != 2) {System.err.println("usage: java PrintQuotaInfo <SM-address> <subscriber-name> ");System.exit(1);}

}}

3-45Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 78: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 3 Blocking API Getting Subscriber Quota Information

3-46Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 79: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

OL-24191-02

C H A P T E R 4

Nonblocking API

Revised: September 20, 2011, OL-24191-02

IntroductionThis chapter introduces features unique to the Nonblocking API. It presents all Nonblocking API methods and provides code examples for each method.

This chapter consists of the following sections:

• Reliability Support, page 4-2

• Autoreconnect Support, page 4-3

• Multithreading Support, page 4-3

• ResultHandler Interface, page 4-4

• Nonblocking API Construction, page 4-6

• Nonblocking API Initialization, page 4-8

• Nonblocking API Methods, page 4-9

• Nonblocking API Code Examples, page 4-12

4-1Cisco SCMS SM Java API Programmer Guide

Page 80: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 4 Nonblocking API Reliability Support

Reliability SupportThe Nonblocking API can work in two different modes—reliable and nonreliable. When the mode is not specified, the default is reliable mode.

• Reliable Mode, page 4-2

• Nonreliable Mode, page 4-2

Reliable ModeIn reliable mode, the API ensures that no requests to the Subscriber Manager are lost. The API maintains an internal storage for all API requests that are sent to the Subscriber Manager. After a reply from the Subscriber Manager is received, the request is considered committed and the API can remove the request from its internal storage. If the connection between the API and the Subscriber Manager fails, the API accumulates all requests in its internal storage until the connection to the Subscriber Manager is established. On reconnection, the API resends all noncommitted and committed requests to the Subscriber Manager, so that no requests are lost.

Note In reliable mode, the order of resending requests is guaranteed. The API resends the requests in the order in which they were called.

Nonreliable ModeIn nonreliable mode, the API does not ensure that requests sent to the Subscriber Manager are executed. In addition, all requests that are sent by the API when the connection to the Subscriber Manager is down are lost unless an external reliability mechanism is implemented.

4-2Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 81: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 4 Nonblocking API Autoreconnect Support

Autoreconnect SupportThe Nonblocking API supports autoreconnection to the Subscriber Manager to address connection failures. When this option is activated, the API can determine when the connection to the Subscriber Manager is lost. When the connection is lost, the API activates a reconnection task that tries to reconnect to the Subscriber Manager until it is successful.

Note The autoreconnect support option can be activated in both reliability modes.

Multithreading SupportThe Nonblocking API supports an unlimited number of threads calling its methods simultaneously.

Note In a multithreaded scenario for the Nonblocking API, the order of invocation is guaranteed. The API performs operations in the same order in which they were called.

4-3Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 82: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 4 Nonblocking API ResultHandler Interface

ResultHandler InterfaceThe Nonblocking API enables you to set a result handler. A result handler is an interface with two methods, handleSuccess and handleError, as represented in the following code:

public interface ResultHandler { /** * handle a successful result */ public void handleSuccess(long handle, Object result);

/** * handle a failure result */ public void handleError(long handle, Object result);}

You should implement this interface if you want to be informed about the success or error results of operations performed through the API.

Note This is the only interface for retrieving results. Results cannot be returned immediately after the API method has returned to the caller.

Note To receive operation results, set the result handler of the API before calling API methods for which you want to receive results. Set the result handler after the API is connected (as in the “ResultHandler Interface Example” section on page 4-4).

Both handleSuccess and handleError methods accept two parameters:

• Handle—Each API operation return-value is a handle of type long. This handle enables correlation between operation calls and their results. When a handle operation is called with a handle of value X, the result will match the operation that returned the same handle value (X) to the caller.

• Result—Actual result of the operation. Some operations may return a result of NULL.

ResultHandler Interface ExampleThe following example is a simple implementation of a result handler that prints a message to stdout (when the result is successful) or to stderr (when the result is a failure). This main method initiates the API and assigns a result handler.

For correct operation of the result handler, follow the code sequence presented in this example.

4-4Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 83: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 4 Nonblocking API ResultHandler Interface Example

Note This example does not demonstrate the use of callback handles.

import com.pcube.management.framework.rpc.ResultHandler;import com.pcube.management.api.SMNonBlockingApi;

public class ResultHandlerExample implements ResultHandler{

public void handleSuccess(long handle, Object result) { System.out.println("success: handle="+handle+", result="+result); }

public void handleError(long handle, Object result) { System.err.println("error: handle="+handle+", result="+result); }

public static void main (String args[]) throws Exception{ if (args.length != 1) { System.err.println("usage: ResultHandlerExample <sm-ip>"); System.exit(1); }

//note the order of operations! SMNonBlockingApi nbapi = new SMNonBlockingApi(); nbapi.connect(args[0]); nbapi.setResultHandler(new ResultHandlerExample()); nbapi.login(...); }}

4-5Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 84: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 4 Nonblocking API Nonblocking API Construction

Nonblocking API ConstructionIn addition to the constructors described in the “API Construction” section on page 2-3, the Nonblocking API provides constructors that enable you to set the reconnect period and the reliability mode.

Nonblocking API SyntaxThe syntax for the additional Nonblocking API constructors is as follows:

public SMNonBlockingApi(long autoReconnectInterval)public SMNonBlockingApi(boolean reliable, long autoReconnectInterval)public SMNonBlockingApi(String legName, long autoReconnectInterval)public SMNonBlockingApi(String legName, boolean reliable, long autoReconnectInterval)

Nonblocking API ArgumentsThe following list describes the constructor arguments for the additional Nonblocking API constructors:

• autoReconnectInterval—Defines the interval (in milliseconds) between attempts to reconnect, as follows:

– If the value is 0 or less, the reconnection task is not activated (no autoreconnect is attempted).

– If the value is greater than 0 and if there is a connection failure, the reconnection task is activated every autoReconnectInterval milliseconds.

Default value is –1 (no autoreconnect is attempted).

Note To enable the autoreconnect support, the connect method of the API must be activated at least once. For more information, see the “Nonblocking API Code Examples” section on page 4-12.

• reliable—An argument that defines whether the API should work in reliable mode, as follows:

– TRUE—The API works in reliable mode.

– FALSE—The API works in nonreliable mode.

Default value is TRUE (the API works in reliable mode).

• legName—The name of the LEG, as described in the “API Construction” section on page 2-3.

Nonblocking API ExamplesThe following example constructs a reliable API with an autoreconnection interval of 10 seconds:

SMNonBlockingAPI nbapi = SMNonBlockingAPI(10000); nbapi.connect(<SM IP address>);

4-6Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 85: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 4 Nonblocking API Nonblocking API Examples

The following example constructs a reliable API without autoreconnection support:

// API construction SMNonBlockingAPI nbapi = SMNonBlockingAPI(); // Connect to the API nbapi.connect(<SM IP address>);

The following example constructs a nonreliable API with autoreconnection support:

// API construction SMNonBlockingAPI nbapi = SMNonBlockingAPI(false,10000); // Initial connection - to enable the reconnect task nbapi.connect(<SM IP address>);

4-7Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 86: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 4 Nonblocking API Nonblocking API Initialization

Nonblocking API InitializationThe Nonblocking API enables you to initialize certain internal properties to customize the API. This initialization is performed by using the API init method.

Note For the settings to take effect, the init method must be called before the connect method.

You can set the following properties:

• Output queue size—The internal buffer size that limits the maximum number of requests that can be accumulated by the API until they are sent to the Subscriber Manager. The default is 1024.

• Operation timeout—The desired timeout (in milliseconds) on a nonresponding proprietary remote procedure call (PRPC) protocol connection. The default is 45 seconds.

Nonblocking API Initialization SyntaxThe syntax for the Nonblocking API init method is as follows:

public void init(Properties properties)

Nonblocking API Initialization ParametersThe Nonblocking API init method has the following parameters:

• properties (java.util.Properties)—Enables setting the following properties described previously:

– To set the output queue size, use prpc.client.output.machinemode.recordnum.

– To set the operation timeout, use prpc.client.operation.timeout.

Nonblocking API Initialization ExampleThe following Nonblocking API code illustrates how to customize properties during initialization. Note that the init method is called before the connect method.

// API construction SMNonBlockingAPI nbapi = SMNonBlockingAPI(10000); // API initialization java.util.Properties p = new java.util.Properties(); p.setProperty("prpc.client.output.machinemode.recordnum", 2048); p.setProperty("prpc.client.operation.timeout", 60000);// 1 minute nbapi.init(p); // initial connect to the API to enable the reconnect task nbapi.connect(<SM API address>);

4-8Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 87: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 4 Nonblocking API Nonblocking API Methods

Nonblocking API MethodsThis section describes the methods of the Nonblocking API.

All methods return a handle of type long that can be used to correlate operation calls and their results. See the “ResultHandler Interface” section on page 4-4.

The operation results passed to the result handler are similar to the return values described in the same method in the Chapter 3, “Blocking API”, except for the following:

• Basic types are converted to their Java class representation. For example, int is translated to java.lang.Integer.

• Return values of Void are translated to NULL.

Note An error is passed to the result handler only if the matching operation in the Blocking API generates an exception with the same arguments that correspond to the state of the Subscriber Manager database at the time of the call.

All methods will generate java.lang.IllegalStateException if called before a connection with the Subscriber Manager is established.

This section describes the following methods:

• login, page 4-9

• logoutByName, page 4-10

• logoutByNameFromDomain, page 4-10

• logoutByMapping, page 4-10

• loginCable, page 4-10

• logoutCable, page 4-11

loginThis section provides the syntax for the login operation.

Syntax

The login syntax is as follows:

public long login(String subscriberName, String[] mappings, short[] mappingTypes, String[] propertyKeys, String[] propertyValues, String domain, boolean isMappingAdditive, int autoLogoutTime)

The operation functionality is the same as the matching Blocking API operation. See the “login” section on page 3-5 for more information.

4-9Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 88: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 4 Nonblocking API logoutByName

logoutByNameThis section provides the syntax for the logoutByName operation.

Syntax

The logoutByName syntax is as follows:

public long logoutByName(String subscriberName, String[] mappings, short[] mappingTypes)

The operation functionality is the same as the matching Blocking API operation. See the “logoutByName” section on page 3-7 for more information.

logoutByNameFromDomainThis section provides the syntax for the logoutByNameFromDomain operation.

Syntax

The logoutByNameFromDomain syntax is as follows:

public long logoutByNameFromDomain(String subscriberName, String[] mappings, short[] mappingTypes, String domain)

The operation functionality is the same as the matching Blocking API operation. See the “logoutByNameFromDomain” section on page 3-10 for more information.

logoutByMappingThis section provides the syntax for logoutByMapping operation.

Syntax

The logoutByMapping syntax is as follows:

public long logoutByMapping(String mapping, short mappingType, String domain)

The operation functionality is the same as the matching Blocking API operation. See the “logoutByMapping” section on page 3-11 for more information.

loginCableThis section provides the syntax for the loginCable operation.

4-10Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 89: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 4 Nonblocking API logoutCable

Syntax

The loginCable syntax is as follows:

public long loginCable(String CPE, String CM, String IP, int lease, String domain, String[] propertyKeys, String[] propertyValues)

The operation functionality is the same as the matching Blocking API operation. See the “loginCable” section on page 3-13 for more information.

logoutCableThis section provides the syntax for the logoutCable operation.

Syntax

The logoutCable syntax is as follows:

public long logoutCable(String CPE, String CM, String IP, String domain)

The operation functionality is the same as the matching Blocking API operation. See the “logoutCable” section on page 3-15 for more information.

4-11Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 90: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 4 Nonblocking API Nonblocking API Code Examples

Nonblocking API Code ExamplesThis section presents example code for logging in and logging out subscribers.

Login and LogoutThe following example logs in a predefined number of subscribers to the Subscriber Manager and then logs them out. Note the implementation of a disconnect listener and a result handler.

package nonblocking;

import com.pcube.management.framework.rpc.DisconnectListener;import com.pcube.management.framework.rpc.ResultHandler;import com.pcube.management.api.SMNonBlockingApi;import com.pcube.management.api.SMApiConstants;

class LoginLogoutDisconnectListener implements DisconnectListener { public void connectionIsDown() { System.err.println("disconnect listener:: connection is down"); }}

class LoginLogoutResultHandler implements ResultHandler { int count = 0; //prints a success result every 100 results public synchronized void handleSuccess(long handle, Object result) { Object tmp = null; if (++count%100 == 0) { tmp = result instanceof Object[] ? ((Object[])result)[0] : result; System.out.println("\tresult "+count+":\t"+tmp); } }

//prints every error that occurs public synchronized void handleError(long handle, Object result) { System.err.println("\terror: "+count+":\t"+ result); ++count; } //waits for result number 'last result' to arrive public synchronized void waitForLastResult(int lastResult) { while (count<lastResult) { try { wait(100); } catch (InterruptedException ie) { ie.printStackTrace(); } } }}

public class LoginLogout { public static void main (String args[]) throws Exception{ //check arguments checkArguments(args); int numSubscribersToLogin = Integer.parseInt(args[2]);

//instantiation SMNonBlockingApi nbapi = new SMNonBlockingApi();

4-12Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 91: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 4 Nonblocking API Login and Logout

try { //initation nbapi.setDisconnectListener( new LoginLogoutDisconnectListener()); nbapi.connect(args[0]); LoginLogoutResultHandler resultHandler = new LoginLogoutResultHandler(); nbapi.setResultHandler(resultHandler); //login System.out.println("login of "+numSubscribersToLogin +" subscribers"); for (int i=0; i<numSubscribersToLogin; i++) { nbapi.login("subscriber"+i, //subscriber name getMappings(i), //a single ip mapping new short[]{ SMApiConstants.MAPPING_TYPE_IP }, null, //no properties null, args[1], //domain false, //mappings are not additive -1); //disable autologout } resultHandler.waitForLastResult(numSubscribersToLogin); //logout System.out.println("logout of "+numSubscribersToLogin +" subscribers"); for (int i=0; i<numSubscribersToLogin; i++) { nbapi.logoutByMapping(getMappings(i)[0], SMApiConstants.MAPPING_TYPE_IP, args[1]); } resultHandler.waitForLastResult(numSubscribersToLogin*2); } finally { nbapi.disconnect(); } } static void checkArguments(String[] args) throws Exception{ if (args.length != 3) { System.err.println("usage: java LoginLogout "+ "<SM-address> <domain> <num-susbcribers>"); System.exit(1); } } //'automatic' mapping generator private static String[] getMappings(int i) { return new String[]{ "10." +((int)i/65536)%256 + "." + ((int)(i/256))%256 + "." + (i%256)}; }}

4-13Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 92: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Chapter 4 Nonblocking API Login and Logout

4-14Cisco SCMS SM Java API Programmer Guide

OL-24191-02

Page 93: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

COL-24191-02

A

P P E N D I X A List of Error Codes

Revised: September 20, 2011, OL-24191-02

IntroductionThis appendix provides a list of error codes that are used in the Java API.

List of Error CodesError codes interpret the actual error for which RpcErrorException was returned. Use the getErrorCode method to extract the error code.

The error code enumeration is given in the com.pcube.management.api.SMApiConstants interface. Table A-1 gives a list of the error codes and their descriptions.

Table A-1 List of Error Codes

Error Code Description

ERROR_CODE_ARRAY_ACCESS Internal Subscriber Manager error.

ERROR_CODE_ATTRIBUTE_NOT_FOUND Internal Subscriber Manager error.

ERROR_CODE_BAD_SUBSCRIBER_MAPPING A mapping was formatted badly or assigned to the subscriber illegally.

ERROR_CODE_CLASS_CAST Internal Subscriber Manager error.

ERROR_CODE_CLASS_NOT_FOUND Internal Subscriber Manager error.

ERROR_CODE_CLIENT_INTERNAL_ERROR Internal error.

ERROR_CODE_CLIENT_OUT_OF_THREADS Internal error.

ERROR_CODE_DATABASE_EXCEPTION Internal Subscriber Manager error—database error occurred during the operation.

ERROR_CODE_DOMAIN_NOT_FOUND The domain provided to the operation does not exist in the Subscriber Manager domain repository.

ERROR_CODE_ILLEGAL_ARGUMENT One of the arguments provided to the method is illegal.

A-1isco SCMS SM Java API Programmer Guide

Page 94: Cisco SCMS Subscriber Manager Java API Programmer Guide · Cisco SCMS SM Java API Programmer Guide OL-24191-02 API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings

Appendix A List of Error Codes List of Error Codes

ERROR_CODE_ILLEGAL_STATE Internal Subscriber Manager error.

ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME The subscriber name provided has more than 40 characters or has illegal characters.

ERROR_CODE_NOT_A_SUSBCRIBER_DOMAIN The domain provided to the operation exists in the Subscriber Manager domain repository but is not a subscriber domain.

ERROR_CODE_NULL_POINTER Internal Subscriber Manager error.

ERROR_CODE_NUMBER_FORMAT A VLAN mapping string provided to the API does not represent a decimal number.

ERROR_CODE_OBJECT_NOT_FOUND Internal Subscriber Manager error.

ERROR_CODE_OPERATION_NOT_FOUND Internal Subscriber Manager error.

ERROR_CODE_OUT_OF_MEMORY Internal Subscriber Manager error.

ERROR_CODE_RUNTIME Internal Subscriber Manager error.

ERROR_CODE_SE_ERROR Internal Subscriber Manager error. The Subscriber Manager could not perform the operation on the SCE device.

ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST The subscriber on which the operation is performed does not exist in the Subscriber Manager database.

ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION The subscriber exists in the Subscriber Manager database but is associated with a domain other than the one specified by the operation.

ERROR_CODE_SUBSCRIBER_MAPPING_CONGESTION The mappings provided for the subscriber by the operation already belong to another subscriber.

ERROR_CODE_SUSBSCRIBER_ALREADY_EXISTS The subscriber on which the operation was performed already exists in the Subscriber Manager database.

ERROR_CODE_NO_QUOTA_INFO_FOR_SUBSCRIBER No quota information for the subscriber exists in the Subscriber Manager database.

ERROR_CODE_INVALID_BUCKETID Invalid bucket ID.

ERROR_CODE_INVALID_BUCKETSIZE Invalid bucket size.

ERROR_REPLENISH_FAILED Quota replenish failed for the subscriber.

ERROR_CODE_SUBSCRIBER_NOT_ASSIGNED_PROFILE Subscriber is not assigned to any profile.

ERROR_CODE_UNKNOWN Internal Subscriber Manager or API error.

Table A-1 List of Error Codes (continued)

Error Code Description

A-2Cisco SCMS SM Java API Programmer Guide

OL-24191-02