ractional clearcase 查询活动变更集问题

ractional clearcase 查询活动变更集问题

用的是cmapi。如果是用clear tool 是很简单的,但没有管理员权限,没有使用到。

已经可以查询到活动了,能查询活动的属性,但不知道如何查询到活动的变更集,在网上找了很多也没找到好的资料,模糊知道好像是放到clear quest 的服务器上的了,但cc remote client能够查询到的,那我们也能查询到吧。

搞了几天不得不放弃了。现在把写成的代码贴出来,求大神指点。

一些资料也贴出来吧

http://www.ibm.com/developerworks/cn/rational/r-cn-cmapi/
https://publib.boulder.ibm.com/infocenter/cqhelp/v7r1m0/index.jsp?topic=/com.ibm.rational.team_api_cq_tut.doc/topics/teamapi_cq_settingup.htm
https://publib.boulder.ibm.com/infocenter/cchelp/v7r1m0/index.jsp?topic=/com.ibm.rational.team_api_cc_tut.doc/topics/teamapi_cc_full_sample.htm

http://pastebin.com/3ju4yYGs
http://space.itpub.net/14780914/viewspace-674292
http://www.google.com.hk/search?hl=en&newwindow=1&safe=active&biw=1280&bih=577&noj=1&q=cm+api+CcActivity&oq=cm+api+CcActivity&aq=f&aqi=&aql=&gs_l=serp.3...3140.3140.0.3622.1.1.0.0.0.0.0.0..1.0...0.0.pLBowUhubU8
http://www.ibm.com/developerworks/forums/thread.jspa?messageID=14442789
https://publib.boulder.ibm.com/infocenter/cchelp/v7r1m0/index.jsp?topic=/com.ibm.rational.team_api.doc/topics/c_location.htm
https://publib.boulder.ibm.com/infocenter/cchelp/v7r1m0/index.jsp?topic=/com.ibm.rational.team_api.doc/topics/c_resources.htm
http://www.ibm.com/developerworks/rational/library/09/continuousintegrationrationalclearcaseremoteclient/


http://blog.naver.com/PostView.nhn?blogId=lateone&logNo=66450244
http://a.scmlife.com/thread-26151-1-1.html


package com.chruan.clearcase.cm.client;

import java.io.File;

import javax.wvcm.ProviderFactory;
import javax.wvcm.WvcmException;
import javax.wvcm.PropertyRequestItem.PropertyRequest;
import javax.wvcm.ProviderFactory.Callback;

import com.ibm.rational.wvcm.stp.StpLocation;
import com.ibm.rational.wvcm.stp.StpProvider;
import com.ibm.rational.wvcm.stp.StpLocation.Namespace;
import com.ibm.rational.wvcm.stp.StpProvider.Domain;
import com.ibm.rational.wvcm.stp.cc.CcActivity;
import com.ibm.rational.wvcm.stp.cc.CcProvider;
import com.ibm.rational.wvcm.stp.cc.CcView;

public class Connection {
	public final static String serverUrl = "http://ccweb.XXXX.com.cn/TeamWeb/services/Team";//cc服务器
	private static final String VIEW_ROOT = "D:\\CCWORK\\ex_Dev_RMSS_2012_9月月度版本";//view文件夹

	public static void main(String[] args) {
		try {
			Connection op = new Connection();

			String username = "ex_username";
			String password = "ex_password";
			Callback callback = new MyAuthCallback(serverUrl, username,
					password);
//			StpProvider p = (StpProvider)ProviderFactory.createProvider(CqProvider.CQ_ONLY_PROVIDER_CLASS, callback);
//			p.cqProvider().setServerUrl(serverUrl);
//			doCQ(p);
//			p.terminate();
			
			StpProvider provider = (StpProvider) ProviderFactory
					.createProvider(CcProvider.CC_ONLY_PROVIDER_CLASS, callback);
			provider.ccProvider().setServerUrl(serverUrl);

			// op.doActivity(provider);
			// op.doView(provider);
			// op.doMyActivity(provider);
			op.doActivity2(provider);

			
			
			// CcStream stream = ccProvider.ccStream(viewLocation);
			// PropertyRequest propertyrequest1 = new PropertyRequest(
			// CcStream.ACTIVITY_LIST
			// );
			// stream = (CcStream)stream.doReadProperties(propertyrequest1);
			// List<CcActivity> listOfAct = stream.getActivityList();
			// for(int i=0;i<listOfAct.size();i++){
			//
			// CcActivity ccActivity = listOfAct.get(i);
			//
			// PropertyRequest activityPropertyRequest = new PropertyRequest(
			// CcActivity.COMMENT,CcActivity.ID,CcActivity.DISPLAY_NAME,CcActivity.LATEST_VERSION_LIST,CcActivity.CREATOR_DISPLAY_NAME
			// );
			//
			// ccActivity =
			// (CcActivity)ccActivity.doReadProperties(activityPropertyRequest);
			// System.out.println(ccActivity.getDisplayName());
			// System.out.println(ccActivity.getId());
			// System.out.println(ccActivity.getCreatorDisplayName());
			// }
			//
			// CcActivity ccact = ccProvider.ccActivity(viewLocation);
			// System.out.println(ccact);
			//
			// // OutputStream content = System.out;
			// PropertyRequest feedback = new PropertyRequest(
			// CcActivity.COMMENT,CcActivity.ID,CcActivity.DISPLAY_NAME,CcActivity.LATEST_VERSION_LIST,CcActivity.CREATOR_DISPLAY_NAME
			// );
			//
			// ccact =(CcActivity) ccact.doReadProperties(feedback);
			// System.out.println(ccact.getDisplayName());

			// content.flush();
			// System.out.println(ccact.getActivityCheckoutList());

			// System.out.println(view);
			// Activity activity = view.getActivity();

			// System.out.println(activity);

			provider.terminate();
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}

	private static void doCQ(StpProvider p) {
		// TODO Auto-generated method stub
		System.out.println(p);
		
	}

	private void doActivity2(StpProvider provider) {
		// TODO Auto-generated method stub
		try {
			StpLocation actacivityLoc = provider
					.stpLocation("activity:edit@/vobs/PV_OPS");
			CcActivity act = provider.ccProvider().ccActivity(actacivityLoc);
			System.out.println(act);
			PropertyRequest activityPropertyRequest = new PropertyRequest(
					CcActivity.COMMENT, CcActivity.ID, CcActivity.DISPLAY_NAME,
					CcActivity.LATEST_VERSION_LIST,
					CcActivity.CREATOR_DISPLAY_NAME,
					CcActivity.WORKSPACE_FOLDER_LIST);

			act = (CcActivity) act.doReadProperties(activityPropertyRequest);
			System.out.println(act.getDisplayName());

		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}

	private void doView(StpProvider provider) {
		// TODO Auto-generated method stub
		try {
			CcProvider ccProvider = provider.ccProvider();

			File viewRoot = new File(VIEW_ROOT);
			StpLocation viewLocation = provider.filePathLocation(
					StpProvider.Domain.CLEAR_CASE, viewRoot);
			CcView view = provider.ccProvider().ccView(viewLocation);
			System.out.println(view);
			// PropertyRequest wantedPro = new PropertyRequest(
			// CcView.STREAM.nest((CcStream.DISPLAY_NAME)));
			PropertyRequest wantedPro = new PropertyRequest(CcView.DISPLAY_NAME);
			view = (CcView) view.doReadProperties(wantedPro);
			System.out.println(view.getDisplayName());
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}

	}

	private void doMyActivity(StpProvider provider) {
		// TODO Auto-generated method stub
		try {
			CcProvider ccProvider = provider.ccProvider();

			File viewRoot = new File(VIEW_ROOT);
			StpLocation viewLocation = provider.filePathLocation(
					StpProvider.Domain.CLEAR_CASE, viewRoot);
			CcActivity view = provider.ccProvider().ccActivity(viewLocation);
			System.out.println(view);
			PropertyRequest wantedPro = new PropertyRequest(
					CcActivity.DISPLAY_NAME);
			view = (CcActivity) view.doReadProperties(wantedPro);
			System.out.println(view.getDisplayName());
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}

	}

	private void doActivity(StpProvider provider) {
		// TODO Auto-generated method stub
		try {

			StpLocation actLocation = provider.ccProvider()
					.userFriendlySelector(Domain.CLEAR_CASE,
							Namespace.ACTIVITY, "edit", "/vobs/RIFMS_VOB");
			CcActivity activity = provider.ccProvider().ccActivity(actLocation);
			System.out.println(activity);
			showActivityProperty(activity);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}

	}

	private void showActivityProperty(CcActivity activity) {
		// TODO Auto-generated method stub
		try {
			PropertyRequest activityPropertyRequest = new PropertyRequest(
					CcActivity.COMMENT, CcActivity.ID, CcActivity.DISPLAY_NAME,
					CcActivity.LATEST_VERSION_LIST,
					CcActivity.CREATOR_DISPLAY_NAME);

			CcActivity act = (CcActivity) activity
					.doReadProperties(activityPropertyRequest);
			System.out.println(act.getDisplayName());
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}

	private static class MyAuthCallback implements Callback {

		private final String serverUrl;
		private final String login;
		private final String password;

		public MyAuthCallback(String serverUrl, String login, String password) {
			this.serverUrl = serverUrl;
			this.login = login;
			this.password = password;
		}

		public Authentication getAuthentication(String realm, int retryCount)
				throws WvcmException {
			// TODO Auto-generated method stub
			return new Authentication() {
				public String loginName() {
					// On Windows servers, this should return domain and
					// username separated by a backslash
					return login;
				}

				public String password() {
					return password;
				}
			};
		}

	}
}


你可能感兴趣的:(exception,list,String,活动,Authentication,callback)