This example shows how to find an item by using the item name and then how to change the name and description of the retrieved item.

This example uses the steps that are described in the Edit the Settings of a Library Item procedure.

...
import com.vmware.content.library.Item;
import com.vmware.content.library.ItemModel;
...

// List the items in a published library
     Item libItemService = serviceManager.getVapiService(Item.class);
     List<String> itemIds = libItemService.list(libraryId.getId());
     for (String itemId : itemIds) {
         ItemModel singleItem = libItemService.get(itemId);

// List the files uploaded to each library item and print their names and size
         com.vmware.content.library.item.File itemFilesService = 
                serviceManager.getVapiService(com.vmware.content.library.item.File.class);
         List<com.vmware.content.library.item.FileTypes.Info> fileInfos = 
                itemFilesService.list(itemId);
             for (com.vmware.content.library.item.FileTypes.Info singleFile : fileInfos) {
                 System.out.println("Library item with name "+ singleFile.getName() + " has size 
                                     " + singleFile.getSize());
             }

// Change the name and description of the library item with the specified name
               if (singleItem.getName().equals("simpleVmTemplate")) {
                    ItemModel libItemUpdated = new ItemModel();
                    libItemUpdated.setName("newItemName");
                    libItemUpdated.setDescription("Description of the newItemName");
                    libItemService.update(singleItem.getId(), libItemUpdated);
                }
        }