com.microsoft.tfs.core.clients.versioncontrol.workspacecache
Class WorkspaceInfo

java.lang.Object
  extended by com.microsoft.tfs.core.clients.versioncontrol.workspacecache.WorkspaceInfo
All Implemented Interfaces:
java.lang.Comparable<WorkspaceInfo>

public final class WorkspaceInfo
extends java.lang.Object
implements java.lang.Comparable<WorkspaceInfo>

Holds the properties of a cached workspace.

Since:
TEE-SDK-11.0
Thread-safety:
thread-compatible

Constructor Summary
WorkspaceInfo(com.microsoft.tfs.core.clients.versioncontrol.workspacecache.internal.InternalServerInfo serverInfo, Workspace workspace)
           
 
Method Summary
static boolean areMappedPathSetsEqual(java.lang.String[] set1, java.lang.String[] set2)
          Returns true if two sets of mapped local paths are identical.
static boolean areOwnerAliasesSetsEqual(java.lang.String[] set1, java.lang.String[] set2)
          Returns true if two sets of owner aliases are identical.
 int compareTo(WorkspaceInfo other)
          
 void copyLocalMetadata(WorkspaceInfo oldInfo)
          This method is used by Workstation to keep local metadata when updating the cache after querying the server.
 boolean equals(java.lang.Object obj)
          
 java.lang.String formatWorkspaceNameForException(WorkspaceInfo conflictingWorkspace)
          Formats the conflicting workspace name for exception when there is a conflict.
 java.lang.String getComment()
           
 java.lang.String getComputer()
           
 java.lang.String getDisplayName()
           
 SavedCheckin getLastSavedCheckin()
           
 WorkspaceLocation getLocation()
           
 java.lang.String[] getMappedPaths()
          The mapped local paths of the workspace.
 java.lang.String getMapping(java.lang.String path)
          This method is for LocalCache to use.
 java.lang.String getName()
           
 WorkspaceOptions getOptions()
           
 java.lang.String[] getOwnerAliases()
           
 java.lang.String getOwnerDisplayName()
           
 java.lang.String getOwnerName()
           
 java.lang.String getQualifiedName()
           
 java.lang.String getSecurityToken()
           
 com.microsoft.tfs.core.clients.versioncontrol.workspacecache.internal.InternalServerInfo getServer()
           
 com.microsoft.tfs.util.GUID getServerGUID()
           
 java.net.URI getServerURI()
           
 LocalWorkspaceState getState()
           
 Workspace getWorkspace(TFSTeamProjectCollection collection)
          Get the workspace object that matches this CachedWorkspace.
 int hashCode()
          
static WorkspaceInfo loadFromXML(com.microsoft.tfs.core.clients.versioncontrol.workspacecache.internal.InternalServerInfo serverInfo, org.w3c.dom.Element workspaceInfoNode)
          Creates an instance from the XML representation used in the cache file.
 void markClean()
          Only used by LocalCache to clear the state after a cache merge.
 boolean ownerNameMatches(java.lang.String ownerName)
          Returns true if the owner name matches any of the valid owner names for this workspace.
 void saveAsXML(org.w3c.dom.Element parent)
          Saves this instance to the XML format used in the cache file.
 void setLastSavedCheckin(SavedCheckin value, Workstation workstationToSave)
          Sets the settings associated with the last saved checkin attempt
 void setState(LocalWorkspaceState newState)
           
 java.lang.String toString()
           
 void update(WorkspaceInfo ws, boolean fromCache)
          Updates this workspace using the comment, computer, and mappings of the workspace object passed in, which must have the same name, owner, and repository as this workspace instance.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WorkspaceInfo

public WorkspaceInfo(com.microsoft.tfs.core.clients.versioncontrol.workspacecache.internal.InternalServerInfo serverInfo,
                     Workspace workspace)
Method Detail

getWorkspace

public Workspace getWorkspace(TFSTeamProjectCollection collection)
Get the workspace object that matches this CachedWorkspace.

Parameters:
collection - the team project collection to use (must not be null)
Returns:
the workspace or null if it was not found on the server

getMapping

public java.lang.String getMapping(java.lang.String path)
This method is for LocalCache to use. Gets the mapping for the given path. The mapping returned is the actual mapping, which may be for an ancestor of the path. For example, if c:\x is mapped, GetMapping("c:\x\y\z\a.txt") will return c:\x.

Parameters:
path - the path
Returns:
the mapping for the path

equals

public boolean equals(java.lang.Object obj)

Returns true if the WorkspaceInfo objects are equal according to workspace name, owner, and repository.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Gets the hash code for this instance (computed from name, owner, and repository guid).

Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(WorkspaceInfo other)

Compares two workspace info objects, first comparing the server names, then comparing the workspace names, and finally comparing owners.

Specified by:
compareTo in interface java.lang.Comparable<WorkspaceInfo>

loadFromXML

public static WorkspaceInfo loadFromXML(com.microsoft.tfs.core.clients.versioncontrol.workspacecache.internal.InternalServerInfo serverInfo,
                                        org.w3c.dom.Element workspaceInfoNode)
Creates an instance from the XML representation used in the cache file.

Parameters:
serverINfo - the workspace's host server
workspaceInfoNode - the node to load from
Returns:
an instance of a WorkspaceInfo created from the XML

saveAsXML

public void saveAsXML(org.w3c.dom.Element parent)
Saves this instance to the XML format used in the cache file.

Parameters:
parent - the "ServerInfo" element to append a node to with this WorkspaceInfo's data

markClean

public void markClean()
Only used by LocalCache to clear the state after a cache merge.


formatWorkspaceNameForException

public java.lang.String formatWorkspaceNameForException(WorkspaceInfo conflictingWorkspace)
Formats the conflicting workspace name for exception when there is a conflict. The owner of the workspace is included when the owner is different.

Parameters:
conflictingWorkspace - the workspace that conflicts
Returns:
the formatted workspace name

areMappedPathSetsEqual

public static boolean areMappedPathSetsEqual(java.lang.String[] set1,
                                             java.lang.String[] set2)
Returns true if two sets of mapped local paths are identical.

Parameters:
set1 - the first set (must not be null)
set2 - the second set (must not be null)
Returns:
True if the two sets are identical, false otherwise

areOwnerAliasesSetsEqual

public static boolean areOwnerAliasesSetsEqual(java.lang.String[] set1,
                                               java.lang.String[] set2)
Returns true if two sets of owner aliases are identical.

Parameters:
set1 - The first set of owner aliases (must not be null)
set2 - The second set of owner aliases (must not be null)
Returns:
True if the two sets are identical, false otherwise

update

public void update(WorkspaceInfo ws,
                   boolean fromCache)
Updates this workspace using the comment, computer, and mappings of the workspace object passed in, which must have the same name, owner, and repository as this workspace instance.

Parameters:
ws - the workspace from which to get updated info (must not be null)
fromCache - if true, this update is from the cache file and will not affected the modification state; use false for updates from the server

copyLocalMetadata

public void copyLocalMetadata(WorkspaceInfo oldInfo)
This method is used by Workstation to keep local metadata when updating the cache after querying the server.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

ownerNameMatches

public boolean ownerNameMatches(java.lang.String ownerName)
Returns true if the owner name matches any of the valid owner names for this workspace.

Parameters:
ownerName - the name to match (must not be null or empty)

getServerURI

public java.net.URI getServerURI()
Returns:
the URI of the associated Team Foundation Server

getServerGUID

public com.microsoft.tfs.util.GUID getServerGUID()
Returns:
The GUID of the associated Team Foundation Server

getName

public java.lang.String getName()
Returns:
the name of the workspace

getOwnerName

public java.lang.String getOwnerName()
Returns:
the identity name of the workspace owner

getOwnerDisplayName

public java.lang.String getOwnerDisplayName()
Returns:
return the display name of the workspace owner

getOwnerAliases

public java.lang.String[] getOwnerAliases()
Returns:
the aliases of the workspace owner

getDisplayName

public java.lang.String getDisplayName()
Returns:
the formatted display name of the workspace

getQualifiedName

public java.lang.String getQualifiedName()
Returns:
the formatted unique name of the workspace

getComputer

public java.lang.String getComputer()
Returns:
the computer the workspace is located on

getComment

public java.lang.String getComment()
Returns:
the comment associated with this workspace

getLocation

public WorkspaceLocation getLocation()
Returns:
a WorkspaceLocation that indicates the location where data (pending changes, local versions) for this workspace are stored

getMappedPaths

public java.lang.String[] getMappedPaths()
The mapped local paths of the workspace.


getLastSavedCheckin

public SavedCheckin getLastSavedCheckin()
Returns:
the settings associated with the last saved checkin attempt

setLastSavedCheckin

public void setLastSavedCheckin(SavedCheckin value,
                                Workstation workstationToSave)
Sets the settings associated with the last saved checkin attempt


getSecurityToken

public java.lang.String getSecurityToken()
Returns:
the user's security identifier (may be null for older servers)

getOptions

public WorkspaceOptions getOptions()
Returns:
the options set on a workspace

getServer

public com.microsoft.tfs.core.clients.versioncontrol.workspacecache.internal.InternalServerInfo getServer()

getState

public LocalWorkspaceState getState()

setState

public void setState(LocalWorkspaceState newState)


© 2015 Microsoft. All rights reserved.