org.apache.sling.api.resource.ResourceMetadata Java Examples
The following examples show how to use
org.apache.sling.api.resource.ResourceMetadata.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RelationTypesDataSourceServlet.java From aem-core-cif-components with Apache License 2.0 | 7 votes |
@Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { ResourceBundle resourceBundle = request.getResourceBundle(null); List<Resource> values = new ArrayList<>(); for (RelationType relationType : RelationType.values()) { ValueMap vm = new ValueMapDecorator(new HashMap<String, Object>()); vm.put("value", relationType); vm.put("text", toText(resourceBundle, relationType.getText())); values.add(new ValueMapResource(request.getResourceResolver(), new ResourceMetadata(), JcrConstants.NT_UNSTRUCTURED, vm)); } DataSource ds = new SimpleDataSource(values.iterator()); request.setAttribute(DataSource.class.getName(), ds); }
Example #2
Source File: CacheableResource.java From sling-whiteboard with Apache License 2.0 | 5 votes |
public CacheableResource(RemoteStorageProvider remoteStorageProvider, RemoteResourceReference remoteResourceReference, String path, Map<String, Object> properties) { this.remoteStorageProvider = remoteStorageProvider; this.remoteResourceReference = remoteResourceReference; this.path = path; resourceType = Optional.of((String) properties.get(ResourceResolver.PROPERTY_RESOURCE_TYPE)).orElse(NT_UNSTRUCTURED); resourceSuperType = (String) properties.get(SlingConstants.NAMESPACE_PREFIX + ":" + SlingConstants.PROPERTY_RESOURCE_SUPER_TYPE); valueMap = new ValueMapDecorator(Collections.unmodifiableMap(properties)); resourceMetadata = new ResourceMetadata(); resourceMetadata.setCreationTime(remoteResourceReference.getCreated()); resourceMetadata.setModificationTime(remoteResourceReference.getLastModified()); if (remoteResourceReference.getType() == RemoteResourceReference.Type.FILE) { resourceMetadata.setContentLength(remoteResourceReference.getSize()); } }
Example #3
Source File: SlingQueryImplicitStrategyCheck.java From AEM-Rules-for-SonarQube with Apache License 2.0 | 5 votes |
public void testVer2() { this.variable = Optional.of(resource.getResourceMetadata()) .map(metadata -> metadata.get(ResourceMetadata.RESOLUTION_PATH)) .filter(String.class::isInstance) .map(String::valueOf) .map(path -> resource.getResourceResolver().getResource(path)) .map(r -> $(r).find(SOMETHING).asList()) // Noncompliant .map(list -> list.get(0)); }
Example #4
Source File: SlingQueryImplicitStrategyCheck.java From AEM-Rules-for-SonarQube with Apache License 2.0 | 5 votes |
public void testVer1() { this.variable = Optional.of(resource.getResourceMetadata()) .map(metadata -> metadata.get(ResourceMetadata.RESOLUTION_PATH)) .filter(String.class::isInstance) .map(String::valueOf) .map(path -> resource.getResourceResolver().getResource(path)) .map(r -> $(r).searchStrategy(SearchStrategy.QUERY).find(SOMETHING).asList()) .map(list -> list.get(0)); }
Example #5
Source File: SimpleDataSourceBuilder.java From APM with Apache License 2.0 | 5 votes |
private Resource createDataSourceItem(ResourceResolver resolver, String name, String value) { Map<String, Object> valueMap = ImmutableMap.of( CONFIGURATION_NAME_PROP, name, CONFIGURATION_PATH_PROP, value ); ValueMapDecorator result = new ValueMapDecorator(valueMap); return new ValueMapResource(resolver, new ResourceMetadata(), JcrConstants.NT_RESOURCE, result); }
Example #6
Source File: MarkdownResource.java From sling-whiteboard with Apache License 2.0 | 5 votes |
private ResourceMetadata getResourceMetadata0() { if ( !backingFile.exists() || !backingFile.canRead() ) { return null; } ResourceMetadata metadata = new ResourceMetadata(); metadata.setModificationTime(backingFile.lastModified()); metadata.setResolutionPath(path); return metadata; }
Example #7
Source File: MarkdownResource.java From sling-whiteboard with Apache License 2.0 | 5 votes |
@Override public ResourceMetadata getResourceMetadata() { if ( metadata == null ) { metadata = getResourceMetadata0(); } return metadata; }
Example #8
Source File: CatalogIdentifierDatasource.java From commerce-cif-connector with Apache License 2.0 | 5 votes |
protected List<Resource> generateResources(ResourceResolver resolver, List<String> properties) { return properties.stream().map(property -> { Map<String, Object> resourceProperties = new HashMap<String, Object>() { { put("text", property); put("value", property); } }; ValueMapResource syntheticResource = new ValueMapResource(resolver, new ResourceMetadata(), "", new ValueMapDecorator( resourceProperties)); return syntheticResource; }).collect(Collectors.toList()); }
Example #9
Source File: MockResource.java From sling-whiteboard with Apache License 2.0 | 5 votes |
public MockResource(ResourceResolver resolver, String path) { this.resolver = resolver; this.path = path; this.metadata = new ResourceMetadata(); metadata.put(ResourceMetadata.RESOLUTION_PATH, path); metadata.put(ResourceMetadata.RESOLUTION_PATH_INFO, path); }
Example #10
Source File: FileResource.java From sling-whiteboard with Apache License 2.0 | 5 votes |
public FileResource(final ResourceResolver resourceResolver, final String path, final File file) { this.resolver = resourceResolver; this.path = path; this.file = file; this.metadata = new ResourceMetadata(); this.metadata.setModificationTime(file.lastModified()); this.metadata.setResolutionPath(path); if (file.isFile()) { this.metadata.setContentLength(file.length()); } }
Example #11
Source File: TagsResource.java From sling-samples with Apache License 2.0 | 5 votes |
private TagsResource(ResourceResolver resolver, String path, String[] tags) { this.path = path; this.metadata = new ResourceMetadata(); this.metadata.setResolutionPath(path); this.resolver = resolver; properties.put("tags", tags); }
Example #12
Source File: MockResource.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override public ResourceMetadata getResourceMetadata() { return metadata; }
Example #13
Source File: MvResource.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override public ResourceMetadata getResourceMetadata() { return metaData; }
Example #14
Source File: CacheableResource.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override @NotNull public ResourceMetadata getResourceMetadata() { return resourceMetadata; }
Example #15
Source File: CacheableResourceWrapper.java From sling-whiteboard with Apache License 2.0 | 4 votes |
CacheableResourceWrapper(@NotNull ResolveContext<RemoteResourceProviderContext> context, @NotNull CacheableResource resource) { super(resource); this.context = context; this.resource = resource; resourceMetadata = (ResourceMetadata) resource.getResourceMetadata().clone(); }
Example #16
Source File: CacheableResourceWrapper.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override @NotNull public ResourceMetadata getResourceMetadata() { return resourceMetadata; }
Example #17
Source File: FileResource.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override public ResourceMetadata getResourceMetadata() { return metadata; }
Example #18
Source File: MockResource.java From sling-samples with Apache License 2.0 | 4 votes |
@Override public ResourceMetadata getResourceMetadata() { return null; }
Example #19
Source File: TagsResource.java From sling-samples with Apache License 2.0 | 4 votes |
@Override public ResourceMetadata getResourceMetadata() { return metadata; }
Example #20
Source File: ItemResourceImpl.java From jackalope with Apache License 2.0 | 4 votes |
@Override public ResourceMetadata getResourceMetadata() { ResourceMetadata metadata = new ResourceMetadata(); metadata.setResolutionPath(getPath()); return metadata; }