on 09-29-2007 11:31 AM
Hello Developers,
i am haveing problems converting an Binary MdmValue into something that i can write to the Filesystem. I am using the MDMJavaAPI_Ver5.5.42.65 resulting from SP5 Patch 2 Hotfix 4.
I want to retrieve PDFs and Images with the RetrieveBlobCommand and store them on the Filesystem.
The Command is executed and i get the BLOB with:
blobCommand.getBlob();
The debugger shows me that i got a hold on the Objekt as an MultiRegionValue of type BINARY (int 15).
After I got the MdmValue
"test"
i want to cast the object to BinaryValue but I get a java.jang.ClassCastException.Why do I want to cast the result!? Because I want to use the method
getBytes()
of the BinaryValue to get the byte[] to write this over OutputStream to Filesystem. Is this the right way or am I on the wrong track?
Here is my coding:
RetrieveBlobCommand blobCommand = new RetrieveBlobCommand(this.caRepositoryConnection);
blobCommand.setTableId(PDFs.TBL);
blobCommand.setSession(this.sRepositorySession);
blobCommand.setRecordId(pdfblobRecord.getId());
try {
blobCommand.execute();
} catch (CommandException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
MdmValue test = blobCommand.getBlob();
// Will be 15 after execution
int type = test.getType();
// On this line the code crashes with java.lang.ClassCastException
// I dont see why this happens
BinaryValue bv = (BinaryValue) test;
Has anyone some idea how i can manage to store the retrieved BLOB to the Filesystem?
Any hint is highly appreciated!
THX
After a lot of testing finally i found the solution to my problem!
//MDM MULTIREGION VALUE is the result of the getblob method
// Now I get the avalible region codes for the result and store to String[]
String[] regions = ((MultiregionValue) blobCommand.getBlob()).getRegionCodes();
// 1. get the value corresponding to the region code and store as MdmValue
MdmValue test = ((MultiregionValue) blobCommand.getBlob()).getValue(regions[0]);
// 2. Now it is possible to cast to BinaryValue
BinaryValue bv = (BinaryValue) test;
So my problem is finally solved.
Hope this will help if you have the same problem.
Regards,
Tobi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
25 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.