|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2000, 2010 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2011 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 34-39
Link Here
|
| 34 |
import org.eclipse.osgi.util.NLS; |
34 |
import org.eclipse.osgi.util.NLS; |
| 35 |
|
35 |
|
| 36 |
public class SaveManager implements IElementInfoFlattener, IManager, IStringPoolParticipant { |
36 |
public class SaveManager implements IElementInfoFlattener, IManager, IStringPoolParticipant { |
|
|
37 |
class MasterTable extends Properties { |
| 38 |
private static final long serialVersionUID = 1L; |
| 39 |
|
| 40 |
/* (non-Javadoc) |
| 41 |
* @see java.util.Hashtable#put(java.lang.Object, java.lang.Object) |
| 42 |
*/ |
| 43 |
public synchronized Object put(Object key, Object value) { |
| 44 |
Object prev = super.put(key, value); |
| 45 |
if (prev != null && ROOT_SEQUENCE_NUMBER_KEY.equals(key)) { |
| 46 |
int prevSeqNum = new Integer((String) prev).intValue(); |
| 47 |
int currSeqNum = new Integer((String) value).intValue(); |
| 48 |
if (prevSeqNum > currSeqNum) { |
| 49 |
//revert last put operation |
| 50 |
super.put(key, prev); |
| 51 |
//notify about the problem, do not throw exception but add the exception to know where it occurred |
| 52 |
String message = "Cannot set lower sequence number for root (previous: " + prevSeqNum + ", new: " + currSeqNum + "). Ignoring the new value."; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
| 53 |
Policy.log(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, IResourceStatus.INTERNAL_ERROR, message, new IllegalArgumentException(message))); |
| 54 |
} |
| 55 |
} |
| 56 |
return prev; |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
protected static final String ROOT_SEQUENCE_NUMBER_KEY = Path.ROOT.toString() + LocalMetaArea.F_TREE; |
| 37 |
protected static final String CLEAR_DELTA_PREFIX = "clearDelta_"; //$NON-NLS-1$ |
61 |
protected static final String CLEAR_DELTA_PREFIX = "clearDelta_"; //$NON-NLS-1$ |
| 38 |
protected static final String DELTA_EXPIRATION_PREFIX = "deltaExpiration_"; //$NON-NLS-1$ |
62 |
protected static final String DELTA_EXPIRATION_PREFIX = "deltaExpiration_"; //$NON-NLS-1$ |
| 39 |
protected static final int DONE_SAVING = 3; |
63 |
protected static final int DONE_SAVING = 3; |
|
Lines 55-61
Link Here
|
| 55 |
protected static final String SAVE_NUMBER_PREFIX = "saveNumber_"; //$NON-NLS-1$ |
79 |
protected static final String SAVE_NUMBER_PREFIX = "saveNumber_"; //$NON-NLS-1$ |
| 56 |
protected static final int SAVING = 2; |
80 |
protected static final int SAVING = 2; |
| 57 |
protected ElementTree lastSnap; |
81 |
protected ElementTree lastSnap; |
| 58 |
protected Properties masterTable; |
82 |
protected MasterTable masterTable; |
| 59 |
|
83 |
|
| 60 |
/** |
84 |
/** |
| 61 |
* A flag indicating that a save operation is occurring. This is a signal |
85 |
* A flag indicating that a save operation is occurring. This is a signal |
|
Lines 793-799
Link Here
|
| 793 |
|
817 |
|
| 794 |
protected void restoreMasterTable() throws CoreException { |
818 |
protected void restoreMasterTable() throws CoreException { |
| 795 |
long start = System.currentTimeMillis(); |
819 |
long start = System.currentTimeMillis(); |
| 796 |
masterTable = new Properties(); |
820 |
masterTable = new MasterTable(); |
| 797 |
IPath location = workspace.getMetaArea().getSafeTableLocationFor(ResourcesPlugin.PI_RESOURCES); |
821 |
IPath location = workspace.getMetaArea().getSafeTableLocationFor(ResourcesPlugin.PI_RESOURCES); |
| 798 |
java.io.File target = location.toFile(); |
822 |
java.io.File target = location.toFile(); |
| 799 |
if (!target.exists()) { |
823 |
if (!target.exists()) { |