java - programmatically load repository workspace components into local workspace -


i'm retriving repository workspace programatically snippet:

iworkspacemanager workspacemanager = scmplatform.getworkspacemanager(teamrepository); iworkspacesearchcriteria wssearchcriteria = workspacesearchcriteria.factory.newinstance(); wssearchcriteria.setkind(iworkspacesearchcriteria.workspaces); wssearchcriteria.setexactownername("ownername"); //replaced real parameter list<iworkspacehandle> workspacehandles = workspacemanager.findworkspaces(wssearchcriteria,integer.max_value, monitor);   //so, here got repworkspace: irepositoryworkspace mydesiredrepositoryworkspace = workspacehandles.get(0); 

how can programatically fetch/load components repository workspace eclipse workspace?

you can components snippet:

list<icomponent> componentlist = new arraylist<icomponent>(); for(object componenthandle: mydesiredrepositoryworkspace.getcomponents() ){     iitemhandle handle = (iitemhandle) componenthandle;     iitemmanager itemmanager = teamrepository.itemmanager();     icomponent component = (icomponent) itemmanager.fetchcompleteitem(handle, iitemmanager.default, monitor );     componentlist.add(component); } 

after have repository workspace, have components each workspace i'm not able load repository workspace local workspace.

i'm developint eclipse plugin, you'll need following plugins (or imports plain-java-api directly):

  • com.ibm.team.rtc.common
  • com.ibm.team.repository.client
  • com.ibm.team.scm.client
  • com.ibm.team.scm.common
  • com.ibm.team.process.common

ok, loading works iloadrule2, found way, sadly involves bypass via xml-files. requires access sandbox, it's described below ^_^

let's assume have our workspace , our components (as mentioned in question), can load workspace snippet:

isharingmanager sharingmanager = filesystemcore.getsharingmanager(); file workspaceroot = resourcesplugin.getworkspace().getroot().getlocation().tofile();                                pathlocation pathlocation = new pathlocation(workspaceroot.getabsolutepath()); ilocation sandboxlocation = pathlocation.getcanonicalform(); isandbox sandbox = sharingmanager.getsandbox(sandboxlocation, false); loaddilemmahandler p = loaddilemmahandler.getdefault();  monitor.subtask("searching load rules file");  file f = loadruleutility.createloadrules(componentlist); inputstream ins = new fileinputstream(f); reader xmlreader = new inputstreamreader(ins); iloadrule2 rule = iloadrulefactory.loadrulefactory.getloadrule(con, xmlreader, monitor);                                     iloadoperation loadoperator = rule.getloadop(sandbox, p, monitor); monitor.subtask("loading files rtc server..."); loadoperator.run(monitor); 

ok, magic of loadruleutility.createloadrules() creates xml file describes workspaces's components. (i'm using dom).

it has this:

<?xml version="1.0" encoding="utf-8" standalone="no"?> <scm:sourcecontrolloadrule eclipseprojectoptions="import" version="1" xmlns:scm="http://com.ibm.team.scm">      <!-- each component in repository workspace -->     <parentloadrule>         <component name="component_name"/>         <parentfolder repositorypath="/"/>     </parentloadrule>  </scm:sourcecontrolloadrule> 

to unload components have delete them:

iproject[] projects = resourcesplugin.getworkspace().getroot().getprojects(); for(iproject project: projects){     try {         project.delete(true, true, monitor);     } catch (coreexception e) {         e.printstacktrace();     } } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -