using System; using TestFramework.ApplicationAPI; using TestFramework.AuthenticateAPI; using TestFramework; namespace Tests.resource { /// <summary> /// Summary description for ResourcePassport. /// /// this example assigns to a resource in the RPM /// repository a passport and international readiness /// </summary> public class ResourcePassport { public ResourcePassport() { } //All these variables are used in this sample public static String resourceName = "IBM_testABCDEF"; //Session ID is use for all transaction and is get from the //Authenticate.login function. The session ID will replace // the User password while transacting public static String sessionid = ""; public void sampleTest() { // start the communication with the api sessionid = APISetup.SetUp(); // Declare the resource wich we are going to use Resource res = null; // create a resourceScope to keep track of the relation // between the resource and the passport ResourceScope rScope = new ResourceScope(); // adjust resource scope to keep relation rScope.passport = true; // create a passport Passport passport = new Passport(); // Find the resource in RPM using XPath. // take resource in RPM repository by its // fullname or externalid res = (Resource)APISetup.application. loadFromXpath(sessionid, "/Resource[fullname='" + resourceName + "']", rScope ).rpmObjectList[0]; // initialise the passport with default values passport.hasValidPassport = true; passport.expiryDate = new DateTime(2008, 10,10,10,10,10); // assign the resource to the passport as a parent passport.parent = res; // add additional visas to international readiness Visa visa = new Visa(); visa.country = (CitizenshipCountryCode)APISetup. application.loadFromXpath(sessionid, "/CitizenshipCountryCode[value='USA']", null ).rpmObjectList[0]; visa.expiryDate = new DateTime(2008, 10,10,10,10,10); visa.parent = passport; passport.visas = new Visa[] {visa}; // assign the passport to the ressource res.passport = passport; // save the resource in the RPM repository // use the sessionid acquired in the setUp // use a resource scope to relate with passport SaveResult save = APISetup.application.save(sessionid, res, rScope, ReloadType.SavedResult ); APISetup.checkForErrors( save ); // end the communication with the api. APISetup.CleanUp(sessionid); } } }