001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */package com.liferay.portal.kernel.lar;
014    
015    import com.liferay.portal.kernel.util.AutoResetThreadLocal;
016    
017    import java.util.ArrayList;
018    import java.util.HashMap;
019    import java.util.List;
020    import java.util.Map;
021    
022    /**
023    * @author Tamas Molnar
024    */
025    public class StagingIndexingDeletionThreadLocal {
026    
027            public static Map<String, List<String>> getDeletionKeysMap() {
028                    return _deletionKeysMap.get();
029            }
030    
031            public static void setDeletionKey(String className, String uid) {
032                    Map<String, List<String>> deletionKeysMap = _deletionKeysMap.get();
033    
034                    if (!deletionKeysMap.containsKey(className)) {
035                            deletionKeysMap.put(className, new ArrayList<String>());
036                    }
037    
038                    List<String> uids = deletionKeysMap.get(className);
039    
040                    if (!uids.contains(uid)) {
041                            uids.add(uid);
042                    }
043            }
044    
045            private static ThreadLocal<Map<String, List<String>>> _deletionKeysMap =
046                    new AutoResetThreadLocal<Map<String, List<String>>>(
047                            StagingIndexingDeletionThreadLocal.class + "._deletionKeysMap",
048                            new HashMap<String, List<String>>());
049    
050    }