org.apache.sling.api.resource.Resource.getChild()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中org.apache.sling.api.resource.Resource.getChild方法的一些代码示例,展示了Resource.getChild的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resource.getChild方法的具体详情如下:
包路径:org.apache.sling.api.resource.Resource
类名称:Resource
方法名:getChild

Resource.getChild介绍

[英]Returns the child at the given relative path of this resource or null if no such child exists.

This method is a convenience and returns exactly the same resources as calling getResourceResolver().getResource(resource, relPath).
[中]返回此资源的给定相对路径处的子项,如果不存在此类子项,则返回null
此方法非常方便,返回的资源与调用getResourceResolver().getResource(resource, relPath)时完全相同。

代码示例

代码示例来源:origin: adobe/aem-core-wcm-components

@Override
  public String getActiveItem() {
    if (activeItemName == null) {
      Resource active = resource.getChild(activeItem);
      if (active != null) {
        activeItemName = activeItem;
      }
    }
    return activeItemName;
  }
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

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;
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

public Map<String, Object> getMetadata() {
  Resource meta = frozenResource.getChild(METADATA_PATH);
  if (meta == null) {
    return null;
  }
  return meta.getValueMap();
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

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;
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

@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();
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

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;
  }
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

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);
}

代码示例来源:origin: org.apache.sling/org.apache.sling.api

/**
 * 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);
}

代码示例来源:origin: org.apache.sling/org.apache.sling.resourcecollection

/**
 * 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);
}

代码示例来源:origin: org.apache.sling/org.apache.sling.pipes

/**
 * 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);
}

代码示例来源:origin: org.apache.sling/org.apache.sling.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;
}

代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle

@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();
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

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);
  }
}

代码示例来源:origin: adobe/aem-core-wcm-components

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;
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

public EvolutionContextImpl(Resource resource, EvolutionConfig config) {
  this.resource = resource.isResourceType("cq:Page") ? resource.getChild("jcr:content") : resource;
  this.config = config;
  populateEvolutions();
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

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);
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

public String getMetadataValue(final String name) {
  Resource meta = frozenResource.getChild(METADATA_PATH);
  if (meta == null) {
    return null;
  }
  return meta.getValueMap().get(name, String.class);
}

代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle

public EvolutionContextImpl(Resource resource, EvolutionConfig config) {
  this.resource = resource.isResourceType("cq:Page") ? resource.getChild("jcr:content") : resource;
  this.config = config;
  populateEvolutions();
}

代码示例来源:origin: com.cognifide.cq/cqsm-bundle

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;
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

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);
  }
}

相关文章