This example is based on the code in the ContentLibraryWorkflow.java sample file. The sample resource is located in the following vCloud Suite SDK for Java directory: client/samples/java/com/vmware/vcloud/suite/samples/interop .

This example uses the steps that are described in the Subscribe to a Content Library procedure.

...
import com.vmware.content.LibraryModel;
import com.vmware.content.SubscribedLibrary;
import com.vmware.content.library.SubscriptionInfo;
import com.vmware.content.library.StorageBacking;
...
 
// Create a StorageBacking instance to store 
// the contents of the subscribed library on the local file system.
       StorageBacking libraryBacking = new StorageBacking();
       libraryBacking.setType(StorageBacking.Type.OTHER);
       libraryBacking.setStorageUri(URI.create("/mnt/nfs/cls-root"));

// Create a new SubscriptionInfo object to define the subscription
// behavior of the library. 
       SubscriptionInfo subscriptionInfo = new SubscriptionInfo();
       subscriptionInfo.setAuthenticationMethod
         (com.vmware.content.library.SubscriptionInfo.AuthenticationMethod.BASIC);
       subscriptionInfo.setUserName("libraryUser");
       subscriptionInfo.setPassword("password".toCharArray());
       subscriptionInfo.setSubscriptionUrl(URI.create("https://www.acmecompary.com/library_inventory/lib.json"));

// Specify that the content of the subscribed library will be downloaded immediately.
       subscriptionInfo.setAutomaticSyncEnabled(true);

// Set an SHA-1 hash of the SSL certificate of the remote endpoint.
       subscriptionInfo.setSslThumbprint("9B:00:3F:C4:4E:B1:F3:F9:0D:70:47:48:E7:0B:D1:A7:0E:DE:60:A5");

// Create a new LibraryModel object for the subscribed library. 
       LibraryModel libraryModel = new LibraryModel();
       libraryModel.setType(LibraryModel.LibraryType.SUBSCRIBED);
       libraryModel.setName("SubscrLibrary");

// Attach the storage backing and the subscription info to the library model. 
       libraryModel.setStorageBackings(Collections.singletonList(libraryBacking));
       libraryModel.setSubscriptionInfo(subscriptionInfo);

// Create the new subscribed library.
       String clientToken = UUID.randomUUID().toString();
       SubscribedLibrary subscribedLibService = serviceManager.getVapiService(SubscribedLibrary.class);
       String subscribedLibId = subscribedLibService.create(clientToken, libraryModel);