public class Category extends JahiaObject
Title: Category object
Description: This Category class is used to associate any objects within Jahia, be they Content Objects, Categories or others. It also provides static methods to manipulate Categories in the persistence back-end. This class is self-sufficient for most operations as it uses the category service back-end to perform most of it's work.
Copyright: Copyright (c) 2002
Company: Jahia Ltd
| Modifier and Type | Field and Description |
|---|---|
protected static CategoryService |
categoryService |
static String |
PATH_DELIMITER |
objectKey| Constructor and Description |
|---|
Category(CategoryBean categoryBean) |
| Modifier and Type | Method and Description |
|---|---|
static Category |
createCategory(String key,
Category parentCategory)
New category constructor.
|
void |
delete()
Deletes this category and all associated data (but does not recursively
delete categories !), notably associations with child and parent objects,
titles in all languages, and finally the category itself.
|
boolean |
equals(Object category) |
static List<Category> |
findCategoriesByPropNameAndValue(String propName,
String propValue,
JahiaUser p)
Finds categories by specifying property name and
property value.
|
static void |
getAllChildrenCategoriesFrom(Category startCategory,
JahiaUser p,
List<Category> result) |
static List<Category> |
getCategoriesContainingStringInTitle(String string,
String rootCategoryKey,
String languageCode,
JahiaUser p) |
static javax.jcr.Node |
getCategoriesRoot() |
static javax.jcr.Node |
getCategoriesRoot(JahiaUser p) |
static List<Category> |
getCategoriesWithKeyPrefix(String keyPrefix,
String rootCategoryKey,
JahiaUser p) |
static List<Category> |
getCategoriesWithtitlePrefix(String titlePrefix,
String rootCategoryKey,
String languageCode,
JahiaUser p) |
static Category |
getCategory(String key) |
static Category |
getCategory(String key,
JahiaUser p) |
protected CategoryBean |
getCategoryBean() |
static Category |
getCategoryByPath(String categoryPath,
JahiaUser p) |
static Category |
getCategoryByUUID(String categoryUUID) |
static Category |
getCategoryByUUID(String categoryUUID,
JahiaUser p) |
static String |
getCategoryKey(String categoryPath)
Returns the category key from the full category path.
|
String |
getCategoryPath()
Returns the path representation of the form
/root/catKey1/catKeyB/thisCategoryKey |
static String |
getCategoryPath(String categoryKey)
Returns the path representation of the form
/root/catKey1/catKeyB/thisCategoryKey |
List<Category> |
getChildCategories()
Retrieves the list of child category keys for this category.
|
List<Category> |
getChildCategories(boolean recursive)
Retrieves the list of child category keys for this category.
|
List<Category> |
getChildCategories(JahiaUser p)
Retrieves the list of child categories for this category and at the same
time checking permissions for the principal.
|
static JahiaObject |
getChildInstance(ObjectKey objectKey) |
static JahiaObject |
getChildInstance(ObjectKey objectKey,
JahiaUser p)
Instance generator.
|
static Category |
getChildInstance(String IDInType) |
static Category |
getChildInstance(String IDInType,
JahiaUser p) |
List<ObjectKey> |
getChildObjectKeys()
Retrieves the list of child object keys for this category.
|
String |
getID() |
CategoryBean |
getJahiaCategory() |
String |
getKey() |
static Category |
getLastCategoryNode(String path)
The last category node for a category path of the form /root/catKey1/catKeyB
|
static Set<Category> |
getObjectCategories(ObjectKey objectKey)
Returns a set of categories with which this object is associated.
|
ObjectKey |
getObjectKey()
Returns the object key that fully identifies the content object within
a Jahia system.
|
List<Category> |
getParentCategories() |
List<Category> |
getParentCategories(JahiaUser p)
Retrieves the list of parent categories for this category, checking the
rights if a principal is specified.
|
List<ObjectKey> |
getParentObjectKeys()
Retrieves the list of parent object keys for this category.
|
Properties |
getProperties() |
String |
getProperty(String propertyName) |
static List<Category> |
getRootCategories(JahiaUser p) |
String |
getTitle(Locale locale)
Returns the title in the specified language if it exists, or null if
it doesn't exist
|
String |
getTitle(Locale locale,
String defaultValue) |
int |
hashCode() |
void |
removeProperty(String propertyName)
Removes a property.
|
void |
removeTitle(Locale locale)
Removes a title for this category in a given locale
|
void |
setProperties(Properties newProperties)
Sets a whole new set of properties for this category.
|
void |
setProperty(String propertyName,
String propertyValue)
Sets a single property.
|
void |
setTitle(Locale locale,
String title)
Sets a title for this category in a given locale
|
String |
toString() |
getInstance, getInstance, getInstanceAsObject, getInstanceAsObject, registerType, unregisterTypepublic static final String PATH_DELIMITER
protected static CategoryService categoryService
public Category(CategoryBean categoryBean)
public static Category createCategory(String key, Category parentCategory) throws JahiaException
key - the unique key name for the new categoryparentCategory - the parent category for this new category,
it may be null to create an un-associated categoryJahiaException - if there was an error while communicating with
the databasepublic static javax.jcr.Node getCategoriesRoot()
throws JahiaException
JahiaExceptionpublic static javax.jcr.Node getCategoriesRoot(JahiaUser p) throws JahiaException
p - the Principal for which to retrieve the category, checking rights
to make sure he has access to it. If this object is null, then no rights
check will be performed.JahiaException - thrown if there was a problem communicating with
the databasepublic static List<Category> getRootCategories(JahiaUser p) throws JahiaException
p - the Principal for which to retrieve the category, checking rights
to make sure he has access to it. If this object is null, then no rights
check will be performed.JahiaException - thrown if there was a problem communicating with
the databasepublic static Category getCategory(String key, JahiaUser p) throws JahiaException
key - the key for the category to retrievep - the Principal for which to retrieve the category, checking rights
to make sure he has access to it. If this object is null, then no rights
check will be performed.JahiaException - thrown if there was a problem communicating with
the databasepublic static Category getCategory(String key) throws JahiaException
JahiaExceptionpublic static List<Category> getCategoriesWithKeyPrefix(String keyPrefix, String rootCategoryKey, JahiaUser p) throws JahiaException
JahiaExceptionpublic static List<Category> getCategoriesWithtitlePrefix(String titlePrefix, String rootCategoryKey, String languageCode, JahiaUser p) throws JahiaException
JahiaExceptionpublic static List<Category> getCategoriesContainingStringInTitle(String string, String rootCategoryKey, String languageCode, JahiaUser p) throws JahiaException
JahiaExceptionpublic static void getAllChildrenCategoriesFrom(Category startCategory, JahiaUser p, List<Category> result) throws JahiaException
JahiaExceptionpublic static Category getCategoryByUUID(String categoryUUID, JahiaUser p) throws JahiaException
categoryUUID - the category ID for the category to retrievep - the Principal for which to retrieve the category, checking rights
to make sure he has access to it. If this object is null, then no rights
check will be performed.JahiaException - thrown if there was a problem communicating with
the databasepublic static Category getCategoryByUUID(String categoryUUID) throws JahiaException
categoryUUID - the category ID for the category to retrieve for the current principal for which to retrieve the category, checking rights
to make sure he has access to it. If this object is null, then no rights
check will be performed.JahiaException - thrown if there was a problem communicating with
the databasepublic static Category getCategoryByPath(String categoryPath, JahiaUser p) throws JahiaException
categoryPath - the category path for the category to retrievep - the Principal for which to retrieve the category, checking rights
to make sure he has access to it. If this object is null, then no rights
check will be performed.JahiaException - thrown if there was a problem communicating with
the databasepublic static JahiaObject getChildInstance(ObjectKey objectKey, JahiaUser p)
objectKey - an ObjectKey instance for the object we want to retrieve
an instance of.public static JahiaObject getChildInstance(ObjectKey objectKey)
public static Set<Category> getObjectCategories(ObjectKey objectKey) throws JahiaException
objectKey - the object key for the object for which to retrieve the
categoriesJahiaException - thrown if there was a problem communicating with
the database.public static List<Category> findCategoriesByPropNameAndValue(String propName, String propValue, JahiaUser p)
propName - a property name that will be used to
retrieve categories by their ID. Use "%" character for partial matching.propValue - a partial property value that will be used to
retrieve categories by their ID. Use "%" character for partial matching.p - the Principal for which to retrieve the category, checking rights
to make sure he has access to it. If this object is null, then no rights
check will be performed.public String getKey()
public String getID()
protected CategoryBean getCategoryBean()
public ObjectKey getObjectKey()
JahiaObjectgetObjectKey in class JahiaObjectpublic List<Category> getChildCategories(JahiaUser p) throws JahiaException
p - the principal for which to check the permissionJahiaException - thrown if there was a problem communicating with
the databasepublic List<Category> getChildCategories() throws JahiaException
JahiaException - thrown if there was a problem communicating with
the databasepublic List<Category> getParentCategories(JahiaUser p) throws JahiaException
p - the Principal for which to retrieve the category, checking rights
to make sure he has access to it. If this object is null, then no rights
check will be performed.JahiaException - thrown if there was a problem communicating with
the databasepublic List<Category> getParentCategories() throws JahiaException
JahiaExceptionpublic List<ObjectKey> getChildObjectKeys() throws JahiaException
JahiaException - thrown if there was a problem communicating with
the databasepublic List<Category> getChildCategories(boolean recursive) throws JahiaException
recursive - If true, include recursively childs category of childs eitherJahiaException - thrown if there was a problem communicating with
the databaseJahiaExceptionpublic List<ObjectKey> getParentObjectKeys() throws JahiaException
JahiaException - thrown if there was a problem communicating with
the databasepublic String getTitle(Locale locale)
locale - the locale which specifies the language for which to
retrieve the title.public String getTitle(Locale locale, String defaultValue)
locale - defaultValue - public void setTitle(Locale locale, String title)
locale - the locale in which we want to set the titletitle - the String containing the title for the specified locale.public void removeTitle(Locale locale)
locale - the locale for which we want to remove the titlepublic void delete()
throws JahiaException
JahiaException - thrown if there was an error while removing any
of the associations, titles or the category itself from the database.
todo ACLs are not deleted here, we must add thispublic Properties getProperties()
public void setProperties(Properties newProperties)
newProperties - the full set of properties to set for this
category.public String getProperty(String propertyName)
propertyName - the name of the property for which to retrieve the
valuepublic void setProperty(String propertyName, String propertyValue)
propertyName - the name of the property to setpropertyValue - the value to set for this propertypublic void removeProperty(String propertyName)
propertyName - the name of the property to remove.public CategoryBean getJahiaCategory()
public String getCategoryPath() throws JahiaException
/root/catKey1/catKeyB/thisCategoryKeyJahiaExceptionpublic static Category getLastCategoryNode(String path) throws JahiaException
path - JahiaExceptionpublic static String getCategoryKey(String categoryPath)
categoryPath - the full category pathpublic static String getCategoryPath(String categoryKey) throws JahiaException
/root/catKey1/catKeyB/thisCategoryKeyJahiaExceptionCopyright © 2004–2020 Jahia Solutions Group SA. All rights reserved.