#137487 - 04/23/07 11:31 AM
Re: Cannot open catalog; ARERR 9006
[Re: Shark_7-11]
|
Stealth Member
Registered: 02/13/07
Posts: 15
Loc: Fairfax, VA, USA
|
Hello,
thanks for the help.
Port and rpc numbers are not set or are set to zero, so that port mapper service is used.
public RemedyContext(String userName, String password, String target, int port, int rpcNumber) throws Exception { this.context = new ARServerUser(userName, password, Locale.getDefault().getLanguage(), target); try { Util.ARSetServerPort(this.context, new NameID(target), port, rpcNumber); } catch (ARException e) { throw new Exception("Connection exception: " + getErrorString(e), e); }catch(UnsatisfiedLinkError l) { throw new Exception("Missing Library exception: " + l.toString(), l); }catch(NoClassDefFoundError t) { throw new Exception("Missing Class exception: " + t.toString(), t); }catch(Throwable t) { throw new Exception("Exception: " + t.toString(), t); } }
|
|
Top
|
|
|
|
|
#137503 - 04/24/07 10:01 AM
Re: Cannot open catalog; ARERR 9006
[Re: Ranga]
|
Stealth Member
   
Registered: 09/26/06
Posts: 267
|
I can't quite Remember where I got this but I used this before as sample code. (Might be old, used it in version 6.0.1 I think but should still work) Here the left the locale string empty. I'm not sure where your error could be. Can you log in and do anything? like this.context.logout() ? import com.remedy.arsys.api.*; import java.util.Date; import java.text.DateFormat;
public class getEntryDiary { public static void main(String[] args) { get(); }
static void get() { //create context ARServerUser context = new ARServerUser("Demo", "", "", "93i2a");
try { //Get an entry factory. We will be using the EntryFactory findByKey method. This method requires 3 arguements, context, EntryKey,EntryCriteria. //The two blocks of code that follow creating the factory object create those required objects for the findBykey method. EntryFactory entfact = EntryFactory.getFactory();
//create an new EntryKey object whose constructor takes a NameID(form name) and a EntryID(record ID). EntryKey key = new EntryKey(new NameID("test1"), new EntryID("000000000000001"));
//Create an EntryCriteria object. Since the constructor for EntryCriteria expects an array of FieldID objects in an EntryListFieldInfo array object the //following block of code is necessary. We say that we want to create a new EntryListFieldInfo array object that will hold 2 values. We then say //that we want a new FieldID array object that will hold two field id values. Next we construct a new FieldID object whose constructor wants a //field id in the form of a long int, at the same time we create the object we set it into the FieldID array object. We do this for field id's 1 and 8. //Next, we create a new EntryListFieldInfo object whose constructor loads the FieldID array element into each EntryListFieldInfo array element. EntryListFieldInfo[] fieldlist = new EntryListFieldInfo[2]; FieldID[] fields = new FieldID[2]; fields[0] = new FieldID(1); fields[1] = new FieldID(536870917); fieldlist[0] = new EntryListFieldInfo(fields[0]); fieldlist[1] = new EntryListFieldInfo(fields[1]);
//Now that we have an EntryListFieldInfo array object containing the required FieldID references, we can set that as the entry criteria for the //EntryCriteria object. We use the EntryCriteria classes setEntryListFieldInfo method to do this. EntryCriteria entrycrit = new EntryCriteria(fieldlist); entrycrit.setEntryListFieldInfo(fieldlist);
//We have now defined the required arguments so we can use the findByKey method of the EntryFactory to return the entry we want based on the EntryKey. //****NOTE: the findByKey method will call the Remedy Java API Proxy class method ARGetEntry which will in turn, after passing through the //JNI layer, call the C function ARGetEntry.
Entry entry = entfact.findByKey(context, key, entrycrit);
//Now we have the entry, i.e. record 000000000000001. To get at the field/value pairs for fields ids 1 and 536870917 we need to get those pairs using //the Entry class method getEntryItems. Since this method returns a array of EntryItem objects, we store the return value in an EntryItem[] reference //variable. Regular fields such as Entry ID(fid 1) values can be retrieved by using the EntryItem getValue method which returns a Value which can //then be converted to a String and displayed. Diary fields, however, are somewhat tricky, see below. EntryItem[] entrylist = entry.getEntryItems();
Value val = entrylist[0].getValue(); val.toString(); System.out.println("Entry ID = " + val);
//The actual encoded text of the diary field is stored in the EntryItem list, however the getValue() method of EntryItem returns a Value, however //we need a Diary, so we cast to Diary. The hardest part about Diary fields is you cannot call the Diary class constructor directly, actually you could //but you would need to know the encoded String of the diary field, which most humans wouldn't know. //The big secret to this is that when you get the entry Items our JNI calls the constructor for the Diary class for you //giving you access to all the needed Diary class methods.
Value entryItem = entrylist[1].getValue(); Diary diaryValue = null; diaryValue = (Diary) entryItem.getValue();
//Decode all the encoded values in the diary field and store each seperate entry in the diary field in a DiaryInfo array list. DiaryInfo[] diaryInfo = null; diaryInfo = diaryValue.decode(context); for (int i = 0; i < diaryInfo.length; ++i) { //walk the DiaryInfo array list and get the diary text using the DiaryInfo method getDiaryInfo(). //also, get timestamp and user info for each diary entry. String diaryString = diaryInfo[i].getDiaryInfo(); Timestamp time = diaryInfo[i].getTimestamp(); AccessNameID name = diaryInfo[i].getUser(); Date dateobj = time.toDate(); DateFormat datetime = DateFormat.getInstance(); String timestamp = datetime.format(dateobj); String username = name.toString(); System.out.println(timestamp); System.out.println(username); System.out.println(diaryString); }
//release the factory instance entfact.releaseInstance(entry); } //catch and print out any errors catch (ARException e) { e.describe(); } //clear the context created finally { context.clear(); } }
}
_________________________
Mayhem, Chaos and Anarchy My job here is complete!
|
|
Top
|
|
|
|
|
|
|