AquaLogic User Interaction Development Guide

     Previous Next  Open TOC in new window   View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Editing Publisher Content Items Using IDK Remote APIs

To edit an existing Publisher content item, use the IContentItemManager and IContentItem interfaces in the IDK.

To edit an existing content item programmatically, follow the steps below. (To open a content item for editing in Publisher Explorer, use the URL returned by IContentItem.getEditorURL.)
  1. Create a PRC session. For details, see Initiating a PRC Session to Use IDK Remote APIs.
  2. Retrieve the content item.
    • To retrieve a content item in a specific folder by name, use IContentItemManager.getContentItem and pass in the folder object and content item name.
    • To retrieve a content item by its UUID, use IContentItemManager.getContentItem and pass in the content item UUID.
    • To retrieve all the content items in a folder, use IContentItemManager.getContentItems and pass in the folder object.
    • To retrieve all the content items created from a specific Data Entry Template, use IContentItemManager.getContentItems and pass in the folder object and the Data Entry Template object.
  3. Check out the content item using IContentItemManager.checkOutItem.
    Note: You must check out a content item before it can be edited.
  4. Retrieve the properties of the content item using IContentItem.getAllProperties or the appropriate getPropertyValue method.
  5. Set the new value for the property using the appropriate setPropertyValue method for the property.
  6. Store your changes by checking in the content item using IContentItem.checkInContentItem.
These examples upgrade the severity of a support incident by updating two values in the associated content item. To find the appropriate property to update, this example checks for the property type.

Java

...
// check out the content item 
itemManager.checkOutItem(contentItem);

//Retrieve all the properties of the content item.
IBaseProperty[] allProps = contentItem.getAllProperties();
for (int i = 0; i < allProps.length; i++) 
{
	//Check for a text property.
	if (allProps[i] instanceof ITextBlockProperty) 
	{
		//Retrieve the value of the text property.
		String oldValue = contentItem.getTextBlockPropertyValue((ITextBlockProperty)allProps[i]);

		//Add a message to the existing string. 
		contentItem.setTextBlockPropertyValue((ITextBlockProperty)allProps[i], "Severity upgraded. " + oldValue); 
	}
	
	//Check for a double property.
	else if (allProps[i] instanceof IDoubleProperty) 
	{ 
		//Set the new value of the existing property
		contentItem.setIntegerPropertyValue((IIntegerProperty)allProps[i], .9);
	}
}
//Check in the content item to maintain the persistence of the updated values.
itemManager.checkInItem(contentItem, "Severity Upgraded");
...

.NET (C#)

...
//Check out the content item.
itemManager.CheckOutItem(contentItem);

//Retrieve all the properties on the content item.
IBaseProperty[] allProps = contentItem.GetAllProperties();
for (int i = 0; i < allProps.Length; i++)
{
  	//Check for a text block property.
  	if (allProps[i] is ITextBlockProperty)
  	{
		String oldValue = "";
		if (contentItem.HasPropertyValue(allProps[i]))
		{
			//Retrieve the old value.
			oldValue = contentItem.GetTextBlockPropertyValue(allProps[i]);
		}
		//Set the new value.
		contentItem.SetTextBlockPropertyValue(allProps[i], "Severity upgraded. " + oldValue);
	}
	//Check for an integer property.
	else if (allProps[i] is IDoubleProperty)
	{
		//Set the new value for the existing property
		contentItem.SetIntegerPropertyValue(allProps[i], .9);
  }
}
//Check in the content item to store the updated values.
itemManager.CheckInItem(contentItem, "Severity Upgraded");
...

.NET (VB)

...
' Check out the content item.
contentItemManager.CheckOutItem(contentItem)

' Retrieve all the properties on the content item.
Dim allProps As IBaseProperty() = contentItem.GetAllProperties
Dim i As Integer
For i = 0 To allProps.Length - 1
	' Check for a text block property.
	If TypeOf allProps(i) Is ITextBlockProperty Then
		Dim oldValue As String = ""
		If contentItem.HasPropertyValue(allProps(i)) Then
			'Retrieve the old text block value if it has been set previously.
			oldValue = contentItem.GetTextBlockPropertyValue(allProps(i))
		End If
		' Set the new value.
		contentItem.SetTextBlockPropertyValue(allProps(i), ("Severity upgraded. " & oldValue))
	Else
		' Test if the property is an integer property.
		If TypeOf allProps(i) Is IIntegerProperty Then
			' Set the new value for the existing property
			contentItem.SetIntegerPropertyValue(allProps(i), (.9))
		End If
End If
Next i

'Check in the content item to store the updated values.
contentItemManager.CheckInItem(contentItem, "Severity Upgraded")
...

  Back to Top      Previous Next