An Organization object is probably the most complex registry object. This object normally includes the following attributes, in addition to those common to all objects:
One or more PostalAddress objects.
One or more TelephoneNumber objects.
A PrimaryContact object, which is a User object. A User object normally includes a PersonName object and collections of TelephoneNumber, EmailAddress, and PostalAddress objects.
One or more Service objects and their associated ServiceBinding objects.
An organization can also have one or more child organizations, which can in turn have children, to form a hierarchy of organizations.
The following code fragment creates an organization and specifies its name, description, postal address, and telephone number.
// Create organization name and description Organization org = blcm.createOrganization("The ebXML Coffee Break"); InternationalString is = blcm.createInternationalString("Purveyor of " + "the finest coffees. Established 1905"); org.setDescription(is); // create postal address for organization String streetNumber = "99"; String street = "Imaginary Ave. Suite 33"; String city = "Imaginary City"; String state = "NY"); String country = "USA"); String postalCode = "00000"; String type = "Type US"; PostalAddress postAddr = blcm.createPostalAddress(streetNumber, street, city, state, country, postalCode, type); org.setPostalAddress(postAddr); // create telephone number for organization TelephoneNumber tNum = blcm.createTelephoneNumber(); tNum.setCountryCode("1"); tNum.setAreaCode("100"); tNum.setNumber("100-1000"); tNum.setType(CanonicalConstants.CANONICAL_PHONE_TYPE_CODE_OfficePhone); Collection tNums = new ArrayList(); tNums.add(tNum); org.setTelephoneNumbers(tNums);
The telephone number type is the value of a concept in the PhoneType classification scheme: "OfficePhone", "MobilePhone", "HomePhone", "FAX", or "Beeper". Use the CanonicalConstants code for the phone type.
To create a hierarchy of organizations, use the Organization.addChildOrganization method to add one organization to another, or use the Organization.addChildOrganizations method to add a Collection of organizations to another.
Most organizations publish themselves to a registry to offer services, so JAXR has facilities to add services to an organization. Typically, you first create the service by publishing a WSDL file (see Creating Services by Publishing WSDL Files). Then you add the service to the organization.
Like an Organization object, a Service object has a name, a description, and a unique key that is generated by the Registry when the service is registered. A Service object can also have classifications.
In addition to the attributes common to all objects, a service also commonly has service bindings, which provide information about how to access the service. A ServiceBinding object normally has a description and an access URI,.
The following code fragment shows how to locate a previously published service and add it to the organization. This example uses the service published in Creating a Service by Publishing a WSDL File: Example.
String serviceId = "urn:Foo:service:MyCoffeeService"; Service service = (Service) bqm.getRegistryObject(serviceId); System.out.println("Service URN is " + serviceId); Collection services = new ArrayList(); services.add(service); org.addServices(services);
If you create an organization without specifying a primary contact, the default primary contact is the User object that created the organization (that is, the user whose credentials you set when you created the connection to the Registry). However, you can specify a different user as the primary contact.
A User is also a complex type of registry object. It normally includes the following attributes, in addition to those common to all objects:
A PersonName object
One or more PostalAddress objects
One or more TelephoneNumber objects
One or more EmailAddress objects
One or more URL objects that represent the user’s home page
Typically, users create themselves by registering using the Web Console. It is highly uncommon to use JAXR to create a user. The sample programs create users to illustrate the User object and to generate organizations with different primary contacts.
The following code fragment creates a User and then sets that User as the primary contact for the organization. This User has a telephone number and email address but no postal address.
// Create primary contact, set name User primaryContact = blcm.createUser(); String userId = primaryContact.getKey().getId(); System.out.println("User URN is " + userId); PersonName pName = blcm.createPersonName("Jane", "M.", "Doe"); primaryContact.setPersonName(pName); // Set primary contact phone number TelephoneNumber pctNum = blcm.createTelephoneNumber(); pctNum.setCountryCode("1"); pctNum.setAreaCode("100"); pctNum.setNumber("100-1001"); pctNum.setType(CanonicalConstants.CANONICAL_PHONE_TYPE_CODE_MobilePhone); Collection phoneNums = new ArrayList(); phoneNums.add(pctNum); primaryContact.setTelephoneNumbers(phoneNums); // Set primary contact email address EmailAddress emailAddress = blcm.createEmailAddress("jane.doe@TheCoffeeBreak.com"); emailAddress.setType(CanonicalConstants.CANONICAL_EMAIL_TYPE_CODE_OfficeEmail)); Collection emailAddresses = new ArrayList(); emailAddresses.add(emailAddress); primaryContact.setEmailAddresses(emailAddresses); URL pcUrl = new URL((bundle.getString("person.url")); primaryContact.setUrl(pcUrl); // Set primary contact for organization org.setPrimaryContact(primaryContact);
The telephone number type for the primary contact is the value of a concept in the PhoneType classification scheme: "OfficePhone", "MobilePhone", "HomePhone", "FAX", or "Beeper". The email address type for the primary contact is the value of a concept in the EmailType classification scheme: either "OfficeEmail" or "HomeEmail". Use the CanonicalConstants codes for these types.
For examples of creating an organization, see JAXRPublishOrg.java and JAXRPublishOrgNoPC.java in the directory INSTALL/registry-samples/organizations/src.
The JAXRPublishOrg example creates an organization and its primary contact. It adds a service, the one published in Creating a Service by Publishing a WSDL File: Example. The example displays the unique identifiers for the organization, user, and service so that you can use the identifiers later when you delete the objects. This example creates a fictitious User as the primary contact for the organization. The name of the organization is The ebXML Coffee Break.
The other example, JAXRPublishOrgNoPC.java, does not set a primary contact for the organization. In this case, the primary contact by default is the User who is authenticated when you run the program. The name of this organization is DefaultPCOrg.
Go to the directory INSTALL/registry-samples/organizations.
Type the following commands:
Ant-base/ant pub-org Ant-base/ant pub-org-nopc |
For examples of publishing and retrieving an organization hierarchy, see JAXRPublishOrgFamily.java and JAXRSearchOrgFamily.java in the directory INSTALL/registry-samples/organizations/src.