@Singleton public class NodeNameHelper extends Object
Constructor and Description |
---|
NodeNameHelper(MagnoliaConfigurationProperties magnoliaConfigurationProperties) |
Modifier and Type | Method and Description |
---|---|
String |
getUniqueName(javax.jcr.Node parent,
String name) |
String |
getUniqueName(javax.jcr.Session session,
String parentPath,
String name)
Checks if an item already exists with given name in JCR, and returns a unique name;
if necessary, an increment is appended to the name.
|
String |
getUniqueName(javax.jcr.Session session,
String parentPath,
String name,
String extension)
Checks if an item already exists with given name in JCR, and returns a unique name;
if necessary, an increment is inserted into the name, before the given extension.
|
String |
getValidatedName(String name)
Replace illegal characters based on magnolia property magnolia.ut8.enabled.
|
String |
getValidatedName(String name,
String charset)
If charset equals
UTF-8 , replaces the following characters with a dash - :
Jackrabbit not allowed 32: [ ] 91: [[] 93: []] 42: [*] 34: ["] 58 [:] 92: [\] 39 :[']
URL not valid {@code 59: [;] 47: [/] 63: [?] |
boolean |
isValidName(String name) |
boolean |
isValidName(String name,
String charset) |
@Inject public NodeNameHelper(MagnoliaConfigurationProperties magnoliaConfigurationProperties)
public String getUniqueName(javax.jcr.Session session, String parentPath, String name) throws javax.jcr.RepositoryException
Given the following tree:
/ ├── a ├── b └── b0 NodeUtil.getUniqueName(session, "/", "a") = "a0" NodeUtil.getUniqueName(session, "/", "b") = "b1" NodeUtil.getUniqueName(session, "/", "b0") = "b1" NodeUtil.getUniqueName(session, "/", "c") = "c"
javax.jcr.RepositoryException
public String getUniqueName(javax.jcr.Session session, String parentPath, String name, String extension) throws javax.jcr.RepositoryException
Given the following tree:
/ ├── a.txt ├── b.txt └── b0.txt NodeUtil.getUniqueName(session, "/", "a.txt", "txt") = "a0.txt" NodeUtil.getUniqueName(session, "/", "b.txt", "txt") = "b1.txt" NodeUtil.getUniqueName(session, "/", "b0.txt", "txt") = "b1.txt" NodeUtil.getUniqueName(session, "/", "c.txt", "txt") = "c.txt" NodeUtil.getUniqueName(session, "/", "a.foo", "txt") = "a.foo"
javax.jcr.RepositoryException
public String getUniqueName(javax.jcr.Node parent, String name) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public String getValidatedName(String name)
public String getValidatedName(String name, String charset)
UTF-8
, replaces the following characters with a dash -
:
Jackrabbit not allowed 32: [ ] 91: [[] 93: []] 42: [*] 34: ["] 58 [:] 92: [\] 39 :[']
URL not valid 59: [;] 47: [/] 63: [?] 43: [+] 37: [%] 33: [!] 35:[#] 94: [^]
.
Otherwise, replaces illegal characters with a dash -
except for [_] [0-9], [A-Z], [a-z], [-], [_], [.]
.
Please notice that a valid name can not begin with dot or period [.]
.
public boolean isValidName(String name)
Copyright © 2003–2018 Magnolia International Ltd.. All rights reserved.