Package com.composum.sling.nodes.browser
Class Browser
- java.lang.Object
-
- com.composum.sling.core.AbstractSlingBean
-
- com.composum.sling.core.AbstractServletBean
-
- com.composum.sling.nodes.console.ConsoleServletBean
-
- com.composum.sling.nodes.browser.Browser
-
- All Implemented Interfaces:
RestrictedBean
,SlingBean
public class Browser extends ConsoleServletBean
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
Browser.NodeHandle
a JSP bean for a node (for the current node)static class
Browser.Reference
-
Nested classes/interfaces inherited from class com.composum.sling.core.AbstractSlingBean
AbstractSlingBean.NodeClosure
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_MIME_TYPE
static Map<String,String>
EDITOR_MODES
static Map<String,String>
FILE_ICONS
static String
HTML
static String
JSP
static String
OAK_RESOURCE
static String
PDF
static String
PROP_DATA
static String
PROP_MIME_TYPE
static Pattern
SETUP_SCRIPT_PATTERN
static String
TYPE_FILE
static String
TYPE_RESOURCE
static String
TYPE_UNSTRUCTURED
-
Fields inherited from class com.composum.sling.core.AbstractSlingBean
context, queryManager, request, resolver, resource, response, session, sling
-
-
Constructor Summary
Constructors Constructor Description Browser()
Browser(BeanContext context)
Browser(BeanContext context, org.apache.sling.api.resource.Resource resource)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull Collection<SceneConfigurations.Config>
getAvailableScenes()
String
getBasePath()
Browser.NodeHandle
getCurrent()
Returns a JSP handle of the node displayed currently by the browser.String
getCurrentPathUrl()
Returns a URL to the current nodes View based on the nodes path (without mapping).String
getCurrentUrl()
Returns a URL to the current nodes View with mapping according to the configuration.String
getEditCodeUrl()
Returns a URL to the current nodes View with mapping according to the configuration.@NotNull String
getFileIcon()
static @NotNull String
getFileIcon(@NotNull ResourceHandle resource)
@NotNull String
getFilePath()
static @NotNull String
getFilePath(@NotNull ResourceHandle resource)
static @NotNull String
getFileType(Map<String,String> typeMap, String mimeType, String extension)
Determines the text type for the current node using the mimeType (if present) and the extension.String
getImageCSS()
String
getMappedUrl()
Returns a URL to the current nodes View with resolver mapping.String
getMimeType()
the content mime type declared for the current resourcestatic @NotNull String
getMimeType(@NotNull org.apache.sling.api.resource.Resource resource)
String
getName()
returns the name of the resource wrapped by this bean@NotNull String
getNameExtension()
@Nullable String
getOverlayPath()
Path of resource type within /mnt/overlay .String
getOverlayRoot()
@NotNull String
getOverridePath()
Path within /mnt/override.String
getOverrideRoot()
Browser.NodeHandle
getParent()
List<Browser.NodeHandle>
getParents()
String
getPrimaryType()
@NotNull Map<String,Browser.Reference>
getRelatedPathSet()
Set of related paths: for resource types the resource type found in the search path and /mnt/(override|overlay), base paths, resource types.@NotNull String
getResourceType()
the content resource type (sling:resourceType) declared for the current resourcestatic @Nullable String
getResourceType(@NotNull ResourceHandle resource)
protected @Nullable String
getResourceType(@Nullable String resourceType)
Remove any search path / /mnt/overlay from given path to a resource type = "normalize" path to resource type.protected @NotNull Map<String,Browser.Reference>
getResourceTypeSet()
Paths for the locations relevant to the resource typein search paths, /mnt/override / /mnt/overlay, mapped to the label information.@NotNull List<String>
getSupertypeChain()
The chain of resource super types.String
getTabType()
@NotNull String
getTextSnippet()
@NotNull String
getTextType()
Determines the text type for the current node using the mimeType (if present) and the extension.static @NotNull String
getTextType(@NotNull ResourceHandle resource)
protected @Nullable org.apache.sling.api.resource.Resource
getTypeResource(@Nullable String resourceType, boolean includeOverlay)
Returns the resource for a resourceType (the "highest" in the search path), or the resource if the path is absolute.protected Map<String,Browser.Reference>
getTypeRootLabels()
protected @NotNull List<String>
getTypeSearchPath(boolean includeOverlay)
String
getViewType()
boolean
isAsset()
boolean
isCaConfigRelevant()
boolean
isCanHaveAcl()
boolean
isDeclaringType()
boolean
isFile()
static boolean
isFile(@NotNull ResourceHandle resource)
boolean
isImage()
boolean
isJcrResource()
boolean
isMergedResource()
boolean
isOverlayAvailable()
boolean
isOverlayResource()
boolean
isOverrideAvailable()
boolean
isOverrideResource()
boolean
isRenderable()
static boolean
isRenderable(@NotNull ResourceHandle resource, @Nullable String extension)
boolean
isSceneAvailable()
boolean
isSetupScript()
boolean
isSourcePath()
boolean
isText()
static boolean
isText(@NotNull ResourceHandle resource)
boolean
isTyped()
returns 'true' if the current resource has a well known resource typeboolean
isVersionable()
boolean
isVideo()
InputStream
openFile()
-
Methods inherited from class com.composum.sling.nodes.console.ConsoleServletBean
initialize
-
Methods inherited from class com.composum.sling.core.AbstractServletBean
initialize
-
Methods inherited from class com.composum.sling.core.AbstractSlingBean
executeQuery, findBeans, findNodes, findNodes, findPathList, getContentResource, getDomId, getHasTitle, getId, getInherited, getInherited, getNode, getParent, getParent, getPath, getPermissible, getProperty, getProperty, getQueryManager, getRequest, getResolver, getResource, getResponse, getServiceKey, getSession, getSling, getStringId, getTitle, getType, getUrl, getUsername, isPermissible, isReadAllowed, isWriteAllowed, toString, toString
-
-
-
-
Field Detail
-
TYPE_FILE
public static final String TYPE_FILE
- See Also:
- Constant Field Values
-
TYPE_RESOURCE
public static final String TYPE_RESOURCE
- See Also:
- Constant Field Values
-
OAK_RESOURCE
public static final String OAK_RESOURCE
- See Also:
- Constant Field Values
-
TYPE_UNSTRUCTURED
public static final String TYPE_UNSTRUCTURED
- See Also:
- Constant Field Values
-
HTML
public static final String HTML
- See Also:
- Constant Field Values
-
JSP
public static final String JSP
- See Also:
- Constant Field Values
-
PDF
public static final String PDF
- See Also:
- Constant Field Values
-
PROP_DATA
public static final String PROP_DATA
- See Also:
- Constant Field Values
-
PROP_MIME_TYPE
public static final String PROP_MIME_TYPE
- See Also:
- Constant Field Values
-
DEFAULT_MIME_TYPE
public static final String DEFAULT_MIME_TYPE
- See Also:
- Constant Field Values
-
SETUP_SCRIPT_PATTERN
public static final Pattern SETUP_SCRIPT_PATTERN
-
-
Constructor Detail
-
Browser
public Browser(BeanContext context, org.apache.sling.api.resource.Resource resource)
-
Browser
public Browser(BeanContext context)
-
Browser
public Browser()
-
-
Method Detail
-
getPrimaryType
public String getPrimaryType()
-
isTyped
public boolean isTyped()
returns 'true' if the current resource has a well known resource type
-
isDeclaringType
public boolean isDeclaringType()
- Returns:
- 'true' if the current resource itself declares a resource type
-
isSourcePath
public boolean isSourcePath()
- Returns:
- 'true' if the current resource itself 'implements' a resource type
-
getResourceType
@NotNull public @NotNull String getResourceType()
the content resource type (sling:resourceType) declared for the current resource
-
getResourceType
@Nullable public static @Nullable String getResourceType(@NotNull @NotNull ResourceHandle resource)
-
getResourceType
@Nullable protected @Nullable String getResourceType(@Nullable @Nullable String resourceType)
Remove any search path / /mnt/overlay from given path to a resource type = "normalize" path to resource type.
-
getTypeResource
@Nullable protected @Nullable org.apache.sling.api.resource.Resource getTypeResource(@Nullable @Nullable String resourceType, boolean includeOverlay)
Returns the resource for a resourceType (the "highest" in the search path), or the resource if the path is absolute.
-
getTypeSearchPath
@NotNull protected @NotNull List<String> getTypeSearchPath(boolean includeOverlay)
-
getSupertypeChain
@NotNull public @NotNull List<String> getSupertypeChain()
The chain of resource super types. This is also included for content resources since this is used quite often in AEM.- See Also:
- "https://experienceleague.adobe.com/docs/experience-manager-65/developing/introduction/the-basics.html?lang=en#sling-request-processing"
-
getResourceTypeSet
@NotNull protected @NotNull Map<String,Browser.Reference> getResourceTypeSet()
Paths for the locations relevant to the resource typein search paths, /mnt/override / /mnt/overlay, mapped to the label information.
-
getRelatedPathSet
@NotNull public @NotNull Map<String,Browser.Reference> getRelatedPathSet()
Set of related paths: for resource types the resource type found in the search path and /mnt/(override|overlay), base paths, resource types.
-
getBasePath
public String getBasePath()
-
getOverlayRoot
public String getOverlayRoot()
-
isOverlayResource
public boolean isOverlayResource()
-
isOverlayAvailable
public boolean isOverlayAvailable()
-
getOverlayPath
@Nullable public @Nullable String getOverlayPath()
Path of resource type within /mnt/overlay . If not a declaring resource, this doesn't make sense -> null.
-
getOverrideRoot
public String getOverrideRoot()
-
isOverrideResource
public boolean isOverrideResource()
-
isOverrideAvailable
public boolean isOverrideAvailable()
-
getOverridePath
@NotNull public @NotNull String getOverridePath()
Path within /mnt/override.
-
getTypeRootLabels
protected Map<String,Browser.Reference> getTypeRootLabels()
-
isSceneAvailable
public boolean isSceneAvailable()
-
getAvailableScenes
@NotNull public @NotNull Collection<SceneConfigurations.Config> getAvailableScenes()
-
isRenderable
public boolean isRenderable()
-
isRenderable
public static boolean isRenderable(@NotNull @NotNull ResourceHandle resource, @Nullable @Nullable String extension)
-
isFile
public boolean isFile()
-
isFile
public static boolean isFile(@NotNull @NotNull ResourceHandle resource)
-
getFilePath
@NotNull public @NotNull String getFilePath()
-
getFilePath
@NotNull public static @NotNull String getFilePath(@NotNull @NotNull ResourceHandle resource)
-
getFileIcon
@NotNull public @NotNull String getFileIcon()
-
getFileIcon
@NotNull public static @NotNull String getFileIcon(@NotNull @NotNull ResourceHandle resource)
-
openFile
public InputStream openFile()
-
isAsset
public boolean isAsset()
-
isImage
public boolean isImage()
-
getImageCSS
public String getImageCSS()
-
isVideo
public boolean isVideo()
-
isText
public boolean isText()
-
isText
public static boolean isText(@NotNull @NotNull ResourceHandle resource)
-
isMergedResource
public boolean isMergedResource()
-
isJcrResource
public boolean isJcrResource()
-
isCanHaveAcl
public boolean isCanHaveAcl()
-
isVersionable
public boolean isVersionable()
-
isCaConfigRelevant
public boolean isCaConfigRelevant()
-
isSetupScript
public boolean isSetupScript()
-
getTextSnippet
@NotNull public @NotNull String getTextSnippet()
-
getNameExtension
@NotNull public @NotNull String getNameExtension()
-
getTextType
@NotNull public @NotNull String getTextType()
Determines the text type for the current node using the mimeType (if present) and the extension.
-
getTextType
@NotNull public static @NotNull String getTextType(@NotNull @NotNull ResourceHandle resource)
-
getFileType
@NotNull public static @NotNull String getFileType(Map<String,String> typeMap, String mimeType, String extension)
Determines the text type for the current node using the mimeType (if present) and the extension.- Returns:
- the type of the text file (script language) or ""
-
getViewType
public String getViewType()
-
getTabType
public String getTabType()
-
getName
public String getName()
Description copied from interface:SlingBean
returns the name of the resource wrapped by this bean- Specified by:
getName
in interfaceSlingBean
- Overrides:
getName
in classAbstractSlingBean
-
getCurrent
public Browser.NodeHandle getCurrent()
Returns a JSP handle of the node displayed currently by the browser.
-
getCurrentPathUrl
public String getCurrentPathUrl()
Returns a URL to the current nodes View based on the nodes path (without mapping).
-
getMappedUrl
public String getMappedUrl()
Returns a URL to the current nodes View with resolver mapping.
-
getCurrentUrl
public String getCurrentUrl()
Returns a URL to the current nodes View with mapping according to the configuration.
-
getEditCodeUrl
public String getEditCodeUrl()
Returns a URL to the current nodes View with mapping according to the configuration.
-
getMimeType
public String getMimeType()
the content mime type declared for the current resource
-
getMimeType
@NotNull public static @NotNull String getMimeType(@NotNull @NotNull org.apache.sling.api.resource.Resource resource)
-
getParent
public Browser.NodeHandle getParent()
-
getParents
public List<Browser.NodeHandle> getParents()
-
-