Enterprise Administration > Windchill Data Loading > Creating Load Methods > Creating New Methods for Loading > About Load Methods > Additional Utilities within a Method
  
Additional Utilities within a Method
The following are utilities or helper methods for use within a method:
The LoadServerHelper.getTargetContainer() method can be used to get a target container for a load. This is the container specified in the load file set, or, if using LoadFromFile, it is specified using the -CONT_PATH command line option.
If no container was specified, it will display a warning message and try to use the Exchange container.
The LoadServerHelper.getTargetDomain() method can be used to get a target domain for a load. The input file may specify the domain path as follows:
Full path (/System)—It looks in the target container and then in Exchange.
Container qualified path ([/]/System)—If the container is a parent organization for the target container, you can use [/Org] for container path part.
Domain name (System)—For migration purposes, it also supports use of the domain name. If the domain name is a special domain, it will return this domain. Otherwise, it will return the domain with the root parent in the Exchange container.
The LoadServerHelper.changePrincipal(user) method can be used to change the effective user for a set of actions. This can be used only if the user who was authenticated for this session is a member of the administrative group. After processing one line of data, the load utility sets the participant (formerly called a principal) back to the original one if the method it called changed the participant.
The LoadServerHelper.removeCacheValue(MY_KEY) method and LoadServerHelper.setCacheValue(MY_KEY,my_object) method can be used to cache objects between calls to a specific method or calls to different methods. The load utility calls one method per line in the data file. Loading documents and then loading multiple content files into a document is one example of first creating a document, caching it, and returning to the load. The load then reads in the next data line, which is a content line.
The LoadContent method retrieves the cached data as follows:
ContentHolder contentHolder =
(ContentHolder)LoadServerHelper.getCacheValue(CURRENT_CH_KEY);
This method adds the content file to the document. If you are creating an object that can hold content (files and URLs) and you want to load multiple content items on lines following the object in the data file, you must cache the object using the following constant:
private static String CURRENT_CH_KEY = "Current ContentHolder";
If you want to cache an object for another reason, you must create a unique key string. It is recommended that you clear your cached object at the beginning of the next create so that if the create fails, the next operation depending on it fails and does not corrupt other data. The cache of all objects is cleared after the last data line is processed.
* 
The cache does not clear items by itself. If you cache lots of items with different keys and run the method multiple times through a load file, this limits the size of your load file because you can run out of memory.