Studio Developer Manual / Version 2010
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, e.g as 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.