targetDoc.setLastModified(now); targetDoc.setCreated(now);
DocumentMetadata metadata = new DocumentMetadata(); metadata.setLastModified(now); metadata.setCreated(now); targetDoc.setMetadata(metadata);
	public DocumentImpl storeTemporaryDoc(org.exist.memtree.DocumentImpl doc)     throws EXistException, PermissionDeniedException, LockException {        TransactionManager transact = pool.getTransactionManager();        Txn transaction = transact.beginTransaction();                user = pool.getSecurityManager().getUser(SecurityManager.DBA_USER);		String docName = MD5.md(Thread.currentThread().getName() + Long.toString(System.currentTimeMillis())) +			".xml";		Collection temp = openCollection(TEMP_COLLECTION, Lock.WRITE_LOCK);                try {            if(temp == null)                temp = createTempCollection(transaction);            else                transaction.registerLock(temp.getLock(), Lock.WRITE_LOCK);            DocumentImpl targetDoc = new DocumentImpl(this, temp);            targetDoc.setFileName(docName);            targetDoc.setPermissions(0771);            long now = System.currentTimeMillis();            targetDoc.setLastModified(now);            targetDoc.setCreated(now);            targetDoc.setDocId(getNextDocumentId(transaction, temp));    		DOMIndexer indexer = new DOMIndexer(this, transaction, doc, targetDoc);            indexer.scan();            indexer.store();            temp.addDocument(transaction, this, targetDoc);            storeDocument(transaction, targetDoc);            closeDocument();            flush();            transact.commit(transaction);            return targetDoc;        } catch (Exception e) {            transact.abort(transaction);        }        return null;	}