View | Details | Raw Unified | Return to bug 215299 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/core/internal/resources/Resource.java (-41 / +37 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-1021 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
1018
	/* (non-Javadoc)
1019
	/* (non-Javadoc)
1020
	 * @see IResource#getPersistentProperties()
1021
	 */
1022
	public Map getPersistentProperties() throws CoreException {
1023
		checkAccessibleAndLocal(DEPTH_ZERO);
1024
		return getPropertyManager().getProperties(this);
1025
	}
1026
1027
	/* (non-Javadoc)
1019
	 * @see IResource#getProject()
1028
	 * @see IResource#getProject()
1020
	 */
1029
	 */
1021
	public IProject getProject() {
1030
	public IProject getProject() {
Lines 1073-1085 Link Here
1073
	 * @see IResource#getSessionProperty(QualifiedName)
1082
	 * @see IResource#getSessionProperty(QualifiedName)
1074
	 */
1083
	 */
1075
	public Object getSessionProperty(QualifiedName key) throws CoreException {
1084
	public Object getSessionProperty(QualifiedName key) throws CoreException {
1076
		ResourceInfo info = getResourceInfo(false, false);
1085
		ResourceInfo info = checkAccessibleAndLocal(DEPTH_ZERO);
1077
		int flags = getFlags(info);
1078
		checkAccessible(flags);
1079
		checkLocal(flags, DEPTH_ZERO);
1080
		return info.getSessionProperty(key);
1086
		return info.getSessionProperty(key);
1081
	}
1087
	}
1082
1088
1089
	/* (non-Javadoc)
1090
	 * @see IResource#getSessionProperties()
1091
	 */
1092
	public Map getSessionProperties() throws CoreException {
1093
		ResourceInfo info = checkAccessibleAndLocal(DEPTH_ZERO);
1094
		return info.getSessionProperties();
1095
	}
1096
1083
	public IFileStore getStore() {
1097
	public IFileStore getStore() {
1084
		return getLocalManager().getStore(this);
1098
		return getLocalManager().getStore(this);
1085
	}
1099
	}
Lines 1471-1480 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
Lines 1545-1554 Link Here
1545
			throw new IllegalArgumentException("Illegal value: " + value); //$NON-NLS-1$
1556
			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
1557
		// 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.
1558
		// 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);
1559
		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);
1560
		return getLocalManager().setLocalTimeStamp(this, info, value);
1553
	}
1561
	}
1554
1562
Lines 1556-1565 Link Here
1556
	 * @see IResource#setPersistentProperty(QualifiedName, String)
1564
	 * @see IResource#setPersistentProperty(QualifiedName, String)
1557
	 */
1565
	 */
1558
	public void setPersistentProperty(QualifiedName key, String value) throws CoreException {
1566
	public void setPersistentProperty(QualifiedName key, String value) throws CoreException {
1559
		ResourceInfo info = getResourceInfo(false, false);
1567
		checkAccessibleAndLocal(DEPTH_ZERO);
1560
		int flags = getFlags(info);
1561
		checkAccessible(flags);
1562
		checkLocal(flags, DEPTH_ZERO);
1563
		getPropertyManager().setProperty(this, key, value);
1568
		getPropertyManager().setProperty(this, key, value);
1564
	}
1569
	}
1565
1570
Lines 1583-1592 Link Here
1583
	 * @see org.eclipse.core.resources.IResource#setResourceAttributes(org.eclipse.core.resources.ResourceAttributes)
1588
	 * @see org.eclipse.core.resources.IResource#setResourceAttributes(org.eclipse.core.resources.ResourceAttributes)
1584
	 */
1589
	 */
1585
	public void setResourceAttributes(ResourceAttributes attributes) throws CoreException {
1590
	public void setResourceAttributes(ResourceAttributes attributes) throws CoreException {
1586
		ResourceInfo info = getResourceInfo(false, false);
1591
		checkAccessibleAndLocal(DEPTH_ZERO);
1587
		int flags = getFlags(info);
1588
		checkAccessible(flags);
1589
		checkLocal(flags, DEPTH_ZERO);
1590
		getLocalManager().setResourceAttributes(this, attributes);
1592
		getLocalManager().setResourceAttributes(this, attributes);
1591
	}
1593
	}
1592
1594
Lines 1597-1606 Link Here
1597
		// fetch the info but don't bother making it mutable even though we are going
1599
		// 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
1600
		// 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.
1601
		// matter as the change we are doing does not show up in deltas.
1600
		ResourceInfo info = getResourceInfo(false, false);
1602
		ResourceInfo info = checkAccessibleAndLocal(DEPTH_ZERO);
1601
		int flags = getFlags(info);
1602
		checkAccessible(flags);
1603
		checkLocal(flags, DEPTH_ZERO);
1604
		info.setSessionProperty(key, value);
1603
		info.setSessionProperty(key, value);
1605
	}
1604
	}
1606
1605
Lines 1650-1659 Link Here
1650
			final ISchedulingRule rule = workspace.getRuleFactory().modifyRule(this);
1649
			final ISchedulingRule rule = workspace.getRuleFactory().modifyRule(this);
1651
			try {
1650
			try {
1652
				workspace.prepareOperation(rule, monitor);
1651
				workspace.prepareOperation(rule, monitor);
1653
				ResourceInfo info = getResourceInfo(false, false);
1652
				ResourceInfo info = checkAccessibleAndLocal(DEPTH_ZERO);
1654
				int flags = getFlags(info);
1655
				checkAccessible(flags);
1656
				checkLocal(flags, DEPTH_ZERO);
1657
1653
1658
				workspace.beginOperation(true);
1654
				workspace.beginOperation(true);
1659
				// fake a change by incrementing the content ID
1655
				// fake a change by incrementing the content ID
(-)src/org/eclipse/core/internal/resources/ResourceInfo.java (+7 lines)
Lines 189-194 Link Here
189
		return null;
189
		return null;
190
	}
190
	}
191
191
192
	/**
193
	 * Returns the a map of the session properties.
194
	 */
195
	public Map getSessionProperties() {
196
		return sessionProperties;
197
	}
198
	
192
	/** 
199
	/** 
193
	 * Returns the value of the identified session property
200
	 * Returns the value of the identified session property
194
	 */
201
	 */
(-)src/org/eclipse/core/resources/IResource.java (-4 / +32 lines)
Lines 12-17 Link Here
12
package org.eclipse.core.resources;
12
package org.eclipse.core.resources;
13
13
14
import java.net.URI;
14
import java.net.URI;
15
import java.util.Map;
15
import org.eclipse.core.runtime.*;
16
import org.eclipse.core.runtime.*;
16
import org.eclipse.core.runtime.jobs.ISchedulingRule;
17
import org.eclipse.core.runtime.jobs.ISchedulingRule;
17
18
Lines 270-276 Link Here
270
	 * @since 3.2
271
	 * @since 3.2
271
	 */
272
	 */
272
	public static final int TEAM_PRIVATE = 0x800;
273
	public static final int TEAM_PRIVATE = 0x800;
273
	
274
274
	/**
275
	/**
275
	 * Update flag constant (bit mask value 0x1000) indicating that a 
276
	 * Update flag constant (bit mask value 0x1000) indicating that a 
276
	 * resource should be marked as a hidden resource.
277
	 * resource should be marked as a hidden resource.
Lines 1362-1367 Link Here
1362
	public IContainer getParent();
1363
	public IContainer getParent();
1363
1364
1364
	/**
1365
	/**
1366
	 * Returns a map of all persistent properties of this resource.
1367
	 *
1368
	 * @return a Map containing the persistent properties where the key is
1369
	 * 	   the qualified name of the property and the value is the value of the property.
1370
	 * @exception CoreException if this method fails. Reasons include:
1371
	 * <ul>
1372
	 * <li> This resource does not exist.</li>
1373
	 * <li> This resource is not local.</li>
1374
	 * <li> This resource is a project that is not open.</li>
1375
	 * </ul>
1376
	 */
1377
	public Map getPersistentProperties() throws CoreException;
1378
1379
	/**
1365
	 * Returns the value of the persistent property of this resource identified
1380
	 * Returns the value of the persistent property of this resource identified
1366
	 * by the given key, or <code>null</code> if this resource has no such property.
1381
	 * by the given key, or <code>null</code> if this resource has no such property.
1367
	 *
1382
	 *
Lines 1502-1507 Link Here
1502
	public ResourceAttributes getResourceAttributes();
1517
	public ResourceAttributes getResourceAttributes();
1503
1518
1504
	/**
1519
	/**
1520
	 * Returns a map of all session properties of this resource.
1521
	 *
1522
	 * @return a Map containing the session properties where the key is
1523
	 * 	   the qualified name of the property and the value is the value of the property.
1524
	 * @exception CoreException if this method fails. Reasons include:
1525
	 * <ul>
1526
	 * <li> This resource does not exist.</li>
1527
	 * <li> This resource is not local.</li>
1528
	 * <li> This resource is a project that is not open.</li>
1529
	 * </ul>
1530
	 */
1531
	public Map getSessionProperties() throws CoreException;
1532
1533
	/**
1505
	 * Returns the value of the session property of this resource identified
1534
	 * Returns the value of the session property of this resource identified
1506
	 * by the given key, or <code>null</code> if this resource has no such property.
1535
	 * by the given key, or <code>null</code> if this resource has no such property.
1507
	 *
1536
	 *
Lines 1582-1588 Link Here
1582
	 * @since 2.0
1611
	 * @since 2.0
1583
	 */
1612
	 */
1584
	public boolean isDerived();
1613
	public boolean isDerived();
1585
	
1614
1586
	/**
1615
	/**
1587
	 * Returns whether this resource subtree is marked as derived. Returns 
1616
	 * Returns whether this resource subtree is marked as derived. Returns 
1588
	 * <code>false</code> if this resource does not exist.
1617
	 * <code>false</code> if this resource does not exist.
Lines 2504-2509 Link Here
2504
	 * @see IResourceDelta#DESCRIPTION
2533
	 * @see IResourceDelta#DESCRIPTION
2505
	 */
2534
	 */
2506
	public void touch(IProgressMonitor monitor) throws CoreException;
2535
	public void touch(IProgressMonitor monitor) throws CoreException;
2507
	
2536
2508
	
2509
}
2537
}
(-)src/org/eclipse/core/tests/resources/IResourceTest.java (+78 lines)
Lines 1698-1703 Link Here
1698
		project.open(null);
1698
		project.open(null);
1699
		assertEquals(stamp, file.getModificationStamp());
1699
		assertEquals(stamp, file.getModificationStamp());
1700
	}
1700
	}
1701
	
1702
	/**
1703
	 * Test properties.
1704
	 */
1705
	public void testProperties() throws CoreException {
1706
		QualifiedName qn1 = new QualifiedName("package", "property1");
1707
		QualifiedName qn2 = new QualifiedName("package", "property2");
1708
		
1709
		IProject project = getWorkspace().getRoot().getProject("P1");
1710
		IProject project2 = getWorkspace().getRoot().getProject("P2");
1711
		project.create(null);
1712
		project.open(null);
1713
		project.setPersistentProperty(qn1, "value1");
1714
		project.setPersistentProperty(qn2, "value2");
1715
		project.setSessionProperty(qn1, "value1");
1716
		project.setSessionProperty(qn2, "value2");
1717
		
1718
		assertEquals("value1", project.getPersistentProperty(qn1));
1719
		assertEquals("value2", project.getPersistentProperty(qn2));
1720
		assertEquals("value1", project.getSessionProperty(qn1));
1721
		assertEquals("value2", project.getSessionProperty(qn2));
1722
		
1723
		Map props = project.getPersistentProperties();
1724
		assertEquals(2, props.size());
1725
		assertEquals("value1",props.get(qn1));
1726
		assertEquals("value2",props.get(qn2));
1727
		
1728
		props = project.getSessionProperties();
1729
		// Don't check the size, because other plugins (like team) may add
1730
		// a property depending on if they are present or not
1731
		assertEquals("value1",props.get(qn1));
1732
		assertEquals("value2",props.get(qn2));
1733
		
1734
		project.setPersistentProperty(qn1, null);
1735
		project.setSessionProperty(qn1, null);
1736
1737
		props = project.getPersistentProperties();
1738
		assertEquals(1, props.size());
1739
		assertNull(props.get(qn1));
1740
		assertEquals("value2",props.get(qn2));
1741
		
1742
		props = project.getSessionProperties();
1743
		assertNull(props.get(qn1));
1744
		assertEquals("value2",props.get(qn2));
1745
1746
		// Copy
1747
		project.copy(project2.getFullPath(), true, null);
1748
1749
		// Persistent properties go with the copy
1750
		props = project2.getPersistentProperties();
1751
		assertEquals(1, props.size());
1752
		assertNull(props.get(qn1));
1753
		assertEquals("value2",props.get(qn2));
1754
1755
		// Session properties don't
1756
		props = project2.getSessionProperties();
1757
		// Don't check size (see above)
1758
		assertNull(props.get(qn1));
1759
		assertNull(props.get(qn2));
1760
		
1761
		
1762
		// Test persistence
1763
		project.close(null);
1764
		project.open(null);
1765
1766
		// Make sure they are really persistent
1767
		props = project.getPersistentProperties();
1768
		assertEquals(1, props.size());
1769
		assertNull(props.get(qn1));
1770
		assertEquals("value2",props.get(qn2));
1771
1772
		// Make sure they don't persist
1773
		props = project.getSessionProperties();
1774
		// Don't check size (see above)
1775
		assertNull(props.get(qn1));
1776
		assertNull(props.get(qn2));
1777
		
1778
	}
1701
1779
1702
	/**
1780
	/**
1703
	 * Tests IResource.isReadOnly and setReadOnly
1781
	 * Tests IResource.isReadOnly and setReadOnly

Return to bug 215299