Professional Documents
Culture Documents
Anil Peres-da-Silva
Principal Engineer, StarTeam
Borland (A Micro Focus Company)
Public Packages
Java C#
– com.starteam StarTeam
– com.starteam.viewcomparemerge StarTeam.ViewCompareMerge
– com.starteam.events StarTeam.Events
– com.starteam.exceptions StarTeam.Exceptions
– com.starteam.util StarTeam.Util
– com.starteam.xml StarTeam.Xml
– com.starteam.diff StarTeam.Diff
Public Packages
• The SDK C# solution StarTeam.dll depends upon the StarTeam J# assembly (StarTeam.Core.dll) which in turn
depends upon the Microsoft .NET 2.0 native .J# assemblies, vjslib.dll & vjsnativ.dll. They can be downloaded from
http://www.microsoft.com/downloads/en/confirmation.aspx?familyid=f72c74b3-ed0e-4af8-ae63-2f0e42501be1 (32)
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=42C46554-5313-4348-BF81-9BB133518945 (64)
• The .NET 4.0 runtime does not load .NET 2.0 assemblies. Application developers need to assume this responsibility
themselves.
• There are a few issues you may run into when using VS2010.
• If you are developing a Windows Forms Application, the default Project Setting for the Target Framework is
'.NET Framework 4 Client Profile'. Attempting to compile your code with this setting returns the following warning
• Warning The referenced assembly “…" could not be resolved because it has a dependency on "System.Web, …"
which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove
references to assemblies not in the targeted framework or consider retargeting your project.
• & error
Error The type or namespace name 'StarTeam' could not be found (are you missing a using directive or an assembly
reference?)
• To address this, you must change the Target Framework setting to '.NET Framework 4' and rebuild
Public Packages (C# SDK, .NET 4.0 & VS 2010)
• Your 32 bit application code (whether Windows Forms or ASP.NET) must load the vjsnativ & vjslib assembly .dll's.
1) include the assembly System.Runtime.InteropServices;
2) explicitly declare & load the assemblies (keep them loaded for the life of your application)
[DllImport("kernel32.dll")]
private extern static IntPtr LoadLibrary(string fileName);
[DllImport("kernel32.dll")]
private extern static bool FreeLibrary(IntPtr lib);
• string folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System),
@"..\Microsoft.NET\Framework\v2.0.50727");
• folder = Path.GetFullPath(folder);
• IntPtr ptr1 = LoadLibrary(Path.Combine(folder, “vjslib.dll");
IntPtr ptr2 = LoadLibrary(Path.Combine(folder, “vjsnativ.dll");
then instantiate & use the StarTeam objects
Server s = new Server("localhost", 49201);
s.LogOn("Administrator", "Administrator");
…
You may choose to free the loaded libraries when your application is shutting down
FreeLibrary(ptr1); FreeLibrary(ptr2);
Object Model
Grouped classes with common functionality; Reduced ‘clutter’ in com.starteam
Java implementation compiled using JDK 1.5 but constrained to JDK 1.2- api’s (for J#.NET);
client application developers have no such constraint
Encapsulation Techniques:
Tight Binding & Close Coupling example
– Typed Resource is the base of all StarTeam Artifacts; Type is the base of all StarTeam types
– Every Typed Resource has a unique Type
– Items & Projects are both TypedResources; An ItemType is not a ProjectType
– Alternatives development approaches :-
• ItemType.java, ProjectType.java (weak coupling between Item & it’s Type) – the separate classes
approach
• Item.Type, Project.Type (strong coupling between Item & its Type) – the public static class
approach
Consistency & Strong Typing. The ‘objects everywhere’ approach
Object Model
import com.starteam.*;
An application must connect to the StarTeam Server before it can do anything else
Server s = new Server(“localhost”, 49201);
User u = s.logon(“Administrator”, “Administrator”); // is equivalent to s.getLoggedInUser()
if (s.isMPXAvailable())
s.enableMPX(); // MPX aware applications minimize server commands. Updates are pushed to the client
CacheAgent ca = s.locateCacheAgent(“localhost”, 5101); // OR ca = s.autoLocateCacheAgent();
s.disconnect(); // automatically disables MPX, if enabled @see s.disableMPX();
Once a Cache Agent is located, the SDK automatically fetches File Content from the Cache
Agent if available. see {Root/Remote}CacheAgentConfig.xml in your Cache Agent install folder
Commands issued on a server instance are throttled through a single socket. (But multiple server instances can be
used to form a connection pool, which is the basis for the web framework)
Server, MPX & CacheAgent
• MPX is a framework for publish/subscribe messaging. The StarTeamMPX Server uses an advanced caching and
communication technology that both improves the performance of StarTeam clients and extends the scalability of
the StarTeam Server.
• StarTeamMPX benefits StarTeam SDK applications in two important ways:
• Instant Refresh. An MPX-enabled SDK application can refresh changes from the server with very little overhead.
For applications that perform frequent refresh operations, the resulting performance benefits are significant.
• Event-Handling. An MPX-enabled SDK application can subscribe to specific server events (for example an Item
is added, modified or deleted), and provide event-handlers that are invoked when those events occur.
• When MPX is enabled, the SDK establishes a connection to the StarTeamMPX message broker, and subscribes
to events for this server.
• Even though MPX is enabled through a specific Server object, it is really the communication layer between the
SDK and the StarTeam repository that is MPX-enabled. Thus, enabling MPX on a specific Server object also
enables MPX for other Server objects in the same runtime that share the same address and port.
Types & Properties
// TypeCollection extends StarTeamCollection implements java.util.Collection
// StarTeamCollection is a type safe abstract base class for all SDK collections
TypeCollection tc = (Server) s.getTypes();
Type[] tt = (Type[])tc.toArray(new Type[tc.size()]);
for (int i = 0; i < tt.length; i++) {
Type t = tt[i]; // && access the properties for a give Type t
PropertyCollection pc = t.getProperties();
Property[] pp = (Property[])pc.toArray(new Property[pc.size()]);
}
// OR find a Type by it’s name, useful for custom component developers. Custom Components are new to12.0
Story.Type t = (Story.Type)tc.find(“Story”);
//The 12.0 Server supports creation of custom types (components) via the SDK.
@see Server.createType(String xmlDefinition);
Types & Properties
Type.newXXXProperty(…) api’s are used to create/add Custom Properties to any Item derived Type
The StarTeam Server supports creation of all Property Types except Link and Binary Properties
The 12.0 Server Release introduces three new property types; ContentProperty, MapProperty & Multi-Select
Enumerations. It also supports the creation of custom Object and ObjectArray properties - which store User(s) or
Group(s) values; and custom Date (without a time component) properties
Content Property types store arbitrary binary, rich text, html, .pdf etc. content in the StarTeam & Cache Agent Vaults.
Just like File Content, Content Property Values are retrieved either from the server or the closest cache agent.
Map Property types serialize Maps (Hash Sets) of arbitrary key-value pairs to the StarTeam database
Maps can be queried using new Query Relations (CONTAINS_KEY, CONTAINS_VALUE & KEY_CONTAINS_VALUE)
The Map Property supports the native value types String, Integer, Long, Boolean, Double, Float and Date.
In addition, it supports the SDK types Date, DateTime, MD5, GUID, DotNotation, TimeSpan and Content
Multi-Select Enumerations allow more than 1 Enumerated Value to be selected, stored & retrieved.
Types & Properties
Property p = t.newDoubleProperty(“CostPrice”); Create custom properties for a given Type t
p.update(); // issue the server command, and creates the property on the server
p = t.getProperties().find(“Usr_CostPrice”); // the server automatically prefixes Usr_ to the name
Type & Property creation can be slow, and can adversely affect connected users
Folder f = v.getRootFolder(); // every view has a default root folder created by the server
Folder[] kids = f.getSubFolders(); // Folders can be arranged in trees
Projects, View and Folders form a containment hierarchy.
Items are contained in Folders, and can be accessed from the parent folder or the view.
Item.Type cstmTyp = s.getTypes().find(“Visualization”); // Item.Type extends com.starteam.Type
v.findItem(cstmTyp, -1); // load all item id’s of a given type in a single server command
ViewMemberCollection vmc = f.getItems(cstmTyp); // gather the entire set of items in a specific folder
ViewMemberCollection vmc = f.getView().getViewMembers(cstmTyp); // gather the entire set of items in the view
Item itm = v.findItem(cstmTyp, 145); // find a specific item by ID (IDs are unique server wide)
Items & View Members
• ViewMembers are artifacts that reside ‘in a view’, (technically, in the default root
folder of the view)
• Non-Item View Members do not have a parent folder property
• Change Packages & Traces are view members, not items. They do not reside in
parent folders.
• Stock & Custom Components are Items. Items are View Members that reside in a
parent folder in the view. By definition, component instances are contained in their
parent folder and contained in their view.
• Tree Items are Items that have parent child relationships. An entire tree must reside
in a single folder – but different trees may reside in the same or different folders.
• By default (i.e. out of the box) Custom Component Types are surfaced as Item or
TreeItem instances. Client application developers may choose to extend the SDK
object model in their own namespace and have their {Tree}Item derived classes
become first class SDK citizens!
Items & ViewMembers
Every view member has a type, which in turn has a collection of properties.
At runtime, the values of the properties of view member instances can be retrieved or changed generically
Object o = itm.getValue(Property); // return the value of this property for this item instance
Object itm.setValue(Property, Object); // set the value of this property, return the previous value
itm.update(); // persists this item in its new state on the server. The in memory item is no longer dirty
Stock component types also have type safe accessors that supplement the generic get/set Value api’s
When an item is updated more than once, the history of all changes can be queried
ViewMemberCollection history = item.getHistory(); // the first entry in the collection is the tip
Item instances may be shared across folders and views. A share tree represents the class of items with the same root
Item shr = itm.shareTo(f); // share this item to a different folder, return the newly created share
The specified folder may be in the same view or a different view of this project,
Items cannot be shared across servers.
Share[] ss = itm.getAllShares(); // returns the share tree of this item, which may be walked recursively
Items & ViewMembers
for all the stock item types, each generic get/set accessor typically has equivalent type specific accessors
boolean b = ((Boolean)itm.getValue(pc.find(ViewMember.Type.IsReadOnlyProperty.NAME))).booleanValue();
// is equivalent to boolean b = itm.isReadOnly();
// a read-write property example
Requirement.Type rqmtTyp = s.getTypes().REQUIREMENT;
Requirement r = (Requirement)v.findItem(rqmtTyp, 12345);
Requirement.Type.PropertyCollection pc = r.getProperties();
int ambiguities = r.getAmbiguitiesCount(); // is equivalent to…
ambiguities = ((Integer)r.getValue(pc.AMBIGUITIES_COUNT)).intValue();
r.setAmbiguitiesCount(ambiguities); // is equivalent to…
r.setValue(pc.AMBIGUITIES_COUNT, new Integer(ambiguities));
pc.AMBIGUITIES_COUNT is equivalent to pc.find(Requirement.Type.AmbiguitiesCountProperty.NAME)
There is typically more than one way to do the same thing through the SDK. Pick the model that suits you best.
Folders & Items
Folders are Items. Folders are also containers for items.
A folder can have at most one parent folder, bur multiple child folders. An item can have at most one parent folder.
Related Tree Items, i.e. parents, children, descendants, can be contained in at most one folder.
f.populate(cstmTyp, pc, depth); // ensures that the set of items specified by this type and depth are populated with
the set of properties specified in the property collection. The property values need not be up to date over time.
f.refreshItems(cstmTyp, pc, depth); // ensures that the set of items specified by this type and depth are populated with
the set of properties specified in the property collection and are kept up to date. If MPX is enabled, refresh will not
Issue a server command. Without MPX, a server command to re-fetch properties is triggered, whether or not they are
up to date.
boolean f.isRefreshItemsRequired(cstmTyp, pc, depth); // tests whether property values are up to date.
MPX enabled applications will only return true if an in-memory refresh is required. This method always returns true
for applications that are not MPX enabled.
boolean f.isPopulated(cstmTyp) will return true iff all the items of this type in this folder have all properties populated..
Collections
• Public abstract base class StarTeamCollection
– In Java, implements java.util.Collection
– In C#, implements System.Collections.IList
– Assignable member type safety enforced
• Collections returned through SDK Interfaces are immutable & read-only, i.e.
members cannot be added or removed, e.g.
• Server.getTypes() a read-only collection of server supported types .
• Type.getProperties() a read-only collection of type specific properties
• Newly created collections are write-able by default
• new PropertyCollection(), new ViewMemberCollection() return empty, mutable
collections
• Application developers can ‘roll their own’ collections by sub-classing
StarTeamCollection
Collections
ViewMemberCollection
A managed collection of ViewMember instances spanning project(s) or view(s) across a server
provides several methods with bulk implementations, minimizing network round trips
i.e. one command issued (per type, per view) for the entire set of ViewMembers in the collection
ViewMemberCollection vmc = new ViewMemberCollection();
// collect items as necessary from different projects or views or folders across the server
vmc.addAll(s.findProject(“StarDraw”).getDefaultView().getRootFolder().getItems(cstmTyp));
vmc.addAll(s.findProject(“StarDraw”).findView(“Release 1.0 Maintenance”).getRootFolder().getItems(cstmTyp));
PropertyCollection pc = new PropertyCollection();
pc.add(cstmTyp.getProperties().find(ViewMember.Type.ItemDeletedByProperty.NAME); // a stock property
pc.add(cstmTyp.getProperties().find(“Usr_CostPrice”); // a custom property
vmc.getCache().populate(pc); // populate all items in this collection with the property values specified
ViewMemberCollection hstry = vmc.getFromHistory(new DateTime(2009, 00, 01)); // return all historical revisions
of these view members as of the specified date (this may be a smaller set, since some of these items may not have
existed on that day and at that time)
ViewMemberCollection
HistoryContainer hc = vmc.getHistory();
// return all historical revisions of all the ViewMembers in the collection
// to access the history of an individual view member, query the HistoryContainer for that one
ViewMemberCollection hstry = hc.getHistory(vmc.getAt(0)); // the history of the zero-th ViewMember
// History is the set of all revisions of an item from the tip (0 th) to the oldest (nth) instance
vmc.lockExclusive(true); // exclusively lock all the members of this collection (break another users lock), or unlock()
BehaviorContainer bc = vmc.getViewMemberBehavior();
// return the behavior of all view members in this collection; (Behavior describes the branching or floating characteristic)
// to access the behavior of an individual view member, query the BehaviorContainer for that one
ViewMemberBehavior vmb = bc.getBehavior(vmc.getAt(0));
// Similarly, create and use a BehaviorContainer to change the behavior of a set of ViewMembers in bulk;
// using the fewest set of server commands.
Once items are in the view member collection, they can be searched for by itemid or ‘name’, the name being the value of the
Primary Descriptor property. @see vmc.find(int)
TypeCollection
A managed collection of all Types surfaced by the Server. This includes types for custom components created by
application developers, at server startup or on the fly.
The server wide type collection is obtained by querying the server object after login.
@see TypeCollection Server.getTypes();
Types may be iterated over or found by id (int) or name (string); i.e.
Custom types (created at runtime) may be found by name (preferably, since the name is assigned by the
component developer) or integer id (assigned by the server when the type is created).
PropertyCollection
A managed collection of all Properties surfaced by the Server for a given Type. This includes types for custom
components created by application developers, at server startup or on the fly.
A property collection is obtained as a query on a Type.
@see PropertyCollection Type.getProperties();
Properties may be iterated over or found by id (int) or name (string); i.e.
@see PropertyCollection.find(int), PropertyCollection.find(String)
Each SDK Type defines a PropertyCollection that extends the base class PropertyCollection, and provides
accessors for individual properties injected by that type.
Custom properties can be found by name (the server appends Usr_ to the name of custom properties created
through the SDK) or by ID (a unique integer value assigned by the server when the property is created)
Populating Item Properties
If the property value of an item instance is not available in memory, querying for that value issues a server call
Well behaved applications pre-populate the properties they care about, on the items they care about, early.
The SDK can populate a set of requested properties for a given set of items in a single ‘bulk’ server command
PropertyCollection pc = new PropertyCollection();
pc.add(cstmTyp.getProperties().find(ViewMember.Type.ItemDeletedByProperty.NAME); // a stock property
pc.add(cstmTyp.getProperties().find(“Usr_CostPrice”); // a custom property
f.populate(cstmTyp, pc, /*depth=*/ 0); // populate all items // depth = 0 in this folder only
// depth = 1 this folder & its subfolders, etc; depth = -1 recurse entire folder tree from this folder down
ViewMemberCollection vmc = f.getItems(cstmTyp);
for (int i = 0; i < vmc.getSize(); i++) {
ViewMember mbr = (ViewMember)vmc.getAt(i);
User u = mbr.getDeletedBy(); // this property value is now in memory
double dbl = ((Double)mbr.getValue(cstmTyp.getProperties().find(“Usr_CostPrice”))).doubleValue(); // and so is this
boolean b = mbr.isReadOnly(); // but this one is NOT & triggers a separate cross network server command per item!
Poor application performance, increased network traffic, decreased server scalability
} // To conserve memory, discard cached data when done. @see ViewMember.getCacheService().discard();
NetMonitor & ServerCommandListener
// an interface through which server command notifications are fired
// useful for debugging, identifying unnecessary server commands and optimizing client-server traffic in SDK applications
class SrvrCmdLstnr implements ServerCommandListener {
public void onStart(ServerCommandEvent e) {
System.out.println(e.isPropertyFetchTrigered());
System.out.println(e.getCommandName());
}
}
SrvrCmdLstnr scl = new SrvrCmdLstnr(); // // when writing & testing code, put this in a DEBUG section
NetMonitor.addServerCommandListener(scl); // the listener gets notified when the command starts and ends
…
boolean b = mbr.isReadOnly(); // from the earlier example, isPropertyFetchTriggered() will print true in the listener
…
NetMonitor.removeServerCommandListener(scl); // always remove the listener when done
Users & Groups
Given a logged in Server Object s, load Users & Groups from the server. Full user & group information is not
retrieved, since the user logging in may not have administrative privileges to access full account information of
other users. A logged in user with full administrative privileges can retrieve fully loaded users & groups through
ServerAdministration. A user may belong to multiple (un)related groups
User[] uu = s.getActiveUsers(); // s.getUsers() includes deleted users
Group[] gg = s.getActiveGroups(); // s.getGroups() includes deleted groups
User u = s.getLoggedInUser(); // the user who logged into this session
for (int i = 0; i < gg.length; i++) {
Group[] ss = gg[i].getSubGroups(); // subgroups of this group; a group may have only one parent
User[] mm = gg[i].fetchMembers(/*descendants=*/ false); // the set of users who are members of this group
// true to retrieve the entire set of Users who are members of this group and all its descendants
} Groups are MPX enabled from 12.0+ servers; @see refreshUsers(); refreshGroups();
User Group membership (relationship) queries are bulkified from 12.0+ servers
Filters
A Filter is a user definable ordered & grouped collection of Properties
Type cstmTyp = s.getTypes().find(“Visualization”);
Filter[] ff = cstmType.getFilters(); // Load Filters for a specific Type
Filter l = cstmType.getFilter(“<Must Fix CRs>”); // find a filter by Name
Filter l = cstmTyp.getFilter(12345): // find a filter by ID ( a server wide unique integer)
View v = s.findProject(“StarDraw”).getDefaultView();
Label l = v.createViewLabel(“label name”, “description”, DateTime.CURRENT_SERVER_TIME, /*buildLabel=*/ true,
/*frozen=*/ false); // a build label set to the current server time
Label l = v.createRevisionLabel(“label name”, “description”, /*frozen=*/ false); // a revision label
ViewMemberCollection vmcEx = l.getLabeledItems(vmc); // returns the (sub)set of items in this collection which have
label l attached to them
There is no direct way to query a label for the set of items (at the specific revisions) which are attached to it.
Currently, an application needs to fetch all the id’s of any items it is interested in, @see View.findItem(Type, -1)
find the subset which has some revision attached to the label @see Label.getLabeledItems(ViewMemberCollection)
and then query for the actual revisions @see ViewMemberCollection.getFromHistory(Label)
which is a bulk query from StarTeam 12.0
Alternatively, an application may open a view (using a label based configuration) find the items, process them, and
close the view @see View(ViewConfiguration)
Note that opening a view is a fairly expensive operation on the StarTeam server
Traces
A strongly typed bi-directional relationship between two artifacts. Traces can be created across views, projects and
even servers. Traces may be stored in any view on the source or target server, or in a view on an entirely different
Server. Traces may be created between StarTeam artifacts and non StarTeam artifacts (e.g. an HTTP URL)
Traces are ViewMembers, and consequently, may be branched, versioned or shared. However, unlike Items, Traces
are not stored in Folders. Traces are created by VCM, and by Checkin Manager, between the ChangePackage and
any Process Item(s) in Scope. These Traces are created in the same view as the ChangePackage. Unlike links, traces have
history which may be queried. A historical revision may be pinned to different source or target revisions or may float.
Trace t = new Trace(view);
t.setSource(view.findItem(cstmTyp, 12345));
t.setTarget(view.findItem(rqrmntTyp, 67890)); // or alternatively t.setTarget(LinkValue.forURL(“http://www.cnn.com”));
t.unpinTarget(); // the Trace floats at the tip revision of the target
t.update();
TraceCollection trc = view.getTraces(); // query all the traces in a view
TraceCollection trc = trc.getTraces(view.findItem(cstmTyp, 12345)); // find the subset of traces that reference this item
Traces subsume StarTeam links.
Change Packages
• A set of changes comprising a single logical Change
• Committed in a single atomic transaction
• ChangePackage APIs query for ChangeCollection, Source View, Target View and
Transaction properties. All these properties are read-only.
• ChangePacakges may be replayed from one view to another within a project.
• ChangePackages provide a valuable audit trail of file checkin changes & deltas
Attachments
Attachments are named Content values stored by the StarTeam Server per artifact
Each artifact instance has an implicit associated Attachment ‘Property’.
Files & Folders do not subscribe to the Attachment Service. All other ViewMember & Custom Component Types do
The server can store up to 64 attachments per artifact instance.
The 11.0 server stores attachments in a private folder managed by the server.
The 12.0 server stores attachments in the StarTeam vault, keyed by MD5, along with File & Content Values.
(eliminates duplication, orphans can be pruned, fits existing vault back up startegies, etc)
The SDK exposes Attachments as a Content[]. Each Content object has a unique integer ID, a Name & an MD5.
Content[] ViewMember.getAttachments(). The Attachment Content (data payload) itself is fetched by calling the
toBytes(), toFile(), toStream() or toString() api’s on the Content object from the array.
ViewMember.setAttachments(Content[]) saves the Attachments to the server, and updates the internal state with the
new Attachment Names, IDs and MD5s.
Impersonation
Enable User Impersonation via a single connected Server Instance (useful for developing web applications, Import
Export algorithms, etc.)
User admin = s.getLoggedInUser(); // the original logged in User
ImpersonateUser iu = new ImpersonateUser(s);
iu.enableImpersonation(); // once enabled, impersonation cannot be disabled
User u = s.logon(“anotherUser”, “password”); // The StarTeam server does NOT support logging off a User
iu.switchContext(u); // subsequent commands are executed in this user context
iu.switchContext(admin); // until you switch back to a different user, OR alternatively, use
iu.setCommandUser(other); // unlike switchContext(), the other user need NOT have been logged in via this server
instance; but subsequent commands are executed in his/her context at the appropriate privilege level
ViewPollingAgent is used to periodically poll a given view for recent changes, triggering Item, Folder and
ViewMember Update Events describing the changes detected since the last poll.
With this release of the SDK, both ViewConfigurationDiffer and ViewPollingAgent supports event notification
for non item ViewMembers, i.e. ChangePackages and Traces. The two algorithms also support event notification
for custom components. However, both these algorithms are memory intensive.
A lightweight MPX listener, also new to this release of the SDK, may be a preferable alternative.
ViewConfiguration
Used to open rolled back (i.e. snapshots from history) views
View v = s.findProject(“StarDraw”).getDefaultView(); // the ‘tip’ or current configuration of the view
Label[] ll = v.getActivelabels();
v = new View(v, ViewConfiguration.createFrom(new DateTime(2009, 00, 01)); // rolled back to Jan 01, 2009
v = new View(v, ViewConfiguration.createFrom(ll[0]); // rolled back to the label; i.e. the exact moment in server history
when the label was created
v = new View(v, ViewConfiguration.createTip()); // revert back to the tip or current configuration
Opening a rolled back view is expensive. Resources are allocated on the server and retained in the server cache until
the view is closed. Rolled back views represent snapshots from history. New items cannot be added to a rolled back
view. Existing items cannot be modified or deleted.
Rolled back views are used extensively in View Compare Merge (VCM) to pick a fixed point in time at which the
compare is executed, so as not to be influenced by subsequent changes to the tip.
Recycle Bin
A recycle bin is a view that provides access to deleted items & deleted folders
In addition to the standard view api’s, the RecycleBin exposes properties which allow applications to control
the classes of active or deleted items that the RecycleBin should surface.
RecycleBin r = view.getRecycleBin();
r.setIncldeActiveItems(true); // Active items are excluded by default
r.setIncludeDeletedItems(true); // Deleted items are included by default
r.setIncludeDeletedFolders(true); // Deleted folders are included by default
r.setDeletedAsOf(new DateTime(2009/00/01)); // include everything deleted since Jan 01, 2009
// now, surface all active & deleted items in the root folder @see Item.isDeleted()
Item[] all = r.getRootFolder().getItems(cstmTyp);
The RecycleBin is extensively used in VCM to identify ItemDifferences like ‘Deleted in {Source | Target}’
Note that deleted items are no longer available once a view has been purged.
Application
The context of a client application. Creating a Server instance creates a default application instance
Alternatively, create an Application instance, and one or more servers in its context.
Particularly useful for creation and resolution of cross server Traces, federating trace servers, etc.
StarTeam URL’s are well formed URI’s with a formal grammar. StarTeam URLs use ID or NAME schemes
starteam://localhost:49201/0;ns=Project;scheme=id/0;ns=View;scheme=id/197;ns=File;scheme=id;scope=full
starteam://be5ee3b0-c719-49c6-a1a1-
f493764a03f5;id=guid/0;ns=Project;scheme=id/0;ns=View;scheme=id/197;ns=File;scheme=id;scope=full
starteam://localhost:49201/Project_12926ffd7de/Project_12926ffd7de/Folder_ApplicationTest.testResolveURLS_1292
6ffd7df/Folder_ApplicationTest.testResolveURLS_12926ffd7e0/File_ApplicationTest.testResolveURLS_12926ffd7e
1.txt // NAME based URIs are best avoided; they are case sensitive, unwieldy, and not guaranteed to be unique
Workflow
StarTeam Workflow specifies a set of type specific rules, states & state transitions, which are described in XML files
in the StarFlow extensions project. The xml files are created using Workflow Designer.
The workflow engine triggers the rules & validates the state transitions when attempting to update an item of the
specified type.
Application developers can turn on the workflow engine using the static api
Workflow.fromStarFlowExtensions(View) which queries the starflow extensions project for the workflow, loads it
up into memory & attaches it to the respective workflow aware types. An application can also directly load workflow
from an .xml file produced by Workflow designer using any of the three fromFile({Server|Project|View}, java.io.File)
api’s. Once enabled, workflow cannot be disabled for the life of the application.
An application may choose to verify that a workflow step will succeed, i.e. an artifact can be updated in a given step
@see Workflow.canUpdate(TypedResource).
If a workflow enabled application attempts to update an artifact but canUpdate() returns false, an SDK Runtime
Exception will be thrown.
Events
Asynchronous change notification delivered to the client application via standard event listeners
All event objects and event listeners are aggregated in the com.starteam.events namespace
Client applications typically register for Folder, Item, ViewMember or ServerCommand notification
Project, View, Filter, Query & Label notifications are also supported, but may occur less frequently
Applications interested in receiving events create event handlers (implementing the appropriate listener interface)
and register these handlers with the SDK.
import com.starteam.events.*;
import com.starteam.*;
private class ItemEventHandler implements ItemListener {
public void itemAdded(ItemEvent e) {…}
…
}
Events
ItemEventHandler ieh = new ItemEventHandler();
assertTrue(view.getServer().isMPXEnabled()); // Item, Folder or ViewMember Events only fire if MPX is enabled
view.addItemListener(ieh);
…
view.removeItemListener(ieh);
Artifacts defined by components are automatically registered in the server’s component catalog.
Components
All StarTeam (stock &/or custom) components have a common set of properties. These include
View Member ID – a server wide, unique ID
Root Object ID – the shared ID for all members of a given reference (share) tree
Object ID – the shared ID for all members of a given branch
Parent Revision Number – for branchable types, the parent revision at which the resource was branched
Dot Notation – a String based annotation describing an object’s position in its share tree
Created By, Modified By, Deleted By – the User who created, modified or deleted this object
Created At, Modified At, Deleted At – the Date and Time that the object was created, modified or deleted.
Revision Number – a sequential counter issued to each revision of a given object (when an object is updated,
i.e. one or more of its property values are changed, a new revision of the object is created)
In addition, each stock component has a fixed, out of the box set of properties that annotate the type.
Stock Components
Stock components (types) are bundled with StarTeam and shipped with a pre-defined set of properties.
Stock components are customizable. An application can add custom properties to any stock component.
Files and ChangeRequests are Items. Requirements, Tasks and Topics are Tree Items.
Tree Items may form regular top down trees, but not graphs. i.e. a task may have several sub-tasks,
but a task can have only a single parent (task). Items are branchable; Tree Items are not.
For simplicity, the SDK models Folders and Tree Items as Items.
Stock Components – Files & Folders
The file type includes properties like Name, Description, Size, MD5, & HiveID. File content is managed by the server
on a file system called a vault, which is organized by hives. Unlike other StarTeam components, file objects have a
client side representation, namely, physical files in the local file system (workspace) on disk.
Accordingly, files have client side properties such as full (path qualified) name, working file size, MD5 & modified time.
To track differences between the working file on disk and its representation in the StarTeam Vault, the File type has a
Status property, with values like CURRENT (content on disk is identical to that in the vault), MODIFIED (content on
disk is newer than that in the vault) and OUT_OF_DATE (content on disk is older than that in the vault)
The folder type includes properties like Name, Description & Path. Folders too have a client side representation,
namely, working folders on disk. However, non file applications need not surface this client side representation,
treating folders strictly as organizational containers (drawers) of StarTeam components.
The SDK maps the client / server representations of Files & Folders. The StarTeam server itself is completely
unaware of an existing client side representation. The file system is of course unaware of a server representation.
Stock Components – Change Requests
Change Requests, Requirements and Tasks are a class of Process Items. When a set of files is checked in, the
set is associated with a Process Item in a given state. As part of the checkin, the Process Item may be transitioned to
a different state. So for instance, a group of files can be checked in against a Change Request in an Open State
(the Status Property value of the Change Request) and the Status Property value may be moved to a Fixed State.
Currently, Custom Components cannot be used as Process Items.
Threaded Topics include the Recipients property & the text (content) of the topic
Topics can be used as discussion boards
Notification is automatically sent via email or displayed on the toolbar.
Stock components are nothing more than shrink wrapped custom components!
Custom Components
Custom Components can be created & ‘dropped into’ the 12.0 server by the component developer.
The custom component schema is described using a well formed xml definition, published by server engineering
(They may also be created using the SDK api Server.createType(String, boolean).)
Custom Components are either Branchable (Item) types or Tree(Item) types
Item.Type cstmTyp = s.getTypes().find(“MyCustomComponent”); // type metadata for the new component
PropertyCollection prprtys = cstmTyp.getProperties(); // property metadata for this component
ViewMemberCollection vmc = fldr.getItems(cstmTyp); // instances of this custom type in a collection
The SDK knows nothing about Custom Components, except in the most generic way. Out of the box, the
custom component shows up as an SDK Item or TreeItem Type, and can be manipulated using the standard
getValue/setValue accessors. New instance may be created using Item.Type.createItem(Folder)
// TreeItems are Items with two useful additional properties
TreeItem[] kids = itm.getChildren(); // returns a list of the immediate children of this tree item instance
TreeItem prnt = itm.getParent(); // returns the immediate parent of this tree item or NULL if this is a root
Custom Components
Standard CRUD operations can be performed using standard methods like
ViewMember.update() & ViewMember.remove() on custom component instances.
Branchable Custom Component Types have the following specific additional properties
RootObjectID int Integer Property
ParentObjectID int Integer Property
ParentRevision int Integer Property
PathRevision int Integer Property
ViewID int Integer Property
Tree Item Custom Component Types have a specific property identifying the parent tree item ID
ParentID int Integer Property
Custom Components (Extending the Object Model)
Application Developers may choose to extend the SDK Object model, providing class definitions for custom
Components. These definitions belong to the client developers namespace, but are treated as first class SDK citizens!
NOTE: The custom component MUST have been created on the server before client implementation
package com.microfocus.teamDefine;
import com.starteam.*;
public class Visualization extends TreeItem {
private static final String myTypeName = “VISUALIZATION”; // This name MUST match the type name specified
// in the component .xml definition
public Visualization(Folder parentFolder) {
super(myTypeName , parentFolder); // this base class constructor must be called
}
public Visualization(Visualization parent) {
super(parent); // and so must this one
}
// add other apis’ as necessary, extend the StarTeam Type Model implement Client Calculated Properties, if any
Developing Custom Components
The Application Developer may extend the Type Model for the custom components.
(This static class is a member of the component class)
public static class Type extends com.starteam.{Tree}Item.Type {
public static final String NAME = myTypeName; // and assign the type the name
public Type(Server s, Type.MetaData d) {
super(s, d);
}
Add property definitions for custom properties (specified through the xml definition) & client calculated properties
Integer, LongInteger, Double & Text Properties may be sub-classed to create custom client calculated properties
public static class MyClientCalculatedProperty extends IntegerProperty {…}
Any property type definition can be sub-classed for custom properties
public static class MyCustomContentProperty extends ContentProperty {…}
Developing Custom Components
The Application Developer may also extend the Property Model for the custom component.
This static class is a member of the type class, which is a static member of the component class
Visualization vz = vsTyp.createItem(myFolder);
vz..setValue(someproperty, “its value”);
vz.update();
Developing Custom Components
Property Definitions for Client Calculated Properties – Property IDs MUST BE UNIQUE across the Type
Assign each Client Calculated Property a unique incremented ID based on Property.CLIENT_CALCULATED
• static final class CalculatedWeightProperty extends IntegerProperty {
• commit() makes the least number of server calls entirely within a transaction. May comprise of
several remove(), moveTo() and checkin() operations on the server. If an error occurs, the
entire transaction is rolled back.
• A successful commit() creates a ChangePackage in the target view. Each change in the
change collection maps the previous (pre commit) revision of the item to the committed
revision. The source and target revisions of each change are in the same (target) view.
• If a Process Item is specified, a Trace links the Change Package to the Process Item.
• The resultant Change Package may be replayed as a VCM Promote, Rebase or Replicate.
• Multiple calls to checkout() for the same file overwrite the in-memory
internal state accordingly
• mgr.checkout(file);
• mgr.checkout(file, new checkoutOptions()); // assign checkout options to file
• mgr.checkoutTo(file, new java.io.File(“c://temp/”)); // assign different alternate
checkout path to file
• mgr.ignore(file); // remove file from consideration for checkout
Checkout Manager
• Optimized to use all available bulk commands, and use the least number of
server calls.
View Compare Merge
• The VCM APIs allow an application to compare two views, and merge differences from one to the other.
• A typical view compare/merge (VCM) application will perform the following steps:
• Construct a VCM session, specifying the merge type and the source and target views. In a compare only
session, you may specify two different configurations of the same view.
• Set the scope of the session, if necessary. By default, all files and folders are in scope.
• Change the default VCM options, if necessary. Options determine whether or not file content will be
merged automatically, whether source and target items will be locked, and so on.
• Compare the two views.
• Examine the resulting differences. Each difference indicates the source and target items, the difference
type, and the recommended action. You may accept the default action, or overide it with any other legal
action.
• Commit the session. This executes the actions specified for each difference, merging changes to the
target view. The changes are executed as a single atomic transaction.
• When the session is committed, StarTeam creates a ChangePackage in the target view to record the
changes. The ChangePackage includes new file and folder revisions; copies of the difference and update
reports are included as attachments, as is an exported session file that can be used for future reference.
The committed ChangePackage can subsequently be re-opened in a read-only mode, and differences
between pre & post committed files can be reviewed, thus providing an audit trail of changes as they
propagate through the system.
View Compare Merge
• An example of using VCM
import com.starteam.*;
import com.starteam.viewcomparemerge.*;
Server s = new Server(“host”, port);
s.logOn(“user”, “password”);
Project p = s.findProject(“StarDraw”);
View v = p.findView(“Release 1.0 Maintenance”);
Session n = new Session(MergeType.Promote, p.getDefaultView(), v);
n.compare(); // defaults to Files & Folders, @see Session.setScope(Scope)
ItemDifference[] ii = n.getDifferences();
// for, ensure that each ItemDifference can be committed
n.commit(); // executes in a transaction, creates a ChangePackage when done
n.close(); // release all resources, close open views, etc.
Command Processor
• A state-ful implementation in the SDK (augments the state-less implementation from earlier releases)
• Fully backward compatible with existing commands from stcmd
• Automatically supports MPX, Cache Agent, file & object property content
• Automatically supports transactions, bulk commands
• Refactor existing scripts to benefit from maintaining cross command state e.g.…
• Operations that occur on synchronization include checkout of out of date &/or missing files and folders;
• checkin of new &/or modified files & folders. (checkin operations will produce a checkin change package)
• connect localhost:49201
• set project = ‘StarDraw’ view = ‘Release 1.0 Maintenance’
• apply-label -is -lbl Web1 files
• diff -is -w -vl \"New Step 2\
• select * from changerequest into “c:/temp/QueryOutput.txt” separator ;
• select Name, Status, ‘File Time Stamp at Check-in’ from file where query = ‘Files to
Check In’
• select filter = ‘By Status and Responsibility’ from task where folder = ‘Sales
Materials’ or folder = ‘Marketing Materials’ recurse
• update changerequest set synopsis = ‘foo’ where query = ‘Status = Open’
• delete changerequest where query = ‘Status = Open’
• disconnect
Artifact Cache
• A managed collection of typed artifacts & access rights
• Tip caches are self refreshing. Baseline (rolled back) caches are
invariant (i.e read only) w.r.t. time.
• Fully loaded & built up in the context of an Administrator, shared
across all users, including those at lesser privileges
• Build up the cache using cacheViewMembers(WebCacheView,
WebCacheViewMemberType[]); // manage all ViewMembers of the
specified type(s) in the view
• Query the Cache using the api.
– WebCacheViewMember vm = findWebCacheViewMember(WebCacheUser,
int);
Artifact Cache Manager
• A managed collection of Artifact Caches.
• Manages a single Artifact Cache Manager per server, which contains a Tip Cache and
as many historical caches as requested
• Register the Cache Manager for a given server
• Manages all Tip, i.e. Current Projects, Views, etc in the Tip Cache
• Manages a rolled back view (based on label, promotion state or date time) in its own
(baseline) cache
• Discards historical caches after a specified unused expiration window
• Manages web ‘client’ applications that share Artifact Caches
• Artifact Cache Manager, Artifact Cache & the WebCache object model provide a thread
safe connection pool mechanism for developing scalable multi user web applications
• Walk the model starting from the Administrative Context, which returns a
WebCacheServer, WebCacheProjects, etc…
Web Cache Artifact Model
Web Cache Artifact Model
• The web artifacts are wrappers around and peers to the core SDK
artifacts. There is a 1 to 1 mapping between objects at each level.
• The model is complimentary. From the Context, the application
developer can seamlessly switch between WebCache objects and their
native peer’s and vice versa. (@see ArtifactCacheManager.Context)
• The programming metaphor for web and peer objects is identical and
could almost be swapped in place.
• All server calls are issued through the connection pool
• The web cache model forms the basis for the new MicroFocus web
applications currently being developed (code name Topaz)
• But customers can use the model to develop their own web applications.
12.0+ Feature Sets
New SDK namespace, fully revamped, consistent object model
New command line (with rich SQL like extensions)
Workflow support & Checkin Change Packages
New Web Application Development Model
64 bit SDK .jar, .NET SDK assembly
All 12.0+ SDKs are fully backward compatible with the 11.0 server.
MPX enabled
Groups, Access Rights
Work Records & Task Dependencies