A situation occurred when a customer wanted to know how they could pull a Domino RichText 'UserPhoto' field from Domino (names.nsf)...and sync that object to the 'jpegPhoto' attribute in the Domino Directory.
The main work here comes to convert from the RichText object to the byte stream we need for the jpegPhoto. In the example we did the conversation in an AttMap.
The AttMap had the following code to convert the UserPhoto object.
var someobj = work.getObject("UserPhoto");
if (someobj!=null) {
var objs = someobj.getEmbeddedObjects();
if ((objs != null) && (objs.size() > 0))
{
var em = objs.firstElement();
var fin=em.getInputStream();
var bytes = new byte[em.getFileSize()];
fin.read(bytes);
work.setAttribute( "jpegPhoto", bytes );
em.recycle();
}else{
task.logmsg("## NO UserPhoto for user: " +work.ShortName)
system.exitFlow()
}
}
No comments:
Post a Comment