31 Vendor API

This chapter provides an overview of Vendor API and describes the use cases using this API.

This chapter contains the following sections:

31.1 Overview

Vendors are the original source of assets, and are responsible for their support. Vendors are identified by a single name string.

Validation - When saving a Vendor, Oracle Enterprise Repository currently validates that:

  • The vendor name has to be less than 250 characters

  • The Vendor name is unique

Related Subsystem

There is a one to many relationship between assets and vendors (i.e. multiple assets can be linked to the same vendor, but an asset can only have one vendor). When creating or editing assets the Vendor ID metadata element linking the Vendor to the asset can also be modified.

Additional Import(s) Required

import com.flashline.registry.openapi.entity.Vendor;
import com.flashline.registry.openapi.query.VendorCriteria;

31.2 Use Cases

This section describes the use cases using the Vendor API. It contains the following topics:

31.2.1 Use Case: Manipulating Vendors


  • Adding a new Vendor to Oracle Enterprise Repository.

  • Assigning an existing Vendor to an asset.

Sample code is as follows:

package com.flashline.sample.vendorapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Vendor;
import com.flashline.registry.openapi.query.VendorCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
public class Vendors {
  public static void main(String pArgs[]) throws OpenAPIException,
      ServiceException {
    try {
      // Connect to Oracle Enterprise Repository
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],pArgs[2]);
      // -----------------------------------------
      // Create a new vendor
      String newVendorName = "My Vendor";
      Vendor newVendor = repository.vendorCreate(authToken, newVendorName);
      System.out.println("The new vendor id =\"" + newVendor.getID() + "\"");
      // -----------------------------------------
      // Find a vendor and update an asset to use it
      VendorCriteria criteria = new VendorCriteria();
      Vendor[] vendors = repository.vendorQuery(authToken, criteria);
      long myVendorID = vendors[0].getID();
      long MY_ASSET_ID = 569;
      Asset myAsset = repository.assetRead(authToken, MY_ASSET_ID);
      // MY_ASSET_ID must be the asset id of an asset in the repository
      repository.assetUpdate(authToken, myAsset);
      // ----------------------------------------
      // clean up
      repository.vendorDelete(authToken, newVendor.getID());
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
    } catch (RemoteException lEx) {
    } catch (ServiceException lEx) {
    } catch (MalformedURLException lEx) {