Puts a new document in the service. The generate key is globally unique.

@param document document
@return key unique key to reference the document
502489
public String putDocument(Document document) {
		String key = UUID.randomUUID().toString();
		documentMap.put(key, document);
		return key;
	}
217084
public static AtomService documentToService(final Document document) throws ProponoException {
        final AtomService service = new AtomService();
        final Element root = document.getRootElement();
        final List<Element> spaces = root.getChildren("workspace", ATOM_PROTOCOL);
        for (final Element e : spaces) {
            service.addWorkspace(Workspace.elementToWorkspace(e));
        }
        return service;
    }
75900
private synchronized Document asXmlDocument() throws IOException {
    Document doc;
    try {
      doc =
        DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    } catch (ParserConfigurationException pe) {
      throw new IOException(pe);
    }
    Element conf = doc.createElement("configuration");
    doc.appendChild(conf);
    conf.appendChild(doc.createTextNode("\n"));
    handleDeprecation(); //ensure properties is set and deprecation is handled
    for (Enumeration<Object> e = properties.keys(); e.hasMoreElements();) {
      String name = (String)e.nextElement();
      Object object = properties.get(name);
      String value = null;
      if (object instanceof String) {
        value = (String) object;
      }else {
        continue;
      }
      Element propNode = doc.createElement("property");
      conf.appendChild(propNode);

      Element nameNode = doc.createElement("name");
      nameNode.appendChild(doc.createTextNode(name));
      propNode.appendChild(nameNode);

      Element valueNode = doc.createElement("value");
      valueNode.appendChild(doc.createTextNode(value));
      propNode.appendChild(valueNode);

      if (updatingResource != null) {
        String[] sources = updatingResource.get(name);
        if(sources != null) {
          for(String s : sources) {
            Element sourceNode = doc.createElement("source");
            sourceNode.appendChild(doc.createTextNode(s));
            propNode.appendChild(sourceNode);
          }
        }
      }

      conf.appendChild(doc.createTextNode("\n"));
    }
    return doc;
  }
119098
private Document insertDocument(EntityKeyMetadata entityKeyMetadata, Tuple tuple, TupleContext tupleContext ) {
		Document dbObject = objectForInsert( tuple, ( (MongoDBTupleSnapshot) tuple.getSnapshot() ).getDbObject() );
		getCollection( entityKeyMetadata.getTable(), tupleContext.getTupleTypeContext().getOptionsContext() ).insertOne( dbObject );
		return dbObject;
	}
861786
def add_insert(self, document):
        
        validate_is_document_type("document", document)
        # Generate ObjectId client side.
        if not (isinstance(document, RawBSONDocument) or '_id' in document):
            document['_id'] = ObjectId()
        self.ops.append((_INSERT, document))
312413
function initDocument (docName) {
  return db.getDocument(dbName, docName)
    .then(response => response.data._rev) // document already exists
    .catch(response => {
      if (response.status === 404) {
        // create new document
        return db.createDocument(dbName, {foo: 'bar'}, docName)
          .then(response => response.data.rev)
      } else {
        // real error
        return Promise.reject(response)
      }
    })
}
318109
protected static Document createDocument(String document) throws PolicyIndexException {

        // parse policy document and create dom
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        DocumentBuilder builder;
        try {
            builder = factory.newDocumentBuilder();
            Document doc = builder.parse(new InputSource(new StringReader(document)));
            return doc;
        } catch (ParserConfigurationException e) {
            throw new PolicyIndexException(e);
        } catch (SAXException e) {
            throw new PolicyIndexException(e);
        } catch (IOException e) {
            throw new PolicyIndexException(e);
        }
    }
1352159
public Document<K> addDocument(K id, String document)
    {
        return addDocument(id, preprocess(document));
    }
427903
public void write(String key, String document) throws IOException {
    try {
      // Write the key.
      outputStream.write(key.getBytes("UTF-8"));

      // Write the key-document keyDocumentDelimiter.
      outputStream.write(keyDocumentDelimiter.getBytes("UTF-8"));

      // Write the document.
      outputStream.write(document.getBytes("UTF-8"));

      // Write the row keyDocumentDelimiter.
      outputStream.write(rowDelimiter.getBytes("UTF-8"));
    } catch (UnsupportedEncodingException e) { LOGGER.error("Shouldn't happen."); }
  }
618543
public void addDocumentUriParticipantObject(String documentRetrieveUri, String documentUniqueId)
	{
		List<TypeValuePairType> tvp = new LinkedList<>();
		if (documentUniqueId != null) {
			tvp.add(getTypeValuePair("XDSDocumentEntry.uniqueId", documentUniqueId.getBytes()));
		}
		addParticipantObjectIdentification(
				new RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectIDTypeCodes.URI(), 
				null, 
				null, 
				tvp, 
				documentRetrieveUri, 
				RFC3881ParticipantObjectTypeCodes.SYSTEM, 
				RFC3881ParticipantObjectTypeRoleCodes.REPORT,
				null, 
				null);
	}
117250
def add_document(self, document):
        '''
        
        '''

        documents_url = urljoin(self.base_url, self.DOCUMENTS_PAGE)
        data = {"corpus": self.url}
        files = {"blob": document}
        result = self.session.post(documents_url, data=data, files=files)
        if result.status_code == 201:
            return Document(session=self.session, **result.json())
        else:
            raise RuntimeError("Document creation failed with status "
                               "{}. The response was: '{}'".format(result.status_code,
                                result.text))
1352758
public static function create(\Jivoo\Store\Document $document, $name = 'request_token')
    {
        if (! isset($document[$name])) {
            $document[$name] = self::generate();
        }
        return new self($document[$name], $name);
    }
417778
public Task<RemoteInsertManyResult> insertMany(final List<? extends DocumentT> documents) {
    return dispatcher.dispatchTask(new Callable<RemoteInsertManyResult>() {
      @Override
      public RemoteInsertManyResult call() {
        return proxy.insertMany(documents);
      }
    });
  }
510607
public void putDocumentInCache(int n, Source source)
  {

    int cachedNode = getNode(source);

    if (DTM.NULL != cachedNode)
    {
      if (!(cachedNode == n))
        throw new RuntimeException(
          "Programmer's Error!  "
          + "putDocumentInCache found reparse of doc: "
          + source.getSystemId());
      return;
    }
    if (null != source.getSystemId())
    {
      m_sourceTree.addElement(new SourceTree(n, source.getSystemId()));
    }
  }
249871
public static String documentToPrettyString(Document document) {
        StringWriter stringWriter = new StringWriter();
        OutputFormat prettyPrintFormat = OutputFormat.createPrettyPrint();
        XMLWriter xmlWriter = new XMLWriter(stringWriter, prettyPrintFormat);

        try {
            xmlWriter.write(document);
        } catch (IOException e) {
            // Ignore, shouldn't happen.
        }

        return stringWriter.toString();
    }
246781
Document createDocument(Entity entity) {
    int maxIndexingDepth = entity.getEntityType().getIndexingDepth();
    XContentBuilder contentBuilder;
    try {
      contentBuilder = XContentFactory.contentBuilder(JSON);
      XContentGenerator generator = contentBuilder.generator();
      generator.writeStartObject();
      createRec(entity, generator, 0, maxIndexingDepth);
      generator.writeEndObject();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    String documentId = toElasticsearchId(entity.getIdValue());
    return Document.create(documentId, contentBuilder);
  }
851855
def update(self, document_id, update_spec, namespace, timestamp):
        
        document = self.doc_dict[document_id].doc
        updated = self.apply_update(document, update_spec)
        if "_id" in updated:
            updated.pop("_id")
        updated[self.unique_key] = document_id
        self.upsert(updated, namespace, timestamp)
        return updated