psdi.dm.util

Class DMUtil

  • java.lang.Object
    • psdi.dm.util.DMUtil


  • public class DMUtil
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static MXLogger DMLOGGER 
    • Constructor Summary

      Constructors 
      Constructor and Description
      DMUtil() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static boolean checkRestriction(java.sql.Connection conn, java.lang.String source)
      Check if any row exist for this source in target dmrestriction table.
      static void clearNewDeployValues()
      Clear the deploy map
      static long createBulletinBoard(UserInfo ui, boolean isCreate)
      Creates a bulletin board message before start deploying in target environment
      static java.util.jar.JarOutputStream createJarArchive(java.util.jar.JarOutputStream archiveStream, java.lang.String inFileName, java.io.ByteArrayInputStream in)
      Create a jar stream by adding the inputstream to the jar
      static java.lang.String dateInDigits(boolean includeMilliseconds) 
      static void deleteInvalidStagingRows(java.lang.String pkgDefName, java.lang.String source, java.lang.String pkg, UserInfo ui)
      Delete staging records with diststatus 0
      static void deletePreviewLogs(java.lang.String pkgName)
      Delete preview log files
      static void dmMapDefCheck(MboRemote pkgMbo)
      Deploy the package metadata.
      static MboRemote findTopLevelMosForChild(MosInfo mosInfo, MboRemote childMbo)
      Find top level mbo for a child mbo
      static java.lang.String getAttrValues(MboSet mboSet, java.lang.String attrName, int maxCount)
      Returns the attribute values in the mboset in a comma separated string.
      static java.util.LinkedHashMap getCfgObjsForGrp(MboRemote defMbo)
      Get MOSs for groups.
      static java.lang.String getDatabaseName()
      Get the database name from system tables depending on database type.
      static java.lang.String getDatabaseName(java.sql.Connection conn)
      Get the database name from system tables depending on database type.
      static int getDatabaseType(java.sql.Connection conn)
      Get the database type for the connection
      static java.io.File getDatedFile(java.io.File folder, java.lang.String prefix, java.lang.String suffix)
      Generates a filename that is not used, based on a prefix, suffix, and the current date/time.
      static java.lang.String getDBHostName()
      Get the host name where database is installed from system tables depending on database type.
      static java.lang.String getDBHostName(java.sql.Connection conn)
      Get the host name where database is installed from system tables depending on database type.
      static java.lang.String[] getDDCfgGroupNames()
      Returns the Data Dictionary config group's name
      static java.lang.String[] getDDCfgGroupNames(UserInfo ui)
      Returns the Data Dictionary config group's name, use specific UserInfo for PMR 09898,SGC,724.
      static MboSetRemote getDDCfgGroups()
      Get the DMCfgGroup objects which is of type DDMETADATA.
      static MboSetRemote getDDCfgGroups(UserInfo ui)
      Get the DMCfgGroup objects which is of type DDMETADATA with a specific userInfo for PMR 09898,SGC,724.
      static java.util.Map getDeployDefaultValueSet()
      Default values MEA needs to ignore if value in XML is null.
      static MXLogger getDMLogger(UserInfo ui)
      Get the logger for DM
      static long getLongKey(java.lang.String key)
      Given a key string, return its value in long.
      static byte[] getManifestFromFile(java.lang.String fileName, java.lang.String direction) 
      static byte[] getManifestFromStaging(UserInfo ui, java.lang.String pkgName)
      Get the manifest from staging table
      static java.lang.String getMessageText(UserInfo msgUserInfo, java.lang.String errorKey, java.lang.Object[] params)
      Return the message in correct language
      static java.util.HashMap getNewDeployValues()
      Get the deploy map
      static java.lang.String getPackageName(java.lang.String source, java.lang.String pkgDefName)
      Get the package instnce name from source and package definition name
      static java.lang.String[] getPkgAndSourceFromJarName(java.lang.String jarName)
      From pkg archive file, read the pkgdef name and source.Should be only called for file type
      static java.lang.String getPkgFileName(MboRemote stageMbo)
      Get the package file name
      static MboRemote getPKGMETADATACfgGroup()
      Get the DMCfgGroup object which is of type PKGMETAMETADATA.
      static java.lang.String getPKGMETADATAGroupName()
      Returns the package metadata config group's name
      static java.lang.String getPKInfo(MboRemote topMbo)
      Get primary key information in format for storing on DMCompResult.PrimaryKeys.
      static java.lang.String getSchemaName()
      Get the schema name from system tables depending on database type.
      static java.lang.String getSchemaName(java.sql.Connection conn)
      Get the schema name from system tables depending on database type.
      static java.lang.String getSourceName()
      Returns the source name.
      static java.lang.String getSourceName(java.sql.Connection conn) 
      static int getTenantID(MboRemote mbo)
      Returns the TenantID of the Mbo.
      static java.lang.String[] getTypeAndOrderFromFileName(java.lang.String fileName, java.lang.String pkgSrc)
      Read each jar entry and get pkgstaging information from jar entry name
      static boolean inMEATransaction()
      Checks if creation of a mbo is from MEA or not.
      static boolean inMEATransaction(MXTransaction txn)
      Checks if creation of a mbo is from MEA or not.
      static void putNewDeployValues(java.lang.String key, java.lang.Object value) 
      static void readJarArchive(java.io.File jarF, java.lang.String pkgFileName, UserInfo ui)
      Read each jar entry from .zip file and write to the database
      static MboRemote redistributePackage(MboRemote pkgMbo)
      Redistribute a package from target to another new target
      static MboRemote redistributePkgMetaData(MboRemote pkgDefMbo, MboRemote pkgMbo)
      Staging record withtype pkgmetadata has to be recreated again for redistribution
      static void removeBulletinBoard(UserInfo ui, long bbId)
      Removes the bulletin board message
      static void writeLongOpMsg(MboSetRemote mboSet, java.lang.String msg)
      Write long op messages to mbo set.
      static void writeLongOpMsg(UserInfo msgUI, MboSetRemote mboSet, java.lang.String msg)
      Write long op messages to mbo set.
      static java.lang.String writeToDMMessage(MboRemote ownerMbo, java.lang.String pkgName, java.lang.String type, java.lang.String errorKey, java.lang.Throwable t, java.lang.String msgDetail, java.lang.Object[] params, boolean isLongOpMsg)
      Write message to DMMessage table
      static java.lang.String writeToDMMessage(MboRemote ownerMbo, java.lang.String pkgName, java.lang.String type, java.lang.String errorKey, java.lang.Throwable t, java.lang.String msgDetail, java.lang.Object[] params, boolean isLongOpMsg, UserInfo msgUI) 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DMLOGGER

        public static final MXLogger DMLOGGER
    • Constructor Detail

      • DMUtil

        public DMUtil()
    • Method Detail

      • createJarArchive

        public static java.util.jar.JarOutputStream createJarArchive(java.util.jar.JarOutputStream archiveStream,
                                                                     java.lang.String inFileName,
                                                                     java.io.ByteArrayInputStream in)
                                                              throws MXException
        Create a jar stream by adding the inputstream to the jar
        Parameters:
        archiveStream -
        inFileName -
        in -
        Returns:
        Throws:
        MXException
      • getPackageName

        public static java.lang.String getPackageName(java.lang.String source,
                                                      java.lang.String pkgDefName)
                                               throws MXException
        Get the package instnce name from source and package definition name
        Parameters:
        source -
        pkgDefName -
        Returns:
        package name
        Throws:
        MXException
      • getDatedFile

        public static java.io.File getDatedFile(java.io.File folder,
                                                java.lang.String prefix,
                                                java.lang.String suffix)
                                         throws java.rmi.RemoteException
        Generates a filename that is not used, based on a prefix, suffix, and the current date/time. The method will check that the file does not exist before returning.
        Parameters:
        folder - Where the file will be created.
        prefix - The text before the date, i.e. "COLLECTION_OBJSTRUCT_".
        suffix - The text after the date, i.e. ".XML"
        Returns:
        The file with the generated file name, something like "COLLECTION_OBJSTRUCT_201005271145301234.XML"
        Throws:
        java.rmi.RemoteException
      • dateInDigits

        public static java.lang.String dateInDigits(boolean includeMilliseconds)
                                             throws java.rmi.RemoteException
        Throws:
        java.rmi.RemoteException
      • getDDCfgGroups

        public static MboSetRemote getDDCfgGroups(UserInfo ui)
                                           throws MXException
        Get the DMCfgGroup objects which is of type DDMETADATA with a specific userInfo for PMR 09898,SGC,724.
        Parameters:
        UserInfo -
        Throws:
        MXException
      • getDDCfgGroupNames

        public static java.lang.String[] getDDCfgGroupNames()
                                                     throws MXException
        Returns the Data Dictionary config group's name
        Returns:
        Throws:
        MXException
        java.rmi.RemoteException
      • getTenantID

        public static int getTenantID(MboRemote mbo)
                               throws MXException,
                                      java.rmi.RemoteException
        Returns the TenantID of the Mbo. Returns a -1 if no ID is found.
        Parameters:
        mbo -
        Returns:
        Throws:
        MXException
        java.rmi.RemoteException
      • getDDCfgGroupNames

        public static java.lang.String[] getDDCfgGroupNames(UserInfo ui)
                                                     throws MXException
        Returns the Data Dictionary config group's name, use specific UserInfo for PMR 09898,SGC,724.
        Parameters:
        UserInfo -
        Returns:
        Throws:
        MXException
        java.rmi.RemoteException
      • getPKGMETADATACfgGroup

        public static MboRemote getPKGMETADATACfgGroup()
                                                throws MXException
        Get the DMCfgGroup object which is of type PKGMETAMETADATA.
        Throws:
        MXException
      • getPKGMETADATAGroupName

        public static java.lang.String getPKGMETADATAGroupName()
                                                        throws MXException
        Returns the package metadata config group's name
        Returns:
        Throws:
        MXException
        java.rmi.RemoteException
      • getPkgAndSourceFromJarName

        public static java.lang.String[] getPkgAndSourceFromJarName(java.lang.String jarName)
                                                             throws MXException
        From pkg archive file, read the pkgdef name and source.Should be only called for file type
        Parameters:
        jarName -
        Returns:
        String array of pkgdef name and source
        Throws:
        java.lang.Exception
        MXException
      • getTypeAndOrderFromFileName

        public static java.lang.String[] getTypeAndOrderFromFileName(java.lang.String fileName,
                                                                     java.lang.String pkgSrc)
                                                              throws java.lang.Exception
        Read each jar entry and get pkgstaging information from jar entry name
        Parameters:
        fileName -
        pkgSrc -
        Returns:
        Throws:
        java.lang.Exception
      • readJarArchive

        public static void readJarArchive(java.io.File jarF,
                                          java.lang.String pkgFileName,
                                          UserInfo ui)
                                   throws MXException,
                                          java.rmi.RemoteException
        Read each jar entry from .zip file and write to the database
        Parameters:
        pkgStream -
        pkgFileName -
        ui -
        Throws:
        MXException
        java.rmi.RemoteException
      • deleteInvalidStagingRows

        public static void deleteInvalidStagingRows(java.lang.String pkgDefName,
                                                    java.lang.String source,
                                                    java.lang.String pkg,
                                                    UserInfo ui)
                                             throws java.lang.Exception
        Delete staging records with diststatus 0
        Parameters:
        pkgDefName -
        source -
        pkg -
        ui -
        Throws:
        java.lang.Exception
      • getSourceName

        public static java.lang.String getSourceName()
                                              throws MXException
        Returns the source name. It should be same for a database
        Returns:
        source string
        Throws:
        MXException
      • getSourceName

        public static java.lang.String getSourceName(java.sql.Connection conn)
                                              throws MXException
        Throws:
        MXException
      • getDatabaseName

        public static java.lang.String getDatabaseName(java.sql.Connection conn)
                                                throws MXException
        Get the database name from system tables depending on database type.
        Parameters:
        dbType -
        Returns:
        database name
        Throws:
        MXException
        java.rmi.RemoteException
      • getDatabaseName

        public static java.lang.String getDatabaseName()
                                                throws MXException
        Get the database name from system tables depending on database type.
        Parameters:
        dbType -
        Returns:
        database name
        Throws:
        MXException
        java.rmi.RemoteException
      • getSchemaName

        public static java.lang.String getSchemaName(java.sql.Connection conn)
                                              throws MXException
        Get the schema name from system tables depending on database type.
        Parameters:
        dbType -
        Returns:
        schema name
        Throws:
        MXException
        java.rmi.RemoteException
      • getSchemaName

        public static java.lang.String getSchemaName()
                                              throws MXException
        Get the schema name from system tables depending on database type.
        Parameters:
        dbType -
        Returns:
        schema name
        Throws:
        MXException
        java.rmi.RemoteException
      • getDBHostName

        public static java.lang.String getDBHostName(java.sql.Connection conn)
                                              throws MXException
        Get the host name where database is installed from system tables depending on database type.
        Parameters:
        dbType -
        Returns:
        host name
        Throws:
        MXException
        java.rmi.RemoteException
      • getDBHostName

        public static java.lang.String getDBHostName()
                                              throws MXException
        Get the host name where database is installed from system tables depending on database type.
        Parameters:
        dbType -
        Returns:
        host name
        Throws:
        MXException
        java.rmi.RemoteException
      • checkRestriction

        public static boolean checkRestriction(java.sql.Connection conn,
                                               java.lang.String source)
                                        throws MXException
        Check if any row exist for this source in target dmrestriction table. If exist don't distribute
        Parameters:
        conn -
        source -
        Returns:
        true if allowed else false
        Throws:
        MXException
      • inMEATransaction

        public static boolean inMEATransaction(MXTransaction txn)
                                        throws java.rmi.RemoteException
        Checks if creation of a mbo is from MEA or not.
        Parameters:
        txn -
        Returns:
        true if MEA is creating mbo from XML in deploy else false
        Throws:
        java.rmi.RemoteException
      • inMEATransaction

        public static boolean inMEATransaction()
                                        throws java.rmi.RemoteException
        Checks if creation of a mbo is from MEA or not.
        Parameters:
        txn -
        Returns:
        true if MEA is creating mbo from XML in deploy else false
        Throws:
        java.rmi.RemoteException
      • createBulletinBoard

        public static long createBulletinBoard(UserInfo ui,
                                               boolean isCreate)
                                        throws MXException,
                                               java.rmi.RemoteException
        Creates a bulletin board message before start deploying in target environment
        Throws:
        MXException
        java.rmi.RemoteException
      • removeBulletinBoard

        public static void removeBulletinBoard(UserInfo ui,
                                               long bbId)
                                        throws MXException,
                                               java.rmi.RemoteException
        Removes the bulletin board message
        Parameters:
        ui -
        bbId -
        Throws:
        MXException
        java.rmi.RemoteException
      • redistributePackage

        public static MboRemote redistributePackage(MboRemote pkgMbo)
                                             throws MXException,
                                                    java.rmi.RemoteException
        Redistribute a package from target to another new target
        Throws:
        MXException
        java.rmi.RemoteException
      • redistributePkgMetaData

        public static MboRemote redistributePkgMetaData(MboRemote pkgDefMbo,
                                                        MboRemote pkgMbo)
                                                 throws java.lang.Exception
        Staging record withtype pkgmetadata has to be recreated again for redistribution
        Parameters:
        pkgDefMbo -
        pkgMbo -
        Returns:
        packagembo after save
        Throws:
        MXException
        java.rmi.RemoteException
        java.lang.Exception
      • writeToDMMessage

        public static java.lang.String writeToDMMessage(MboRemote ownerMbo,
                                                        java.lang.String pkgName,
                                                        java.lang.String type,
                                                        java.lang.String errorKey,
                                                        java.lang.Throwable t,
                                                        java.lang.String msgDetail,
                                                        java.lang.Object[] params,
                                                        boolean isLongOpMsg)
        Write message to DMMessage table
        Parameters:
        ownerMbo -
        pkgName -
        type -
        errorKey -
        t -
        msgDetail -
        params -
        Returns:
        The message written
        Throws:
        MXException
      • writeToDMMessage

        public static java.lang.String writeToDMMessage(MboRemote ownerMbo,
                                                        java.lang.String pkgName,
                                                        java.lang.String type,
                                                        java.lang.String errorKey,
                                                        java.lang.Throwable t,
                                                        java.lang.String msgDetail,
                                                        java.lang.Object[] params,
                                                        boolean isLongOpMsg,
                                                        UserInfo msgUI)
      • getLongKey

        public static long getLongKey(java.lang.String key)
        Given a key string, return its value in long.
        Parameters:
        key -
        Returns:
      • getDeployDefaultValueSet

        public static java.util.Map getDeployDefaultValueSet()
        Default values MEA needs to ignore if value in XML is null.
        Returns:
        set of default values
      • getAttrValues

        public static java.lang.String getAttrValues(MboSet mboSet,
                                                     java.lang.String attrName,
                                                     int maxCount)
                                              throws MXException,
                                                     java.rmi.RemoteException
        Returns the attribute values in the mboset in a comma separated string.
        Parameters:
        mboSet - The mbo set which attribute values are being extracted.
        attrName - The attribute name.
        maxCount - The maximum number of values shown in the list. The rest will be represented by "...". If maxCount=-1, will print all values in set.
        Returns:
        Throws:
        MXException
        java.rmi.RemoteException
      • getManifestFromFile

        public static byte[] getManifestFromFile(java.lang.String fileName,
                                                 java.lang.String direction)
                                          throws MXException
        Throws:
        MXException
      • writeLongOpMsg

        public static void writeLongOpMsg(MboSetRemote mboSet,
                                          java.lang.String msg)
                                   throws java.rmi.RemoteException
        Write long op messages to mbo set.
        Parameters:
        mboSet -
        msg -
        Throws:
        java.rmi.RemoteException
      • writeLongOpMsg

        public static void writeLongOpMsg(UserInfo msgUI,
                                          MboSetRemote mboSet,
                                          java.lang.String msg)
                                   throws java.rmi.RemoteException
        Write long op messages to mbo set.
        Parameters:
        userinfo - for messages
        mboSet -
        msg -
        Throws:
        java.rmi.RemoteException
      • putNewDeployValues

        public static void putNewDeployValues(java.lang.String key,
                                              java.lang.Object value)
                                       throws java.rmi.RemoteException
        Throws:
        java.rmi.RemoteException
      • clearNewDeployValues

        public static void clearNewDeployValues()
        Clear the deploy map
        Throws:
        java.rmi.RemoteException
      • getNewDeployValues

        public static java.util.HashMap getNewDeployValues()
        Get the deploy map
        Returns:
        HashMap
      • getPkgFileName

        public static java.lang.String getPkgFileName(MboRemote stageMbo)
                                               throws MXException,
                                                      java.rmi.RemoteException
        Get the package file name
        Parameters:
        stageMbo -
        Returns:
        file name
        Throws:
        MXException
        java.rmi.RemoteException
      • getManifestFromStaging

        public static byte[] getManifestFromStaging(UserInfo ui,
                                                    java.lang.String pkgName)
                                             throws MXException,
                                                    java.rmi.RemoteException
        Get the manifest from staging table
        Parameters:
        ui -
        pkgName -
        Returns:
        manifest
        Throws:
        MXException
        java.rmi.RemoteException
      • getDMLogger

        public static MXLogger getDMLogger(UserInfo ui)
        Get the logger for DM
        Parameters:
        ui -
        Returns:
        logger
      • deletePreviewLogs

        public static void deletePreviewLogs(java.lang.String pkgName)
                                      throws MXException,
                                             java.rmi.RemoteException
        Delete preview log files
        Throws:
        java.lang.Exception
        MXException
        java.rmi.RemoteException
      • getMessageText

        public static java.lang.String getMessageText(UserInfo msgUserInfo,
                                                      java.lang.String errorKey,
                                                      java.lang.Object[] params)
        Return the message in correct language
        Parameters:
        msgUserInfo -
        errorKey -
        Returns:
        message
      • getCfgObjsForGrp

        public static java.util.LinkedHashMap getCfgObjsForGrp(MboRemote defMbo)
                                                        throws MXException,
                                                               java.rmi.RemoteException
        Get MOSs for groups.
        Returns:
        LinkedHashMap>
        Throws:
        MXException
        java.rmi.RemoteException
      • getDatabaseType

        public static int getDatabaseType(java.sql.Connection conn)
                                   throws java.lang.Exception
        Get the database type for the connection
        Parameters:
        conn -
        Returns:
        UpgConstants.ORACLE/UpgConstants.SQLSERVER/UpgConstants.DB2
        Throws:
        java.lang.Exception
      • findTopLevelMosForChild

        public static MboRemote findTopLevelMosForChild(MosInfo mosInfo,
                                                        MboRemote childMbo)
                                                 throws MXException,
                                                        java.rmi.RemoteException
        Find top level mbo for a child mbo
        Parameters:
        mosInfo -
        childMbo -
        Returns:
        top level mbo for a child mbo
        Throws:
        MXException
        java.rmi.RemoteException
      • getPKInfo

        public static java.lang.String getPKInfo(MboRemote topMbo)
                                          throws MXException,
                                                 java.rmi.RemoteException
        Get primary key information in format for storing on DMCompResult.PrimaryKeys.
        Parameters:
        MboRemote - top level mbo
        Returns:
        keys
        Throws:
        MXException
        java.rmi.RemoteException
      • dmMapDefCheck

        public static void dmMapDefCheck(MboRemote pkgMbo)
                                  throws MXException,
                                         java.rmi.RemoteException
        Deploy the package metadata. Returns the package mbo if successful.
        Throws:
        MXException
        java.rmi.RemoteException