Creating an artifact in a remote application

Once the object has been obtained through the com.sodius.oslc.server.process.ProjectAreaAssociationStore class, you have the necessary information to request the Service Provider of the remote application, and get its available Creation Factories.

Requesting the remote application Service Provider

Having the Jira project associations you can get the complete remote Service Provider this way:

   	Collection<ProjectAreaAssociation> projectAreaAssociations = ... // the project associations
	ProjectAreaAssociation remoteProjectArea =;	
	OslcClient client = OslcClients.basic(new UsernamePasswordCredentials(userName, password)).create();	
	ServiceProvider serviceProvider = new GetServiceProvider(client, remoteProjectArea.getServiceProvider().getAbout()).get();

Finding a Creation Factory URL

Having the remote Service Provider this is the way to find a Creation Factory URL:

	Service cmService = OslcCore.Finder.forServices(serviceProvider).domain(OslcCm.DOMAIN).findFirst();
	Collection<CreationFactory> creationFactories = OslcCore.Finder.forCreationFactories(cmService).resourceType(OslcCm.TYPE_CHANGE_REQUEST).findAll(); // for Change Management factories
	URI creationFactoryURI =;

Creating an artifact in memory

In this example we will create a Change Request

Some attributes, defined in the OSLC standard, can be manipulated with getters/setters:

	ChangeRequest changeRequest = new ChangeRequest();
	changeRequest.setTitle("Test Title");

Each OSLC application can also define its own attributes. If you know these attributes namespace and property name, you can set them using:

	QName qname = new QName(CM_CUSTOM_NAMESPACE, "attributeName", CM_CUSTOM_NAMESPACE_PREFIX);
	changeRequest.getExtendedProperties().put(qname, attributeValue);

To get the list of known attributes for the object to create, it is possible to use a REST client with the URL of the resource shapes found on the creation factory: creationFactory.getResourceShapes().

Creating an artifact in the remote application

Once you have the artifact and the URL of the desired Creation Factory you can ask the remote application to save it:

	PostResource<ChangeRequest, ChangeRequest> httpPost = new PostResource<>(client, creationFactoryURI, changeRequest, OslcMediaType.APPLICATION_RDF_XML_TYPE,
                    ChangeRequest.class, OslcMediaType.APPLICATION_RDF_XML_TYPE);                
	ResourceResponse<ChangeRequest> postResponse =;
The URI of the created artifact can be found with postResponse.getEntity().getAbout();.