Commit fe8683b1 authored by Mathijs den Burger's avatar Mathijs den Burger

CMS-10656 Also log exception when node cannot be found, code cleanup

parent ddae21f5
/*
* Copyright 2013-2015 Hippo B.V. (http://www.onehippo.com)
* Copyright 2013-2017 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -233,9 +233,9 @@ public class CKEditorNodePlugin extends AbstractCKEditorPlugin<Node> {
return null;
}
private IBrowseService getBrowser() {
private IBrowseService<IModel<Node>> getBrowser() {
final String browserId = getPluginConfig().getString(IBrowseService.BROWSER_ID, "service.browse");
return getPluginContext().getService(browserId, IBrowseService.class);
return (IBrowseService<IModel<Node>>) getPluginContext().getService(browserId, IBrowseService.class);
}
private IModel<Node> getNodeModel() {
......
......@@ -25,6 +25,7 @@ import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptReferenceHeaderItem;
import org.apache.wicket.markup.head.OnLoadHeaderItem;
import org.apache.wicket.model.IModel;
import org.apache.wicket.request.Request;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.resource.JavaScriptResourceReference;
......@@ -45,9 +46,9 @@ class PreviewLinksBehavior extends AbstractDefaultAjaxBehavior {
private static final ResourceReference PREVIEW_LINKS_SERVICE_JS =
new JavaScriptResourceReference(PreviewLinksBehavior.class, "preview-links-service.js");
private final IBrowseService browser;
private final IBrowseService<IModel<Node>> browser;
PreviewLinksBehavior(final IBrowseService browser) {
PreviewLinksBehavior(final IBrowseService<IModel<Node>> browser) {
this.browser = browser;
}
......@@ -58,7 +59,6 @@ class PreviewLinksBehavior extends AbstractDefaultAjaxBehavior {
if (uuid != null && !"null".equals(uuid) && browser != null) {
final Node targetNode = getNodeById(uuid);
if (targetNode == null) {
log.info("Node with UUID {} could not be loaded", uuid);
final String message = new ClassResourceModel("brokenlink-alert",
PreviewLinksBehavior.class).getObject();
target.appendJavaScript("alert('" + message + "');");
......@@ -76,6 +76,7 @@ class PreviewLinksBehavior extends AbstractDefaultAjaxBehavior {
return targetNode;
}
} catch (final RepositoryException ignore) {
log.info("Node with UUID {} could not be loaded", uuid, ignore);
}
return null;
}
......
......@@ -57,7 +57,7 @@ public class RichTextDiffWithLinksAndImagesPanel extends AbstractRichTextDiffPan
public RichTextDiffWithLinksAndImagesPanel(final String id,
final IModel<Node> baseNodeModel,
final IModel<Node> currentNodeModel,
final IBrowseService browser,
final IBrowseService<IModel<Node>> browser,
final DiffService diffService,
final IHtmlCleanerService cleaner) {
super(id);
......@@ -103,14 +103,14 @@ public class RichTextDiffWithLinksAndImagesPanel extends AbstractRichTextDiffPan
return new HtmlDiffModel(scriptlessBase, scriptlessCurrent, diffService);
}
private static JcrPropertyValueModel getContentModelOrNull(final IModel<Node> nodeModel) {
private static JcrPropertyValueModel<String> getContentModelOrNull(final IModel<Node> nodeModel) {
final Node node = nodeModel.getObject();
try {
if (node == null) {
return null;
}
final Property prop = node.getProperty(HippoStdNodeType.HIPPOSTD_CONTENT);
return new JcrPropertyValueModel(new JcrPropertyModel(prop));
return new JcrPropertyValueModel<>(new JcrPropertyModel(prop));
} catch (final RepositoryException e) {
log.error("Cannot read HTML content from '" + JcrUtils.getNodePathQuietly(node) + "'", e);
}
......
......@@ -38,7 +38,7 @@ public class RichTextPreviewWithLinksAndImagesPanel extends AbstractRichTextView
public RichTextPreviewWithLinksAndImagesPanel(final String id,
final IModel<Node> nodeModel,
final IModel<String> htmlModel,
final IBrowseService browser,
final IBrowseService<IModel<Node>> browser,
final IHtmlCleanerService cleaner) {
super(id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment