on 10-11-2006 7:43 AM
Hi ppl,
I am working on MDM SP3. I want to upload images using java api. I tried the following code.
catalog = new CatalogData();
int resultLogin = catalog.Login(hostname, port,username,password, language);
byte[] imageBuf = readFile("C:\temp\bus.bmp");
A2iFields fields = new A2iFields();
fields.Add(new A2iField("Data ID", new Value (imageBuf)));
fields.Add(new A2iField("Name", new Value("pic.bmp")));
fields.Add(new A2iField("Original Name", new Value("bus.bmp")));
fields.Add(new A2iField("Data Group ID", new Value(1)));
int origLocationId = 0;
try {
origLocationId =
catalog.AddDataLocation("C:\temp\bus.bmp",0,DataLocationType.RemovableMediaLocation);
} catch (StringException e2) {
e2.printStackTrace();
}
fields.Add(new A2iField("Original Location ID", new Value(origLocationId)));
fields.Add(new A2iField("Has Original", new Value(true)));
String imageTable = "Images";
try {
catalog.AddRecord(imageTable, fields, -1, -1);
} catch (StringException e) {
e.printStackTrace();
System.out.println(e.GetErrorCode());
System.out.println(e.GetRCMessage(e.GetErrorCode()));
e.A2iPrintError();
}
But it throws the following error
a2i.core.StringException: AddRecord error
at a2i.common.CatalogData.AddRecord(Unknown Source)
at a2i.common.CatalogData.AddRecord(Unknown Source)
at MDMCon.MDMTest.main(MDMTest.java:88)
-2147483647
No message for RC (0x80000001)
Error code: 0x80000001
Error message : No message for RC (0x80000001)
Help me solve this issue
its very Urgent
Vijay
Hi Vijay,
The return code (2147483647) is a "bad parameter" code (see the file constant-values.html which is part of the javadoc package of the MDM4J API).
Walter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Walter,
thank you for this info
On the "installation CD" I found the information here ...\MDM\JAVA_API\MDM4J_Ver5.5.33.13.zip -> constant-values.html , and it is good to know the RC Codes do have a meaning.
Further, there is the API RC.GetTextForError that returns the text of the error, so after getting the RC code from an API, I assume it is possible to get its text too.
Thank you.
Laszlo.
Hi Vijay,
If I remember correctly the error is caused by spaces in the Field names, like "Data ID", "Original Name" and "Original Location ID".
Try replacing these names with "DataID", "OriginalName" and "OriginalLocationID".
All of this has changed in SP4, because now you have to use the Code value instead of Field name.
Let me know if this helps.
Leo
Hi, Walter!
These fragments of code are identical (StringException.GetRCMessage just invokes corresponding method in class RC):
public class StringException
...
...
public static String GetRCMessage(int i)
{
return RC.GetTextForError(i);
}
public static String GetRCMessage(int i, LanguageOrder languageorder)
{
return RC.GetTextForError(i, languageorder);
}
...
...
Hi, Vijayasarathy Raghunathan.
To resolve the problem with undefined messages for return codes:
LanguageOrder lo = catalog.GetLanguageOrder();
String rcMessage = RC.GetTextForError( rc, lo );
OR (for example to translate RC of unsuccessful login):
1) Create "dummy" implementation of interface LanguageOrder:
import a2i.core.LanguageOrder;
import java.util.ResourceBundle;
public class EnglishLanguageOrder
implements LanguageOrder
{
public EnglishLanguageOrder()
{
}
public String GetString(String s, String s1)
{
return getStringEnglish(s, s1);
}
public static String getStringEnglish(String s, String s1)
{
String s2 = s + "_" + "en";
String s3 = ResourceBundle.getBundle(s2).getString(s1);
return s3;
}
}
2) get a message in English:
String rcMessage = RC.GetTextForError( rc, new EnglishLanguageOrder() );
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.