use of org.openntf.domino.exceptions.DominoNonSummaryLimitException in project org.openntf.domino by OpenNTF.
the class Document method replaceItemValue.
/**
* replaceItemValue writes itemFriendly values or a Collection of itemFriendly values.
*
* if "autoSerialisation" is enabled. Data exceeding 32k is serialized with replaceItemValueCustomData. If MIME_BEAN_SUFFIX is set, the
* original item contains the String $ObjectData (=MIME_BEAN_SUFFIX). This is important, if you display data in a view, so that you see
* immediately, that only serialized content is available
*
* @see org.openntf.domino.Document#replaceItemValue(java.lang.String, java.lang.Object)
*/
@Override
public Item replaceItemValue(final String itemName, final Object value, final Boolean isSummary, final boolean boxCompatibleOnly, final boolean returnItem) {
Item result = null;
try {
try {
// Special case. If the argument is an Item, just copy it.
if (value instanceof Item) {
List<lotus.domino.Base> recycleThis = null;
lotus.domino.Item tmpResult;
recycleThis = new ArrayList<lotus.domino.Base>();
// remove the mime item first, so that it will not collide with MIME etc.
MIMEEntity mimeChk = getMIMEEntity(itemName);
if (mimeChk != null) {
try {
mimeChk.remove();
} finally {
closeMIMEEntities(true, itemName);
}
}
beginEdit();
tmpResult = getDelegate().replaceItemValue(itemName, TypeUtils.toDominoFriendly(value, getAncestorSession(), recycleThis));
markDirty(itemName, true);
s_recycle(tmpResult);
if (returnItem) {
return getFactory().create(Item.SCHEMA, this, itemName);
} else {
return null;
}
}
result = replaceItemValueLotus(itemName, value, isSummary, returnItem);
} catch (Exception ex2) {
if (this.getAutoMime() == AutoMime.WRAP_NONE) {
// AutoMime completely disabled.
throw ex2;
}
if (!boxCompatibleOnly || ex2 instanceof DominoNonSummaryLimitException) {
// if the value exceeds 32k or we are called from put() (means boxCompatibleOnly=false) we try to write the object as MIME
result = replaceItemValueCustomData(itemName, "mime-bean", value, returnItem);
} else if (this.getAutoMime() == AutoMime.WRAP_ALL) {
// Compatibility mode
result = replaceItemValueCustomData(itemName, "mime-bean", value, returnItem);
log_.log(Level.INFO, "Writing " + value == null ? "null" : value.getClass() + " causes a " + ex2 + " as AutoMime.WRAP_ALL is enabled, the value will be wrapped in a MIME bean." + " Consider using 'put' or something similar in your code.");
} else {
throw ex2;
}
}
// TODO RPr: What is this?
if (this.shouldWriteItemMeta_) {
// If we've gotten this far, it must be legal - update or create the item info map
Class<?> valueClass;
if (value == null) {
valueClass = Null.class;
} else {
valueClass = value.getClass();
}
Map<String, Map<String, Serializable>> itemInfo = getItemInfo();
Map<String, Serializable> infoNode = null;
if (itemInfo.containsKey(itemName)) {
infoNode = itemInfo.get(itemName);
} else {
infoNode = new HashMap<String, Serializable>();
}
infoNode.put("valueClass", valueClass.getName());
// For sanity checking if the value was changed outside of Java
infoNode.put("updated", new Date());
itemInfo.put(itemName, infoNode);
}
} catch (Throwable t) {
DominoUtils.handleException(t, this, "Item=" + itemName);
}
return result;
}
Aggregations