protected PolicyBean doGetPolicy ( PolicyType type , String organizationId , String entityId , String entityVersion , long policyId ) throws PolicyNotFoundException { try { storage . beginTx ( ) ; PolicyBean policy = storage . getPolicy ( type , organizationId , entityId , entityVersion , policyId ) ; if ( policy == null ) { throw ExceptionFactory . policyNotFoundException ( policyId ) ; } storage . commitTx ( ) ; if ( policy . getType ( ) != type ) { throw ExceptionFactory . policyNotFoundException ( policyId ) ; } if ( ! policy . getOrganizationId ( ) . equals ( organizationId ) ) { throw ExceptionFactory . policyNotFoundException ( policyId ) ; } if ( ! policy . getEntityId ( ) . equals ( entityId ) ) { throw ExceptionFactory . policyNotFoundException ( policyId ) ; } if ( ! policy . getEntityVersion ( ) . equals ( entityVersion ) ) { throw ExceptionFactory . policyNotFoundException ( policyId ) ; } PolicyTemplateUtil . generatePolicyDescription ( policy ) ; return policy ; } catch ( AbstractRestException e ) { storage . rollbackTx ( ) ; throw e ; } catch ( Exception e ) { storage . rollbackTx ( ) ; throw new SystemErrorException ( e ) ; } }
Gets a policy by its id . Also verifies that the policy really does belong to the entity indicated .