Juniper NETWORK AND SECURITY MANAGER 2010.4 - API GUIDE REV 1 Manual page 125

Api guide
Table of Contents

Advertisement

Sample Code
Copyright © 2010, Juniper Networks, Inc.
</address>
</address>
* Tests replacing an Address object
*/
public void testReplaceAddressObject() {
try {
File addressFile = new File(webDir + File.separator + pathOfInput +
"/Input/" + "testAddressReplace.xml");
System.out.println("Running testReplaceAddressObject()");
ModifyObjectViewRequest request = new ModifyObjectViewRequest();
request.setAuthToken(DataCentricServiceTest.authToken);
ModifyViewCommandType modifyCmd = new ModifyViewCommandType();
//specifies the address object to replace:
ObjectIdentifierType objectId = new ObjectIdentifierType();
objectId.setCategory("address");
objectId.setDomainId(new UnsignedShort("1"));
ObjectIdOrNameType objIdOrName = new ObjectIdOrNameType();
//objIdOrName.setObjectId(new UnsignedInt("1"));
objIdOrName.setObjectName("AddrA");
objectId.setObjectIdOrName(objIdOrName);
ReplaceObjectViewType replaceObject = new ReplaceObjectViewType();
//reads the new address in XML format from the file
"testAddressReplace.xml :
XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
XMLStreamReader parser =
xmlInputFactory.createXMLStreamReader(new
FileInputStream(addressFile));
StAXOMBuilder builder = new StAXOMBuilder(parser);
OMElement ome = builder.getDocumentElement();
replaceObject.setObjecData(new ObjectDataType());
replaceObject.getObjecData().setData(this.createOpaqueDataType(ome));
replaceObject.setObjectIdentifier(objectId);
modifyCmd.setReplaceObject(replaceObject);
request.addCommand(modifyCmd);
ModifyObjectViewResponse response =
DataCentricServiceTest.stub.ModifyObjectViewRequest(request);
assertTrue(response.getStatus() == StatusCodeType.Success);
} catch (Exception e) {
e.printStackTrace();
}
}
Chapter 11: Using APIs for Shared Object Management
107

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the NETWORK AND SECURITY MANAGER 2010.4 - API GUIDE REV 1 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Network and security manager 2010.4

Table of Contents