Studio Developer Manual / Version 2204
Table Of ContentsWhile the Studio server already uses the preview URL service, it is possible to extend the service by providing additional preview providers or by integrating the preview URL service in a different environment than the Studio server, for example, as a microservice to an external preview.
@Override public Optional<Preview> getPreviewUrl( Content entity, PreviewSettings previewSettings, Map<String, Object> parameters ) { return Optional.of( Preview.of( previewSettings, "https://mypreviewservice.com/path/to/service/" + entity.getId(), isPreviewUrlService()) ); } @Override public boolean isPreviewUrlService() { return false; } @Override public boolean validate(PreviewSettings previewSettings) { return true; }
The example above 'calculates' direct preview URLs, so isPreviewUrlService()
has to return 'false'.
The calculation in this example is very static, eliminating the need to validate any configuration of the preview
settings. More sophisticated implementations may validate the values of the given 'previewSettings'. The validate
method is invoked by the preview URL service, whenever the configuration of a preview is changed, added or removed.
If the validation fails (returning false
), the preview will not become available through the
preview URL service.