I created the below code to accomplish the task. PFB the code:
String rtcURL = "https://*****";
String user = "**";
String pass = "***";
JazzRootServicesHelper helper = new JazzRootServicesHelper(rtcURL, OSLCConstants.OSLC_RM_V2);
JazzFormAuthClient client = helper.initFormClient(user, pass, "https://***");
if (client.formLogin() == 200)
System.out.println("Login SUCCESS!");
String catalogUrl = helper.getCatalogUrl();
String serviceProviderUrl = client.lookupServiceProviderUrl(catalogUrl, "TestProjectFromOSLCCode");
String requirementFactory = client.lookupCreationFactory(serviceProviderUrl, OSLCConstants.OSLC_RM_V2,
OSLCConstants.RM_REQUIREMENT_TYPE);
URI uri = new URI("https://****");
// ******
ResourceShape featureInstanceShape = RmUtil.lookupRequirementsInstanceShapes(serviceProviderUrl,
OSLCConstants.OSLC_RM_V2, OSLCConstants.RM_REQUIREMENT_TYPE, client, "Requirement");
// ******
Requirement requirement = new Requirement();
requirement.setInstanceShape(featureInstanceShape.getAbout());
requirement.setTitle("Test Artifact Using Code001");
requirement.setDescription("Test Artifact Using Code");
requirement.setServiceProvider(uri);
String primaryText = "Test Primary Text";
org.w3c.dom.Element obj = RmUtil.convertStringToHTML(primaryText);
requirement.getExtendedProperties().put(RmConstants.PROPERTY_PRIMARY_TEXT, obj);
ClientResponse response = client.createResource(requirementFactory, requirement,
OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_RDF_XML);
if (response.getStatusCode() == HttpStatus.SC_OK) {
System.out.println("Success");
}
Thanks
Vaibhav