Package org.exist.util

Examples of org.exist.util.FileInputSource


    }


    public EXistInputSource getInputSource()
    {
        return( new FileInputSource( descriptor ) );
    }
View Full Code Here


    {
        final File             child = new File( descriptor.getParentFile(), describedItem );
        EXistInputSource is    = null;

        if( child.isFile() && child.canRead() ) {
            is = new FileInputSource( child );
        }

        return( is );
    }
View Full Code Here

            }
   
            tm = db.getTransactionManager();
            txn = tm.beginTransaction();

            FileInputSource is = new FileInputSource(file);
         
            final IndexInfo info = collection.validateXMLResource(txn, broker, uri.lastSegment(), is);
//          info.getDocument().getMetadata().setMimeType(mimeType.getName());
 
          is = new FileInputSource(file);
          collection.store(txn, broker, info, is, false);

            tm.commit(txn);
           
        } catch ( final Exception e ) {
View Full Code Here

            } else {
                //convert BINARY to XML
               
                final File file = broker.getBinaryFile((BinaryDocument) doc);

                FileInputSource is = new FileInputSource(file);
               
                final IndexInfo info = destination.validateXMLResource(txn, broker, newName, is);
                info.getDocument().getMetadata().setMimeType(mimeType.getName());

                is = new FileInputSource(file);
                destination.store(txn, broker, info, is, false);
               
                source.removeBinaryResource(txn, broker, doc);
            }
        } else {
            if (doc.getResourceType() == DocumentImpl.BINARY_FILE) {
              //BINARY to BINARY

              //move to same type as it
                broker.moveResource(txn, doc, destination, newName);
               
            } else {
                //convert XML to BINARY
                // xml file
                final Serializer serializer = broker.getSerializer();
                serializer.setUser(broker.getSubject());
                serializer.setProperties(XML_OUTPUT_PROPERTIES);
               
                File tempFile = null;
                FileInputStream is = null;
        try {
                    tempFile = File.createTempFile("eXist-resource-", ".xml");
                    tempFile.deleteOnExit();
                   
                    final Writer w = new OutputStreamWriter(new FileOutputStream(tempFile), "UTF-8");

                    serializer.serialize(doc, w);
                    w.flush();
                    w.close();
                   
                    is = new FileInputStream(tempFile);
                   
                    final DocumentMetadata meta = doc.getMetadata();
                   
                    final Date created = new Date(meta.getCreated());
                    final Date lastModified = new Date(meta.getLastModified());
   
                    BinaryDocument binary = destination.validateBinaryResource(txn, broker, newName, is, mimeType.getName(), -1, created, lastModified);
                   
                    binary = destination.addBinaryResource(txn, broker, binary, is, mimeType.getName(), -1, created, lastModified);
                   
                    source.removeXMLResource(txn, broker, doc.getFileURI());
                   
                } finally {
                  if (is != null)
                    {is.close();}

                  if (tempFile != null)
                    {tempFile.delete();}
                }
            }
View Full Code Here

      assertEquals(true, testFile.canRead());
     
      broker = pool.get(pool.getSecurityManager().getSystemSubject());
      assertNotNull(broker);
     
      InputSource is = new FileInputSource(testFile);
      transact = pool.getTransactionManager();
      assertNotNull(transact);
      transaction = transact.beginTransaction();
      IndexInfo info = root.validateXMLResource(transaction, broker, XmldbURI.create("test2.xml"), is);
     
View Full Code Here

TOP

Related Classes of org.exist.util.FileInputSource

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.