Examples of BinaryResource


Examples of org.xmldb.api.modules.BinaryResource

   
    private void storeBinary(final String fileName) throws XMLDBException {
        final File file = new File(fileName);
        if (file.canRead()) {
            final MimeType mime = MimeTable.getInstance().getContentTypeFor(file.getName());
            final BinaryResource resource = (BinaryResource) current.createResource(file.getName(), "BinaryResource");
            resource.setContent(file);
            ((EXistResource)resource).setMimeType(mime == null ? "application/octet-stream" : mime.getName());
            current.storeResource(resource);
        }
    }
View Full Code Here

Examples of org.xmldb.api.modules.BinaryResource

    }

    @Test
    public void updateBinary() throws XMLDBException {
        for (int i = 0; i < REPEAT; i++) {
            BinaryResource binaryResource = (BinaryResource)testCollection.createResource("test1.xml", "BinaryResource");
            binaryResource.setContent(binFile);
            testCollection.storeResource(binaryResource);

            Resource resource = testCollection.getResource("test1.xml");
            assertNotNull(resource);
            System.out.println("Content:\n" + resource.getContent().toString());
View Full Code Here

Examples of org.xmldb.api.modules.BinaryResource

    // with same docname test fails for windows
    @Test
    public void updateBinary_windows() throws XMLDBException {
        for (int i = 0; i < REPEAT; i++) {
            BinaryResource binaryResource = (BinaryResource)testCollection.createResource("test.xml", "BinaryResource");
            binaryResource.setContent(binFile);
            testCollection.storeResource(binaryResource);

            Resource resource = testCollection.getResource("test.xml");
            assertNotNull(resource);
            System.out.println("Content:\n" + resource.getContent().toString());
View Full Code Here

Examples of org.xmldb.api.modules.BinaryResource

        final XMLResource doc = (XMLResource) testCollection.createResource(LOG_NAME, "XMLResource" );
        doc.setContent(EMPTY_LOG);
        testCollection.storeResource(doc);

        final BinaryResource module = (BinaryResource) testCollection.createResource(MODULE_NAME, "BinaryResource" );
        ((EXistResource)module).setMimeType("application/xquery");
        module.setContent(MODULE.getBytes());
        testCollection.storeResource(module);
    }
View Full Code Here

Examples of org.xmldb.api.modules.BinaryResource

    }


    @Test
    public void storeDocument_invalidTriggerForPrepare() throws XMLDBException {
        final BinaryResource invalidModule = (BinaryResource) testCollection.createResource(MODULE_NAME, "BinaryResource" );
        ((EXistResource)invalidModule).setMimeType("application/xquery");
        invalidModule.setContent(INVALID_MODULE.getBytes());
        testCollection.storeResource(invalidModule);

        // configure the Collection with the trigger under test
        final IndexQueryService idxConf = (IndexQueryService)testCollection.getService("IndexQueryService", "1.0");
        idxConf.configureCollection(COLLECTION_CONFIG);
View Full Code Here

Examples of org.xmldb.api.modules.BinaryResource

            if (home != null)
                fLogo = new File(home, "webapp/" + BINARY_RESOURCE_FILENAME);
            else
                fLogo = new File("webapp/" + BINARY_RESOURCE_FILENAME);
            //store the eXist logo in the test collection
      BinaryResource br = (BinaryResource)testCollection.createResource(BINARY_RESOURCE_FILENAME, "BinaryResource");
      br.setContent(fLogo);
      testCollection.storeResource(br);
       
      //create an XML resource with the logo base64 embedded in it
      String queryStore = "xquery version \"1.0\";\n\n"
      + "let $embedded := <logo><image>{util:binary-doc(\"" + TEST_COLLECTION + "/" + BINARY_RESOURCE_FILENAME + "\")}</image></logo> return\n"
View Full Code Here

Examples of org.xmldb.api.modules.BinaryResource

        return collection;
    }

    private void writeModule(Collection collection, String modulename, String module) throws XMLDBException {
        LOG.info("Create module " + modulename);
        BinaryResource res = (BinaryResource) collection.createResource(modulename, "BinaryResource");
        ((EXistResource) res).setMimeType("application/xquery");
        res.setContent(module.getBytes());
        collection.storeResource(res);
        collection.close();
    }
View Full Code Here

Examples of org.xmldb.api.modules.BinaryResource

   
    @BeforeClass
    public static void beforeClass() throws XMLDBException {
  // jetty.port.standalone
        root = DatabaseManager.getCollection("xmldb:exist://localhost:" + System.getProperty("jetty.port") + "/xmlrpc/db", "admin", "");
        BinaryResource res = (BinaryResource)root.createResource(XQUERY_FILENAME, "BinaryResource");
        ((EXistResource) res).setMimeType("application/xquery");
        res.setContent(XQUERY);
        root.storeResource(res);
        UserManagementService ums = (UserManagementService)root.getService("UserManagementService", "1.0");
        ums.chmod(res, 0777);
    }
View Full Code Here

Examples of org.xmldb.api.modules.BinaryResource

        ums.chmod(res, 0777);
    }

    @AfterClass
    public static void afterClass() throws XMLDBException {
        BinaryResource res = (BinaryResource)root.getResource(XQUERY_FILENAME);
        root.removeResource(res);
    }
View Full Code Here

Examples of org.xmldb.api.modules.BinaryResource

    @BeforeClass
    public static void beforeClass() throws XMLDBException {
  // jetty.port.standalone
        root = DatabaseManager.getCollection("xmldb:exist://localhost:" + System.getProperty("jetty.port") + "/xmlrpc/db", "admin", "");
        BinaryResource res = (BinaryResource)root.createResource(XQUERY_FILENAME, "BinaryResource");
        ((EXistResource) res).setMimeType("application/xquery");
        res.setContent(XQUERY);
        root.storeResource(res);
        UserManagementService ums = (UserManagementService)root.getService("UserManagementService", "1.0");
        ums.chmod(res, 0777);
    }
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.