public class ReferenceSearch
extends java.lang.Object
ReferenceSearch
provides methods that search references to
resources (e.g. a path in a property to an image)Modifier and Type | Class and Description |
---|---|
static class |
ReferenceSearch.Info
Holds information about the search results
|
Constructor and Description |
---|
ReferenceSearch() |
Modifier and Type | Method and Description |
---|---|
java.util.Collection<java.lang.String> |
adjustReferences(Node node,
java.lang.String path,
java.lang.String destination)
Adjusts all references to
path to destination
in the properties below the specified node . |
java.util.Collection<java.lang.String> |
adjustReferences(Node node,
java.lang.String path,
java.lang.String destination,
boolean shallow,
java.util.Set<java.lang.String> excludedProperties)
Adjusts all references to
path to destination
in the properties below the specified node . |
java.util.Collection<java.lang.String> |
adjustReferences(ResourceResolver resolver,
java.lang.String path,
java.lang.String destination,
java.lang.String[] refPaths)
Adjusts all references to
path to destination
in the pages specified by refPaths . |
static java.lang.String |
escapeIllegalXpathSearchChars(java.lang.String s)
Escapes illegal XPath search characters.
|
int |
getMaxReferencesPerPage()
Returns the maximum number of references that can be added to a page info.
|
java.lang.String |
getSearchRoot()
Returns the search root.
|
boolean |
isExact()
Returns the shallow flag.
|
boolean |
isHollow()
Returns the
hollow flag. |
java.util.Map<java.lang.String,ReferenceSearch.Info> |
search(ResourceResolver resolver,
java.lang.String path)
Searches for references to the given path.
|
ReferenceSearch |
setExact(boolean exact)
Sets the
exact flag. |
ReferenceSearch |
setHollow(boolean hollow)
Sets the
hollow flag. |
ReferenceSearch |
setMaxReferencesPerPage(int maxReferencesPerPage)
Sets the value of
maxReferencesPerPage . |
ReferenceSearch |
setPredicate(AbstractResourcePredicate resourcePredicate)
Set the
resourcePredicate , this predicate is evaluated for
each search result and can be used to filter results. |
ReferenceSearch |
setRepository(SlingRepository repository)
Deprecated.
The repository was used by the implementation to create an administrative session in
adjustReferences(ResourceResolver, String, String, String[]) . Instead, specify a resource resolver
which is sufficiently authorized to adjust references at the desired locations. |
ReferenceSearch |
setSearchRoot(java.lang.String searchRoot)
Sets the search root
|
public ReferenceSearch setRepository(SlingRepository repository)
adjustReferences(ResourceResolver, String, String, String[])
. Instead, specify a resource resolver
which is sufficiently authorized to adjust references at the desired locations.repository
- The repositorypublic java.lang.String getSearchRoot()
public ReferenceSearch setSearchRoot(java.lang.String searchRoot)
searchRoot
- the search rootpublic boolean isExact()
setExact(boolean)
public ReferenceSearch setExact(boolean exact)
exact
flag. If true
only exact
references are searched (and replaced). otherwise also references to
child resources are included.exact
- true
if perform an exact searchpublic boolean isHollow()
hollow
flag.hollow
flag.setHollow(boolean)
public ReferenceSearch setHollow(boolean hollow)
hollow
flag. If true
the returned info will contain only properties of the page
and not the page object itself.hollow
- true
if perform a hollow searchpublic int getMaxReferencesPerPage()
setMaxReferencesPerPage(int)
public ReferenceSearch setMaxReferencesPerPage(int maxReferencesPerPage)
maxReferencesPerPage
.
The maximum number of references that can be added to a page info.maxReferencesPerPage
- The maximum number of references that can be added to a page info.public ReferenceSearch setPredicate(AbstractResourcePredicate resourcePredicate)
resourcePredicate
, this predicate is evaluated for
each search result and can be used to filter results.resourcePredicate
- an instance of AbstractResourcePredicate
public java.util.Map<java.lang.String,ReferenceSearch.Info> search(ResourceResolver resolver, java.lang.String path)
resolver
- the resource resolverpath
- the path to search forpublic java.util.Collection<java.lang.String> adjustReferences(ResourceResolver resolver, java.lang.String path, java.lang.String destination, java.lang.String[] refPaths)
Adjusts all references to path
to destination
in the pages specified by refPaths
. If isExact()
is true
only exact references to path
are
adjusted, otherwise all references to child resources are adjusted, too.
The resource resolver needs to have sufficient permissions (i.e. jcr:read
and
rep:alterProperties
) on the nodes containing references.
resolver
- resolver to operate on.path
- source pathdestination
- destination pathrefPaths
- paths of pages to be adjustedpublic java.util.Collection<java.lang.String> adjustReferences(Node node, java.lang.String path, java.lang.String destination) throws RepositoryException
path
to destination
in the properties below the specified node
. If isExact()
is true
only exact references to path
are
adjusted, otherwise all references to child resources are adjusted, too.node
- (content) node to traversepath
- source pathdestination
- destination pathRepositoryException
- if an error during repository access occurspublic java.util.Collection<java.lang.String> adjustReferences(Node node, java.lang.String path, java.lang.String destination, boolean shallow, java.util.Set<java.lang.String> excludedProperties) throws RepositoryException
path
to destination
in the properties below the specified node
. If isExact()
is true
only exact references to path
are
adjusted, otherwise all references to child resources are adjusted, too.node
- (content) node to adjustpath
- source pathdestination
- destination pathshallow
- if true
child nodes are not traversedexcludedProperties
- a set of excluded property namesRepositoryException
- if an error during repository access occurspublic static java.lang.String escapeIllegalXpathSearchChars(java.lang.String s)
s
- the string to encodeCopyright © 2010 - 2020 Adobe. All Rights Reserved