Problem der Objektsortierung in den Kategorien behoben (Ticket #1318)

git-svn-id: https://svn.libreccm.org/ccm/trunk@1839 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2012-08-29 13:30:56 +00:00
parent 1b69863fa6
commit dd864b7ed4
5 changed files with 102 additions and 71 deletions

View File

@ -71,7 +71,7 @@ public class BaseImage extends ResourceHandlerImpl {
CMS.getConfig().getImageCacheMaxSize()); CMS.getConfig().getImageCacheMaxSize());
} }
} }
private final bool IMAGE_CACHE_PREFETCH = CMS.getConfig().getImageCachePrefetchEnabled(); private final boolean IMAGE_CACHE_PREFETCH = CMS.getConfig().getImageCachePrefetchEnabled();
private static final Logger s_log = Logger.getLogger(BaseImage.class); private static final Logger s_log = Logger.getLogger(BaseImage.class);
/** /**

View File

@ -60,21 +60,26 @@ public class CategorizedObjectsList extends SortableCategoryList {
* This actually performs the sorting * This actually performs the sorting
*/ */
public void respond(PageState ps) throws ServletException { public void respond(PageState ps) throws ServletException {
String event = ps.getControlEventName(); final String event = ps.getControlEventName();
if (NEXT_EVENT.equals(event) || PREV_EVENT.equals(event)) { if (NEXT_EVENT.equals(event) || PREV_EVENT.equals(event)) {
BigDecimal selectedID = new BigDecimal(ps.getControlEventValue()); final BigDecimal selectedID = new BigDecimal(ps.getControlEventValue());
Category parent = getCategory(ps); final Category parent = getCategory(ps);
final ContentItem selectedItem = new ContentItem(selectedID); final ContentItem selectedItem = new ContentItem(selectedID);
final BigDecimal selectedDraftId = selectedItem.getDraftVersion().getID(); final BigDecimal selectedDraftId = selectedItem.getDraftVersion().getID();
if (CMS.getContext().getSecurityManager().canAccess(SecurityManager.CATEGORY_ADMIN)) { if (CMS.getContext().getSecurityManager().canAccess(SecurityManager.CATEGORY_ADMIN)) {
BigDecimal swapId = getSwapID(parent, selectedID, event); final BigDecimal swapId = getSwapID(parent, selectedID, event);
parent.swapSortKeys(selectedID, swapId); parent.swapSortKeys(selectedID, swapId);
final ContentItem draftSwapItem = new ContentItem(swapId); final ContentItem swapItem = new ContentItem(swapId);
final BigDecimal draftSwapId = selectedItem.getDraftVersion().getID(); final BigDecimal swapDraftId = swapItem.getDraftVersion().getID();
parent.swapSortKeys(selectedDraftId, draftSwapId);
final BigDecimal sortKey1 = parent.getSortKey(selectedItem);
final BigDecimal sortKey2 = parent.getSortKey(swapItem);
parent.setSortKey(new ContentItem(selectedDraftId), sortKey1);
parent.setSortKey(new ContentItem(swapDraftId), sortKey2);
} }
} else { } else {

View File

@ -169,6 +169,7 @@ public class OrderedCategorizedObjectsList extends CategorizedObjectsList {
} }
} }
parent.save(); parent.save();
} catch (DataObjectNotFoundException e) { } catch (DataObjectNotFoundException e) {
s_log.error("Trying to create categories with state = " + ps, e); s_log.error("Trying to create categories with state = " + ps, e);
throw new ServletException(e); throw new ServletException(e);

View File

@ -23,6 +23,7 @@ import com.arsdigita.bebop.ParameterSingleSelectionModel;
import com.arsdigita.bebop.parameters.BigDecimalParameter; import com.arsdigita.bebop.parameters.BigDecimalParameter;
import com.arsdigita.categorization.Category; import com.arsdigita.categorization.Category;
import com.arsdigita.cms.CMS; import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.SecurityManager;
import com.arsdigita.cms.ui.SortableList; import com.arsdigita.cms.ui.SortableList;

View File

@ -109,9 +109,9 @@ public class Category extends ACSObject {
* *
*/ */
public static final String BASE_DATA_OBJECT_TYPE = public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.categorization.Category"; "com.arsdigita.categorization.Category";
private static final String BASE_DATA_OBJECT_PACKAGE = private static final String BASE_DATA_OBJECT_PACKAGE =
"com.arsdigita.categorization"; "com.arsdigita.categorization";
/** /**
* The * The
* <code>PrivilegeDescriptor corresponding</code> to the privilege to * <code>PrivilegeDescriptor corresponding</code> to the privilege to
@ -119,7 +119,7 @@ public class Category extends ACSObject {
* *
*/ */
public static final PrivilegeDescriptor MAP_DESCRIPTOR = public static final PrivilegeDescriptor MAP_DESCRIPTOR =
new PrivilegeDescriptor( new PrivilegeDescriptor(
"map_to_category"); "map_to_category");
// Quasimodo: Begin // Quasimodo: Begin
private static CategorizationConfig s_config = CategorizationConfig private static CategorizationConfig s_config = CategorizationConfig
@ -185,7 +185,7 @@ public class Category extends ACSObject {
* An attribute name for the underlying data object. * An attribute name for the underlying data object.
*/ */
public static final String IGNORE_PARENT_INDEX_ITEM = public static final String IGNORE_PARENT_INDEX_ITEM =
"ignoreParentIndexItem"; "ignoreParentIndexItem";
/** /**
* An attribute name for the underlying data object. * An attribute name for the underlying data object.
*/ */
@ -197,7 +197,7 @@ public class Category extends ACSObject {
public static final String LOCALIZATIONS = "localizations"; public static final String LOCALIZATIONS = "localizations";
// some named queries in the pdl files // some named queries in the pdl files
private static final String CHILD_CATEGORY_IDS = private static final String CHILD_CATEGORY_IDS =
"com.arsdigita.categorization.childCategoryIDs"; "com.arsdigita.categorization.childCategoryIDs";
private static final String CURRENT_SORT_KEY = "currentSortKey"; private static final String CURRENT_SORT_KEY = "currentSortKey";
private HierarchyDenormalization m_hierarchy; private HierarchyDenormalization m_hierarchy;
// Quasimodo: Begin // Quasimodo: Begin
@ -416,7 +416,8 @@ public class Category extends ACSObject {
public String getName(String locale) { public String getName(String locale) {
// Test for localized version // Test for localized version
if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null
&& m_categoryLocalizationCollection.
localizationExists(locale)) { localizationExists(locale)) {
// Return value of isEnabled from localized version, so categories could be disabled depending on locale // Return value of isEnabled from localized version, so categories could be disabled depending on locale
@ -517,7 +518,7 @@ public class Category extends ACSObject {
* @return category path * @return category path
*/ */
public String getPreferredQualifiedName(String delimiter, public String getPreferredQualifiedName(String delimiter,
boolean includeRoot) { boolean includeRoot) {
// is this a synonym? // is this a synonym?
CategoryCollection cc = new CategoryCollection(getRelatedCategories( CategoryCollection cc = new CategoryCollection(getRelatedCategories(
PREFERRED)); PREFERRED));
@ -525,7 +526,7 @@ public class Category extends ACSObject {
Category preferred = cc.getCategory(); Category preferred = cc.getCategory();
cc.close(); cc.close();
String preferredPath = preferred.getQualifiedName(delimiter, String preferredPath = preferred.getQualifiedName(delimiter,
includeRoot); includeRoot);
return preferredPath + " (" + getName() + ")"; return preferredPath + " (" + getName() + ")";
} else { } else {
return getQualifiedName(delimiter, includeRoot); return getQualifiedName(delimiter, includeRoot);
@ -602,7 +603,8 @@ public class Category extends ACSObject {
// Test for localized version // Test for localized version
// HACK // HACK
if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null
&& m_categoryLocalizationCollection.
localizationExists(locale)) { localizationExists(locale)) {
// Return value of isEnabled from localized version, so categories could be disabled depending on locale // Return value of isEnabled from localized version, so categories could be disabled depending on locale
@ -679,7 +681,8 @@ public class Category extends ACSObject {
public String getURL(String locale) { public String getURL(String locale) {
// Test for localized version // Test for localized version
if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null
&& m_categoryLocalizationCollection.
localizationExists(locale)) { localizationExists(locale)) {
// Return value of isEnabled from localized version, so categories could be disabled depending on locale // Return value of isEnabled from localized version, so categories could be disabled depending on locale
@ -751,7 +754,8 @@ public class Category extends ACSObject {
} }
// Test for localized version // Test for localized version
if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null
&& m_categoryLocalizationCollection.
localizationExists(locale)) { localizationExists(locale)) {
// Return value of isEnabled from localized version, so categories could be disabled depending on locale // Return value of isEnabled from localized version, so categories could be disabled depending on locale
@ -950,8 +954,8 @@ public class Category extends ACSObject {
try { try {
if (children.next()) { if (children.next()) {
throw new CategorizationException("This category is the default parent of another category." throw new CategorizationException("This category is the default parent of another category."
+ " You must explicitly delete the child categories first. " + " You must explicitly delete the child categories first. "
+ "Child category: " + children. + "Child category: " + children.
getDataObject()); getDataObject());
} }
} finally { } finally {
@ -959,13 +963,13 @@ public class Category extends ACSObject {
} }
DataAssociationCursor objects = DataAssociationCursor objects =
((DataAssociation) get(CHILD_OBJECTS)).cursor(); ((DataAssociation) get(CHILD_OBJECTS)).cursor();
if (objects != null) { if (objects != null) {
try { try {
if (objects.next()) { if (objects.next()) {
throw new CategorizationException("This category has child objects. You must delete " throw new CategorizationException("This category has child objects. You must delete "
+ " any such objects explicitly, before deleting the " + " any such objects explicitly, before deleting the "
+ " category. Child object: " + objects. + " category. Child object: " + objects.
getDataObject()); getDataObject());
} }
} finally { } finally {
@ -999,7 +1003,7 @@ public class Category extends ACSObject {
public void deleteCategorySubtree() { public void deleteCategorySubtree() {
// we get the association between this category and its children // we get the association between this category and its children
DataAssociationCursor cursor = DataAssociationCursor cursor =
((DataAssociation) get(RELATED_CATEGORIES)).cursor(); ((DataAssociation) get(RELATED_CATEGORIES)).cursor();
while (cursor.next()) { while (cursor.next()) {
DataObject link = cursor.getLink(); DataObject link = cursor.getLink();
@ -1038,7 +1042,7 @@ public class Category extends ACSObject {
} }
DataAssociationCursor cursor = DataAssociationCursor cursor =
((DataAssociation) get(RELATED_CATEGORIES)).cursor(); ((DataAssociation) get(RELATED_CATEGORIES)).cursor();
while (cursor.next()) { while (cursor.next()) {
DataObject link = cursor.getLink(); DataObject link = cursor.getLink();
@ -1167,12 +1171,12 @@ public class Category extends ACSObject {
return; return;
} }
Assert.isFalse(isAbstract(), Assert.isFalse(isAbstract(),
"You cannot categorize an object " "You cannot categorize an object "
+ "within an abstract category. If you are " + "within an abstract category. If you are "
+ "seeing this message then your UI is " + "seeing this message then your UI is "
+ "allowing you to do something that you " + "allowing you to do something that you "
+ "are not allowed to do and you " + "are not allowed to do and you "
+ "should email your site administrator."); + "should email your site administrator.");
if (RELATED.equals(relationType)) { if (RELATED.equals(relationType)) {
throw new CategorizationException( throw new CategorizationException(
@ -1181,24 +1185,24 @@ public class Category extends ACSObject {
} }
DataAssociationCursor cursor = DataAssociationCursor cursor =
((DataAssociation) get(CHILD_OBJECTS)).cursor(); ((DataAssociation) get(CHILD_OBJECTS)).cursor();
cursor.addEqualsFilter(ID, acsObj.getID()); cursor.addEqualsFilter(ID, acsObj.getID());
if (cursor.size() == 0) { if (cursor.size() == 0) {
// if the cursor.size() > 0 then the object is already // if the cursor.size() > 0 then the object is already
// a child and does not need to be added again. // a child and does not need to be added again.
DataObject link = add(CHILD_OBJECTS, acsObj); DataObject link = add(CHILD_OBJECTS, acsObj);
if (sortKey != null) { if (sortKey != null) {
link.set("sortKey", sortKey); link.set("sortKey", sortKey);
} }
Categorization.triggerMapEvent(this, acsObj); Categorization.triggerMapEvent(this, acsObj);
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug(acsObj + " added to " + CHILD_OBJECTS + " of catID=" s_log.debug(acsObj + " added to " + CHILD_OBJECTS + " of catID="
+ getID() + " type=" + relationType + " (ignored)"); + getID() + " type=" + relationType + " (ignored)");
} }
} else { } else {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug(acsObj + " is already related to catID=" + getID() s_log.debug(acsObj + " is already related to catID=" + getID()
+ " type=" + relationType + " (ignored)"); + " type=" + relationType + " (ignored)");
} }
} }
} }
@ -1207,8 +1211,8 @@ public class Category extends ACSObject {
// Let's check for loops. // Let's check for loops.
if ("child".equals(relationType) && category.isMemberOfSubtree(this)) { if ("child".equals(relationType) && category.isMemberOfSubtree(this)) {
throw new CategorizationException("The object that you are " throw new CategorizationException("The object that you are "
+ "trying to add as a child is already " + "trying to add as a child is already "
+ "a member of the subtree."); + "a member of the subtree.");
} }
@ -1216,7 +1220,7 @@ public class Category extends ACSObject {
// Otherwise, we add and then update. // Otherwise, we add and then update.
DataAssociationCursor cursor = DataAssociationCursor cursor =
((DataAssociation) get(RELATED_CATEGORIES)).cursor(); ((DataAssociation) get(RELATED_CATEGORIES)).cursor();
cursor.addEqualsFilter(ID, category.getID()); cursor.addEqualsFilter(ID, category.getID());
DataObject link; DataObject link;
if (cursor.next()) { if (cursor.next()) {
@ -1235,7 +1239,7 @@ public class Category extends ACSObject {
cursor.close(); cursor.close();
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("updating related catID=" + category.getID() + " type=" s_log.debug("updating related catID=" + category.getID() + " type="
+ relationType + " default=false"); + relationType + " default=false");
} }
link.set(REL_TYPE, relationType); link.set(REL_TYPE, relationType);
@ -1412,7 +1416,7 @@ public class Category extends ACSObject {
*/ */
public long getParentCategoryCount() { public long getParentCategoryCount() {
DataAssociationCursor cursor = DataAssociationCursor cursor =
((DataAssociation) get(PARENTS)).cursor(); ((DataAssociation) get(PARENTS)).cursor();
try { try {
return cursor.size(); return cursor.size();
} finally { } finally {
@ -1444,7 +1448,7 @@ public class Category extends ACSObject {
boolean found = false; boolean found = false;
DataAssociationCursor cursor = DataAssociationCursor cursor =
((DataAssociation) get(PARENTS)).cursor(); ((DataAssociation) get(PARENTS)).cursor();
while (cursor.next()) { while (cursor.next()) {
DataObject category = cursor.getDataObject(); DataObject category = cursor.getDataObject();
DataObject link = cursor.getLink(); DataObject link = cursor.getLink();
@ -1480,7 +1484,7 @@ public class Category extends ACSObject {
} }
DataAssociationCursor cursor = DataAssociationCursor cursor =
((DataAssociation) get(CHILD_OBJECTS)).cursor(); ((DataAssociation) get(CHILD_OBJECTS)).cursor();
cursor.addEqualsFilter(ID, child.getID()); cursor.addEqualsFilter(ID, child.getID());
if (cursor.next()) { if (cursor.next()) {
@ -1546,7 +1550,7 @@ public class Category extends ACSObject {
} }
DataAssociationCursor cursor = DataAssociationCursor cursor =
((DataAssociation) get(CHILD_OBJECTS)).cursor(); ((DataAssociation) get(CHILD_OBJECTS)).cursor();
cursor.addEqualsFilter(ID, child.getID()); cursor.addEqualsFilter(ID, child.getID());
if (cursor.next()) { if (cursor.next()) {
@ -1602,7 +1606,7 @@ public class Category extends ACSObject {
private void swapCategoryKeys(int key, int nextKey) { private void swapCategoryKeys(int key, int nextKey) {
swapKeys(getSession().retrieveDataOperation( swapKeys(getSession().retrieveDataOperation(
"com.arsdigita.categorization.swapCategoryWithNextCategory"), "com.arsdigita.categorization.swapCategoryWithNextCategory"),
key, nextKey); key, nextKey);
} }
/** /**
@ -1611,7 +1615,7 @@ public class Category extends ACSObject {
private void swapObjectKeys(int key, int nextKey) { private void swapObjectKeys(int key, int nextKey) {
swapKeys(getSession().retrieveDataOperation( swapKeys(getSession().retrieveDataOperation(
"com.arsdigita.categorization.swapObjectWithNextObject"), "com.arsdigita.categorization.swapObjectWithNextObject"),
key, nextKey); key, nextKey);
} }
/** /**
@ -1640,6 +1644,24 @@ public class Category extends ACSObject {
} }
} }
public BigDecimal getSortKey(final ACSObject object) {
return getSortKey(object.getID());
}
public BigDecimal getSortKey(final BigDecimal objId) {
final DataAssociationCursor cursor = ((DataAssociation) get(CHILD_OBJECTS)).cursor();
cursor.addEqualsFilter(ID, objId);
if (cursor.next()) {
return (BigDecimal) cursor.getLink().get(SORT_KEY);
}
return null;
}
public void setSortKey(ACSObject object, int key) {
setSortKey(object, new BigDecimal(key));
}
/** /**
* Explicitly sets the sort key for this child object (category or * Explicitly sets the sort key for this child object (category or
* otherwise). * otherwise).
@ -1647,19 +1669,19 @@ public class Category extends ACSObject {
* @param child The child object or category to set the sortKey for * @param child The child object or category to set the sortKey for
* @param key The integer to use for the sortKey * @param key The integer to use for the sortKey
*/ */
public void setSortKey(ACSObject child, int key) { public void setSortKey(ACSObject child, BigDecimal key) {
if (isCategory(child)) { if (isCategory(child)) {
setSortKey((Category) child, key); setSortKey((Category) child, key);
return; return;
} }
DataAssociationCursor cursor = DataAssociationCursor cursor =
((DataAssociation) get(CHILD_OBJECTS)).cursor(); ((DataAssociation) get(CHILD_OBJECTS)).cursor();
cursor.addEqualsFilter(ID, child.getID()); cursor.addEqualsFilter(ID, child.getID());
if (cursor.next()) { if (cursor.next()) {
DataObject link = cursor.getLink(); DataObject link = cursor.getLink();
link.set(SORT_KEY, new BigDecimal(key)); link.set(SORT_KEY, key);
} }
cursor.close(); cursor.close();
} }
@ -1680,7 +1702,7 @@ public class Category extends ACSObject {
BigDecimal key2; BigDecimal key2;
DataAssociationCursor cursor = DataAssociationCursor cursor =
((DataAssociation) get(CHILD_OBJECTS)).cursor(); ((DataAssociation) get(CHILD_OBJECTS)).cursor();
cursor.addEqualsFilter(ID, childID1); cursor.addEqualsFilter(ID, childID1);
if (cursor.next()) { if (cursor.next()) {
link1 = cursor.getLink(); link1 = cursor.getLink();
@ -1726,10 +1748,10 @@ public class Category extends ACSObject {
*/ */
public DataAssociationCursor getRelatedCategories(String relation) { public DataAssociationCursor getRelatedCategories(String relation) {
Assert.isTrue(relation.equals(CHILD) || relation.equals(RELATED) Assert.isTrue(relation.equals(CHILD) || relation.equals(RELATED)
|| relation.equals(PREFERRED), || relation.equals(PREFERRED),
" invalid relation {" + relation + "}"); " invalid relation {" + relation + "}");
DataAssociationCursor cursor = DataAssociationCursor cursor =
((DataAssociation) get(RELATED_CATEGORIES)).cursor(); ((DataAssociation) get(RELATED_CATEGORIES)).cursor();
cursor.addEqualsFilter("link.relationType", relation); cursor.addEqualsFilter("link.relationType", relation);
return cursor; return cursor;
} }
@ -1811,7 +1833,7 @@ public class Category extends ACSObject {
} }
StringBuilder sb = StringBuilder sb =
new StringBuilder(path.length() + pathExtension.length() + 1); new StringBuilder(path.length() + pathExtension.length() + 1);
sb.append(path).append(".").append(pathExtension); sb.append(path).append(".").append(pathExtension);
return sb.toString(); return sb.toString();
} }
@ -1825,7 +1847,7 @@ public class Category extends ACSObject {
*/ */
public long getNumberOfChildObjects() { public long getNumberOfChildObjects() {
DataAssociationCursor association = DataAssociationCursor association =
((DataAssociation) get(CHILD_OBJECTS)).cursor(); ((DataAssociation) get(CHILD_OBJECTS)).cursor();
if (association == null) { if (association == null) {
return 0; return 0;
} else { } else {
@ -1850,7 +1872,7 @@ public class Category extends ACSObject {
*/ */
public Category getDefaultParentCategory() { public Category getDefaultParentCategory() {
DataAssociationCursor cursor = DataAssociationCursor cursor =
((DataAssociation) get(PARENTS)).cursor(); ((DataAssociation) get(PARENTS)).cursor();
cursor.addEqualsFilter("link.isDefault", Boolean.TRUE); cursor.addEqualsFilter("link.isDefault", Boolean.TRUE);
try { try {
@ -1862,7 +1884,7 @@ public class Category extends ACSObject {
} }
throw new CategoryNotFoundException("The Category " + this + " does " throw new CategoryNotFoundException("The Category " + this + " does "
+ "not have a default parent"); + "not have a default parent");
} }
/** /**
@ -1913,7 +1935,7 @@ public class Category extends ACSObject {
*/ */
public CategoryCollection getDefaultAscendants() { public CategoryCollection getDefaultAscendants() {
DataCollection collection = DataCollection collection =
getSession().retrieve(BASE_DATA_OBJECT_TYPE); getSession().retrieve(BASE_DATA_OBJECT_TYPE);
String ids = (String) get(DEFAULT_ANCESTORS); String ids = (String) get(DEFAULT_ANCESTORS);
if (ids == null) { if (ids == null) {
@ -1970,7 +1992,7 @@ public class Category extends ACSObject {
*/ */
public CategorizedCollection getDescendantObjects() { public CategorizedCollection getDescendantObjects() {
return getDescendantObjects(ACSObject.BASE_DATA_OBJECT_TYPE, return getDescendantObjects(ACSObject.BASE_DATA_OBJECT_TYPE,
"categories.roTransParents"); "categories.roTransParents");
} }
private static String appendID(String path) { private static String appendID(String path) {
@ -1980,7 +2002,7 @@ public class Category extends ACSObject {
} }
public CategorizedCollection getDescendantObjects(String objectType, public CategorizedCollection getDescendantObjects(String objectType,
String path) { String path) {
s_log.info("retrieving objectType=" + objectType + "; path=" + path); s_log.info("retrieving objectType=" + objectType + "; path=" + path);
final CategorizedCollection result = new CategorizedCollection(getSession(). final CategorizedCollection result = new CategorizedCollection(getSession().
retrieve(objectType)); retrieve(objectType));
@ -2053,6 +2075,7 @@ public class Category extends ACSObject {
public String getToken() { public String getToken() {
return m_token; return m_token;
} }
} }
@Override @Override
@ -2071,7 +2094,7 @@ public class Category extends ACSObject {
DataCollection dc = SessionManager.getSession().retrieve( DataCollection dc = SessionManager.getSession().retrieve(
"com.arsdigita.categorization.UseContext"); "com.arsdigita.categorization.UseContext");
dc.addFilter("categoryOwner.id = :ownerID").set("ownerID", dc.addFilter("categoryOwner.id = :ownerID").set("ownerID",
acsObj.getID()); acsObj.getID());
return dc; return dc;
} }
@ -2118,9 +2141,9 @@ public class Category extends ACSObject {
DataObject secondRoot = cats.getDataObject(); DataObject secondRoot = cats.getDataObject();
cats.close(); cats.close();
throw new IllegalStateException("there is more than one root for object:\n" throw new IllegalStateException("there is more than one root for object:\n"
+ object + "\nfirst root: " + object + "\nfirst root: "
+ triple + "\nsecond root: " + triple + "\nsecond root: "
+ secondRoot); + secondRoot);
} }
cats.close(); cats.close();
} }
@ -2161,14 +2184,14 @@ public class Category extends ACSObject {
* @param root the root category for the object * @param root the root category for the object
*/ */
public static void setRootForObject(ACSObject acsObj, Category rootCat, public static void setRootForObject(ACSObject acsObj, Category rootCat,
String context) { String context) {
DataCollection rootCats = getRootCategoriesAssoc(acsObj); DataCollection rootCats = getRootCategoriesAssoc(acsObj);
rootCats.addEqualsFilter(USE_CONTEXT, context); rootCats.addEqualsFilter(USE_CONTEXT, context);
if (rootCats.next()) { if (rootCats.next()) {
DataObject triple = rootCats.getDataObject(); DataObject triple = rootCats.getDataObject();
triple.set(ROOT_CATEGORY, triple.set(ROOT_CATEGORY,
DomainServiceInterfaceExposer.getDataObject(rootCat)); DomainServiceInterfaceExposer.getDataObject(rootCat));
rootCats.close(); rootCats.close();
return; return;
} }
@ -2185,9 +2208,9 @@ public class Category extends ACSObject {
throw new UncheckedWrapperException(ex); throw new UncheckedWrapperException(ex);
} }
triple.set(CATEGORY_OWNER, triple.set(CATEGORY_OWNER,
DomainServiceInterfaceExposer.getDataObject(acsObj)); DomainServiceInterfaceExposer.getDataObject(acsObj));
triple.set(ROOT_CATEGORY, triple.set(ROOT_CATEGORY,
DomainServiceInterfaceExposer.getDataObject(rootCat)); DomainServiceInterfaceExposer.getDataObject(rootCat));
triple.set(USE_CONTEXT, context); triple.set(USE_CONTEXT, context);
} }
@ -2304,7 +2327,7 @@ public class Category extends ACSObject {
* Add a new language set to this category * Add a new language set to this category
*/ */
public boolean addLanguage(String locale, String name, String description, public boolean addLanguage(String locale, String name, String description,
String url) { String url) {
// If locale don't exist // If locale don't exist
if (!locale.isEmpty() && m_categoryLocalizationCollection != null && !m_categoryLocalizationCollection. if (!locale.isEmpty() && m_categoryLocalizationCollection != null && !m_categoryLocalizationCollection.
@ -2356,4 +2379,5 @@ public class Category extends ACSObject {
return false; return false;
} }
} }