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 Publish an Existing Content Library procedure.

...
import com.vmware.content.LibraryModel;
import com.vmware.content.LocalLibrary;
import com.vmware.content.library.PublishInfo;
import com.vmware.content.library.StorageBacking;
...

// Access the LocalLibrary service.
      LocalLibrary localLibraryService = serviceManager.getVapiService(LocalLibrary.class);

// Retrieve an existing local library.
      LibraryModel libraryModel = localLibraryService.get(libraryId);
      PublishInfo publishInfo = new PublishInfo();

// Configure how the local library is published by using BASIC authentication.
      publishInfo.setUserName("vcsp");
      publishInfo.setPassword("password".toCharArray());
      publishInfo.setAuthenticationMethod(AuthenticationMethod.BASIC);

// Set the local library to published and update the library instance.
      publishInfo.setPublished(true);
      libraryModel.setPublishInfo(publishInfo);
      localLibraryService.update(libraryModel.getId(), libraryModel);