Hi Experts,
I've written a TBO for a custom object type and I'm trying to set one custom attribute in Centera Storage.
The attribute will hold value of MD5 of the uploaded file.
I'm writing my code is doSave method in TBO, the code is as below
protected synchronized void doSave(boolean arg0, String arg1, Object[] arg2)
throws DfException {
// TODO Auto-generated method stub
super.doSave(arg0, arg1, arg2);
//if(isNew()){
IDfSession session = getSession();
IDfId documentId = getObjectId();
IDfSysObject dfSysObject = (IDfSysObject)session.getObject(documentId);
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
InputStream is = dfSysObject.getContent();
byte[] buffer = new byte[8192];
int read = 0;
while( (read = is.read(buffer)) > 0)
{
digest.update(buffer, 0, read);
}
byte[] md5sum = digest.digest();
BigInteger bigInt = new BigInteger(1, md5sum);
String output = bigInt.toString(16);
setString("md5_value", output);
setString("custom_attr1", getString("custom_attr1"));
setString("custom_attr2", getString("custom_attr2"));
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// trying centera setting
String formattedAttributeString = "md5_value"+"=\""+getString("md5_value")+"\",";
try {
boolean suc = session.apiExec("setcontentattrs",getObjectId().toString()+","+"xls"+",0,,'"+formattedAttributeString+"'");
if(suc){
setString("custom_attr2", "Prashant");
}else{
setString("custom_attr2", "Kasbe");
}
} catch (Exception e) {
DfLogger.warn( this,"\\\\\\\\\\ -------- warn - xx is called --------------- ///////////"+e.getMessage(),null, null);
}
The apiExec method I used in past with normal DFC to set attributes in Centera while importing.
The error in logs is as below:
\\\\\ -------- warn - xx is called --------------- ///////////[DM_SYSOBJECT_E_CANT_GET_CONTENT]error: "Cannot access content for id '090197c880072659', format 'xls', page '0', page modifier ''"
Please let me know how can I resolve this issue.
Regards
Prashant