vijay
Newbie
Karma: 0
Posts: 1
|
 |
« on: March 21, 2011, 07:08:49 am » |
|
Hi All,
I am using Maximo psdi classes to write a java programme to create a person and Maximo User. I am able to create a Person record and able to fetch all the data in MAXUSER recordset as well. However getting the exceptions while creating the MAXUSER. Below is the sample code that I am using.
import java.rmi.RemoteException; import psdi.mbo.MboConstants; import psdi.mbo.MboRemote; import psdi.mbo.MboSetRemote; import psdi.mbo.MboValueData; import psdi.security.UserInfo; import psdi.server.MXServer; import psdi.server.MXServer_Stub; import psdi.util.MXApplicationException; import psdi.util.MXException; import psdi.util.MXSession; import javax.*; import java.rmi.Naming; import java.util.*;
public class MaximoConn { public static void main(String[] args) { System.out.println("START");
try { System.out.println("Establishing Connection"); MXSession mxsession = MXSession.getSession() ;
mxsession.setHost("localhost:1099/MXServer"); mxsession.setUserName("maxadmin"); mxsession.setPassword("maxadmin"); mxsession.connect(); System.out.println("Connection Established"); MboSetRemote mboPersonSet = mxsession.getMboSet("PERSON"); MboRemote pmbo = mboPersonSet.add(); pmbo.setValue("PERSONID","TEST"); mboPersonSet.save(); /* Able to create the Person as well */ try{ /* Create the User and associate the above Created Person with it */ MboSetRemote mboset = mxsession.getMboSet("MAXUSER") ; MboRemote mbo = mboset.add(); mbo.setValue("USERID","TEST"); mbo.setValue("PERSONID","TEST"); mbo.setValue("LOGINID","test"); mbo.setValue("PASSWORD","password",MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION); mbo.setValue("PASSWORDCHECK","password",MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION); mboset.save(); /* Getting exception here in attributes PASSWORD and USERID */ }catch(MXException e){ Throwable thr = e.detail; System.out.println(e.getStackTrace().toString()); if(thr!=null){ System.out.println(thr.getMessage()); } System.out.println(" "+e.getLocalizedMessage()); Object objarr[] = e.params; if(objarr.length > 0){ for(int i =0;i<objarr.length;i++) System.out.println(objarr.toString()); } } /* This Piece of code works well as fetching of all attributes of MAXUSER RecordSet MboSetRemote mboset = mxsession.getMboSet("MAXUSER"); int cpt = mboset.count(); int i=1; while(i<cpt) { MboRemote mbr = mboset.getMbo(i); i++; MboValueData lname = mbr.getMboValueData("USERID"); if(!lname.isNull()){ System.out.println("USERID "+lname.getData()); } lname = mbr.getMboValueData("PERSONID"); if(!lname.isNull()){ System.out.println("PERSONID "+lname.getData()); } lname = mbr.getMboValueData("STATUS"); if(!lname.isNull()){ System.out.println("STATUS "+lname.getData()); } lname = mbr.getMboValueData("TYPE"); if(!lname.isNull()){ System.out.println("TYPE "+lname.getData()); } lname = mbr.getMboValueData("QUERYWITHSITE"); if(!lname.isNull()){ System.out.println("QUERYWITHSITE "+lname.getData()); } lname = mbr.getMboValueData("FORCEEXPIRATION"); if(!lname.isNull()){ System.out.println("FORCEEXPIRATION "+lname.getData()); } lname = mbr.getMboValueData("FAILEDLOGINS"); if(!lname.isNull()){ System.out.println("FAILEDLOGINS "+lname.getData()); } lname = mbr.getMboValueData("PASSWORD"); if(!lname.isNull()){ System.out.println("PASSWORD "+lname.getData()); } lname = mbr.getMboValueData("LOGINID"); if(!lname.isNull()){ System.out.println("LOGINID "+lname.getData()); } lname = mbr.getMboValueData("MAXUSERID"); if(!lname.isNull()){ System.out.println("MAXUSERID "+lname.getData()); } lname = mbr.getMboValueData("SYSUSER"); if(!lname.isNull()){ System.out.println("SYSUSER "+lname.getData()); } System.out.println("********************"); } */ mxsession.disconnect(); } catch(Exception e){ System.out.println("Some Exception Occured.."); System.out.println(e.getMessage()); } }
}
Any help to resolve it will be great.
|