Package org.xmldb.api.base

Examples of org.xmldb.api.base.Collection.createResource()


        //
        // Create a binary resource, save it in the 'current' collection,
        // then list resources.
        //

        Resource newResource = collection.createResource(null, "BinaryResource");
        newResource.setContent(new byte[] { 0x00, 0x10, 0x01, 0x11 });
        collection.storeResource(newResource);
        String id = newResource.getId();

        String[] resources = collection.listResources();
View Full Code Here


    /*
     * Create a binary resource, save it in the 'current' collection,
     * then remove it and verify that it was indeed removed.
     */

        Resource newResource = collection.createResource(null, "BinaryResource");
        newResource.setContent(new byte[] { 0x00, 0x10, 0x01, 0x11 });
    collection.storeResource(newResource);
    String id = newResource.getId();

    Resource foundResource = collection.getResource(id);
View Full Code Here

    /*
     * Create a binary resource, set / get meta data
     */

        Resource newResource = collection.createResource(null, "BinaryResource");
        newResource.setContent(new byte[] { 0x00, 0x10, 0x01, 0x11 });
    collection.storeResource(newResource);
    String id = newResource.getId();

        MetaService service = (MetaService)collection.getService("MetaService", "1.0");
View Full Code Here

        Collection col = DatabaseManager.getCollection(driver + "/" + path);
        if (col == null) {
            throw new XindiceException("DatabaseManager.getCollection(" + driver + "/" + path + ") returned null");
        }

        XMLResource document = (XMLResource) col.createResource(name, "XMLResource");
        document.setContent(doc);
        col.storeResource(document);
    }

    public int countDocument(String path) throws Exception {
View Full Code Here

    }

    public void testInsertDocumentAsDOM() throws Exception {
        Collection col = this.client.getCollection(TEST_COLLECTION_PATH);

        XMLResource document = (XMLResource) col.createResource("testdoc", "XMLResource");
        document.setContentAsDOM(DOMParser.toDocument(CONTENT));
        col.storeResource(document);
        assertEquals(1, this.client.countDocument(TEST_COLLECTION_PATH));

        String content = this.client.getDocument(TEST_COLLECTION_PATH, "testdoc");
View Full Code Here

                if (o != null) {
                    System.out.println("Object found as db oject, deleting it..");
                    db.deleteObject(o);
                }
                System.out.println("resource is null, create the resource with name " + resourceName);
                resource = (XMLResource) col.createResource(resourceName, XMLResource.RESOURCE_TYPE);
            }
            else {
                System.out.println("deleting resource" + resourceName);
                col.removeResource(resource);
                resource = (XMLResource) col.createResource(resourceName, XMLResource.RESOURCE_TYPE);
View Full Code Here

                resource = (XMLResource) col.createResource(resourceName, XMLResource.RESOURCE_TYPE);
            }
            else {
                System.out.println("deleting resource" + resourceName);
                col.removeResource(resource);
                resource = (XMLResource) col.createResource(resourceName, XMLResource.RESOURCE_TYPE);
            }
            System.out.println("Created resource " + resourceName + " with id " + resource.getId());
            // double check to see if it actually works
            resource = (XMLResource)col.getResource(resourceName);
            System.out.println("Resource found with name " + resource.getId());          
View Full Code Here

   */
  public void insert(Element pElement) throws PMException {
    try {
      Collection col = getXmlDbCollection();
      String id = getId(pElement);
      XMLResource resource = (XMLResource) col.createResource(id, XMLResource.RESOURCE_TYPE);
      ContentHandler ch = resource.setContentAsSAX();
      Marshaller marshaller = getManager().getFactory().createMarshaller();
      marshaller.marshal(pElement, ch);
      col.storeResource(resource);
    } catch (XMLDBException e) {
View Full Code Here

   */
  public void delete(Element pElement) throws PMException {
    try {
     Collection col = getXmlDbCollection();
     String id = getId(pElement);
     XMLResource resource = (XMLResource) col.createResource(id, XMLResource.RESOURCE_TYPE);
     col.removeResource(resource);
   } catch (XMLDBException e) {
     throw new PMException(e);
   } catch (IllegalAccessException e) {
     throw new PMException(e);
View Full Code Here

            if (name.equals("")) {
                name = collection.createId();
                this.url += name;
            }
            Resource resource = collection.createResource(name, "XMLResource");

            resource.setContent(content);
            collection.storeResource(resource);

            getLogger().debug("Written to resource " + name);
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.