Cisco Systems, Inc.

com.pcube.apps.engage
Class UpgradeApiUtils

java.lang.Object
  extended by com.pcube.apps.engage.UpgradeApiUtils

public abstract class UpgradeApiUtils
extends java.lang.Object

A utility class for the DPI MNG Interface

Author:
uron

Field Summary
static int HTTP_URL_FLAVOR_TYPE
          HTTP URL Flavor type
static int SERVICE_ELEMENT_INITIATING_SIDE_BOTH
          initiating side both
static int SERVICE_ELEMENT_INITIATING_SIDE_NETWORK
          initiating side network
static int SERVICE_ELEMENT_INITIATING_SIDE_SUBSCRIBER
          initiating side subscriber
 
Constructor Summary
UpgradeApiUtils()
           
 
Method Summary
static boolean addFlavor(Policy policy, java.lang.String name, int flavorType, int index, int replaceIndex, java.lang.String[] params)
          Create a flavor with an index.
static boolean addFlavor(Policy policy, java.lang.String name, int flavorType, int index, java.lang.String[] params)
          Create a flavor with an index.
static boolean addFlavor(Policy policy, java.lang.String name, int flavorType, java.lang.String[] params)
          Add flavor without giving a flavor index - the first available index will be given DPI programmers should use this function
static boolean addProtocol(Policy policy, java.lang.String name, int index)
           
static boolean addProtocolElement(Policy policy, java.lang.String protocolName, java.lang.String signatureName)
           
static boolean addService(Policy policy, java.lang.String name, int index, int replaceIndex)
          Adds a new service
static boolean addServiceElement(Policy policy, java.lang.String serviceName, java.lang.String protocolName, java.lang.String flavorName, java.lang.String zoneName, int initiatingSide)
          Add service element.
static boolean addSignature(Policy policy, java.lang.String name, int signatureId)
          Add signature.
static boolean addTcpPortBasedProtocolElement(Policy policy, java.lang.String protocolName, long port)
           
static boolean addTcpPortBasedProtocolElement(Policy policy, java.lang.String protocolName, long portMin, long portMax)
           
static boolean addTcpPortBasedProtocolElementIPV6(Policy policy, java.lang.String protocolName, long port)
           
static boolean addTcpPortBasedProtocolElementIPV6(Policy policy, java.lang.String protocolName, long portMin, long portMax)
           
static boolean addUdpPortBasedProtocolElement(Policy policy, java.lang.String protocolName, long port)
           
static boolean addUdpPortBasedProtocolElement(Policy policy, java.lang.String protocolName, long portMin, long portMax)
           
static boolean addUdpPortBasedProtocolElementIPV6(Policy policy, java.lang.String protocolName, long port)
           
static boolean addUdpPortBasedProtocolElementIPV6(Policy policy, java.lang.String protocolName, long portMin, long portMax)
           
static boolean addZone(Policy policy, java.lang.String name, int index, int replaceIndex)
          Add a new zone
static void clearErrorMessages()
          clear all error messages
static boolean doesSignatureExist(Policy policy, int index)
           
static boolean doesSignatureExist(Policy policy, java.lang.String name)
           
static boolean dpiExists()
          Check if the DPI MNG jar exists.
static java.lang.String getDpiUpgradeClassName()
          Get the upgrade class name
static java.lang.String[] getErrorMessages()
          get all error messages in an array (last error at the end of the array)
static int getFreeFlavorIndex(Policy policy)
          get the next free flavor index DPI programmers should use this function
static int getFreeZoneIndex(Policy policy)
          get the next free zone index DPI programmers should use this function
static java.lang.String getLastErrorMessage()
          get the last error message
static java.io.File getUpgradeDpiJarFile()
          get the upgrade jar file
static void removeUpgradeJarFile()
           
static boolean renameService(Policy policy, java.lang.String name, java.lang.String newName)
          Renaming service.
static boolean safeDeleteService(Policy policy, java.lang.String name)
          Removes a service.
static boolean safeDeleteSignature(Policy policy, int index)
          Deletes a signature by its index.
static boolean safeDeleteSignature(Policy policy, java.lang.String name)
          Deletes a signature by its name.
static boolean safeRenameSignature(Policy policy, java.lang.String name, java.lang.String newName)
          renames signature.
static boolean saveFile(java.io.File origin, java.io.File destination)
           
static boolean setServiceGlobalCounter(Policy policy, java.lang.String name, int index)
          set global counter to a service
static boolean setServiceParent(Policy policy, java.lang.String serviceName, java.lang.String parentServiceName)
           
static boolean setServiceSubscriberCounter(Policy policy, java.lang.String name, int index)
          set subscriber counter to a service
static boolean setTunable(com.pcube.management.framework.client.SessionObject session, java.lang.String tunableName, java.lang.Object value)
           
static boolean setUpgradeDpiJarFile(java.io.File upgradeJarFile)
          Set a file as the upgrade jar file - used by MNG and not by the PL
static boolean validateDpiJar()
          Validates the upgrade jar file - if it exists and if it contains the upgrade class
static void validateDpiJar(java.io.File upgradeFile)
          Check that a file is a valid jar file with the required upgrade class
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTTP_URL_FLAVOR_TYPE

public static final int HTTP_URL_FLAVOR_TYPE
HTTP URL Flavor type

See Also:
Constant Field Values

SERVICE_ELEMENT_INITIATING_SIDE_BOTH

public static final int SERVICE_ELEMENT_INITIATING_SIDE_BOTH
initiating side both

See Also:
Constant Field Values

SERVICE_ELEMENT_INITIATING_SIDE_NETWORK

public static final int SERVICE_ELEMENT_INITIATING_SIDE_NETWORK
initiating side network

See Also:
Constant Field Values

SERVICE_ELEMENT_INITIATING_SIDE_SUBSCRIBER

public static final int SERVICE_ELEMENT_INITIATING_SIDE_SUBSCRIBER
initiating side subscriber

See Also:
Constant Field Values
Constructor Detail

UpgradeApiUtils

public UpgradeApiUtils()
Method Detail

getFreeZoneIndex

public static int getFreeZoneIndex(Policy policy)
get the next free zone index DPI programmers should use this function

Parameters:
policy - - the policy to get the zone index
Returns:
int returns zone index

addFlavor

public static boolean addFlavor(Policy policy,
                                java.lang.String name,
                                int flavorType,
                                java.lang.String[] params)
                         throws java.lang.IndexOutOfBoundsException,
                                ApplyException,
                                DuplicateItemException,
                                java.lang.IllegalArgumentException
Add flavor without giving a flavor index - the first available index will be given DPI programmers should use this function

Parameters:
policy - - the policy to add the flavor to
name - - new flavor name
flavorType -
params - - the flavor item parameters
Returns:
Throws:
java.lang.IndexOutOfBoundsException - if all flavor indices are taken
ApplyException
DuplicateItemException - if there is such a flavor name
java.lang.IllegalArgumentException - if the url flavor paramters are incorrect

getFreeFlavorIndex

public static int getFreeFlavorIndex(Policy policy)
get the next free flavor index DPI programmers should use this function

Parameters:
policy - - the policy to get the flavor index
Returns:
int returns flavor index

addFlavor

public static boolean addFlavor(Policy policy,
                                java.lang.String name,
                                int flavorType,
                                int index,
                                java.lang.String[] params)
                         throws java.lang.IndexOutOfBoundsException,
                                ApplyException,
                                DuplicateItemException,
                                java.lang.IllegalArgumentException
Create a flavor with an index. This function should be avoided if there is no strict need for a specific index Users can create flavors and if there is a clash with the index the original thhis function will replace the index of the existing flavor with an available index.

Parameters:
policy -
name -
flavorType -
index -
params -
Returns:
Throws:
java.lang.IndexOutOfBoundsException
ApplyException
DuplicateItemException
java.lang.IllegalArgumentException

addFlavor

public static boolean addFlavor(Policy policy,
                                java.lang.String name,
                                int flavorType,
                                int index,
                                int replaceIndex,
                                java.lang.String[] params)
                         throws ApplyException,
                                DuplicateItemException,
                                java.lang.IllegalArgumentException
Create a flavor with an index. This function should be avoided if there is no strict need for a specific index Users can create flavors and if there is a clash with the index the original thhis function will replace the index of the existing flavor with the replaceIndex.

Parameters:
policy -
name -
flavorType -
index - the flavor index
replaceIndex - the flavor index to give to an existing flavor that already has the desired index
params -
Returns:
Throws:
ApplyException
DuplicateItemException
java.lang.IllegalArgumentException

addZone

public static boolean addZone(Policy policy,
                              java.lang.String name,
                              int index,
                              int replaceIndex)
                       throws DuplicateItemException
Add a new zone

Parameters:
policy -
name - zone name
index - zone index
replaceIndex - the index to give to an existing zone that already has the desired index
Returns:
Throws:
DuplicateItemException

safeDeleteSignature

public static boolean safeDeleteSignature(Policy policy,
                                          java.lang.String name)
Deletes a signature by its name. If signature does not exist, returns false Removes the signature and all references to it

Parameters:
policy -
name -
Returns:

safeDeleteSignature

public static boolean safeDeleteSignature(Policy policy,
                                          int index)
Deletes a signature by its index. If signature does not exist, returns false Removes the signature and all references to it

Parameters:
policy -
index -
Returns:

safeRenameSignature

public static boolean safeRenameSignature(Policy policy,
                                          java.lang.String name,
                                          java.lang.String newName)
renames signature. Returns false if no such signature or if replace name exists

Parameters:
policy -
name -
newName -
Returns:

addSignature

public static boolean addSignature(Policy policy,
                                   java.lang.String name,
                                   int signatureId)
                            throws DuplicateItemException
Add signature.

Parameters:
policy -
name -
newName -
Returns:
Throws:
DuplicateItemException - if a signature with such name or index exists

doesSignatureExist

public static boolean doesSignatureExist(Policy policy,
                                         java.lang.String name)

doesSignatureExist

public static boolean doesSignatureExist(Policy policy,
                                         int index)

renameService

public static boolean renameService(Policy policy,
                                    java.lang.String name,
                                    java.lang.String newName)
                             throws ItemNotFoundException,
                                    DuplicateItemException
Renaming service.

Parameters:
policy -
name -
newName -
Returns:
Throws:
ItemNotFoundException - if no such service
DuplicateItemException - if replace name already exists

safeDeleteService

public static boolean safeDeleteService(Policy policy,
                                        java.lang.String name)
                                 throws ItemNotFoundException
Removes a service. Returns false if no such service Removes all references to the service (service rules)

Parameters:
policy -
name -
Returns:
Throws:
ItemNotFoundException

addService

public static boolean addService(Policy policy,
                                 java.lang.String name,
                                 int index,
                                 int replaceIndex)
                          throws ApplyException,
                                 DuplicateItemException,
                                 ItemNotFoundException
Adds a new service

Parameters:
policy -
name -
index -
replaceIndex -
Returns:
Throws:
ApplyException
DuplicateItemException
ItemNotFoundException

setServiceGlobalCounter

public static boolean setServiceGlobalCounter(Policy policy,
                                              java.lang.String name,
                                              int index)
                                       throws ApplyException,
                                              java.lang.IllegalArgumentException,
                                              ItemNotFoundException,
                                              com.pcube.apps.engage.foundations.FullCollectionException,
                                              DuplicateItemException
set global counter to a service

Parameters:
policy -
name - service name
index - counter index
Returns:
Throws:
ApplyException
java.lang.IllegalArgumentException - if no such service
ItemNotFoundException - if no such service
com.pcube.apps.engage.foundations.FullCollectionException - if there are no more counters available
DuplicateItemException - if counter is already taken

setServiceSubscriberCounter

public static boolean setServiceSubscriberCounter(Policy policy,
                                                  java.lang.String name,
                                                  int index)
                                           throws ApplyException,
                                                  java.lang.IllegalArgumentException,
                                                  ItemNotFoundException,
                                                  com.pcube.apps.engage.foundations.FullCollectionException,
                                                  DuplicateItemException
set subscriber counter to a service

Parameters:
policy -
name -
index -
Returns:
Throws:
ApplyException
java.lang.IllegalArgumentException - if no such service
ItemNotFoundException - if no such service
com.pcube.apps.engage.foundations.FullCollectionException - if there are no more counters available
DuplicateItemException - if counter is already taken

addServiceElement

public static boolean addServiceElement(Policy policy,
                                        java.lang.String serviceName,
                                        java.lang.String protocolName,
                                        java.lang.String flavorName,
                                        java.lang.String zoneName,
                                        int initiatingSide)
                                 throws ItemNotFoundException,
                                        java.lang.IndexOutOfBoundsException,
                                        ApplyException,
                                        DuplicateItemException,
                                        java.lang.IllegalArgumentException
Add service element. If any of the element parameters protocol, flavor or zone are wildcard (*) set null.

Parameters:
policy -
serviceName - an existing service or a new service name that will be added
protocolName - existing protocol name or null for any protocol
flavorName - existing flavor name or null for any flavor
zoneName - existing zone name or null for any zone
initiatingSide -
Returns:
Throws:
ItemNotFoundException
java.lang.IndexOutOfBoundsException
ApplyException
DuplicateItemException
java.lang.IllegalArgumentException

getUpgradeDpiJarFile

public static java.io.File getUpgradeDpiJarFile()
get the upgrade jar file

Returns:

dpiExists

public static boolean dpiExists()
Check if the DPI MNG jar exists. If it does not exist, try to set the default jar, which is a resource of SCA BB MNG, unless there is a system property named DPI_UPGRADE which does not have "true" as it's value This system property is aimed to be a back door for disabling the DPI MNG altogether by deleting the DPI jar \.pcube\dpi-3.5.0.jar and disabling using the default DPI jar which is part of the MNG

Returns:

validateDpiJar

public static boolean validateDpiJar()
Validates the upgrade jar file - if it exists and if it contains the upgrade class

Returns:

getDpiUpgradeClassName

public static java.lang.String getDpiUpgradeClassName()
Get the upgrade class name

Returns:

getLastErrorMessage

public static java.lang.String getLastErrorMessage()
get the last error message

Returns:

getErrorMessages

public static java.lang.String[] getErrorMessages()
get all error messages in an array (last error at the end of the array)

Returns:

clearErrorMessages

public static void clearErrorMessages()
clear all error messages


validateDpiJar

public static void validateDpiJar(java.io.File upgradeFile)
                           throws java.lang.IllegalArgumentException
Check that a file is a valid jar file with the required upgrade class

Parameters:
upgradeFile -
Throws:
java.lang.IllegalArgumentException

setUpgradeDpiJarFile

public static boolean setUpgradeDpiJarFile(java.io.File upgradeJarFile)
                                    throws java.io.IOException,
                                           java.lang.IllegalArgumentException
Set a file as the upgrade jar file - used by MNG and not by the PL

Parameters:
upgradeJarFile -
Returns:
Throws:
java.lang.IllegalArgumentException
java.io.IOException

removeUpgradeJarFile

public static void removeUpgradeJarFile()

saveFile

public static boolean saveFile(java.io.File origin,
                               java.io.File destination)
                        throws java.io.IOException
Throws:
java.io.IOException

addProtocol

public static boolean addProtocol(Policy policy,
                                  java.lang.String name,
                                  int index)
                           throws DuplicateItemException
Throws:
DuplicateItemException

addTcpPortBasedProtocolElement

public static boolean addTcpPortBasedProtocolElement(Policy policy,
                                                     java.lang.String protocolName,
                                                     long port)
                                              throws DuplicateItemException
Throws:
DuplicateItemException

addTcpPortBasedProtocolElementIPV6

public static boolean addTcpPortBasedProtocolElementIPV6(Policy policy,
                                                         java.lang.String protocolName,
                                                         long port)
                                                  throws DuplicateItemException
Throws:
DuplicateItemException

addTcpPortBasedProtocolElement

public static boolean addTcpPortBasedProtocolElement(Policy policy,
                                                     java.lang.String protocolName,
                                                     long portMin,
                                                     long portMax)
                                              throws DuplicateItemException
Throws:
DuplicateItemException

addTcpPortBasedProtocolElementIPV6

public static boolean addTcpPortBasedProtocolElementIPV6(Policy policy,
                                                         java.lang.String protocolName,
                                                         long portMin,
                                                         long portMax)
                                                  throws DuplicateItemException
Throws:
DuplicateItemException

addUdpPortBasedProtocolElement

public static boolean addUdpPortBasedProtocolElement(Policy policy,
                                                     java.lang.String protocolName,
                                                     long port)
                                              throws DuplicateItemException
Throws:
DuplicateItemException

addUdpPortBasedProtocolElementIPV6

public static boolean addUdpPortBasedProtocolElementIPV6(Policy policy,
                                                         java.lang.String protocolName,
                                                         long port)
                                                  throws DuplicateItemException
Throws:
DuplicateItemException

addUdpPortBasedProtocolElement

public static boolean addUdpPortBasedProtocolElement(Policy policy,
                                                     java.lang.String protocolName,
                                                     long portMin,
                                                     long portMax)
                                              throws DuplicateItemException
Throws:
DuplicateItemException

addUdpPortBasedProtocolElementIPV6

public static boolean addUdpPortBasedProtocolElementIPV6(Policy policy,
                                                         java.lang.String protocolName,
                                                         long portMin,
                                                         long portMax)
                                                  throws DuplicateItemException
Throws:
DuplicateItemException

addProtocolElement

public static boolean addProtocolElement(Policy policy,
                                         java.lang.String protocolName,
                                         java.lang.String signatureName)
                                  throws DuplicateItemException
Throws:
DuplicateItemException

setServiceParent

public static boolean setServiceParent(Policy policy,
                                       java.lang.String serviceName,
                                       java.lang.String parentServiceName)
                                throws ItemNotFoundException
Throws:
ItemNotFoundException

setTunable

public static boolean setTunable(com.pcube.management.framework.client.SessionObject session,
                                 java.lang.String tunableName,
                                 java.lang.Object value)
                          throws ApplyException
Throws:
ApplyException

Cisco Systems, Inc.

Copyright © 2013 Cisco Systems, Inc. Confidential.