private void addTransformInterceptors ( List < Interceptor < ? > > inInterceptors , List < Interceptor < ? > > outInterceptors , boolean newClient ) { // The old service expects the Customer data be qualified with // the 'http://customer/v1' namespace. // The new service expects the Customer data be qualified with // the 'http://customer/v2' namespace. // If it is an old client talking to the new service then: // - the out transformation interceptor is configured for // 'http://customer/v1' qualified data be transformed into // 'http://customer/v2' qualified data. // - the in transformation interceptor is configured for // 'http://customer/v2' qualified response data be transformed into // 'http://customer/v1' qualified data. // If it is a new client talking to the old service then: // - the out transformation interceptor is configured for // 'http://customer/v2' qualified data be transformed into // 'http://customer/v1' qualified data. // - the in transformation interceptor is configured for // 'http://customer/v1' qualified response data be transformed into // 'http://customer/v2' qualified data. // - new Customer type also introduces a briefDescription property // which needs to be dropped for the old service validation to succeed // this configuration can be provided externally Map < String , String > newToOldTransformMap = new HashMap < String , String > ( ) ; newToOldTransformMap . put ( "{http://customer/v2}*" , "{http://customer/v1}*" ) ; Map < String , String > oldToNewTransformMap = Collections . singletonMap ( "{http://customer/v1}*" , "{http://customer/v2}*" ) ; TransformOutInterceptor outTransform = new TransformOutInterceptor ( ) ; outTransform . setOutTransformElements ( newClient ? newToOldTransformMap : oldToNewTransformMap ) ; if ( newClient ) { newToOldTransformMap . put ( "{http://customer/v2}briefDescription" , "" ) ; //outTransform.setOutDropElements( // Collections.singletonList("{http://customer/v2}briefDescription")); } TransformInInterceptor inTransform = new TransformInInterceptor ( ) ; inTransform . setInTransformElements ( newClient ? oldToNewTransformMap : newToOldTransformMap ) ; inInterceptors . add ( inTransform ) ; outInterceptors . add ( outTransform ) ; }
Prepares transformation interceptors for a client .