protected String handleAddException ( IOException e , ItemData item ) throws RepositoryException , InvalidItemStateException { StringBuilder message = new StringBuilder ( "[" ) ; message . append ( containerName ) . append ( "] ADD " ) . append ( item . isNode ( ) ? "NODE. " : "PROPERTY. " ) ; String errMessage = e . getMessage ( ) ; String itemInfo = item . getQPath ( ) . getAsString ( ) + ", ID: " + item . getIdentifier ( ) + ", ParentID: " + item . getParentIdentifier ( ) + ( errMessage != null ? ". Cause >>>> " + errMessage : "" ) ; // try detect integrity violation RepositoryException ownException = null ; try { NodeData parent = ( NodeData ) conn . getItemData ( item . getParentIdentifier ( ) ) ; if ( parent != null ) { // have a parent try { ItemData me = conn . getItemData ( item . getIdentifier ( ) ) ; if ( me != null ) { // item already exists message . append ( "Item already exists in storage: " ) . append ( itemInfo ) ; ownException = new ItemExistsException ( message . toString ( ) , e ) ; throw ownException ; } me = conn . getItemData ( parent , new QPathEntry ( item . getQPath ( ) . getName ( ) , item . getQPath ( ) . getIndex ( ) ) , ItemType . getItemType ( item ) ) ; if ( me != null ) { message . append ( "Item already exists in storage: " ) . append ( itemInfo ) ; ownException = new ItemExistsException ( message . toString ( ) , e ) ; throw ownException ; } } catch ( Exception ep ) { // item not found or other things but error of item reading if ( ownException != null ) throw ownException ; } message . append ( "Error of item add. " ) . append ( itemInfo ) ; ownException = new RepositoryException ( message . toString ( ) , e ) ; throw ownException ; } } catch ( Exception ep ) { // no parent or error access it if ( ownException != null ) throw ownException ; } message . append ( "Error of item add. " ) . append ( itemInfo ) ; throw new JCRInvalidItemStateException ( message . toString ( ) , item . getIdentifier ( ) , ItemState . ADDED , e ) ; }
Handle Add IOException .