Package org.apache.xindice.core.meta

Examples of org.apache.xindice.core.meta.MetaData


            }
            params.put(RPCDefaultMessage.COMPRESSED, "true");

            Object result = runRemoteCommand(id == null ? "GetCollectionMeta" : "GetDocumentMeta", params);
            Document metaDoc = DOMParser.toDocument(result.toString());
            MetaData meta = new MetaData(id);
            meta.streamFromXML(metaDoc.getDocumentElement(), true);
            return meta;
        } catch (Exception e) {
            throw FaultCodes.createXMLDBException(e);
        }
    }
View Full Code Here


        Hashtable result = new Hashtable();
        if (!col.isMetaEnabled()) {
            // meta information is not enabled !
            throw new Exception(MISSING_META_CONFIGURATION);
        }
        MetaData meta = col.getCollectionMeta();
        Document doc = new DocumentImpl();
        doc.appendChild(meta.streamToXML(doc, true));

        result.put(RESULT, TextWriter.toString(doc));
        return result;
    }
View Full Code Here

        if (!message.containsKey(NAME)) {
            throw new Exception(MISSING_NAME_PARAM);
        }
        String docname = (String) message.get(NAME);
        MetaData meta = col.getDocumentMeta(docname);
        Document doc = new DocumentImpl();
        doc.appendChild(meta.streamToXML(doc, true));

        result.put(RESULT, TextWriter.toString(doc));
        return result;
    }
View Full Code Here

        // Get meta service
        Collection col = this.client.getCollection(TEST_COLLECTION_PATH);
        MetaService service = (MetaService) col.getService("MetaService", "1.0");

        // Get meta data
        MetaData data = service.getMetaData();
        assertNotNull("MetaData is not found for the collection!", data);
        assertTrue("Creation time is 0!", data.getCreatedTime() != 0);
        assertTrue("Modification time is 0!", data.getLastModifiedTime() != 0);
        long created0 = data.getCreatedTime();
        long modified0 = data.getLastModifiedTime();

        // Sleep and get it again
        Thread.sleep(150);
        data = service.getMetaData();
        long created1 = data.getCreatedTime();
        long modified1 = data.getLastModifiedTime();
        assertEquals("Creation time changed on 2nd get (diff: "+ (created1 - created0) +")!", created0, created1);
        assertEquals("Modification time changed on 2nd get (diff: "+ (modified1 - modified0) +")!", modified0, modified1);

        // Sleep, add new document, and get metadata again
        Thread.sleep(150);
        this.client.insertDocument(TEST_COLLECTION_PATH, DOCUMENT_ID2, DOCUMENT2);

        data = service.getMetaData();
        assertNotNull("MetaData is not found for the collection after update!", data);
        long created2 = data.getCreatedTime();
        long modified2 = data.getLastModifiedTime();
        assertEquals("Creation time changed on update (diff: "+ (created2 - created1) +")!", created1, created2);
        assertTrue("Modification time has not changed on update!", modified1 != modified2);
    }
View Full Code Here

        // Get meta service
        Collection col = this.client.getCollection(TEST_COLLECTION_PATH);
        MetaService service = (MetaService) col.getService("MetaService", "1.0");

        // Get meta data
        MetaData data = service.getMetaData(DOCUMENT_ID1);
        assertNotNull("MetaData is not found for document " + DOCUMENT_ID1 + "!", data);
        assertTrue("Creation time is 0!", data.getCreatedTime() != 0);
        assertTrue("Modification time is 0!", data.getLastModifiedTime() != 0);
        long created0 = data.getCreatedTime();
        long modified0 = data.getLastModifiedTime();

        // Sleep and get it again
        Thread.sleep(150);
        data = service.getMetaData(DOCUMENT_ID1);
        long created1 = data.getCreatedTime();
        long modified1 = data.getLastModifiedTime();
        assertEquals("Creation time changed on 2nd get (diff: "+ (created1 - created0) +")!", created0, created1);
        assertEquals("Modification time changed on 2nd get (diff: "+ (modified1 - modified0) +")!", modified0, modified1);

        // Sleep and update the document and get data again
        Thread.sleep(150);
        this.client.updateDocument(TEST_COLLECTION_PATH, DOCUMENT_ID1, DOCUMENT2);

        data = service.getMetaData(DOCUMENT_ID1);
        assertNotNull("MetaData is not found for document " + DOCUMENT_ID1 + " after update!", data);
        long created2 = data.getCreatedTime();
        long modified2 = data.getLastModifiedTime();
        assertEquals("Creation time changed on update (diff: "+ (created2 - created1) +")!", created1, created2);
        assertTrue("Modification time has not changed on update!", modified1 != modified2);
    }
View Full Code Here

        // Get meta service
        Collection col = this.client.getCollection(TEST_COLLECTION_PATH);
        MetaService service = (MetaService) col.getService("MetaService", "1.0");

        // Get meta data
        MetaData data = service.getMetaData();
        long created0 = data.getCreatedTime();
        long modified0 = data.getLastModifiedTime();

        // Sleep and set metadata
        Thread.sleep(150);
        data.setContext(created0 - 500, modified0 - 500);
        service.setMetaData(data);

        // Get metadata again
        data = service.getMetaData();
        long created1 = data.getCreatedTime();
        long modified1 = data.getLastModifiedTime();
        assertEquals("Creation time changed on set (diff: "+ (created1 - created0) +")!", created0, created1);
        assertEquals("Modification time changed on set (diff: "+ (modified1 - modified0) +")!", modified0, modified1);
    }
View Full Code Here

        // Get meta service
        Collection col = this.client.getCollection(TEST_COLLECTION_PATH);
        MetaService service = (MetaService) col.getService("MetaService", "1.0");

        // Get meta data
        MetaData data = service.getMetaData(DOCUMENT_ID1);
        long created0 = data.getCreatedTime();
        long modified0 = data.getLastModifiedTime();

        // Sleep and set metadata
        Thread.sleep(150);
        data.setContext(created0 - 500, modified0 - 500);
        service.setMetaData(DOCUMENT_ID1, data);

        // Get metadata again
        data = service.getMetaData(DOCUMENT_ID1);
        long created1 = data.getCreatedTime();
        long modified1 = data.getLastModifiedTime();
        assertEquals("Creation time changed on set (diff: "+ (created1 - created0) +")!", created0, created1);
        assertEquals("Modification time changed on set (diff: "+ (modified1 - modified0) +")!", modified0, modified1);
    }
View Full Code Here

        Collection col = this.client.getCollection(TEST_COLLECTION_PATH);
        MetaService service = (MetaService) col.getService("MetaService", "1.0");

        // Get meta data
        String value0 = "MetaAttributeValue" + System.currentTimeMillis();
        MetaData data = service.getMetaData();
        data.setAttribute(ATTRIBUTE_ID, value0);
        service.setMetaData(data);

        // Get metadata again
        data = service.getMetaData();
        String value1 = (String)data.getAttribute(ATTRIBUTE_ID);
        assertEquals("Attribute value does not match!", value0, value1);
    }
View Full Code Here

        Collection col = this.client.getCollection(TEST_COLLECTION_PATH);
        MetaService service = (MetaService) col.getService("MetaService", "1.0");

        // Get meta data
        String value0 = "MetaAttributeValue" + System.currentTimeMillis();
        MetaData data = service.getMetaData(DOCUMENT_ID1);
        data.setAttribute(ATTRIBUTE_ID, value0);
        service.setMetaData(DOCUMENT_ID1, data);

        // Get metadata again
        data = service.getMetaData(DOCUMENT_ID1);
        String value1 = (String)data.getAttribute(ATTRIBUTE_ID);
        assertEquals("Attribute value does not match!", value0, value1);
    }
View Full Code Here

     */
    public MetaData getCollectionMeta(Collection collection) throws DBException {
        Collection mcol = getMetaCollection(collection, true);

        if (null != mcol) {
            MetaData meta = (MetaData) mcol.getObject(COLLECTION_META_DATA);
            if (meta == null) {
                meta = new MetaData();
            }

            if (meta.getType() == MetaData.UNKNOWN) {
                meta.setType(MetaData.COLLECTION);
            }
            meta.setOwner(collection.getCanonicalName());
            meta.setDirty(false);
            return meta;
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.apache.xindice.core.meta.MetaData

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.