/** * Implements check whether to apply drag&drop support as described in {@link DragDropSupport}. * @param mediaRequest Media request * @param wcmComponentContext WCM component context * @return true if drag&droup can be applied. */ public static boolean canApplyDragDropSupport(@NotNull MediaRequest mediaRequest, @Nullable ComponentContext wcmComponentContext) { switch (mediaRequest.getMediaArgs().getDragDropSupport()) { case ALWAYS: return true; case NEVER: return false; case AUTO: String resourcePath = null; if (mediaRequest.getResource() != null) { resourcePath = mediaRequest.getResource().getPath(); } String componentResourcePath = null; if (wcmComponentContext != null && wcmComponentContext.getResource() != null) { componentResourcePath = wcmComponentContext.getResource().getPath(); } return resourcePath != null && StringUtils.equals(resourcePath, componentResourcePath); default: throw new IllegalArgumentException("Unsupported drag&drop support mode: " + mediaRequest.getMediaArgs().getDragDropSupport()); } }