com.microsoft.tfs.core.clients.versioncontrol
Class Workstation

java.lang.Object
  extended by com.microsoft.tfs.core.clients.versioncontrol.Workstation

public class Workstation
extends java.lang.Object


Method Summary
 void addWorkstationEventListener(VersionControlClient client)
          Adds a VersionControlClient whose VersionControlEventEngine will receive events from this Workstation class.
 void checkForLocalItemExclusionUpdates(VersionControlClient client, boolean force)
          Checks to see if the default local item exclusions have changed on the server.
 void ensureUpdateWorkspaceInfoCache(VersionControlClient client, java.lang.String ownerName)
          If updateWorkspaceInfoCache() has not yet been called for the specified server and owner, this method will call it.
 void ensureUpdateWorkspaceInfoCache(VersionControlClient client, java.lang.String ownerName, long maxAgeMillis)
          If updateWorkspaceInfoCache() has not yet been called for the specified server and owner within the specified time, this method will call it.
 WorkspaceInfo[] getAllLocalWorkspaceInfo()
          Get a list of all cached local workspace info objects.
 com.microsoft.tfs.core.clients.versioncontrol.workspacecache.internal.InternalCache getCache()
          Internal method to get the InternalCache.
static java.io.File getConfigurationDirectory(PersistenceStoreProvider provider)
          Gets the directory where Workstation stores its non-cache configuration files.
static Workstation getCurrent(PersistenceStoreProvider persistenceProvider)
          Gets the "current" (for this computer) Workstation that uses the specified PersistenceStoreProvider to read and write its cache and config files.
 java.lang.String[] getLocalItemExclusions(VersionControlClient client)
          Returns the set of local item exclusions for this user on this machine.
 WorkspaceInfo getLocalWorkspaceInfo(com.microsoft.tfs.util.GUID repositoryGuid, java.lang.String workspaceName, java.lang.String workspaceOwner)
          Get the cached local workspace info for the specified workspace.
 WorkspaceInfo getLocalWorkspaceInfo(java.lang.String path)
          Get the cached local workspace info for the workspace that contains the specified path.
 WorkspaceInfo getLocalWorkspaceInfo(VersionControlClient client, java.lang.String workspaceName, java.lang.String workspaceOwner)
          Get the cached local workspace info for the specified workspace.
 WorkspaceInfo[] getLocalWorkspaceInfoRecursively(java.lang.String path)
          Gets the workspace at or workspaces below the path.
 java.lang.String getName()
           
 NotificationManager getNotificationManager()
           
static java.io.File getOfflineMetadataFileRoot(PersistenceStoreProvider provider)
          Returns the directory location where workspace local version metadata files are stored.
 WorkspaceInfo insertWorkspaceIntoCache(Workspace localWorkspace)
          This helper method inserts a workspace into the Workstation cache.
 boolean isCacheEnabled()
          When true, the cache directory exists and will be used.
 boolean isConfigurationEnabled()
          When true, the configuration directory exists and will be used.
 boolean isExplicitlyMapped(java.lang.String path)
          Returns true if the specified local path is explicitly mapped in a workspace (i.e., it is a root mapping).
 boolean isMapped(java.lang.String path)
          Returns true if the specified local path is mapped in a workspace.
 void notifyForChangesetReconciled(VersionControlClient client, int changesetID)
          Send a cross-process notification through the current NotificationManager that a changeset was reconciled after a gated check-in.
 void notifyForFolderContentChanged(VersionControlClient client)
          Send a cross-process notification through the current NotificationManager that server data changed without a new changeset being created (from destroy, branch objects, etc.).
 void notifyForFolderContentChanged(VersionControlClient client, int changesetID)
          Send a cross-process notification through the current NotificationManager that server data changed with a new changeset created.
 void notifyForWorkspace(Workspace workspace, Notification notification)
          Send a cross-process notification through the current NotificationManager for an event that happened in the specified workspace.
 WorkspaceInfo[] queryLocalWorkspaceInfo(VersionControlClient client, java.lang.String workspaceName, java.lang.String workspaceOwner)
          Get a list of cached local workspace info.
 void reloadCache()
          Call Workstation.Current.ReloadCache() to force a reload of the cache file from disk.
 WorkspaceInfo[] removeCachedWorkspaceInfo(java.net.URI serverUri, java.lang.String workspaceName, java.lang.String workspaceOwner)
          Removes from the cache the workspace specified.
 WorkspaceInfo[] removeCachedWorkspaceInfo(VersionControlClient client)
          Removes from the cache the workspaces for the specified source control repository.
 WorkspaceInfo[] removeCachedWorkspaceInfo(VersionControlClient client, java.lang.String ownerName)
          Removes from the cache the workspaces for the specified source control repository.
 void removeLocalItemExclusion(VersionControlClient client, java.lang.String exclusion)
          Removes an exclusion from the local item exclusion list.
 void removeWorkstationEventListener(VersionControlClient client)
          Removes a listener previously added with addWorkstationEventListener(VersionControlClient).
 void saveConfigIfDirty()
          Internal method to save the cache if it has been modified.
 void setLocalItemExclusions(VersionControlClient client, java.lang.String[] exclusions)
          Overwrites the list of local item exclusions with the list passed in.
 NotificationManager setNotificationManager(NotificationManager newManager)
          Sets the NotificationManager this workstation uses to send and receive intra- and inter-process notifications about things like changes to mappings, new pending changes, merge completion.
 void updateServerURIReferences(VersionControlClient client, java.net.URI uri)
          Updates the cache to reference the specified source control repository using the specified URI, if different.
 void updateWorkspaceInfoCache(VersionControlClient client, java.lang.String ownerName)
          Loads into the cache the workspaces residing in the specified source control repository and having the specified owner.
 void updateWorkspaceInfoCache(VersionControlClient client, java.lang.String ownerName, java.util.concurrent.atomic.AtomicReference<Workspace[]> workspaces)
          Loads into the cache the workspaces residing in the specified source control repository and having the specified owner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getCurrent

public static Workstation getCurrent(PersistenceStoreProvider persistenceProvider)
Gets the "current" (for this computer) Workstation that uses the specified PersistenceStoreProvider to read and write its cache and config files.

Parameters:
persistenceProvider - the PersistenceStoreProvider the Workstation will use (must not be null)
Returns:
the Workstation (never null)

addWorkstationEventListener

public void addWorkstationEventListener(VersionControlClient client)
Adds a VersionControlClient whose VersionControlEventEngine will receive events from this Workstation class. This special pattern is used because of the automatic caching done for Workstation instances.

Parameters:
client - the client to add (must not be null)

removeWorkstationEventListener

public void removeWorkstationEventListener(VersionControlClient client)
Removes a listener previously added with addWorkstationEventListener(VersionControlClient).

Parameters:
client - the client to remove (must not be null)

setNotificationManager

public NotificationManager setNotificationManager(NotificationManager newManager)
Sets the NotificationManager this workstation uses to send and receive intra- and inter-process notifications about things like changes to mappings, new pending changes, merge completion.

Does not call NotificationManager.close() on the old manager being replaced.

Parameters:
newManager - the notification manager to use or null to stop sending and receiving notifications
Returns:
the existing NotificationManager or null if there wasn't one

getNotificationManager

public NotificationManager getNotificationManager()
Returns:
the NotificationManager this Workstation is using or null if there is no active NotificationManager.

notifyForWorkspace

public void notifyForWorkspace(Workspace workspace,
                               Notification notification)
Send a cross-process notification through the current NotificationManager for an event that happened in the specified workspace.

This method may be called on any thread (does not have to be the UI thread).

Parameters:
workspace - the workspace where the event happened (must not be null)
notification - the notification to send (must not be null)

notifyForChangesetReconciled

public void notifyForChangesetReconciled(VersionControlClient client,
                                         int changesetID)
Send a cross-process notification through the current NotificationManager that a changeset was reconciled after a gated check-in.

This method may be called on any thread (does not have to be the UI thread).

Parameters:
client - the client where the reconcile happened (must not be null)
changesetID - of changeset reconciled

notifyForFolderContentChanged

public void notifyForFolderContentChanged(VersionControlClient client)
Send a cross-process notification through the current NotificationManager that server data changed without a new changeset being created (from destroy, branch objects, etc.).

This method may be called on any thread (does not have to be the UI thread).

Parameters:
client - the client where the change happened (must not be null)

notifyForFolderContentChanged

public void notifyForFolderContentChanged(VersionControlClient client,
                                          int changesetID)
Send a cross-process notification through the current NotificationManager that server data changed with a new changeset created.

This method may be called on any thread (does not have to be the UI thread).

Parameters:
client - the client where the change happened (must not be null)
changesetID - the ID of the committed changeset

getAllLocalWorkspaceInfo

public WorkspaceInfo[] getAllLocalWorkspaceInfo()
Get a list of all cached local workspace info objects.

Returns:
workspace info objects

getLocalWorkspaceInfo

public WorkspaceInfo getLocalWorkspaceInfo(VersionControlClient client,
                                           java.lang.String workspaceName,
                                           java.lang.String workspaceOwner)
Get the cached local workspace info for the specified workspace.

Parameters:
sourceControl - the server associated with the specified workspace
workspaceName - the name of the workspace
workspaceOwner - the workspace owner
Returns:
info on the workspace or null

getLocalWorkspaceInfo

public WorkspaceInfo getLocalWorkspaceInfo(com.microsoft.tfs.util.GUID repositoryGuid,
                                           java.lang.String workspaceName,
                                           java.lang.String workspaceOwner)
Get the cached local workspace info for the specified workspace.

Parameters:
repositoryGuid - GUID for the associated server
workspaceName - the name of the workspace (must not be null)
workspaceOwner - the workspace owner (must not be null)
Returns:
info on the workspace or null

getLocalWorkspaceInfo

public WorkspaceInfo getLocalWorkspaceInfo(java.lang.String path)
Get the cached local workspace info for the workspace that contains the specified path.

Parameters:
path - the local path (must not be null or empty)
Returns:
info on the containing workspace or null if not in a workspace

getLocalWorkspaceInfoRecursively

public WorkspaceInfo[] getLocalWorkspaceInfoRecursively(java.lang.String path)
Gets the workspace at or workspaces below the path.

Parameters:
path - the path (must not be null or empty)
Returns:
the workspaces for the path and its children

queryLocalWorkspaceInfo

public WorkspaceInfo[] queryLocalWorkspaceInfo(VersionControlClient client,
                                               java.lang.String workspaceName,
                                               java.lang.String workspaceOwner)
Get a list of cached local workspace info. If workspaceName is null, all workspaces in the cache file for the specified owner are returned. If workspaceName is not null, then only those workspaces with a matching name are returned.

Parameters:
sourceControl - the source control repository (if null, any repository)
workspaceName - the name of the workspace (if null, all workspaces for this computer)
workspaceOwner - the workspace owner (if null, any workspace owner)
Returns:
the matching workspace info instances

isMapped

public boolean isMapped(java.lang.String path)
Returns true if the specified local path is mapped in a workspace.

Parameters:
the - local path
Returns:
true if the path is mapped in a workspace; false otherwise

isExplicitlyMapped

public boolean isExplicitlyMapped(java.lang.String path)
Returns true if the specified local path is explicitly mapped in a workspace (i.e., it is a root mapping).

Parameters:
the - local path
Returns:
true if the path is explicitly mapped in a workspace; false otherwise

ensureUpdateWorkspaceInfoCache

public void ensureUpdateWorkspaceInfoCache(VersionControlClient client,
                                           java.lang.String ownerName)
If updateWorkspaceInfoCache() has not yet been called for the specified server and owner, this method will call it. Otherwise, it returns without contacting the server.


ensureUpdateWorkspaceInfoCache

public void ensureUpdateWorkspaceInfoCache(VersionControlClient client,
                                           java.lang.String ownerName,
                                           long maxAgeMillis)
If updateWorkspaceInfoCache() has not yet been called for the specified server and owner within the specified time, this method will call it. Otherwise, it returns without contacting the server.

Parameters:
client - the client (must not be null)
ownerName - the owner of the workspaces (must not be null or empty)
maxAgeMillis - the maximum age (not time) of the last request in milliseconds

updateServerURIReferences

public void updateServerURIReferences(VersionControlClient client,
                                      java.net.URI uri)
Updates the cache to reference the specified source control repository using the specified URI, if different.

Parameters:
client - the version control client (must not be null)
uri - the URI for the server to use in the cache (must not be null)

updateWorkspaceInfoCache

public void updateWorkspaceInfoCache(VersionControlClient client,
                                     java.lang.String ownerName)
Loads into the cache the workspaces residing in the specified source control repository and having the specified owner.

Parameters:
client - the client (must not be null)
ownerName - the owner of the workspaces (must not be null or empty)

updateWorkspaceInfoCache

public void updateWorkspaceInfoCache(VersionControlClient client,
                                     java.lang.String ownerName,
                                     java.util.concurrent.atomic.AtomicReference<Workspace[]> workspaces)
Loads into the cache the workspaces residing in the specified source control repository and having the specified owner. Returns the workspaces from the QueryWorkspaces call made by this method.

Parameters:
client - the client (must not be null)
ownerName - the owner of the workspaces (must not be null or empty)
workspaces - the holder for the workspaces (must not be null)

insertWorkspaceIntoCache

public WorkspaceInfo insertWorkspaceIntoCache(Workspace localWorkspace)
This helper method inserts a workspace into the Workstation cache. The caller is responsible for writing out the Workstation cache.


removeCachedWorkspaceInfo

public WorkspaceInfo[] removeCachedWorkspaceInfo(VersionControlClient client)
Removes from the cache the workspaces for the specified source control repository.

Parameters:
client - the source control repository
Returns:
the WorkspaceInfo objects that are removed from the cache

removeCachedWorkspaceInfo

public WorkspaceInfo[] removeCachedWorkspaceInfo(VersionControlClient client,
                                                 java.lang.String ownerName)
Removes from the cache the workspaces for the specified source control repository.

Parameters:
client - the source control repository (must not be null)
ownerName - the owner of the workspaces (must not be null or empty) the owner of the workspaces
Returns:
the WorkspaceInfo objects that are removed from the cache

removeCachedWorkspaceInfo

public WorkspaceInfo[] removeCachedWorkspaceInfo(java.net.URI serverUri,
                                                 java.lang.String workspaceName,
                                                 java.lang.String workspaceOwner)
Removes from the cache the workspace specified. Since the server may no longer exist, the server is not contacted and the match is by name.

Parameters:
serverUri - the URI of the server containing the workspaces to remove from the cache; passing null matches all servers
workspaceName - the name of the workspace to remove from the cache; passing null matches all workspaces
workspaceOwner - the owner of the workspace to remove from the cache; passing null matches all owners
Returns:
the WorkspaceInfo objects that were removed from the cache

saveConfigIfDirty

public void saveConfigIfDirty()
Internal method to save the cache if it has been modified.


getCache

public com.microsoft.tfs.core.clients.versioncontrol.workspacecache.internal.InternalCache getCache()
Internal method to get the InternalCache.


reloadCache

public void reloadCache()
Call Workstation.Current.ReloadCache() to force a reload of the cache file from disk.


removeLocalItemExclusion

public void removeLocalItemExclusion(VersionControlClient client,
                                     java.lang.String exclusion)
Removes an exclusion from the local item exclusion list.

Parameters:
The - exclusion to remove (must not be null or empty)

getLocalItemExclusions

public java.lang.String[] getLocalItemExclusions(VersionControlClient client)
Returns the set of local item exclusions for this user on this machine.


setLocalItemExclusions

public void setLocalItemExclusions(VersionControlClient client,
                                   java.lang.String[] exclusions)
Overwrites the list of local item exclusions with the list passed in.

Parameters:
exclusions - The new exclusions

checkForLocalItemExclusionUpdates

public void checkForLocalItemExclusionUpdates(VersionControlClient client,
                                              boolean force)
Checks to see if the default local item exclusions have changed on the server. If force is false, this will only happen once a week.

Parameters:
force - if true the server is contacted every time, otherwise if enough time has elapsed since the last check

getName

public java.lang.String getName()
Returns:
the name of this Workstation (aka machine name or computer name).

isCacheEnabled

public boolean isCacheEnabled()
When true, the cache directory exists and will be used. When false, either we don't have access to the directory, it doesn't exist, or it has been set to false by the application, and we'll need to run without the cache.


isConfigurationEnabled

public boolean isConfigurationEnabled()
When true, the configuration directory exists and will be used. When false, either we don't have access to the directory, it doesn't exist, or it has been set to false by the application, and we'll need to run without the configuration cache.


getConfigurationDirectory

public static java.io.File getConfigurationDirectory(PersistenceStoreProvider provider)
Gets the directory where Workstation stores its non-cache configuration files. This may not be the given PersistenceStoreProvider's value if certain environment variables or application config settings are specified.

Parameters:
provider - the PersistenceStoreProvider to get the default location from (must not be null)
Returns:
the directory where Workstation will store its configuration files or null if the configuration directory is not available

getOfflineMetadataFileRoot

public static java.io.File getOfflineMetadataFileRoot(PersistenceStoreProvider provider)
Returns the directory location where workspace local version metadata files are stored.

Parameters:
provider - the provider to find configuration storage with (must not be null)


© 2015 Microsoft. All rights reserved.