Package org.openntf.domino

Examples of org.openntf.domino.Document


      importer.importDxl(getDxl().getXml(), database);

      noteId_ = importer.getFirstImportedNoteID();

      // Reset the DXL so that it can pick up new noteinfo
      Document document = database.getDocumentByID(noteId_);
      DxlExporter exporter = getAncestorSession().createDxlExporter();
      exporter.setForceNoteFormat(true);
      exporter.setOutputDOCTYPE(false);
      loadDxl(exporter.exportDxl(document));
    } catch (IOException e) {
View Full Code Here


    }
  }

  public Map<String, byte[]> getClassData() {
    // For this one, we'll need the note in the database
    Document doc = getDocument();
    if (doc != null) {
      try {
        EmbeddedObject obj = doc.getAttachment("%%object%%.jar");

        InputStream objInputStream = obj.getInputStream();
        JarInputStream jis = new JarInputStream(objInputStream);
        JarEntry entry = jis.getNextJarEntry();
        Map<String, byte[]> classData = new TreeMap<String, byte[]>();
View Full Code Here

    }
  }

  @Override
  public String[] getXotsClassNames() {
    Document iconDoc = getDocument();
    if (iconDoc != null && iconDoc.hasItem("$Xots")) {
      String[] xotsClassNames = iconDoc.getItemValue("$Xots", String[].class);
      if (xotsClassNames != null) {
        return xotsClassNames;
      }
    }
    return new String[] {};
View Full Code Here

    //      Thread.sleep(100);
    //    } catch (InterruptedException e1) {
    //      DominoUtils.handleException(e1);
    //      return null;
    //    }
    Document result = null;
    boolean go = true;
    go = fireListener(generateEvent(Events.BEFORE_CREATE_DOCUMENT, this, null));
    if (go) {
      try {
        if (!getDelegate().isOpen()) {
View Full Code Here

   *
   * @see org.openntf.domino.Database#createDocument(java.util.Map)
   */
  @Override
  public Document createDocument(final Map<String, Object> itemValues) {
    Document doc = this.createDocument();
    for (Map.Entry<String, Object> entry : itemValues.entrySet()) {
      doc.replaceItemValue(entry.getKey(), entry.getValue());
    }
    return doc;
  }
View Full Code Here

   *
   * @see org.openntf.domino.Database#createDocument(java.lang.Object[])
   */
  @Override
  public Document createDocument(final Object... keyValuePairs) {
    Document doc = this.createDocument();
    if (keyValuePairs.length >= 2) {
      for (int i = 0; i < keyValuePairs.length; i += 2) {
        doc.replaceItemValue(keyValuePairs[i].toString(), keyValuePairs[i + 1]);
      }
    }
    return doc;
  }
View Full Code Here

  public Document getDocumentWithKey(final Serializable key, final boolean createOnFail) {
    try {
      if (key != null) {
        String checksum = DominoUtils.toUnid(key);

        Document doc = this.getDocumentByUNID(checksum);
        if (doc == null && createOnFail) {
          doc = this.createDocument();
          doc.setUniversalID(checksum);
          doc.replaceItemValue("$Created", new Date());
          doc.replaceItemValue("$$Key", key);
        }
        return doc;

      } else if (createOnFail) {
        log_.log(java.util.logging.Level.WARNING,
            "Document by key requested with null key. This is probably not what you meant to do...");
        Document doc = this.createDocument();
        doc.replaceItemValue("$Created", new Date());
        doc.replaceItemValue("$$Key", "");
        return doc;
      }
    } catch (Exception e) {
      DominoUtils.handleException(e, this);
    }
View Full Code Here

  public Locale getLocale() {
    if (getLocaleCalled)
      return dbLocale;
    getLocaleCalled = true;

    Document doc = getDesign().getIconNote().getDocument();
    if (doc == null)
      return null;
    String lStr = doc.getItemValueString("$DefaultLanguage");
    if (lStr == null || lStr.length() < 2)
      return null;
    String language = lStr.substring(0, 2).toLowerCase();
    String country = (lStr.length() >= 5 && lStr.charAt(2) == '-') ? lStr.substring(3, 5).toUpperCase() : "";
    return dbLocale = new Locale(language, country);
View Full Code Here

    result = props.get(propertyName);
    if (result == null || Deferred.INSTANCE.equals(result)) {
      try {
        Map<String, Object> delegate = getDelegate();
        if (delegate instanceof Document) {
          Document doc = (Document) delegate;
          result = doc.getItemValue(propertyName, T);
        } else {
          result = T.cast(delegate.get(propertyName));
        }
        if (result == null) {
          props.put(propertyName, Null.INSTANCE);
        } else if (result instanceof Serializable) {
          props.put(propertyName, result);
        } else {
          log_.log(Level.FINE, "Got a value from the document but it's not Serializable. It's a " + result.getClass().getName());
          props.put(propertyName, result);
        }
      } catch (Exception e) {
        log_.log(Level.WARNING, "Exception occured attempting to get value from document for " + propertyName
            + " so we cannot return a value", e);
      }
    } else if (result == Null.INSTANCE) {

    } else {
      if (result != null && !T.isAssignableFrom(result.getClass())) {
        try {
          Map<String, Object> delegate = getDelegate();
          if (delegate instanceof Document) {
            Document doc = (Document) delegate;
            result = doc.getItemValue(propertyName, T);
          } else {
            Object chk = delegate.get(propertyName);
            if (chk != null) {
              result = T.cast(delegate.get(propertyName));
            }
View Full Code Here

    private void writeLogRecToDB(final OL_LogRecord ollr) {
      try {
        if (_logDb == null)
          _logDb = Factory.getSession().getDatabase(_myDBPath);
        Document olDoc = _logDb.createDocument();
        olDoc.replaceItemValue("Form", _logFormName);
        Throwable t = ollr._logRec.getThrown();
        if (t != null) {
          StackTraceElement[] sttr = t.getStackTrace();
          int interestingInd = (sttr.length == 0) ? -11 : 0;
          NotesException ne = null;
          if (t instanceof NotesException)
            ne = (NotesException) t;
          else if (t instanceof OpenNTFNotesException && t.getCause() instanceof NotesException) {
            ne = (NotesException) t.getCause();
            interestingInd++;
          }
          if (ne != null) {
            olDoc.replaceItemValue("LogErrorNumber", ne.id);
            olDoc.replaceItemValue("LogErrorMessage", ne.text);

          } else
            olDoc.replaceItemValue("LogErrorMessage", getMessage(ollr._logRec));
          if (interestingInd >= 0) {
            StackTraceElement ste = sttr[interestingInd];
            olDoc.replaceItemValue("LogErrorLine", ste.getLineNumber());
            olDoc.replaceItemValue("LogFromMethod", ste.getClassName() + "." + ste.getMethodName());
          }
        }
        olDoc.replaceItemValue("LogStackTrace", getStackTrace(t));
        Level l = ollr._logRec.getLevel();
        if (l == null)
          l = Level.WARNING;
        olDoc.replaceItemValue("LogSeverity", l.getName());
        olDoc.replaceItemValue("LogEventTime", new Date(ollr._logRec.getMillis()));
        olDoc.replaceItemValue("LogEventType", "Log");
        olDoc.replaceItemValue("LogMessage", getMessage(ollr._logRec));
        olDoc.replaceItemValue("LogFromDatabase", ollr._dbPath);
        olDoc.replaceItemValue("LogFromServer", ollr._serverName);
        olDoc.replaceItemValue("LogFromAgent", ollr._agentName);
        olDoc.replaceItemValue("LogAgentLanguage", "Java");
        olDoc.replaceItemValue("LogUserName", ollr._userName);
        olDoc.replaceItemValue("LogEffectiveName", ollr._effectiveUserName);
        olDoc.replaceItemValue("LogAccessLevel", ollr._accessLevel);
        olDoc.replaceItemValue("LogUserRoles", ollr._userRoles);
        olDoc.replaceItemValue("LogClientVersion", ollr._clientVersion);
        olDoc.replaceItemValue("LogAgentStartTime", _parentStartTime);
        if (ollr._exceptionDetails == null)
          olDoc.replaceItemValue("LogExceptionDetails", "* Not available *");
        else {
          int sz = ollr._exceptionDetails.size();
          String[] excds = new String[sz];
          for (int i = 0; i < sz; i++)
            excds[i] = ollr._exceptionDetails.get(i).toString();
          olDoc.replaceItemValue("LogExceptionDetails", excds);
        }
        if (ollr._lastWrappedDocs == null)
          olDoc.replaceItemValue("LogLastWrappedDocuments", "* Not available *");
        else
          olDoc.replaceItemValue("LogLastWrappedDocuments", ollr._lastWrappedDocs);
        olDoc.replaceItemValue("$PublicAccess", "1");
        olDoc.save(true);
      } catch (Exception e) {
        printException(e);
      }
    }
View Full Code Here

TOP

Related Classes of org.openntf.domino.Document

Copyright © 2018 www.massapicom. 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.