Creating Registration Records in batch

You can create multiple Registration Records in one single HTTP request. This action reduces latency when you create many resources at the cost of more complex requests and responses.

About this task

Creating Registration Records in batch can also simplify the resources and relationships creation.

Only users or groups that are mapped to the RegistryProviderAdminRole and RegistryAdminRole roles can send requests to the batch service, since the operations involve the creation or update of resources in the Resource Registry.

For more information about the users and groups roles, see Authenticated access to resources.

The creation of Registration Records in batch is implemented through the OSLC Automation Specification as an Automation request that contains the collection of Registration Records to be created.

Procedure

  1. Send an HTTP HEAD request to the Provider Registry collection URL. For example, https://oslc-registry/olsc/pr/collection.
  2. Locate the Resource Registry automation collection URL in the Link header of the response. The automation collection URL is identified by the http://jazz.net/ns/ism/registry#resource-automation-collection relationship.
  3. Construct the RDF payload with a representation of the resources to be created in batch. For example, ...,<https://oslc-registry/oslc/rr/operations/collection>; rel="http://jazz.net/ns/ism/registry#resource-automation-collection",....
  4. Ensure that you specified the identifying URL http://jazz.net/ns/ism/registry#CreateRegistrationRecords as the value for the oslc_auto:executesAutomationPlan property:
    <?xml version="1.0" encoding="UTF-8"?>
    <rdf:RDF
        xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:dcterms = "http://purl.org/dc/terms/"
        xmlns:rdfs = "http://www.w3.org/2000/01/rdf-schema#"
        xmlns:crtv = "http://open-services.net/ns/crtv#"
        xmlns:rr = "http://jazz.net/ns/ism/registry#"
        xmlns:oslc = "http://open-services.net/ns/core#"
        xmlns:oslc_auto = "http://open-services.net/ns/auto#">
        <oslc_auto:AutomationRequest>
            <dcterms:title>Registration Record creation request</dcterms:title>
    <dcterms:identifier>RegistrationRecordCreateRequest</dcterms:identifier>
    					<oslc_auto:inputParameter>
                <oslc_auto:ParameterInstance> 
                    <oslc:name>records</oslc:name>
                    <rdf:value>  
                        <rr:Records>
                            <rdfs:member>
                                <crtv:ComputerSystem rdf:about = 
    														"http://itmfvs.ibm.com/devices/computer-0269a3a3">
                                    <oslc:domain rdf:resource = 
    																"http://open-services.net/ns/monitoring/1.0/"/>
                                    <rr:recordType rdf:resource = 
    																"http://open-services.net/ns/monitoring#cpu-usage"/>
                                    <oslc:serviceProvider rdf:resource = 
    															"https://oslc-registry/oslc/providers/12">
                                    <crtv:manufacturer>IBM</crtv:manufacturer>
                                    <crtv:model>2007CTO</crtv:model>
                                    <crtv:serialNumber>LG3G3K2</crtv:serialNumber>
                                </crtv:ComputerSystem>
                            </rdfs:member>
                            <rdfs:member>
                                <crtv:ComputerSystem rdf:about = 
    														"http://itmfvs.ibm.com/devices/computer-be38967c">
                                    <oslc:domain rdf:resource = 
    															"http://open-services.net/ns/monitoring/1.0/"/>
                                    <rr:recordType rdf:resource = 
    															"http://open-services.net/ns/monitoring#cpu-usage"/>
                                    <oslc:serviceProvider rdf:resource = 
    															"https://oslc-registry/oslc/providers/12">
                                    <crtv:manufacturer>IBM</crtv:manufacturer>
                                    <crtv:model>2007CTO</crtv:model>
                                    <crtv:serialNumber>KM9A1X1</crtv:serialNumber>
                                </crtv:ComputerSystem>
                            </rdfs:member>
                            <rdfs:member>
                                <crtv:ComputerSystem rdf:about = 
    													"http://itmfvs.ibm.com/devices/computer-b130946">
    													<oslc:domain rdf:resource = 
    													"http://open-services.net/ns/monitoring/1.0/"/>
    													<rr:recordType rdf:resource = 
    													"http://open-services.net/ns/monitoring#cpu-usage"/>
                                <oslc:serviceProvider rdf:resource = 
    													"https://oslc-registry/oslc/providers/12">
                                <crtv:manufacturer>IBM</crtv:manufacturer>
                                <crtv:model>2007CTO</crtv:model>
                                <crtv:serialNumber>KCNB1X9</crtv:serialNumber>
    													</crtv:ComputerSystem>
                            </rdfs:member>
                        </rr:Records>
                    </rdf:value>
                </oslc_auto:ParameterInstance>
    								</oslc_auto:inputParameter>
            <oslc_auto:executesAutomationPlan rdf:resource = 
    				"http://jazz.net/ns/ism/registry#CreateRegistrationRecords"/>
        </oslc_auto:AutomationRequest>
    </rdf:RDF>
  5. Optional: Specify the Accept-Language HTTP header with the preferred language for the error response to your request. See Language definition.
  6. Send an HTTP POST request to the automation collection URL.
  7. Ensure that this operation created the Registration Records that are specified in the registry.

Results

The HTTP 200 (OK) status code means that the HTTP POST request was successfully processed, even though there might be failures in individual registrations.

The response body includes an oslc_auto:AutomationResponse payload, and this example shows two successful registrations and one failure:

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
    xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:dcterms = "http://purl.org/dc/terms/"
    xmlns:rdfs = "http://www.w3.org/2000/01/rdf-schema#"
    xmlns:rr = "http://jazz.net/ns/ism/registry#"
    xmlns:oslc = "http://open-services.net/ns/core#"
    xmlns:oslc_auto = "http://open-services.net/ns/auto#">
    <oslc_auto:AutomationResult>
        <dcterms:title>Registration Record creation result</dcterms:title>
        <dcterms:identifier>RegistrationRecordCreateResult</dcterms:identifier>
        <oslc_auto:verdict rdf:resource = "http://open-services.net/ns/auto#passed"/>
        <oslc_auto:verdict rdf:resource = "http://open-services.net/ns/auto#failed"/>
			 <oslc_auto:state rdf:resource="http://open-services.net/ns/auto#complete"/>
        <oslc_auto:reportsOnAutomationPlan rdf:resource = 
				"http://jazz.net/ns/ism/registry#CreateRegistrationRecords"/>
        <oslc_auto:contribution>
            <oslc_auto:ParameterInstance>
                <oslc:name>error</oslc:name>
                <rdf:value>
                    <rr:Errors>
                        <rdfs:member>
                            <oslc:Error>
                                <rr:sourceRecord rdf:resource = 
															"http://itmfvs.ibm.com/devices/computer-b130946"/>
                                <oslc:statusCode>400</oslc:statusCode>
                                <oslc:message>CTJFK0010E The incoming request from the IP 9.48.84.42 
															did not end successfully. The Registry Services application found 
															an error while processing the request to create a Registration Record 
															for the given parameters: 
															"https://oslc-registry/oslc/rr/operations/collection". The specific 
															reason for 	this error is: CTJFK0014E The provided Registration Record 
															definition does not contain the required field: 
															{http://open-services.net/ns/core#}serviceProvider..
														</oslc:message>
													<oslc:extendedError>
												<oslc:ExtendedError>
													<oslc:moreInfo rdf:resource = "https://oslc-registry/oslc/error/messages/CTJFK0001E"/>
												</oslc:ExtendedError>
											</oslc:extendedError>
                       </oslc:Error>
									</rdfs:member>
                    </rr:Errors>
                </rdf:value>
            </oslc_auto:ParameterInstance>
        </oslc_auto:contribution>
        <oslc_auto:contribution>
            <oslc_auto:ParameterInstance>
                <oslc:name>registrationResults</oslc:name>
                <rdf:value>
                    <rr:RegistrationResults>
                        <rdfs:member>
                            <rr:RegistrationResult>
                                <oslc:statusCode>201</oslc:statusCode>
															<!--this resource did not already exist -->
                                <rr:sourceRecord rdf:resource = 
															"http://itmfvs.ibm.com/devices/computer-0269a3a3"/>
                                <rr:registrationRecord rdf:resource = 
															"https://oslc-registry/oslc/registration/205"/>
                            </rr:RegistrationResult>
                        </rdfs:member>
                        <rdfs:member>
                            <rr:RegistrationResult>
                                <oslc:statusCode>200</oslc:statusCode>
															<!--this resource already existed -->
                                <rr:sourceRecord rdf:resource = 
														"http://itmfvs.ibm.com/devices/computer-be38967c"/>
                                <rr:registrationRecord rdf:resource = 
														"https://oslc-registry/oslc/registration/206"/>
                            </rr:RegistrationResult>
                        </rdfs:member>
                    </rr:RegistrationResults>
                </rdf:value>
            </oslc_auto:ParameterInstance>
        </oslc_auto:contribution>
    </oslc_auto:AutomationResult>
</rdf:RDF>

If a failure occurs preventing a Registration Record from being created according to the HTTP request, Registry Services includes an Error record in the results. It also includes a fail verdict to indicate that at least one registration failed.

The Registry Services includes a rr:RegistrationResult record for each registration that is successfully processed and a pass verdict to indicate that at least one registration succeeded.

If an internal error or a parser error occurs preventing the batch operation from being processed, theRegistry Services returns an OSLC error instead of an Automation Result error.

If any other error occurs to your request, the HTTP response contains the appropriate status code and error message. For more information, see Application runtime.