private Optional<String> getMediaDropTargetID() { return componentContext.getEditContext().getEditConfig().getDropTargets().values().stream() .filter(item -> ArrayUtils.contains(item.getGroups(), "media")) .map(item -> item.getId()) .findFirst(); }
private boolean isDroppable(Component component) { return component.isEditable() && (!component.getComponentGroup().equals(GROUP_HIDDEN)); }
@Override public String getCssClassNames() { Set<String> cssClassesSet = componentContext.getCssClassNames(); return StringUtils.join(cssClassesSet, " "); }
private Optional<String> addMediaDroptarget(String refProperty, String cropProperty, String rotationProperty, String name) { Component componentDefinition = WCMUtils.getComponent(resource); // set drop target - with path of current component as default resource type Map<String, String> params = new HashMap<String, String>(); if (componentDefinition != null) { params.put("./" + ResourceResolver.PROPERTY_RESOURCE_TYPE, componentDefinition.getPath()); // clear cropping parameters if a new image is inserted via drag&drop params.put(cropProperty, ""); params.put(rotationProperty, ""); } DropTarget dropTarget = new DropTargetImpl(name, refProperty).setAccept(new String[] { "image/.*" // allow all image mime types }).setGroups(new String[] { "media" // allow drop from DAM contentfinder tab }).setParameters(params); componentContext.getEditContext().getEditConfig().getDropTargets().put(dropTarget.getId(), dropTarget); return Optional.of(dropTarget.getId()); }
private Component findUrlFilterDefinitionComponent(Component component) { if (component == null) { return null; } ValueMap properties = component.getProperties(); // Collections.disjoint returns true if the collections // have nothing in common, so when it is false, use the current resource if (!Collections.disjoint(properties.keySet(), PROPERTY_NAMES)) { return component; } else { // otherwise, look at the resource type resource's super type return findUrlFilterDefinitionComponent(component.getSuperComponent()); } }
Component component = componentManager.getComponent(resourceType); if (component != null) { return component.getPath();
private boolean isPageType(Component component) { if (component == null) { return false; } else if (ArrayUtils.contains(pageTypes, component.getResourceType())) { return true; } else { return isPageType(component.getSuperComponent()); } } }
ComponentEditConfig editConfig = component.getEditConfig(); Map<String, DropTarget> dropTargets = (editConfig != null) ? editConfig.getDropTargets() : null; if (StringUtils.equals(name, dropTarget.getName())) { break; } else { String classNames = dropTarget.getId() + " " + editType.getCssClass(); String placeholderTitle = "Drop Target: " + dropTarget.getName();
private static String doRender(Resource resource, String requestMethod, String requestExtension, SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { SynthesizedSlingHttpServletRequest synthesizedRequest = new SynthesizedSlingHttpServletRequest(request) .setMethod(requestMethod) .setExtension(requestExtension) .setResource(resource); RequestDispatcherOptions rdo = new RequestDispatcherOptions(); IncludeOptions.getOptions(synthesizedRequest, true).setDecorationTagName(""); // @ROCK SOLID MAGIC .. remove decoration <div> by setting it to "" empty string StringResponseWrapper responseWrapper = new StringResponseWrapper(response); RequestDispatcher requestDispatcher = request.getRequestDispatcher(resource, rdo); requestDispatcher.include(synthesizedRequest, responseWrapper); return responseWrapper.getString(); }
private Component findUrlFilterDefinitionComponent(Resource resource, ComponentManager componentManager) { if (resource == null) { return null; } Resource contentResource = resource.getChild("jcr:content"); if (contentResource != null) { resource = contentResource; } Component component = componentManager.getComponentOfResource(resource); return findUrlFilterDefinitionComponent(component); }
@Override public final void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { final WCMMode mode = WCMMode.fromRequest(request); final IncludeOptions includeOptions = IncludeOptions.getOptions(request, true); // Only execute in Publish mode if (false && includeOptions != null && ((mode == null || WCMMode.DISABLED.equals(mode)))) { // Disable CQ Decoration on cq:includes or sling:includes, only in Publish mode includeOptions.setDecorationTagName(""); } // Finally, proceed with the the Filter chain chain.doFilter(request, response); }
/** * Get the current page. * * @param adaptable a SlingHttpServletRequest * @return the current Page if the adaptable was a SlingHttpServletRequest, null otherwise */ public static Page getCurrentPage(Object adaptable) { ComponentContext context = getComponentContext(adaptable); return (context != null) ? context.getPage() : null; }
/** * Determine if a component has a Touch UI dialog for shared or global configs. */ private boolean componentHasTouchDialog(Component component, String dialogName) { Resource dialog = component.getLocalResource(dialogName); return dialog != null && dialog.isResourceType("cq/gui/components/authoring/dialog"); }
/** * Get the current style. * * @param adaptable a SlingHttpServletRequest * @return the current Style if the adaptable was a SlingHttpServletRequest, null otherwise */ private Style getCurrentStyle(Object adaptable) { Design currentDesign = getCurrentDesign(adaptable); ComponentContext componentContext = getComponentContext(adaptable); if (currentDesign != null && componentContext != null) { return currentDesign.getStyle(componentContext.getCell()); } return null; }
private Component findUrlFilterDefinitionComponent(Component component) { if (component == null) { return null; } ValueMap properties = component.getProperties(); // Collections.disjoint returns true if the collections // have nothing in common, so when it is false, use the current resource if (!Collections.disjoint(properties.keySet(), PROPERTY_NAMES)) { return component; } else { // otherwise, look at the resource type resource's super type return findUrlFilterDefinitionComponent(component.getSuperComponent()); } }
private Component findUrlFilterDefinitionComponent(Resource resource, ComponentManager componentManager) { if (resource == null) { return null; } Resource contentResource = resource.getChild("jcr:content"); if (contentResource != null) { resource = contentResource; } Component component = componentManager.getComponentOfResource(resource); return findUrlFilterDefinitionComponent(component); }
/** * Get the current page. * * @param adaptable a SlingHttpServletRequest * @return the current Page if the adaptable was a SlingHttpServletRequest, null otherwise */ private Page getCurrentPage(Object adaptable) { ComponentContext context = getComponentContext(adaptable); return (context != null) ? context.getPage() : null; }
/** * Determine if a component has a Classic UI dialog for shared or global configs. */ private boolean componentHasClassicDialog(Component component, String dialogName) throws RepositoryException { Resource dialog = component.getLocalResource(dialogName); return dialog != null && dialog.adaptTo(Node.class).isNodeType("cq:Dialog"); }
/** * Get the current style. * * @param adaptable a SlingHttpServletRequest * @return the current Style if the adaptable was a SlingHttpServletRequest, null otherwise */ public static Style getCurrentStyle(Object adaptable) { Design currentDesign = getCurrentDesign(adaptable); ComponentContext componentContext = getComponentContext(adaptable); if (currentDesign != null && componentContext != null) { return currentDesign.getStyle(componentContext.getCell()); } return null; }
public String getName() { Page currentPage = WCMUtils.getComponentContext(request).getPage(); return currentPage.getTitle(); } }