diff options
author | Jean Michel-Lemieux | 2002-05-14 21:01:03 +0000 |
---|---|---|
committer | Jean Michel-Lemieux | 2002-05-14 21:01:03 +0000 |
commit | ee4478b5079d58df818eafa1f40c3eefb02e0b3c (patch) | |
tree | 11bb31adb4654bb3b4069e99bbcab3447dc721e3 /bundles | |
parent | dcc249b8827c12e2d1ceeee13aec3f92d851a22e (diff) | |
download | eclipse.platform.team-ee4478b5079d58df818eafa1f40c3eefb02e0b3c.tar.gz eclipse.platform.team-ee4478b5079d58df818eafa1f40c3eefb02e0b3c.tar.xz eclipse.platform.team-ee4478b5079d58df818eafa1f40c3eefb02e0b3c.zip |
*** empty log message ***
Diffstat (limited to 'bundles')
7 files changed, 148 insertions, 127 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/ISiteFactory.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/ISiteFactory.java index 6abe85e99..9b9d05dc0 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/ISiteFactory.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/ISiteFactory.java @@ -10,27 +10,33 @@ ******************************************************************************/ package org.eclipse.team.core.target; +import java.io.ObjectInputStream; import java.util.Properties; +/** + * The <code>ISiteFactory</code> interface must be implemented by any plug-in + * that is providing target management. It provides mechanisms for creating + * concrete <code>Site</code> instances for it's target type. + * + * @see Site + */ public interface ISiteFactory { - /** - * Returns a new target site for the given target specific - * description. + * Responsible for reading from the stream and restoring the classes fields + * then returning a new <code>Site</code> instance. The <code>Site</code> + * instances are written using the <code>Site#writeObject</code> method. * - * @param description the target specific description encoded - * as a string + * @param is the input stream that contains the output of Site#writeObject * @return a new target site */ - public Site newSite(String description); + public Site newSite(ObjectInputStream is); /** - * Returns a new target site for the given target specific - * properties. + * Returns a new target site for the given target specific properties. This + * is mainly used for testing purposes. * - * @param properties the target specific location encoded - * in properties + * @param properties the target specific location encoded in properties * @return a new target site */ public Site newSite(Properties properties); -} +}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/Site.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/Site.java index 3e1f7f39a..188a17996 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/Site.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/Site.java @@ -1,31 +1,84 @@ +/******************************************************************************* + * Copyright (c) 2002 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM - Initial API and implementation + ******************************************************************************/ package org.eclipse.team.core.target; +import java.io.ObjectOutputStream; +import java.net.URL; + import org.eclipse.core.runtime.IPath; import org.eclipse.team.core.TeamException; +/** + * A <code>Site</code> is a place where resources can be deployed and + * retrieved via a target provider. + * + * @see ISiteFactory + */ public abstract class Site { - /* - * Initialize a new Site of the given type. + /** + * Answers a <code>TargetProvider</code> instance for the given path at + * this site. */ - - public Site() { - super(); - } - - public abstract TargetProvider newProvider(IPath intrasitePath) throws TeamException; + public abstract TargetProvider newProvider(IPath intrasitePath) + throws TeamException; + /** + * Answers the type identifier for this site. For example: + * <blockquote><pre> + * org.eclipse.team.target.webdav + * </pre></blockquote> + * + * @return string identifier for this site + */ public abstract String getType(); - public abstract String getDisplayName(); - - public abstract String getUniqueIdentifier(); - - public abstract String encode(); + /** + * Answers the location of this site as a URL. For example: + * <blockquote><pre> + * http://www.mysite.com:14356/dav + * </pre></blockquote> + * + * @return URL location of this site + */ + public abstract URL getURL(); - public abstract IPath getPath(); + /** + * Answers a string that can be displayed to the user that represents + * this site. For example: + * <blockquote><pre> + * http://usename@www.mysite.com/dav (WebDav) + * </pre></blockquote> + */ + public abstract String getDisplayName(); /** + * Writes the state of this site such that the corresponding concrete + * <code>ISiteFactory</code> class can restore the site. + * + * @param os the object stream into which to write it's state + */ + public abstract void writeObject(ObjectOutputStream os); + + /** + * Compares two Sites. The result is <code>true</code> if and only if + * the argument is not <code>null</code> and is a Site object that + * represents the same Site as this object. Two Site objects are equal + * if they have the same types and URLs. + * + * @param other the Site to compare against + * + * @return <code>true</code> if the Sites are the same; <code>false</code> + * otherwise + * * @see Object#equals(Object) */ public boolean equals(Object other) { @@ -33,13 +86,15 @@ public abstract class Site { if(! (other instanceof Site)) return false; Site location = (Site)other; return getType().equals(location.getType()) && - getUniqueIdentifier().equals(location.getUniqueIdentifier()); + getURL().equals(location.getURL()); } /** + * Debugging helper + * * @see Object#toString() */ public String toString() { - return getType() + ":" + getUniqueIdentifier(); + return getDisplayName(); } -} +}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetManager.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetManager.java index b0acfba2a..f05be20db 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetManager.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetManager.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2002 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM - Initial API and implementation + ******************************************************************************/ package org.eclipse.team.core.target; import java.io.DataInputStream; @@ -6,6 +16,9 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.net.URL; import java.util.ArrayList; import java.util.Hashtable; import java.util.Iterator; @@ -24,8 +37,8 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.Status; import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.core.TeamPlugin; import org.eclipse.team.internal.core.Policy; +import org.eclipse.team.internal.core.TeamPlugin; import org.eclipse.team.internal.core.target.LocationMapping; public class TargetManager { @@ -52,7 +65,7 @@ public class TargetManager { save(); } - /** + /** * @see TargetProvider#map(IProject) */ public static void map(IProject project, Site site, IPath path) throws TeamException { @@ -102,7 +115,7 @@ public class TargetManager { } else { LocationMapping mapping = new LocationMapping(mappingBytes); Site site = - getSite(mapping.getType(), mapping.getLocationId()); + getSite(mapping.getType(), mapping.getURL()); if (site != null) { return site.newProvider(mapping.getPath()); } @@ -115,11 +128,11 @@ public class TargetManager { } } - public static Site getSite(String type, String id) { + public static Site getSite(String type, URL id) { for (Iterator it = sites.iterator(); it.hasNext();) { Site element = (Site) it.next(); if (element.getType().equals(type) - && element.getUniqueIdentifier().equals(id)) { + && element.getURL().equals(id)) { return element; } } @@ -173,14 +186,13 @@ public class TargetManager { int repoCount = dis.readInt(); for (int i = 0; i < repoCount; i++) { String id = dis.readUTF(); - String siteData = dis.readUTF(); ISiteFactory factory = (ISiteFactory) getSiteFactory(id); if (factory == null) { //todo: log error return; } - Site site = factory.newSite(siteData); + Site site = factory.newSite(new ObjectInputStream(dis)); sites.add(site); } } @@ -192,7 +204,7 @@ public class TargetManager { while (iter.hasNext()) { Site site = (Site) iter.next(); dos.writeUTF(site.getType()); - dos.writeUTF(site.encode()); + site.writeObject(new ObjectOutputStream(dos)); } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java index a07fa512b..07e68b54f 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java @@ -1,10 +1,20 @@ +/******************************************************************************* + * Copyright (c) 2002 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM - Initial API and implementation + ******************************************************************************/ package org.eclipse.team.core.target; +import java.net.URL; + import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.QualifiedName; import org.eclipse.team.core.TeamException; public abstract class TargetProvider { @@ -15,22 +25,11 @@ public abstract class TargetProvider { public abstract Site getSite(); /** - * Answers the path describing the place within the site itself - * where the provider stores/retrieves to/from (ie. the target root). - * @return a printable string - */ - public abstract IPath getIntrasitePath(); - - /** * Answers the full path where the provider stores/retrieves to/from. - * The target root is the location + the intra site path. * @return a printable string */ - public IPath getFullPath() { - return getSite().getPath().append(getIntrasitePath()); - } + public abstract URL getURL(); - /** * Updates the local resource to have the same content as the corresponding remote * resource. Where the local resource does not exist, this method will create it. @@ -68,11 +67,4 @@ public abstract class TargetProvider { public abstract void put(IResource[] resources, IProgressMonitor progress) throws TeamException; public abstract void deregister(IProject project); - - /** - * @see Object#toString() - */ - public String toString() { - return getFullPath().toString(); - } } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/LocationMapping.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/LocationMapping.java index 8b1aeba24..8f546e4a4 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/LocationMapping.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/LocationMapping.java @@ -5,6 +5,7 @@ import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import java.net.URL; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; @@ -15,18 +16,18 @@ public class LocationMapping { private final long SERIAL_ID = 1; private String type; - private String locationId; + private URL url; private IPath path; public LocationMapping(Site site, IPath path) { this.type = site.getType(); - this.locationId = site.getUniqueIdentifier(); + this.url = site.getURL(); this.path = path; } - public LocationMapping(String type, String locationId, IPath path) { + public LocationMapping(String type, URL url, IPath path) { this.type = type; - this.locationId = locationId; + this.url = url; this.path = path; } @@ -35,7 +36,7 @@ public class LocationMapping { DataInputStream is = new DataInputStream(bis); long id = is.readLong(); this.type = is.readUTF(); - this.locationId = is.readUTF(); + this.url = new URL(is.readUTF()); this.path = new Path(is.readUTF()); } @@ -49,30 +50,14 @@ public class LocationMapping { } /** - * Sets the type. - * @param type The type to set - */ - public void setType(String type) { - this.type = type; - } - - /** * Gets the locationId. * @return Returns a String */ - public String getLocationId() { - return locationId; + public URL getURL() { + return url; } /** - * Sets the locationId. - * @param locationId The locationId to set - */ - public void setLocationId(String locationId) { - this.locationId = locationId; - } - - /** * @see Object#equals(Object) */ public boolean equals(Object other) { @@ -80,7 +65,8 @@ public class LocationMapping { if(! (other instanceof LocationMapping)) return false; LocationMapping location = (LocationMapping)other; return getType().equals(location.getType()) && - getLocationId().equals(location.getLocationId()); + getURL().equals(location.getURL()) && + getPath().equals(location.getPath()); } /** * Gets the path. @@ -96,7 +82,7 @@ public class LocationMapping { DataOutputStream os = new DataOutputStream(bos); os.writeLong(SERIAL_ID); os.writeUTF(getType()); - os.writeUTF(getLocationId()); + os.writeUTF(getURL().toExternalForm()); os.writeUTF(getPath().toString()); return bos.toByteArray(); } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ResourceState.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ResourceState.java index 92b08f845..f9fe93b8d 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ResourceState.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ResourceState.java @@ -6,6 +6,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; import java.io.IOException; +import java.net.URL; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; @@ -59,9 +60,9 @@ public abstract class ResourceState { */ protected IResource localResource; - protected QualifiedName stateKey; + protected QualifiedName stateKey = new QualifiedName("org.eclipse.team.target", "state_info"); - protected IPath root; + protected URL rootUrl; /** * Constructor for a resource state given a local resource. @@ -69,16 +70,13 @@ public abstract class ResourceState { * * @param localResource the local part of a synchronized pair of resources. */ - public ResourceState(IResource localResource, IPath root) { + public ResourceState(IResource localResource, URL rootUrl) { super(); - this.root = root; - this.stateKey = new QualifiedName(getType(), root.toString()); + this.rootUrl = rootUrl; SynchronizedTargetProvider.getSynchronizer().add(stateKey); this.localResource = localResource; } - public abstract String getType(); - /** * Get the timestamp that represents the base state of the local resource, that is * the state that the local resource had when it was initially fetched from the repository. @@ -437,10 +435,10 @@ public abstract class ResourceState { } /** - * Gets the root. - * @return Returns a IPath + * Method getRoot. + * @return URL of this resource's parent */ - public IPath getRoot() { - return root; + public URL getRoot() { + return rootUrl; } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/SynchronizedTargetProvider.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/SynchronizedTargetProvider.java index 0b06e5a3d..a808b3759 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/SynchronizedTargetProvider.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/SynchronizedTargetProvider.java @@ -27,10 +27,6 @@ import org.eclipse.team.internal.core.TeamPlugin; public abstract class SynchronizedTargetProvider extends TargetProvider { - /* - * Configuration serialization identifier. - */ - private static final int CONFIG_FORMAT_VERSION = 2; private final int depth = IResource.DEPTH_INFINITE; @@ -50,13 +46,6 @@ public abstract class SynchronizedTargetProvider extends TargetProvider { } /** - * Create a target provider. - */ - public SynchronizedTargetProvider() { - super(); - } - - /** * Answers the synchronizer. */ final protected static ISynchronizer getSynchronizer() { @@ -64,6 +53,11 @@ public abstract class SynchronizedTargetProvider extends TargetProvider { } /** + * Answers a new state based on an existing local resource. + */ + abstract public ResourceState newState(IResource resource); + + /** * Get the state descriptor for a given resource. */ public ResourceState getState(IResource resource) { @@ -74,25 +68,6 @@ public abstract class SynchronizedTargetProvider extends TargetProvider { } /** - * Answers a new state based on an existing local resource. - */ - abstract public ResourceState newState(IResource resource); - -/** - * Providers must override this method to configure instances based on the given - * properties map. Different providers will require different types of configuration, - * and therefore they will look for different keys in the properties table. If the provider - * cannot be configured with the values given a <code>TeamException</code> is - * thrown. Subclasses should override this method (and call <code> - * super.configureProvider(Properties)</code>). - */ -// abstract public void configure(Properties properties) throws TeamException; - - - - /*************** Inherited Methods ***************/ - - /** * Get the resource from the provider to the workspace, and remember the fetched * state as the base state of the resource. * @@ -112,11 +87,8 @@ public abstract class SynchronizedTargetProvider extends TargetProvider { /** * Put the resources to the remote. */ - public void put( - IResource[] resources, - IProgressMonitor progress) + public void put(IResource[] resources, IProgressMonitor progress) throws TeamException { - execute(new IRecursiveOperation() { public IStatus visit(IResource resource, IProgressMonitor progress) { // The resource state must be checked-out. |