Package io.wcm.wcm.ui.granite.resource
Class GraniteUiSyntheticResource
- java.lang.Object
-
- org.apache.sling.api.adapter.SlingAdaptable
-
- org.apache.sling.api.resource.AbstractResource
-
- org.apache.sling.api.resource.SyntheticResource
-
- io.wcm.wcm.ui.granite.resource.GraniteUiSyntheticResource
-
- All Implemented Interfaces:
org.apache.sling.api.adapter.Adaptable
,org.apache.sling.api.resource.Resource
@ProviderType public final class GraniteUiSyntheticResource extends org.apache.sling.api.resource.SyntheticResource
Extended version ofSyntheticResource
that allows to pass an own value map and optional child resources. Please note: Accessing child resources does only work when accessingResource.listChildren()
, and not when calling the same method on resourceResolver. This breaks the contract of the resource API, but should work at least for the Granite UI implementation which seems to always use this method.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <Type> Type
adaptTo(java.lang.Class<Type> type)
static org.apache.sling.api.resource.Resource
child(@NotNull org.apache.sling.api.resource.Resource parentResource, @NotNull java.lang.String name, @NotNull java.lang.String resourceType)
Create synthetic resource child resource of the given parent resource.static org.apache.sling.api.resource.Resource
child(@NotNull org.apache.sling.api.resource.Resource parentResource, @NotNull java.lang.String name, @NotNull java.lang.String resourceType, @NotNull org.apache.sling.api.resource.ValueMap valueMap)
Create synthetic resource child resource of the given parent resource.static void
copySubtree(@NotNull org.apache.sling.api.resource.Resource targetParent, @NotNull org.apache.sling.api.resource.Resource source)
Copy the given source resource as synthetic child under the target parent resource, including all children.static org.apache.sling.api.resource.Resource
create(@NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @NotNull org.apache.sling.api.resource.ValueMap valueMap)
Create synthetic resource.static org.apache.sling.api.resource.Resource
create(@NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @Nullable java.lang.String path, @NotNull java.lang.String resourceType)
Create synthetic resource.static org.apache.sling.api.resource.Resource
create(@NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @Nullable java.lang.String path, @NotNull java.lang.String resourceType, @NotNull org.apache.sling.api.resource.ValueMap valueMap)
Create synthetic resource.org.apache.sling.api.resource.Resource
getChild(java.lang.String relPath)
java.lang.Iterable<org.apache.sling.api.resource.Resource>
getChildren()
boolean
hasChildren()
java.util.Iterator<org.apache.sling.api.resource.Resource>
listChildren()
static org.apache.sling.api.resource.Resource
wrap(@NotNull org.apache.sling.api.resource.Resource resource)
Wrap a real resource and create a synthetic resource out of it.static org.apache.sling.api.resource.Resource
wrap(@NotNull org.apache.sling.api.resource.Resource resource, @NotNull org.apache.sling.api.resource.ValueMap valueMap)
Wrap a real resource and create a synthetic resource out of it.static org.apache.sling.api.resource.Resource
wrapMerge(@NotNull org.apache.sling.api.resource.Resource resource, @NotNull org.apache.sling.api.resource.ValueMap valueMap)
Wrap a real resource and create a synthetic resource out of it.-
Methods inherited from class org.apache.sling.api.resource.SyntheticResource
getPath, getResourceMetadata, getResourceResolver, getResourceSuperType, getResourceType, toString
-
Methods inherited from class org.apache.sling.api.resource.AbstractResource
getName, getParent, getValueMap, isResourceType
-
-
-
-
Method Detail
-
adaptTo
public <Type> Type adaptTo(java.lang.Class<Type> type)
- Specified by:
adaptTo
in interfaceorg.apache.sling.api.adapter.Adaptable
- Overrides:
adaptTo
in classorg.apache.sling.api.adapter.SlingAdaptable
-
listChildren
public java.util.Iterator<org.apache.sling.api.resource.Resource> listChildren()
- Specified by:
listChildren
in interfaceorg.apache.sling.api.resource.Resource
- Overrides:
listChildren
in classorg.apache.sling.api.resource.AbstractResource
-
getChildren
public java.lang.Iterable<org.apache.sling.api.resource.Resource> getChildren()
- Specified by:
getChildren
in interfaceorg.apache.sling.api.resource.Resource
- Overrides:
getChildren
in classorg.apache.sling.api.resource.AbstractResource
-
hasChildren
public boolean hasChildren()
- Specified by:
hasChildren
in interfaceorg.apache.sling.api.resource.Resource
- Overrides:
hasChildren
in classorg.apache.sling.api.resource.AbstractResource
-
getChild
public org.apache.sling.api.resource.Resource getChild(java.lang.String relPath)
- Specified by:
getChild
in interfaceorg.apache.sling.api.resource.Resource
- Overrides:
getChild
in classorg.apache.sling.api.resource.AbstractResource
-
create
public static org.apache.sling.api.resource.Resource create(@NotNull @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @NotNull @NotNull org.apache.sling.api.resource.ValueMap valueMap)
Create synthetic resource.- Parameters:
resourceResolver
- Resource resolvervalueMap
- Properties- Returns:
- Resource
-
create
public static org.apache.sling.api.resource.Resource create(@NotNull @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @Nullable @Nullable java.lang.String path, @NotNull @NotNull java.lang.String resourceType)
Create synthetic resource.- Parameters:
resourceResolver
- Resource resolverpath
- Resource pathresourceType
- Resource type- Returns:
- Resource
-
create
public static org.apache.sling.api.resource.Resource create(@NotNull @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @Nullable @Nullable java.lang.String path, @NotNull @NotNull java.lang.String resourceType, @NotNull @NotNull org.apache.sling.api.resource.ValueMap valueMap)
Create synthetic resource.- Parameters:
resourceResolver
- Resource resolverpath
- Resource pathresourceType
- Resource typevalueMap
- Properties- Returns:
- Resource
-
wrap
public static org.apache.sling.api.resource.Resource wrap(@NotNull @NotNull org.apache.sling.api.resource.Resource resource)
Wrap a real resource and create a synthetic resource out of it.- Parameters:
resource
- Real resource- Returns:
- Resource
-
wrap
public static org.apache.sling.api.resource.Resource wrap(@NotNull @NotNull org.apache.sling.api.resource.Resource resource, @NotNull @NotNull org.apache.sling.api.resource.ValueMap valueMap)
Wrap a real resource and create a synthetic resource out of it.- Parameters:
resource
- Real resourcevalueMap
- Properties to use instead of the real properties- Returns:
- Resource
-
wrapMerge
public static org.apache.sling.api.resource.Resource wrapMerge(@NotNull @NotNull org.apache.sling.api.resource.Resource resource, @NotNull @NotNull org.apache.sling.api.resource.ValueMap valueMap)
Wrap a real resource and create a synthetic resource out of it. Merges the given properties with the existing properties of the resource.- Parameters:
resource
- Real resourcevalueMap
- Properties to be merged with the real properties- Returns:
- Resource
-
child
public static org.apache.sling.api.resource.Resource child(@NotNull @NotNull org.apache.sling.api.resource.Resource parentResource, @NotNull @NotNull java.lang.String name, @NotNull @NotNull java.lang.String resourceType)
Create synthetic resource child resource of the given parent resource.- Parameters:
parentResource
- Parent resource (has to be aGraniteUiSyntheticResource
instance)name
- Child resource nameresourceType
- Resource type- Returns:
- Resource
-
child
public static org.apache.sling.api.resource.Resource child(@NotNull @NotNull org.apache.sling.api.resource.Resource parentResource, @NotNull @NotNull java.lang.String name, @NotNull @NotNull java.lang.String resourceType, @NotNull @NotNull org.apache.sling.api.resource.ValueMap valueMap)
Create synthetic resource child resource of the given parent resource.- Parameters:
parentResource
- Parent resource (has to be aGraniteUiSyntheticResource
instance)name
- Child resource nameresourceType
- Resource typevalueMap
- Properties- Returns:
- Resource
-
copySubtree
public static void copySubtree(@NotNull @NotNull org.apache.sling.api.resource.Resource targetParent, @NotNull @NotNull org.apache.sling.api.resource.Resource source)
Copy the given source resource as synthetic child under the target parent resource, including all children.- Parameters:
targetParent
- Target parent resourcesource
- Source resource
-
-