Examples of MIMEEntity


Examples of org.openntf.domino.MIMEEntity

    // TODO RPr: is this mime-safe?
    try {
      String ret = getDelegate().getItemValueString(name);
      if (ret != null && ret.length() != 0)
        return ret;
      MIMEEntity me = getMIMEEntity(name);
      if (me == null)
        return "";
      closeMIMEEntities(false, name);
      Vector<?> v = getItemValue(name);
      ret = "";
View Full Code Here

Examples of org.openntf.domino.MIMEEntity

    // 14-03-14 RPr: disabling convertMime is required here! (Not always... but in some cases)
    boolean convertMime = getAncestorSession().isConvertMime();
    try {
      if (convertMime)
        getAncestorSession().setConvertMime(false);
      MIMEEntity ret = fromLotus(getDelegate().getMIMEEntity(itemName), MIMEEntity.SCHEMA, this);

      if (ret != null) {
        openMIMEEntities.put(itemName.toLowerCase(), ret);
        ret.initItemName(itemName); // here it is allowed to initialize the item with its name
      }

      if (openMIMEEntities.size() > 1) {
        //  throw new BlockedCrashException("Accessing two different MIME items at once can cause a server crash!");
        log_.warning("Accessing two different MIME items at once can cause a server crash!" + openMIMEEntities.keySet());
View Full Code Here

Examples of org.openntf.domino.MIMEEntity

    checkMimeOpen();
    beginEdit();
    try {
      // RPr: it is important to check if this is a MIME entity and remove that this way.
      // Otherwise dangling $FILE items are hanging around in the document
      MIMEEntity mimeChk = getMIMEEntity(name);
      if (mimeChk != null) {
        try {
          mimeChk.remove();
        } finally {
          closeMIMEEntities(true, name);
        }
      }
      if (getAncestorSession().isFixEnabled(Fixes.REMOVE_ITEM)) {
View Full Code Here

Examples of org.openntf.domino.MIMEEntity

    lotus.domino.Item result;
    try {
      // Special case. If the argument is an Item, just copy it.
      if (value instanceof Item) {
        // 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();
        result = getDelegate().replaceItemValue(itemName, toDominoFriendly(value, this, recycleThis));
        markDirty(itemName, true);
        if (returnItem) {
          return fromLotus(result, Item.SCHEMA, this);
        } else {
          s_recycle(result);
          return null;
        }
      }

      // first step: Make it domino friendly and put all converted objects into "dominoFriendly"
      if (value instanceof Collection) {
        Collection<?> coll = (Collection<?>) value;
        dominoFriendly = new Vector<Object>(coll.size());
        for (Object valNode : coll) {
          if (valNode != null) { // CHECKME: Should NULL values discarded?
            if (valNode instanceof BigString)
              isNonSummary = true;
            dominoFriendly.add(toItemFriendly(valNode, this, recycleThis));
          }
        }

      } else if (value.getClass().isArray()) {
        int lh = Array.getLength(value);
        if (lh > MAX_NATIVE_FIELD_SIZE) {        // Then skip making dominoFriendly if it's a primitive
          String cn = value.getClass().getName();
          if (cn.length() == 2)            // It is primitive
            throw new Domino32KLimitException();
        }
        dominoFriendly = new Vector<Object>(lh);
        for (int i = 0; i < lh; i++) {
          Object o = Array.get(value, i);
          if (o != null) { // CHECKME: Should NULL values be discarded?
            if (o instanceof BigString)
              isNonSummary = true;
            dominoFriendly.add(toItemFriendly(o, this, recycleThis));
          }
        }
      } else {
        // Scalar
        dominoFriendly = new Vector<Object>(1);
        if (value instanceof BigString)
          isNonSummary = true;
        dominoFriendly.add(toItemFriendly(value, this, recycleThis));
      }

      // empty vectors are treated as "null"
      if (dominoFriendly.size() == 0) {
        return replaceItemValueLotus(itemName, null, isSummary, returnItem);
      }

      Object firstElement = dominoFriendly.get(0);

      int payloadOverhead = 0;

      if (dominoFriendly.size() > 1) {  // compute overhead first
        // String lists have an global overhead of 2 bytes (maybe the count of values) + 2 bytes for the length of value
        if (firstElement instanceof String)
          payloadOverhead = 2 + 2 * dominoFriendly.size();
        else
          payloadOverhead = 4;
      }

      // Next step: Type checking + length computation
      //
      // Remark: The special case of a String consisting of only ONE @NewLine (i.e.
      //     if (s.equals("\n") || s.equals("\r") || s.equals("\r\n"))
      // where Domino is a bit ailing) won't be extra considered any longer.
      // Neither serialization nor throwing an exception would be reasonable here.

      int payload = payloadOverhead;
      Class<?> firstElementClass;
      if (firstElement instanceof String)
        firstElementClass = String.class;
      else if (firstElement instanceof Number)
        firstElementClass = Number.class;
      else if (firstElement instanceof lotus.domino.DateTime)
        firstElementClass = lotus.domino.DateTime.class;
      else if (firstElement instanceof lotus.domino.DateRange)
        firstElementClass = lotus.domino.DateRange.class;
      // Remark: Domino Java API doesn't accept any Vector of DateRanges (cf. DateRange.java), so the implementation
      // here will work only with Vectors of size 1 (or Vectors of size >= 2000, when Mime Beaning is enabled).
      else
        throw new DataNotCompatibleException(firstElement.getClass() + " is not a supported data type");
      for (Object o : dominoFriendly)
        payload += getLotusPayload(o, firstElementClass);
      if (payload > MAX_NATIVE_FIELD_SIZE) {
        // the datatype is OK, but there's no way to store the data in the Document
        throw new Domino32KLimitException();
      }
      if (firstElementClass == String.class) {   // Strings have to be further inspected, because
        // each sign may demand up to 3 bytes in LMBCS
        int calc = ((payload - payloadOverhead) * 3) + payloadOverhead;
        if (calc >= MAX_NATIVE_FIELD_SIZE) {
          payload = payloadOverhead + getLMBCSPayload(dominoFriendly);
          if (payload > MAX_NATIVE_FIELD_SIZE)
            throw new Domino32KLimitException();
        }
      }
      if (payload > MAX_SUMMARY_FIELD_SIZE) {
        isNonSummary = true;
      }

      MIMEEntity mimeChk = getMIMEEntity(itemName);
      if (mimeChk != null) {
        try {
          mimeChk.remove();
        } finally {
          closeMIMEEntities(true, itemName);
        }
      }
      beginEdit();
View Full Code Here

Examples of org.openntf.domino.MIMEEntity

          ((org.openntf.domino.impl.MIMEEntity) currEntity).closeMIMEEntity();
        }
        openMIMEEntities.clear();
      } else {
        if (openMIMEEntities.containsKey(entityItemName.toLowerCase())) {
          MIMEEntity currEntity = openMIMEEntities.remove(entityItemName.toLowerCase());
          if (currEntity != null)
            ((org.openntf.domino.impl.MIMEEntity) currEntity).closeMIMEEntity();
        }
      }
      boolean ret = false;
View Full Code Here

Examples of org.openntf.domino.MIMEEntity

    try {
      if (itemName == null) {
        itemName = "Body";
      }
      try {
        MIMEEntity wrapped = fromLotus(getDelegate().createMIMEEntity(itemName), MIMEEntity.SCHEMA, this);
        if (wrapped != null) {
          openMIMEEntities.put(itemName.toLowerCase(), wrapped);
          wrapped.initItemName(itemName);
          markDirty(itemName, true);
        }
        return wrapped;
      } catch (NotesException alreadyThere) {
        Item chk = getFirstItem(itemName);
        if (chk != null) {
          log_.log(Level.WARNING,
              "Already found an item for " + itemName + " that is type: " + (chk == null ? "null" : chk.getTypeEx()));
          removeItem(itemName);
        } else {
          MIMEEntity me = getMIMEEntity(itemName);
          markDirty(itemName, true);
          return me;
        }
        closeMIMEEntities(false, itemName);
        MIMEEntity wrapped = fromLotus(getDelegate().createMIMEEntity(itemName), MIMEEntity.SCHEMA, this);
        if (wrapped != null) {
          openMIMEEntities.put(itemName.toLowerCase(), wrapped);
          wrapped.initItemName(itemName);
          markDirty(itemName, true);
        }
        return wrapped;
      }
      // return fromLotus(getDelegate().createMIMEEntity(itemName), MIMEEntity.class, this);
View Full Code Here

Examples of org.openntf.domino.MIMEEntity

  @Override
  public <T> T getItemValue(final String name, final Class<?> T) throws ItemNotFoundException, DataNotCompatibleException {
    // TODO NTF - Add type conversion extensibility of some kind, maybe attached to the Database or the Session

    // RPr: this should be equal to the code below.
    MIMEEntity entity = getMIMEEntity(name);
    if (entity == null) {
      Object result = TypeUtils.itemValueToClass(this, name, T);
      return (T) result;
    } else {
      try {
View Full Code Here

Examples of org.openntf.domino.MIMEEntity

    Vector<?> vals = null;

    try {
      // Check the item type to see if it's MIME - if so, then see if it's a MIMEBean
      // This is a bit more expensive than I'd like
      MIMEEntity entity = this.getMIMEEntity(name);
      if (entity != null) {
        try {
          Object mimeValue = Documents.getItemValueMIME(this, name, entity);
          if (mimeValue != null) {
            if (mimeValue instanceof Vector) {
              return (Vector<Object>) mimeValue;
            }
            if (mimeValue instanceof Collection) {
              return new Vector<Object>((Collection<Object>) mimeValue);
            }
            if (mimeValue.getClass().isArray()) {
              Vector<Object> ret;
              if (mimeValue.getClass().getName().length() != 2) // In case of on array of primitives the cast to Object[] obviously doesn't work
                ret = (Vector<Object>) Arrays.asList((Object[]) mimeValue);
              else {
                int lh = Array.getLength(mimeValue);
                ret = new Vector<Object>(lh);
                for (int i = 0; i < lh; i++)
                  ret.add(Array.get(mimeValue, i));
              }
              return ret;
            }
            Vector<Object> result = new Vector<Object>(1);
            result.add(mimeValue);
            return result;
          } else {
            log_.log(Level.WARNING, "We found a MIMEEntity for item name " + name
                + " but the value from the MIMEEntity is null so we likely need to look at the regular field.");

            // TODO NTF: What if we have a "real" mime item like a body field (Handle RT/MIME correctly)
            Vector<Object> result = new Vector<Object>(1);
            result.add(entity.getContentAsText()); // TODO: not sure if that is correct
            return result;
          }
        } finally {
          closeMIMEEntities(false, name);
        }
View Full Code Here

Examples of org.openntf.domino.MIMEEntity

   */
  @Override
  public Object getItemValueCustomData(final String itemName, final String dataTypeName) throws IOException, ClassNotFoundException {
    checkMimeOpen();
    if (dataTypeName == null || "mime-bean".equals(dataTypeName)) {
      MIMEEntity entity = this.getMIMEEntity(itemName);
      if (entity != null) {
        try {
          return Documents.getItemValueMIME(this, itemName, entity);
        } finally {
          closeMIMEEntities(false, itemName);
View Full Code Here

Examples of org.openntf.domino.MIMEEntity

    checkMimeOpen();
    try {
      byte[] ret = getDelegate().getItemValueCustomDataBytes(itemName, dataTypeName);
      if (ret != null && ret.length != 0)
        return ret;
      MIMEEntity entity;
      if ((entity = getMIMEEntity(itemName)) == null)
        return ret;
      Object o = null;
      try {
        o = Documents.getItemValueMIME(this, itemName, entity);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.