View | Details | Raw Unified | Return to bug 216884
Collapse All | Expand All

(-)src/org/eclipse/core/internal/properties/IPropertyManager.java (+4 lines)
Lines 72-75 Link Here
72
	 * be found, returns an empty map. 
72
	 * be found, returns an empty map. 
73
	 */
73
	 */
74
	public Map getProperties(IResource resource) throws CoreException;
74
	public Map getProperties(IResource resource) throws CoreException;
75
	
76
	public void restorePropertiesFromDeleted(IResource target) throws CoreException;
77
	public void savePropertiesAsDeleted(IResource resource) throws CoreException;
78
	public void removeDeletedProperties(IResource resource) throws CoreException;
75
}
79
}
(-)src/org/eclipse/core/internal/properties/PropertyManager2.java (-4 / +44 lines)
Lines 65-73 Link Here
65
	}
65
	}
66
66
67
	BucketTree tree;
67
	BucketTree tree;
68
	BucketTree deletedTree;
68
69
69
	public PropertyManager2(Workspace workspace) {
70
	public PropertyManager2(Workspace workspace) {
70
		this.tree = new BucketTree(workspace, new PropertyBucket());
71
		this.tree = new BucketTree(workspace, new PropertyBucket());
72
		this.deletedTree = new BucketTree(workspace, new DeletedPropertyBucket());
71
	}
73
	}
72
74
73
	public void closePropertyStore(IResource target) throws CoreException {
75
	public void closePropertyStore(IResource target) throws CoreException {
Lines 96-102 Link Here
96
	}
98
	}
97
99
98
	public synchronized void deleteProperties(IResource target, int depth) throws CoreException {
100
	public synchronized void deleteProperties(IResource target, int depth) throws CoreException {
99
		tree.accept(new PropertyBucket.Visitor() {
101
		deleteProperties(target, depth, tree);
102
	}
103
104
	public synchronized void deleteProperties(IResource target, int depth, BucketTree treeToUse) throws CoreException {
105
		treeToUse.accept(new PropertyBucket.Visitor() {
100
			public int visit(Entry entry) {
106
			public int visit(Entry entry) {
101
				entry.delete();
107
				entry.delete();
102
				return CONTINUE;
108
				return CONTINUE;
Lines 109-116 Link Here
109
	}
115
	}
110
116
111
	public synchronized Map getProperties(IResource target) throws CoreException {
117
	public synchronized Map getProperties(IResource target) throws CoreException {
118
		return getProperties(target, tree);
119
	}
120
121
	protected synchronized Map getProperties(IResource target, BucketTree treeToUse) throws CoreException {
112
		final Map result = new HashMap();
122
		final Map result = new HashMap();
113
		tree.accept(new PropertyBucket.Visitor() {
123
		treeToUse.accept(new PropertyBucket.Visitor() {
114
			public int visit(Entry entry) {
124
			public int visit(Entry entry) {
115
				PropertyEntry propertyEntry = (PropertyEntry) entry;
125
				PropertyEntry propertyEntry = (PropertyEntry) entry;
116
				int propertyCount = propertyEntry.getOccurrences();
126
				int propertyCount = propertyEntry.getOccurrences();
Lines 141-147 Link Here
141
		return tree.getVersionFile();
151
		return tree.getVersionFile();
142
	}
152
	}
143
153
154
	public void removeDeletedProperties(IResource target) throws CoreException {
155
		deleteProperties(target, IResource.DEPTH_INFINITE, deletedTree);
156
	}
157
158
	public void restorePropertiesFromDeleted(IResource target) throws CoreException
159
	{
160
		Map properties = getProperties(target, deletedTree);
161
		Iterator keys = properties.keySet().iterator();
162
		while (keys.hasNext()) {
163
			QualifiedName key = (QualifiedName) keys.next();
164
			String value = (String) properties.get(key);
165
			setProperty(target, key, value);
166
		}
167
	}
168
	
169
	public void savePropertiesAsDeleted(IResource target) throws CoreException
170
	{
171
		Map properties = getProperties(target);
172
		Iterator keys = properties.keySet().iterator();
173
		while (keys.hasNext()) {
174
			QualifiedName key = (QualifiedName) keys.next();
175
			String value = (String) properties.get(key);
176
			setProperty(target, key, value, deletedTree);
177
		}
178
	}
179
	
144
	public synchronized void setProperty(IResource target, QualifiedName name, String value) throws CoreException {
180
	public synchronized void setProperty(IResource target, QualifiedName name, String value) throws CoreException {
181
		setProperty(target, name, value, this.tree);
182
	}
183
184
	protected synchronized void setProperty(IResource target, QualifiedName name, String value, BucketTree treeToUse) throws CoreException {
145
		//resource may have been deleted concurrently
185
		//resource may have been deleted concurrently
146
		//must check for existence within synchronized method
186
		//must check for existence within synchronized method
147
		Resource resource = (Resource) target;
187
		Resource resource = (Resource) target;
Lines 159-166 Link Here
159
		}
199
		}
160
200
161
		IPath resourcePath = target.getFullPath();
201
		IPath resourcePath = target.getFullPath();
162
		tree.loadBucketFor(resourcePath);
202
		treeToUse.loadBucketFor(resourcePath);
163
		PropertyBucket current = (PropertyBucket) tree.getCurrent();
203
		PropertyBucket current = (PropertyBucket) treeToUse.getCurrent();
164
		current.setProperty(resourcePath, name, value);
204
		current.setProperty(resourcePath, name, value);
165
		current.save();
205
		current.save();
166
	}
206
	}
(-)src/org/eclipse/core/internal/resources/Resource.java (-41 / +45 lines)
Lines 192-197 Link Here
192
		checkExists(flags, true);
192
		checkExists(flags, true);
193
	}
193
	}
194
194
195
	protected ResourceInfo checkAccessibleAndLocal(int depth) throws CoreException {
196
		ResourceInfo info = getResourceInfo(false, false);
197
		int flags = getFlags(info);
198
		checkAccessible(flags);
199
		checkLocal(flags, depth);
200
		return info;
201
	}
202
	
195
	/**
203
	/**
196
	 * This method reports errors in two different ways. It can throw a
204
	 * This method reports errors in two different ways. It can throw a
197
	 * CoreException or return a status. CoreExceptions are used according to the
205
	 * CoreException or return a status. CoreExceptions are used according to the
Lines 218-228 Link Here
218
		}
226
		}
219
		checkValidPath(destination, destinationType, false);
227
		checkValidPath(destination, destinationType, false);
220
228
221
		ResourceInfo info = getResourceInfo(false, false);
229
		ResourceInfo info;
222
		int flags = getFlags(info);
230
		checkAccessibleAndLocal(DEPTH_INFINITE);
223
		checkAccessible(flags);
231
		
224
		checkLocal(flags, DEPTH_INFINITE);
225
226
		Resource dest = workspace.newResource(destination, destinationType);
232
		Resource dest = workspace.newResource(destination, destinationType);
227
		dest.checkDoesNotExist();
233
		dest.checkDoesNotExist();
228
234
Lines 350-359 Link Here
350
		}
356
		}
351
		checkValidPath(destination, destinationType, false);
357
		checkValidPath(destination, destinationType, false);
352
358
353
		ResourceInfo info = getResourceInfo(false, false);
359
		ResourceInfo info;
354
		int flags = getFlags(info);
360
		checkAccessibleAndLocal(DEPTH_INFINITE);
355
		checkAccessible(flags);
356
		checkLocal(flags, DEPTH_INFINITE);
357
361
358
		Resource dest = workspace.newResource(destination, destinationType);
362
		Resource dest = workspace.newResource(destination, destinationType);
359
363
Lines 1008-1017 Link Here
1008
	 * @see IResource#getPersistentProperty(QualifiedName)
1012
	 * @see IResource#getPersistentProperty(QualifiedName)
1009
	 */
1013
	 */
1010
	public String getPersistentProperty(QualifiedName key) throws CoreException {
1014
	public String getPersistentProperty(QualifiedName key) throws CoreException {
1011
		ResourceInfo info = getResourceInfo(false, false);
1015
		checkAccessibleAndLocal(DEPTH_ZERO);
1012
		int flags = getFlags(info);
1013
		checkAccessible(flags);
1014
		checkLocal(flags, DEPTH_ZERO);
1015
		return getPropertyManager().getProperty(this, key);
1016
		return getPropertyManager().getProperty(this, key);
1016
	}
1017
	}
1017
1018
Lines 1073-1082 Link Here
1073
	 * @see IResource#getSessionProperty(QualifiedName)
1074
	 * @see IResource#getSessionProperty(QualifiedName)
1074
	 */
1075
	 */
1075
	public Object getSessionProperty(QualifiedName key) throws CoreException {
1076
	public Object getSessionProperty(QualifiedName key) throws CoreException {
1076
		ResourceInfo info = getResourceInfo(false, false);
1077
		ResourceInfo info = checkAccessibleAndLocal(DEPTH_ZERO);
1077
		int flags = getFlags(info);
1078
		checkAccessible(flags);
1079
		checkLocal(flags, DEPTH_ZERO);
1080
		return info.getSessionProperty(key);
1078
		return info.getSessionProperty(key);
1081
	}
1079
	}
1082
1080
Lines 1450-1455 Link Here
1450
	}
1448
	}
1451
1449
1452
	/* (non-Javadoc)
1450
	/* (non-Javadoc)
1451
	 * @see IResource#removeDeletedPersistentProperties
1452
	 */
1453
	public void removeDeletedPersistentProperties() throws CoreException {
1454
		// The resource is deleted when this is called
1455
		getPropertyManager().removeDeletedProperties(this);
1456
	}
1457
1458
	/* (non-Javadoc)
1453
	 * Method declared on {@link IPathRequestor}.
1459
	 * Method declared on {@link IPathRequestor}.
1454
	 */
1460
	 */
1455
	public String requestName() {
1461
	public String requestName() {
Lines 1464-1469 Link Here
1464
	}
1470
	}
1465
1471
1466
	/* (non-Javadoc)
1472
	/* (non-Javadoc)
1473
	 * @see IResource#restorePersistentPropertiesFromDeleted()
1474
	 */
1475
	public void restorePersistentPropertiesFromDeleted() throws CoreException {
1476
		checkAccessibleAndLocal(DEPTH_ZERO);
1477
		getPropertyManager().restorePropertiesFromDeleted(this);
1478
	}
1479
1480
	/* (non-Javadoc)
1467
	 * @see IResource#revertModificationStamp
1481
	 * @see IResource#revertModificationStamp
1468
	 */
1482
	 */
1469
	public void revertModificationStamp(long value) throws CoreException {
1483
	public void revertModificationStamp(long value) throws CoreException {
Lines 1471-1484 Link Here
1471
			throw new IllegalArgumentException("Illegal value: " + value); //$NON-NLS-1$
1485
			throw new IllegalArgumentException("Illegal value: " + value); //$NON-NLS-1$
1472
		// fetch the info but don't bother making it mutable even though we are going
1486
		// fetch the info but don't bother making it mutable even though we are going
1473
		// to modify it. It really doesn't matter as the change we are doing does not show up in deltas.
1487
		// to modify it. It really doesn't matter as the change we are doing does not show up in deltas.
1474
		ResourceInfo info = getResourceInfo(false, false);
1488
		ResourceInfo info = checkAccessibleAndLocal(DEPTH_ZERO);
1475
		int flags = getFlags(info);
1476
		checkAccessible(flags);
1477
		checkLocal(flags, DEPTH_ZERO);
1478
		info.setModificationStamp(value);
1489
		info.setModificationStamp(value);
1479
	}
1490
	}
1480
1491
1481
	/* (non-Javadoc)
1492
	/* (non-Javadoc)
1493
	 * @see IResource#savePersistentPropertiesAsDeleted()
1494
	 */
1495
	public void savePersistentPropertiesAsDeleted() throws CoreException {
1496
		checkAccessibleAndLocal(DEPTH_ZERO);
1497
		getPropertyManager().savePropertiesAsDeleted(this);
1498
	}
1499
1500
	/* (non-Javadoc)
1482
	 * @see IResource#setDerived(boolean)
1501
	 * @see IResource#setDerived(boolean)
1483
	 */
1502
	 */
1484
	public void setDerived(boolean isDerived) throws CoreException {
1503
	public void setDerived(boolean isDerived) throws CoreException {
Lines 1545-1554 Link Here
1545
			throw new IllegalArgumentException("Illegal value: " + value); //$NON-NLS-1$
1564
			throw new IllegalArgumentException("Illegal value: " + value); //$NON-NLS-1$
1546
		// fetch the info but don't bother making it mutable even though we are going
1565
		// fetch the info but don't bother making it mutable even though we are going
1547
		// to modify it. It really doesn't matter as the change we are doing does not show up in deltas.
1566
		// to modify it. It really doesn't matter as the change we are doing does not show up in deltas.
1548
		ResourceInfo info = getResourceInfo(false, false);
1567
		ResourceInfo info = checkAccessibleAndLocal(DEPTH_ZERO);
1549
		int flags = getFlags(info);
1550
		checkAccessible(flags);
1551
		checkLocal(flags, DEPTH_ZERO);
1552
		return getLocalManager().setLocalTimeStamp(this, info, value);
1568
		return getLocalManager().setLocalTimeStamp(this, info, value);
1553
	}
1569
	}
1554
1570
Lines 1556-1565 Link Here
1556
	 * @see IResource#setPersistentProperty(QualifiedName, String)
1572
	 * @see IResource#setPersistentProperty(QualifiedName, String)
1557
	 */
1573
	 */
1558
	public void setPersistentProperty(QualifiedName key, String value) throws CoreException {
1574
	public void setPersistentProperty(QualifiedName key, String value) throws CoreException {
1559
		ResourceInfo info = getResourceInfo(false, false);
1575
		checkAccessibleAndLocal(DEPTH_ZERO);
1560
		int flags = getFlags(info);
1561
		checkAccessible(flags);
1562
		checkLocal(flags, DEPTH_ZERO);
1563
		getPropertyManager().setProperty(this, key, value);
1576
		getPropertyManager().setProperty(this, key, value);
1564
	}
1577
	}
1565
1578
Lines 1583-1592 Link Here
1583
	 * @see org.eclipse.core.resources.IResource#setResourceAttributes(org.eclipse.core.resources.ResourceAttributes)
1596
	 * @see org.eclipse.core.resources.IResource#setResourceAttributes(org.eclipse.core.resources.ResourceAttributes)
1584
	 */
1597
	 */
1585
	public void setResourceAttributes(ResourceAttributes attributes) throws CoreException {
1598
	public void setResourceAttributes(ResourceAttributes attributes) throws CoreException {
1586
		ResourceInfo info = getResourceInfo(false, false);
1599
		checkAccessibleAndLocal(DEPTH_ZERO);
1587
		int flags = getFlags(info);
1588
		checkAccessible(flags);
1589
		checkLocal(flags, DEPTH_ZERO);
1590
		getLocalManager().setResourceAttributes(this, attributes);
1600
		getLocalManager().setResourceAttributes(this, attributes);
1591
	}
1601
	}
1592
1602
Lines 1597-1606 Link Here
1597
		// fetch the info but don't bother making it mutable even though we are going
1607
		// fetch the info but don't bother making it mutable even though we are going
1598
		// to modify it.  We don't know whether or not the tree is open and it really doesn't
1608
		// to modify it.  We don't know whether or not the tree is open and it really doesn't
1599
		// matter as the change we are doing does not show up in deltas.
1609
		// matter as the change we are doing does not show up in deltas.
1600
		ResourceInfo info = getResourceInfo(false, false);
1610
		ResourceInfo info = checkAccessibleAndLocal(DEPTH_ZERO);
1601
		int flags = getFlags(info);
1602
		checkAccessible(flags);
1603
		checkLocal(flags, DEPTH_ZERO);
1604
		info.setSessionProperty(key, value);
1611
		info.setSessionProperty(key, value);
1605
	}
1612
	}
1606
1613
Lines 1650-1659 Link Here
1650
			final ISchedulingRule rule = workspace.getRuleFactory().modifyRule(this);
1657
			final ISchedulingRule rule = workspace.getRuleFactory().modifyRule(this);
1651
			try {
1658
			try {
1652
				workspace.prepareOperation(rule, monitor);
1659
				workspace.prepareOperation(rule, monitor);
1653
				ResourceInfo info = getResourceInfo(false, false);
1660
				ResourceInfo info = checkAccessibleAndLocal(DEPTH_ZERO);
1654
				int flags = getFlags(info);
1655
				checkAccessible(flags);
1656
				checkLocal(flags, DEPTH_ZERO);
1657
1661
1658
				workspace.beginOperation(true);
1662
				workspace.beginOperation(true);
1659
				// fake a change by incrementing the content ID
1663
				// fake a change by incrementing the content ID
(-)src/org/eclipse/core/resources/IResource.java (-2 / +38 lines)
Lines 270-276 Link Here
270
	 * @since 3.2
270
	 * @since 3.2
271
	 */
271
	 */
272
	public static final int TEAM_PRIVATE = 0x800;
272
	public static final int TEAM_PRIVATE = 0x800;
273
	
273
274
	/**
274
	/**
275
	 * Update flag constant (bit mask value 0x1000) indicating that a 
275
	 * Update flag constant (bit mask value 0x1000) indicating that a 
276
	 * resource should be marked as a hidden resource.
276
	 * resource should be marked as a hidden resource.
Lines 1582-1588 Link Here
1582
	 * @since 2.0
1582
	 * @since 2.0
1583
	 */
1583
	 */
1584
	public boolean isDerived();
1584
	public boolean isDerived();
1585
	
1585
1586
	/**
1586
	/**
1587
	 * Returns whether this resource subtree is marked as derived. Returns 
1587
	 * Returns whether this resource subtree is marked as derived. Returns 
1588
	 * <code>false</code> if this resource does not exist.
1588
	 * <code>false</code> if this resource does not exist.
Lines 2504-2509 Link Here
2504
	 * @see IResourceDelta#DESCRIPTION
2504
	 * @see IResourceDelta#DESCRIPTION
2505
	 */
2505
	 */
2506
	public void touch(IProgressMonitor monitor) throws CoreException;
2506
	public void touch(IProgressMonitor monitor) throws CoreException;
2507
2508
	// Note to Committers (from Francis):  These comments below are minimal, and these
2509
	// methods are not in the correct place.  I will take care of making this
2510
	// right if you indicate you want the patch.
2507
	
2511
	
2508
	
2512
	
2513
	/**
2514
	 * Removes the previously saved persistent properties.
2515
	 * 
2516
	 * This is used to support saving persistent properties when a resource 
2517
	 * has been deleted so that the properties can be restored is the delete is undone.
2518
	 * @throws CoreException
2519
	 */
2520
	public void removeDeletedPersistentProperties() throws CoreException;
2521
2522
	/**
2523
	 * Sets this resource's persistent properties to be those previously
2524
	 * saved when the using the savePersistentPropertiesAsDeleted() method. 
2525
	 * 
2526
	 * This is used to support saving persistent properties when a 
2527
	 * resource has been deleted so that the properties can be restored is the delete is undone.
2528
	 * @throws CoreException
2529
	 */
2530
	public void restorePersistentPropertiesFromDeleted() throws CoreException;
2531
2532
	/**
2533
	 * Saves this resource's persistent properties so they persist after the
2534
	 * resource has been deleted.  This must be followed either by a 
2535
	 * restorePersistentPropertiesFromDeleted() call (if the delete is undone)
2536
	 * or a removeDeletedPersistentProperties (if the delete can never
2537
	 * be undone.
2538
	 * 
2539
	 * This is used to support saving persistent properties when a resource 
2540
	 * has been deleted so that the properties can be restored is the delete is undone.
2541
	 * @throws CoreException
2542
	 */
2543
	public void savePersistentPropertiesAsDeleted() throws CoreException;
2544
2509
}
2545
}
(-)src/org/eclipse/core/internal/properties/DeletedPropertyBucket.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.core.internal.properties;
12
13
/**
14
 * Used to store properties associated with deleted resources.
15
 */
16
public class DeletedPropertyBucket extends PropertyBucket {
17
18
	/* (non-Javadoc)
19
	 * @see org.eclipse.core.internal.localstore.Bucket#getIndexFileName()
20
	 */
21
	protected String getIndexFileName() {
22
		return "deletedProperties.index"; //$NON-NLS-1$
23
	}
24
25
26
}

Return to bug 216884