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, 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() );
Add a comment