Class ItdiBook


  • public class ItdiBook
    extends java.lang.Object
    This wraps the functionality of an IDMLBook and enhances it with the additional functionality needed by the IdML Components.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DELTA_TYPE_IDML
      One of the two modes supported by the IdML schema - delta.
      static java.lang.String REFRESH_TYPE_IDML
      One of the two modes supported by the IdML schema - refresh.
      static int STORE_AS_FILE
      Determines that the generated IdML documents will be stored as a file.
    • Constructor Summary

      Constructors 
      Constructor Description
      ItdiBook​(java.lang.String bookName)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String addConfigurationItem​(java.lang.String classType, IdMLConstants.Operations operationType, Entry entry)
      Adds a Configuration Item (CI) to the IdML book.
      void addRelationship​(java.lang.String relationshipType, IdMLConstants.Operations operationType, Entry entry)
      Adds a Relationship to the IdML book.
      void close()
      Closes this IdML book.
      long getArtifactCount()
      Returns the number of artifacts (CIs and Relationships) added to the IdML so far.
      java.lang.String getContents()
      Returns the contents of the OutputStream used for storing the IdML book.
      java.lang.String getFileName()
      Returns the full name of the IdML book.
      long getFileSize()
      Returns the size of the IdML book.
      java.lang.String getName()
      Returns the name of the IdML book.
      boolean isInMemory()
      Checks if this book is an in-memory IdML.
      boolean isOpened()
      Checks if this book is already opened.
      boolean isRefreshMode()
      Checks if this book uses REFRESH mode.
      boolean isValidateEnabled()
      Checks if validation has been enabled for this book..
      java.lang.String open​(java.lang.String applicationCode, java.lang.String mssHostname, java.lang.String cdmVersion, java.lang.String id, Entry entry)
      Opens the IdML book.
      void reset()
      Empties the contents of the buffer.
      void setDirectoryName​(java.lang.String directoryName)
      Sets the name of the directory where the IdML book will be stored.
      void setName​(java.lang.String bookName)
      Sets the name of the IdML book.
      void setRefresh​(boolean refresh)
      Sets the mode of this IdML book.
      void setStorageType​(int storageType)
      Sets the storage type of this IdML book.
      void setValidate​(boolean validate)
      Sets whether the generated IdML will be validated.
      java.lang.String split()
      Splits this IdML book.
      • Methods inherited from class java.lang.Object

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

      • DELTA_TYPE_IDML

        public static final java.lang.String DELTA_TYPE_IDML
        One of the two modes supported by the IdML schema - delta.
        See Also:
        Constant Field Values
      • REFRESH_TYPE_IDML

        public static final java.lang.String REFRESH_TYPE_IDML
        One of the two modes supported by the IdML schema - refresh.
        See Also:
        Constant Field Values
      • STORE_AS_FILE

        public static final int STORE_AS_FILE
        Determines that the generated IdML documents will be stored as a file.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ItdiBook

        public ItdiBook​(java.lang.String bookName)
        Constructor.
        Parameters:
        bookName - the name of this book.
    • Method Detail

      • getArtifactCount

        public long getArtifactCount()
        Returns the number of artifacts (CIs and Relationships) added to the IdML so far.
        Returns:
        artifact count.
      • getContents

        public java.lang.String getContents()
                                     throws java.io.UnsupportedEncodingException
        Returns the contents of the OutputStream used for storing the IdML book. If the book represents an in-memory IdML its contents will be returned as a String. Otherwise if the book is a file stored IdML null will be returned.
        Returns:
        the contents of the IdML OutputStream.
        Throws:
        java.io.UnsupportedEncodingException - if a problem occurs.
      • getFileName

        public java.lang.String getFileName()
        Returns the full name of the IdML book. The name of the IdML differs from the book name parameter. It is auto-generated during the books creation and contains meta informations, such as MSS data, IdML mode and a timestamp. If the IdML is an in-memory book only this string will be returned. For the file stored IdMLs it will contain the full path to the IdML, as well.
        Returns:
        the auto-generated IdML name.
      • getFileSize

        public long getFileSize()
        Returns the size of the IdML book. This method is only applicable for IdMLs stored as files. For in-memory ones it returns 0.
        Returns:
        size of the file used to store the IdML book..
      • getName

        public java.lang.String getName()
        Returns the name of the IdML book.
        Returns:
        the IdML book name.
      • setDirectoryName

        public void setDirectoryName​(java.lang.String directoryName)
        Sets the name of the directory where the IdML book will be stored. It is applicable only for books stored as files.
        Parameters:
        directoryName - path to the folder where to store the IdML.
      • setName

        public void setName​(java.lang.String bookName)
        Sets the name of the IdML book.
        Parameters:
        bookName - the name to be used by this book.
      • setRefresh

        public void setRefresh​(boolean refresh)
        Sets the mode of this IdML book.
        Parameters:
        refresh - if true the generated IdML will use REFRESH mode, otherwise it will use DELTA mode.
      • setStorageType

        public void setStorageType​(int storageType)
        Sets the storage type of this IdML book.
        Parameters:
        storageType - STORE_AS_FILE - the generated IdML will be stored as a file, STORE_IN_MEMORY - it will be kept in memory.
      • setValidate

        public void setValidate​(boolean validate)
        Sets whether the generated IdML will be validated.
        Parameters:
        validate - if true a validation of the book will be performed after its completion.
      • isInMemory

        public boolean isInMemory()
        Checks if this book is an in-memory IdML.
        Returns:
        true if this book is stored in memory, otherwise false.
      • isOpened

        public boolean isOpened()
        Checks if this book is already opened. A book must be opened in order to add CIs and Relationships to it.
        Returns:
        true if this book is already opened, otherwise false.
      • isRefreshMode

        public boolean isRefreshMode()
        Checks if this book uses REFRESH mode.
        Returns:
        true if this book uses REFRESH, otherwise false.
      • isValidateEnabled

        public boolean isValidateEnabled()
        Checks if validation has been enabled for this book..
        Returns:
        true if this book will be validated, otherwise false.
      • open

        public java.lang.String open​(java.lang.String applicationCode,
                                     java.lang.String mssHostname,
                                     java.lang.String cdmVersion,
                                     java.lang.String id,
                                     Entry entry)
                              throws java.lang.Exception
        Opens the IdML book.
        Parameters:
        applicationCode - the MSS's application code. It is used in the header of the IdML document, when describing the MSS that contains the artifacts described in this IdML.
        mssHostname - the MSS's hostname. It is used in the header of the IdML document, when describing the MSS that contains the artifacts described in this IdML.
        cdmVersion - the version of the Common Data Model used for defining the artifacts in the IdML.
        id - the id used for the MSS in the IdML document. If provided it overrides the default value formed using the MSS's application code and hostname.
        entry - an Entry object containing the attributes for the MSS
        Returns:
        the id used for the MSS.
        Throws:
        java.lang.Exception - if a problem occurs.
      • addConfigurationItem

        public java.lang.String addConfigurationItem​(java.lang.String classType,
                                                     IdMLConstants.Operations operationType,
                                                     Entry entry)
                                              throws com.ibm.dl.production.IDMLInvalidOperationException,
                                                     java.io.IOException
        Adds a Configuration Item (CI) to the IdML book.
        Parameters:
        classType - the class type of the configuration item. It is determined by the Common Data Model.
        operationType - the type of operation under which this item should be added. This will determine what action should be performed with this CI when the IdML book is later loaded to a CMDB. It can be either created, modified or deleted.
        entry - the TDI entry where the attributes needed for this CI are stored.
        Returns:
        the id with which this CI was added in the IdML book. Ids are book-wide unique identifiers given to each CI.
        Throws:
        com.ibm.dl.production.IDMLInvalidOperationException - if a problem with the operation associated with this CI occurs.
        java.io.IOException - if a problem occurs when trying to store the IdML data (either in memory or to a file).
      • addRelationship

        public void addRelationship​(java.lang.String relationshipType,
                                    IdMLConstants.Operations operationType,
                                    Entry entry)
                             throws java.lang.Exception
        Adds a Relationship to the IdML book.
        Parameters:
        relationshipType - the type of the relationship. It is determined by the Common Data Model.
        operationType - the type of operation under which this relationship should be added. This will determine what action should be performed with this Relationship when the IdML book is later loaded to a CMDB. It can be either created, modified or deleted.
        entry - the TDI entry where the attributes needed for this Relationship are stored.
        Throws:
        com.ibm.dl.production.IDMLInvalidOperationException - if a problem with the operation associated with this CI occurs.
        java.lang.Exception - if a problem occurs when trying to store the IdML data (either in memory or to a file).
      • close

        public void close()
                   throws java.lang.Exception
        Closes this IdML book.
        Throws:
        java.lang.Exception - if a problem occurs.
      • reset

        public void reset()
        Empties the contents of the buffer.
      • split

        public java.lang.String split()
                               throws java.lang.Exception
        Splits this IdML book. This action closes the current book (validating it, if this option is enabled) and reopens it with the same meta attributes (MSS data, CDM version, etc.). Splitting is applicable only for IdML books stored as files.
        Returns:
        the filename of the IdML book that was closed.
        Throws:
        java.lang.Exception - if a problem occurs.