@@ -367,29 +367,30 @@ public void handleRequest(final InputStream inputStream, final OutputStream outp
367367
368368 }
369369
370- private void writeResponse (final OutputStream outputStream , final ProgressEvent <ResourceT , CallbackT > response )
370+ protected void writeResponse (final OutputStream outputStream , final ProgressEvent <ResourceT , CallbackT > response )
371371 throws IOException {
372- ResourceT model = response .getResourceModel ();
373- if (model != null ) {
374- JSONObject modelObject = new JSONObject (this .serializer .serialize (model ));
375-
372+ if (response .getResourceModel () != null ) {
376373 // strip write only properties on final results, we will need the intact model
377374 // while provisioning
378375 if (response .getStatus () != OperationStatus .IN_PROGRESS ) {
379- ResourceTypeSchema . load ( provideResourceSchemaJSONObject ()). removeWriteOnlyProperties ( modelObject );
376+ response . setResourceModel ( sanitizeModel ( response . getResourceModel ()) );
380377 }
381-
382- ResourceT sanitizedModel = this .serializer .deserializeStrict (modelObject .toString (), getModelTypeReference ());
383-
384- response .setResourceModel (sanitizedModel );
385378 }
386379
387380 String output = this .serializer .serialize (response );
388381 outputStream .write (output .getBytes (StandardCharsets .UTF_8 ));
389382 outputStream .close ();
390383 }
391384
392- private void validateModel (final JSONObject modelObject ) throws ValidationException , IOException {
385+ protected ResourceT sanitizeModel (final ResourceT model ) throws IOException {
386+ // strip write only properties on final results, we will need the intact model
387+ // while provisioning
388+ final JSONObject modelObject = new JSONObject (this .serializer .serialize (model ));
389+ ResourceTypeSchema .load (provideResourceSchemaJSONObject ()).removeWriteOnlyProperties (modelObject );
390+ return this .serializer .deserializeStrict (modelObject .toString (), getModelTypeReference ());
391+ }
392+
393+ protected void validateModel (final JSONObject modelObject ) throws ValidationException , IOException {
393394 JSONObject resourceSchemaJSONObject = provideResourceSchemaJSONObject ();
394395 if (resourceSchemaJSONObject == null ) {
395396 throw new TerminalException ("Unable to validate incoming model as no schema was provided." );
0 commit comments