📄 containerlistsxrefmanager.java
字号:
package org.jahia.content;import java.util.*;import org.jahia.utils.JahiaConsole;/** * Title: Jahia * Description: The purpose of this class is to provide a cross reference * system between container and pages, in order to know which pages reference * a container. This is necessary since currently this information is defined * only by template developpers and is useful for the HTML cache system when a * container modification is done. This class allows lookups such as : "which * pages access this container via the absolute container reference system?" * Copyright: Copyright (c) 2002 * Company: Jahia Ltd * @author Serge Huber * @version 1.0 */public class ContainerListsXRefManager { private static final String NAME_SEPARATOR = "_"; private static ContainerListsXRefManager theObject = null; protected ContainerListsXRefManager() { JahiaConsole.println("ContainerListsXRefManager", "Initializing..."); } /** * Returns a singleton instance of this service * Note : this is a synchronized access method so it might affect performance * if a lot of threads must access it simultaneously. * @returns the singleton instance. */ public static synchronized ContainerListsXRefManager getInstance() { if (theObject == null) { theObject = new ContainerListsXRefManager(); } return theObject; } // end getInstance /** * Retrieves a list of pageIDs that contain references to a specific * absolute container list. * @param containerListName the name of the containerList referenced on a * absolute way * @param containerListSourcePageID the source page on which we are accessing * the containerList * @returns a Set of Integers containing pageIDs */ public Set getAbsoluteContainerListPageIDs(String siteName, String containerListName, int containerListSourcePageID) { ContainerListKey containerListKey = new ContainerListKey(siteName, containerListName + NAME_SEPARATOR + Integer.toString(containerListSourcePageID)); Set objectRefs = CrossReferenceManager.getInstance().getObjectXRefs(containerListKey); Set pageIDs = new TreeSet(); if (objectRefs == null) { return pageIDs; } Iterator objectRefIter = objectRefs.iterator(); while (objectRefIter.hasNext()) { Object ref = objectRefIter.next(); if (ref instanceof ObjectKey) { ObjectKey refKey = (ObjectKey) ref; if (PageKey.PAGE_TYPE.equals(refKey.getType())) { PageKey pageRefKey = (PageKey) refKey; Integer pageID = new Integer(pageRefKey.getPageID()); pageIDs.add(pageID); } else { JahiaConsole.println("ContainerListsXRefManager.getAbsoluteContainerListPageIDs", "Expected page type in cross reference list, ignoring value... "); } } else { JahiaConsole.println("ContainerListsXRefManager.getAbsoluteContainerListPageIDs", "Invalid key object in cross reference list, ignoring... "); } } return pageIDs; } /** * Adds or updates a cross reference between an absolute container list and * a page * @param containerListName the name of the containerList referenced on a * absolute way * @param containerListSourcePageID the source page on which we are accessing * the containerList * @param pageID the page identifier */ public void setAbsoluteContainerListPageID(String siteName, String containerListName, int containerListSourcePageID, int referencePageID) { ContainerListKey containerListKey = new ContainerListKey(siteName, containerListName + NAME_SEPARATOR + Integer.toString(containerListSourcePageID)); PageKey pageKey = new PageKey(siteName, referencePageID); CrossReferenceManager.getInstance().setObjectXRef(containerListKey, pageKey); } /** * Removes all the cross references for a specified absolute container list * @param containerListName the name of the containerList referenced on a * absolute way * @param containerListSourcePageID the source page on which we are accessing * the containerList */ public void removeAbsoluteContainerList(String siteName, String containerListName, int containerListSourcePageID) { ContainerListKey containerListKey = new ContainerListKey(siteName, containerListName + NAME_SEPARATOR + Integer.toString(containerListSourcePageID)); CrossReferenceManager.getInstance().removeObjectXRefs(containerListKey); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -