public class TranslationUtils extends Object
Modifier and Type | Field and Description |
---|---|
static com.fasterxml.jackson.databind.ObjectMapper |
mapper |
static String |
PN_TRANSLATION_IDS |
static String |
TRANSLATION_TOKEN |
Modifier and Type | Method and Description |
---|---|
static void |
addPropertyToTranslationIds(org.apache.sling.api.resource.Resource resource,
String propertyName,
String dictKeyForPropertyName)
Adds the given dictionary key to the resource value map
|
static String |
get(String path,
String propertyOrObjectKey,
Integer index,
boolean isProperty)
Returns unique dictionary key based on path and property provided.
|
static String |
get(String path,
String propertyOrObjectKey,
Integer index,
boolean isProperty,
String originalKey)
Returns unique dictionary key based on path and property provided.
|
static String |
getDictionaryPath(org.apache.sling.api.resource.ResourceResolver resourceResolver,
String guideContainerPath)
Returns path to the old or new dictionary based on the container path provided
|
static javax.jcr.Node |
getOrAddDictionaryNode(org.apache.sling.api.resource.ResourceResolver resolver,
String containerPath)
Returns or adds dictionary node based on the adaptive form container path provided
|
static String |
getTranslationId(org.apache.sling.api.resource.Resource resource,
String propertyName,
String propertyValue)
Returns translation id for the property name and property value
|
static String |
getTranslationId(org.apache.sling.api.resource.Resource resource,
String propertyName,
String propertyValue,
boolean checkArray)
Returns translation id for the property name and property value
|
static String |
getTranslationId(org.apache.sling.api.resource.ValueMap properties,
String propertyName,
String propertyValue)
Returns translation id for the property name and property value
|
static String |
getTranslationId(org.apache.sling.api.resource.ValueMap properties,
String propertyName,
String propertyValue,
boolean checkArray)
Returns translation id for the property name and property value
|
static boolean |
isNewTranslation(org.apache.sling.api.resource.Resource resource)
Checks if the given resource use's new translation technique (unique keys for each property)
|
static boolean |
isNewTranslation(org.apache.sling.api.resource.ValueMap properties)
Checks if the given resource use's new translation technique (unique keys for each property)
|
static void |
removePropertyFromTranslationIds(org.apache.sling.api.resource.Resource resource,
String propertyName)
Deletes the given dictionary key from the resource value map
|
public static final String TRANSLATION_TOKEN
public static final String PN_TRANSLATION_IDS
public static final com.fasterxml.jackson.databind.ObjectMapper mapper
public static String get(String path, String propertyOrObjectKey, Integer index, boolean isProperty, String originalKey)
path
- path of the current object from its parentpropertyOrObjectKey
- property or name of the objectindex
- index, if property value is of type arrayisProperty
- isProperty, true if the key is a propertyoriginalKey
- existing dictionary key, if a random id is not providedpublic static String get(String path, String propertyOrObjectKey, Integer index, boolean isProperty)
path
- path of the current object from its parentpropertyOrObjectKey
- property or name of the objectindex
- index, if property value is of type arrayisProperty
- isProperty, true if the key is a propertypublic static String getDictionaryPath(org.apache.sling.api.resource.ResourceResolver resourceResolver, String guideContainerPath)
resourceResolver
- reference to the ResourceResolver
guideContainerPath
- path to the form containerpublic static javax.jcr.Node getOrAddDictionaryNode(org.apache.sling.api.resource.ResourceResolver resolver, String containerPath) throws javax.jcr.RepositoryException
resolver
- reference to the ResourceResolver
containerPath
- path to the form containerjavax.jcr.RepositoryException
public static String getTranslationId(org.apache.sling.api.resource.ValueMap properties, String propertyName, String propertyValue, boolean checkArray) throws IOException
properties
- reference to the properties ValueMap
propertyName
- name of the propertypropertyValue
- property valuecheckArray
- if property value is of array type, this should be trueIOException
public static String getTranslationId(org.apache.sling.api.resource.ValueMap properties, String propertyName, String propertyValue) throws IOException
properties
- reference to the properties ValueMap
propertyName
- name of the propertypropertyValue
- property valueIOException
public static boolean isNewTranslation(org.apache.sling.api.resource.ValueMap properties)
properties
- reference to the ValueMap
public static boolean isNewTranslation(org.apache.sling.api.resource.Resource resource)
resource
- reference to the Resource
public static String getTranslationId(org.apache.sling.api.resource.Resource resource, String propertyName, String propertyValue) throws IOException
resource
- reference to the resource Resource
propertyName
- name of the propertypropertyValue
- property valueIOException
public static String getTranslationId(org.apache.sling.api.resource.Resource resource, String propertyName, String propertyValue, boolean checkArray) throws IOException
resource
- reference to the resource Resource
propertyName
- name of the propertypropertyValue
- property valuecheckArray
- if property value is of array type, this should be trueIOException
public static void addPropertyToTranslationIds(org.apache.sling.api.resource.Resource resource, String propertyName, String dictKeyForPropertyName) throws IOException, javax.jcr.RepositoryException
resource
- reference to the Resource
propertyName
- name of the propertydictKeyForPropertyName
- dictionary key for the propertyIOException
javax.jcr.RepositoryException
public static void removePropertyFromTranslationIds(org.apache.sling.api.resource.Resource resource, String propertyName) throws IOException, javax.jcr.RepositoryException
resource
- reference to the Resource
propertyName
- name of the propertyIOException
javax.jcr.RepositoryException
Copyright © 1982–2023 Adobe Systems Incorporated. All rights reserved.