사용자 정의 검토 API를 사용하여 사용자 정의 검토 작성

API를 사용하여 사용자 정의 검토 프로세스를 작성하는 방법을 학습하려면 Bugzilla 클라이언트 샘플을 사용하십시오.

이 태스크 정보

API를 사용하여 특정 상태 및 검토 시나리오를 정의하는 사용자 정의 검토 프로세스를 작성할 수 있습니다. API 사용 방법에 대해 자세히 학습하려면 http://host:port/com.ibm.ram.repository.web/extensionExamples/customReviewProcess/BugzillaReview.jar 디렉토리에 있는 BugzillaReview.jar에서 사용 가능한 예제 Bugzilla 클라이언트를 사용하십시오. 여기서 hostport는 Rational® Asset Manager 서버의 이름과 포트 번호입니다.

http://host:port/com.ibm.ram.repository.web/extensionExamples/customReviewProcess/CustomReviewAPI.jar 디렉토리에 있는 Java™ 아카이브 파일을 여십시오. 여기서, hostport는 Rational Asset Manager 서버의 이름 및 포트 번호입니다.

package com.ibm.ram.extension.demo.review;

import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;

import com.ibm.ram.extension.ConfigurationDetails;
import com.ibm.ram.extension.CustomReviewProcess;
 

Rational Asset Manager에서 검토 프로세스가 시작되면 이 확장은 검토 프로세스를 추적하도록 Bugzilla 클라이언트에서 문제점을 작성합니다. Bugzilla 클라이언트의 각 문제점에는 연관된 문제점 ID 또는 '버그 ID'가 있습니다. 이 ID는 이 확장의 start(...) 메소드에서 리턴되며 Rational Asset Manager에 저장됩니다. 후속 메소드 호출에는 확장이 Bugzilla '버그 ID'와 특정 검토 프로세스 인스턴스를 일치시킬 수 있도록 하는 인스턴스 데이터의 '버그 ID'가 포함됩니다. 다음 예제에서는 검토 프로세스의 인스턴스에 대한 메소드 호출에 대해 설명합니다.

public class BugzillaReviewProcess extends CustomReviewProcess {	

'VERIFIED' Bugzilla 상태는 Rational Asset Manager에서 승인된 상태를 나타냅니다. 승인된 자산은 저장소에서 찾아 다시 사용할 수 있습니다.

public static final String[] APPROVED_STATES = {BugzillaConstants.VERIFIED};

'CLOSED' Bugzilla 상태는 Rational Asset Manager에서 거부된 상태를 나타냅니다. 거부된 자산은 편집 가능한 초안 상태로 리턴됩니다.

public static final String[] REJECTED_STATES = {BugzillaConstants.CLOSED};

'NEW', 'ASSIGNED' 및 'RESOLVED' Bugzilla 상태는 Rational Asset Manager에서 검토 프로세스에 사용됩니다.

public static final String[] NON_FINAL_STATES = {BugzillaConstants.NEW, BugzillaConstants.ASSIGNED,
BugzillaConstants.RESOLVED};
	public static final String USER = "user"; 
	public static final String PASSWORD = "password"; 
	public static final String TITLE = "title"; 	public static
  final String PRODUCT = "product"; 
  public static final String COMPONENT = "component"; 
	public static final String PLATFORM = "platform";  
	public static final String SEVERITY = "severity"; 
	public static final String PRIORITY = "priority"; 
	public static final String OPERATING_SYSTEM = "operatingSystem";
	public static final String VERSION = "version"; 
	public static final String URL = "url"; 	

Rational Asset Manager 서버에 연결할 때 서버 URL, 사용자 이름 및 비밀번호 등의 Bugzilla 클라이언트 세부사항을 구성해야 합니다. 특정 검토 프로세스와 관련된 경우 검토 프로세스의 이름과 같은 선택적 세부사항을 구성할 수 있습니다.

public static final ConfigurationDetails[] CONFIG_DETAILS = { 		
 new ConfigurationDetails (URL, "URL", "The URL of the Bugzilla home page",false, true), 		
 new ConfigurationDetails (USER,"User", "The user account that will be used to access bugzilla", false, true),
 new ConfigurationDetails (PASSWORD, "Password","The password for the account that will be used to access bugzilla", true, true), 		
 new ConfigurationDetails(TITLE, "Title", "The title for the submitted review", false, false), 		
 new ConfigurationDetails(PRODUCT, "Product","Prodcut", "TestProduct", false, false), 		
 new ConfigurationDetails(COMPONENT, "Component","Component", "TestComponent", false, false), 	
 new ConfigurationDetails(PLATFORM, "Platform","Platform", "PC", false, false), 		
 new ConfigurationDetails(SEVERITY, "Severity","Severity", "blocker", false, false), 		
 new ConfigurationDetails(PRIORITY, "Priority","Priority", "P1", false, false), 		
 new ConfigurationDetails(OPERATING_SYSTEM,"Operating system","Operating System", "Windows", false, fals), 		
 new ConfigurationDetails(VERSION, "Version","Version", "other", false, false), 	
};

다음 코드는 알 수 없는 Bugzilla 클라이언트 버그 항목의 ID를 추가합니다.

public static final String UNKNOWN_CUSTOM_ID = "-1";
다음 메소드를 사용하여 검토 프로세스의 끝에 남아 있는 데이터를 정리할 수 있습니다(예: 사용자가 검토를 완료했음을 알림).
참고: 이 메소드의 다음 예제에서는 데이터를 정리하지 않습니다.
public void end(String ramAssetId, String assetVersion, String customAssetId,Map configurationValues, boolean aborted) { 

다음 메소드는 사용자가 정의한 구성 세부사항을 리턴합니다.

public String getName() { 
	return "Bugzilla 2.22.2 review process"; 	}

다음 메소드는 Bugzilla 프로세스의 설명을 리턴합니다.

public String getDescription() { 	
   return "A custom review process that integrates with Bugzilla 2.22.2"; 	}

다음 메소드는 사용자가 정의한 승인된 상태 이름을 리턴합니다. 자산이 이 상태에 도달하면 Rational Asset Manager에서 승인된 상태로 이동합니다.

public String[] getApprovedStateNames(String assetId, String assetVersion,
String instanceData, Map configurationValues) { 		
	return APPROVED_STATES;
}

다음 메소드는 사용자가 정의한 마지막이 아닌 상태 이름을 리턴합니다. 자산이 이 상태 중 하나인 동안 검토 프로세스가 활성이 되며 검토자가 자산을 검토하도록 액세스할 수 있습니다.

public String[] getNonFinalStateNames() { 		
	return NON_FINAL_STATES;
 }

다음 코드는 Bugzilla 서버와 통신하여 인스턴스 데이터에서 제공된 문제점 ID 상태를 판별합니다.

public String getState(String assetId, String assetVersion, String instanceData,Map configurationValues) 
{ 		
return (String)getStatus(getBugId(instanceData),configurationValues).get(BugzillaXMLHandler.BUG_STATUS_NODE); 
}

다음 코드는 인스턴스 데이터의 '버그 ID'를 기반으로 특정 문제점의 URL을 리턴합니다.

public String getURL(String assetId, String assetVersion, String instanceData,Map configurationValues) 
{ 		
int bugId = getBugId(instanceData);String url = BugzillaClient client = new BugzillaClient(new URL((String)configurationValues.get(URL)));
	if(!String.valueOf(bugId).equals(UNKNOWN_CUSTOM_ID))
{
 	url = client.getURL(bugId).toString();	
} 
catch(Exception e) {e.printStackTrace(); 	
} 		
return url;""; try  
{

다음 코드는 검토를 제출할 때마다 호출됩니다. 이 지점에서 이 검토 프로세스와 연관된 문제점을 페치하도록 Bugzilla 클라이언트와 통신해야 합니다(InstanceData로 판별). 그런 다음, 사용자의 검토 의견을 입력하고 사용자가 검토를 승인 또는 거부했는지 여부를 참고하여 문제점의 상태를 계속해서 업데이트해야 합니다.

public String handleReviewSubmitted
	(String assetId, String assetVersion, String instanceData, String username, bool accepted, String comment, InputStream uploadedContent, String fileName, Map configurationValues) 
{ 		
String acceptText = accepted ? "approved" : "rejected"; try 
{ 			
BugzillaClient client = new BugzillaClient(new URL((String)configurationValues.get(URL)));
Map bugStatus = getStatus(getBugId(instanceData),configurationValues);client.updateBug
(
 (String)configurationValues.get(USER),
 (String)configurationValues.get(PASSWORD),getBugId(instanceData),BugzillaConstants.KEEP_CURRENT_STATE, 
 (String)bugStatus.get(BugzillaXMLHandler.PRODUCT_NODE),
 (String)bugStatus.get(BugzillaXMLHandler.COMPONENT_NODE), 
 (String)bugStatus.get(BugzillaXMLHandler.PLATORM_NODE),
 (String)bugStatus.get(BugzillaXMLHandler.SEVERITY_NODE), 
 (String)bugStatus.get(BugzillaXMLHandler.PRIORITY_NODE), 
 (String)bugStatus.get(BugzillaXMLHandler.OP_SYS_NODE), 
 (String)bugStatus.get(BugzillaXMLHandler.VERSION_NODE),"http://", 
 (String)bugStatus.get(BugzillaXMLHandler.TITLE_NODE), username + " has " + acceptText + " with comment: " + comment);
} 
catch(Exceptione)
{ 
e.printStackTrace(); 		
} 		
return instanceData; 
}

다음 코드는 Bugzilla 클라이언트와 통신하여 주어진 검토 프로세스가 승인된 상태인지를 판별합니다.

public boolean isApproved(String assetId, String assetVersion,String instanceData, Map configurationValues) 
{ 		
return BugzillaConstants.VERIFIED_XML.equals(getState(assetId,assetVersion, instanceData, configurationValues));
}

다음 코드는 Bugzilla 클라이언트와 통신하여 주어진 검토 프로세스가 거부된 상태인지를 판별합니다.

public boolean isRejected(String assetId, String assetVersion, 
	String instanceData,Map configurationValues) 
{ 		
return BugzillaConstants.CLOSED_XML.equals(getState(assetId,assetVersion, instanc Data, configurationValues)); 	
}

다음 코드는 검토 프로세스가 시작될 때 호출됩니다. Rational Asset Manager가 이 검토 프로세스의 자산 ID, 자산 버전 및 구성 값을 제공합니다. Bugzilla 클라이언트와 통신하여 이 검토 프로세스의 문제점을 작성해야 합니다. 검토 프로세스의 문제점을 작성하면 해당 문제점과 연관된 '버그 ID'가 Rational Asset Manager에 리턴됩니다. 이 검토 프로세스의 모든 후속 호출에서, 이 메소드로부터 리턴된 String(버그 ID)은 인스턴스 매개변수로 전달됩니다.

public String start(String assetId, String assetVersion, Map configurationValues)
{ 		
	String customId; try 
{ 			
BugzillaClient client = new BugzillaClient
(newURL((String)configurationValues.get(URL))); customId =  String.valueOf(client.enterBug((String)configurationValues.get(USER),
(String)configurationValues.get(PASSWORD),  				
(String)configurationValues.get(PRODUCT),
(String)configurationValues.get(COMPONENT),  				
(String)configurationValues.get(PLATFORM),
(String)configurationValues.get(SEVERITY),  				
(String)configurationValues.get(PRIORITY),
(String)configurationValues.get(OPERATING_SYSTEM),  				
(String)configurationValues.get(VERSION),"http://",  				
(String)configurationValues.get(TITLE), "Review started"));
} 
catch(Exception e) 
{
e.printStackTrace();customId =  UNKNOWN_CUSTOM_ID;	
} 		
return customId; 
} 	
다음 코드는 Bugzilla 클라이언트와 통신하여 특정 문제점 ID 또는 '버그 ID'의 상태를 판별합니다.

@param bugzillaAssetId

@param configurationValues

@return

private Map getStatus(int bugzillaAssetId, Map configurationValues) 
{ 		
BugzillaXMLHandler handler = new BugzillaXMLHandler(); 		
 try 
{ 			
BugzillaClient client = new BugzillaClient(new URL((String)configurationValues.get(URL))); SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setValidating(false); SAXParser sp = factory.newSAXParser(); sp.parse(client.getBugStatus((String)configurationValues.get(USER),
(String)configurationValues.get(PASSWORD), bugzillaAssetId), handler);
} 
catch(Exception e) 
{ 			
e.printStackTrace();
}
return handler.getResult();
}

다음 코드는 Rational Asset Manager에 저장된 인스턴스 데이터에서 Bugzilla '버그 ID'를 판별합니다.

public class BugzillaXMLHandler extends DefaultHandler { 		 		
public static final String BUG_ID_NODE = "bug_id"; 
public static final String PRODUCT_NODE = "product"; 		
public static final String COMPONENT_NODE = "component"; 	
public static final String VERSION_NODE = "version"; 		
public static final String PLATORM_NODE = "rep_platform"; 		
public static final String OP_SYS_NODE = "op_sys"; 		
public static final String BUG_STATUS_NODE = "bug_status"; 
public static final String PRIORITY_NODE = "priority"; 		
public static final String SEVERITY_NODE = "bug_severity"; 		
public static final String TITLE_NODE = "short_desc"; 		 		
private String node; 		
private Map valueMap = new HashMap();
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException 
{ 			
node = qName;
} 		 		
public InputSource resolveEntity(String publicID, String systemID) 
{ 
 return new InputSource(BugzillaReviewProcess.class.getResourceAsStream("bugzilla.dtd"));
} 		 	
public void characters (char ch[], int start, int length) 
{ 	
	 if(node.equals(BUG_ID_NODE) 
 			|| node.equals(PRODUCT_NODE) 
			|| node.equals(COMPONENT_NODE)
  			|| node.equals(VERSION_NODE) 
 			|| node.equals(PLATORM_NODE)
 			|| node.equals(OP_SYS_NODE) 
 			|| node.equals(BUG_STATUS_NODE)  
			|| node.equals(PRIORITY_NODE) 
			|| node.equals(BUG_ID_NODE)
  			|| node.equals(SEVERITY_NODE)
 			|| node.equals(TITLE_NODE)) { 
	 valueMap.put(node,new String(ch, start, length));		 			
} 	
} 		 		
public Map getResult() 
{
	return valueMap; 
		} 
	} 	 
}

피드백