@Override public String getActiveItem() { if (activeItemName == null) { Resource active = resource.getChild(activeItem); if (active != null) { activeItemName = activeItem; } } return activeItemName; } }
public List<Rendition> getRenditions(Asset asset) { Resource renditions = frozenResource.getChild(RENDITIONS_PATH); if (renditions == null) { return Lists.newArrayList(); } List<Rendition> rv = Lists.newArrayList(); for (Resource r : renditions.getChildren()) { rv.add(getRendition(asset, r.getName())); } return rv; }
public Map<String, Object> getMetadata() { Resource meta = frozenResource.getChild(METADATA_PATH); if (meta == null) { return null; } return meta.getValueMap(); }
public Workspace getWorkspace() { // Collecting workspace on get to avoid cyclic recursion between models if (this.workspace == null) { this.workspace = this.resource.getChild(Workspace.NN_WORKSPACE).adaptTo(Workspace.class); } return this.workspace; }
@Override public boolean hasContents(final Resource resource, final int index) { final Resource parResource = resource.getChild(LONG_FORM_TEXT_PAR + index); return parResource != null && parResource.listChildren().hasNext(); }
protected static boolean isThumbnailAutomatic(Resource damFolder) { if (isThumbnailManual(damFolder)) { return false; } else if (damFolder.getChild("jcr:content/folderThumbnail") != null) { scanResult.set("Detected automatic thumbnail and no manual thumbnail"); return true; } return false; } }
public Rendition getRendition(Asset asset, String name) { Resource r = frozenResource.getChild(pathJoiner.join(RENDITIONS_PATH, name)); if (r == null) { return null; } return FrozenRendition.createFrozenRendition(asset, r); }
/** * Returns the value of calling <code>getChild</code> on the * {@link #getResource() wrapped resource}. * * @since 2.1.0 (Sling API Bundle 2.1.0) */ @Override public Resource getChild(String relPath) { return getResource().getChild(relPath); }
/** * Creates a new collection from the given resource * * @param resource the resource */ public ResourceCollectionImpl(Resource resource) { this.resource = resource; resolver = resource.getResourceResolver(); membersResource = resource.getChild(ResourceCollectionConstants.MEMBERS_NODE_NAME); }
/** * Constructor * @param resource resource upon which this model is constructed */ public PipeModel(Resource resource) { currentResource = resource; LOG.debug("constructing Pipe Model with {}", currentResource.getPath()); root = resource.getChild(NN_PIPES); }
@Override public String getStatus(Resource pipeResource) { Resource statusResource = pipeResource.getChild(PN_STATUS); if (statusResource != null){ String status = statusResource.adaptTo(String.class); if (StringUtils.isNotBlank(status)){ return status; } } return STATUS_FINISHED; }
@Override public boolean hasContents(final Resource resource, final int index) { final Resource parResource = resource.getChild(LONG_FORM_TEXT_PAR + index); return parResource != null && parResource.listChildren().hasNext(); }
private ValueMap getProperties(final SlingHttpServletRequest request) { if (request.getResource().getChild("configuration") == null) { log.warn("ACL Packager Configuration node could not be found for: {}", request.getResource()); return new ValueMapDecorator(new HashMap<String, Object>()); } else { return request.getResource().getChild("configuration").adaptTo(ValueMap.class); } }
public static Product getProduct(Resource resource) { Product product = mock(Product.class); when(product.getPath()).thenReturn(resource.getPath()); Resource image = resource.getChild("image"); if (image != null) { ImageResource imageResource = new ImageResource(image); when(product.getImage()).thenReturn(imageResource); } return product; }
public EvolutionContextImpl(Resource resource, EvolutionConfig config) { this.resource = resource.isResourceType("cq:Page") ? resource.getChild("jcr:content") : resource; this.config = config; populateEvolutions(); }
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); }
public String getMetadataValue(final String name) { Resource meta = frozenResource.getChild(METADATA_PATH); if (meta == null) { return null; } return meta.getValueMap().get(name, String.class); }
public EvolutionContextImpl(Resource resource, EvolutionConfig config) { this.resource = resource.isResourceType("cq:Page") ? resource.getChild("jcr:content") : resource; this.config = config; populateEvolutions(); }
private Resource copy(ResourceResolver resolver, String sourcePath, Resource destParent) throws PersistenceException { Resource source = resolver.getResource(sourcePath); Map<String, Object> properties = Maps.newHashMap(source.getValueMap()); properties.remove(JcrConstants.JCR_UUID); Resource dest = resolver.create(destParent, source.getName(), properties); if (source.getChild(JcrConstants.JCR_CONTENT) != null) { copy(resolver, sourcePath + "/" + JcrConstants.JCR_CONTENT, dest); } return dest; }
public void addFailure(String payloadPath, String trackPath, Calendar failedAt) throws RepositoryException { Node failure = JcrUtils.getOrCreateByPath(resource.getChild(Workspace.NN_FAILURES).adaptTo(Node.class), Workspace.NN_FAILURE, true, Workspace.NT_UNORDERED, Workspace.NT_UNORDERED, false); JcrUtil.setProperty(failure, Failure.PN_PAYLOAD_PATH, payloadPath); if (StringUtils.isNotBlank(trackPath)) { JcrUtil.setProperty(failure, Failure.PN_PATH, Payload.dereference(trackPath)); } if (failedAt != null) { JcrUtil.setProperty(failure, Failure.PN_FAILED_AT, failedAt); } }