public String handleDeleteException ( SQLException e , ItemData item ) throws RepositoryException , InvalidItemStateException { StringBuilder message = new StringBuilder ( "[" ) ; message . append ( containerName ) . append ( "] DELETE " ) . append ( item . isNode ( ) ? "NODE. " : "PROPERTY. " ) ; String errMessage = e . getMessage ( ) ; String itemInfo = item . getQPath ( ) . getAsString ( ) + " " + item . getIdentifier ( ) + ( errMessage != null ? ". Cause >>>> " + errMessage : "" ) ; if ( errMessage != null ) { // try detect error by foreign key names String umsg = errMessage . toLowerCase ( ) . toUpperCase ( ) ; if ( umsg . indexOf ( conn . JCR_FK_ITEM_PARENT ) >= 0 ) { message . append ( "Can not delete parent till childs exists. Item " ) . append ( itemInfo ) ; throw new JCRInvalidItemStateException ( message . toString ( ) , item . getIdentifier ( ) , ItemState . DELETED , e ) ; } else if ( umsg . indexOf ( conn . JCR_FK_VALUE_PROPERTY ) >= 0 ) { message . append ( "[FATAL] Can not delete property item till it contains values. Condition: property ID. " ) . append ( itemInfo ) ; throw new RepositoryException ( message . toString ( ) , e ) ; } } message . append ( "Error of item delete " ) . append ( itemInfo ) ; throw new RepositoryException ( message . toString ( ) , e ) ; }
Handle delete Exceptions .