Revision 2520 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/bookmarksandhistory/impl/DefaultBookmarksAndHistoryManager.java
DefaultBookmarksAndHistoryManager.java | ||
---|---|---|
9 | 9 |
import java.util.HashSet; |
10 | 10 |
import java.util.List; |
11 | 11 |
import java.util.Map; |
12 |
import java.util.Set; |
|
12 | 13 |
import org.apache.commons.lang3.StringUtils; |
13 | 14 |
import org.gvsig.tools.ToolsLocator; |
14 | 15 |
import org.gvsig.tools.bookmarksandhistory.Bookmark; |
... | ... | |
27 | 28 |
*/ |
28 | 29 |
public class DefaultBookmarksAndHistoryManager implements BookmarksAndHistoryManager { |
29 | 30 |
|
30 |
private final Map<String, Bookmarks<Object>> bookmarkGroups;
|
|
31 |
private final Map<String, History<Object>> historyGroups;
|
|
31 |
private final Map<String, Bookmarks> bookmarkGroups; |
|
32 |
private final Map<String, History> historyGroups; |
|
32 | 33 |
private ResourcesStorage primaryStorage; |
33 | 34 |
private ResourcesStorage secondaryStorage; |
34 | 35 |
private final int DEFAULT_VALUE_HISTORY_SIZE = 20; |
... | ... | |
80 | 81 |
} |
81 | 82 |
|
82 | 83 |
@Override |
83 |
public void registerBookmarksGroup(String name, Bookmarks<Object> bookmarks) {
|
|
84 |
public void registerBookmarksGroup(String name, Bookmarks bookmarks) { |
|
84 | 85 |
this.bookmarkGroups.put(name, bookmarks); |
85 | 86 |
} |
86 | 87 |
|
... | ... | |
90 | 91 |
} |
91 | 92 |
|
92 | 93 |
@Override |
93 |
public Bookmarks<Object> getBookmarksGroup(String name) {
|
|
94 |
public Bookmarks getBookmarksGroup(String name) { |
|
94 | 95 |
if (!existsBookmarksGroup(name)) { |
95 | 96 |
this.registerBookmarksGroup(name); |
96 | 97 |
} |
... | ... | |
98 | 99 |
} |
99 | 100 |
|
100 | 101 |
@Override |
101 |
public void registerHistoryGroup(String name, History<Object> history) {
|
|
102 |
public void registerHistoryGroup(String name, History history) { |
|
102 | 103 |
this.historyGroups.put(name, history); |
103 | 104 |
} |
104 | 105 |
|
... | ... | |
108 | 109 |
} |
109 | 110 |
|
110 | 111 |
@Override |
111 |
public History<Object> getHistoryGroup(String name) {
|
|
112 |
public History getHistoryGroup(String name) { |
|
112 | 113 |
if (!existsBookmarksHistory(name)) { |
113 | 114 |
this.registerHistoryGroup(name, DEFAULT_VALUE_HISTORY_SIZE); |
114 | 115 |
} |
... | ... | |
131 | 132 |
PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager(); |
132 | 133 |
SimpleIdentityManager userManager = ToolsLocator.getIdentityManager(); |
133 | 134 |
String userName = userManager.getCurrentIdentity().getID(); |
134 |
HashSet<String> addedResources = new HashSet<String>();
|
|
135 |
for (Map.Entry<String, Bookmarks<Object>> bookmarksEntry : this.bookmarkGroups.entrySet()) {
|
|
135 |
Set<String> addedResources = new HashSet<>();
|
|
136 |
for (Map.Entry<String, Bookmarks> bookmarksEntry : this.bookmarkGroups.entrySet()) { |
|
136 | 137 |
String bookmarksGroupName = bookmarksEntry.getKey(); |
137 | 138 |
Bookmarks<Object> bookmarks = bookmarksEntry.getValue(); |
138 | 139 |
for (Bookmark<Object> bookmark : bookmarks) { |
... | ... | |
217 | 218 |
} |
218 | 219 |
} |
219 | 220 |
} catch (Exception ex) { |
220 |
continue; |
|
221 |
LOGGER.debug("Can't load bookmarks",ex); |
|
222 |
// continue; |
|
221 | 223 |
} |
222 | 224 |
} |
223 | 225 |
} |
... | ... | |
227 | 229 |
SimpleIdentityManager userManager = ToolsLocator.getIdentityManager(); |
228 | 230 |
String userName = userManager.getCurrentIdentity().getID(); |
229 | 231 |
|
230 |
for (Map.Entry<String, History<Object>> historyEntry : this.historyGroups.entrySet()) {
|
|
232 |
for (Map.Entry<String, History> historyEntry : this.historyGroups.entrySet()) { |
|
231 | 233 |
String historyGroupName = historyEntry.getKey(); |
232 |
History<Object> history = historyEntry.getValue();
|
|
234 |
History history = historyEntry.getValue(); |
|
233 | 235 |
for (int i = 0; i < history.size(); i++) { |
234 | 236 |
String resourceName = userName + "@HISTORY!" + historyGroupName + "!" + i; |
235 | 237 |
try (ResourcesStorage.Resource resource = storage.getResource(resourceName)) { |
... | ... | |
250 | 252 |
|
251 | 253 |
List<String> names = storage.getResourceNames(); |
252 | 254 |
|
253 |
ArrayList<String> reversedList = new ArrayList<String>(names);
|
|
255 |
List<String> reversedList = new ArrayList<>(names);
|
|
254 | 256 |
Collections.sort(reversedList); |
255 | 257 |
Collections.reverse(reversedList); |
256 | 258 |
|
... | ... | |
278 | 280 |
} |
279 | 281 |
} |
280 | 282 |
} catch (Exception ex) { |
281 |
LOGGER.warn("*Load history resources fail: " + name, ex);
|
|
282 |
continue; |
|
283 |
LOGGER.debug("Load history resources fail: " + name, ex);
|
|
284 |
// continue;
|
|
283 | 285 |
} |
284 | 286 |
} |
285 | 287 |
} |
Also available in: Unified diff