Examples of DataRecord


Examples of org.apache.jackrabbit.core.data.DataRecord

    protected void doDeleteAllOlderThan() throws Exception {
        CachingDataStore ds = createDataStore();
        Random random = new Random(12345);
        byte[] data = new byte[12345];
        random.nextBytes(data);
        DataRecord rec1 = ds.addRecord(new ByteArrayInputStream(data));

        data = new byte[12345];
        random.nextBytes(data);
        DataRecord rec2 = ds.addRecord(new ByteArrayInputStream(data));
       
        Thread.sleep(2000);
        long updateTime = System.currentTimeMillis();
        ds.updateModifiedDateOnAccess(updateTime);

        data = new byte[12345];
        random.nextBytes(data);
        DataRecord rec3 = ds.addRecord(new ByteArrayInputStream(data));

        data = new byte[12345];
        random.nextBytes(data);
        DataRecord rec4 = ds.addRecord(new ByteArrayInputStream(data));

        rec1 = ds.getRecord(rec1.getIdentifier());
        ds.clearInUse();
        assertEquals("only rec2 should be deleted", 1,
            ds.deleteAllOlderThan(updateTime));
        assertNull("rec2 should be null",
            ds.getRecordIfStored(rec2.getIdentifier()));

        Iterator<DataIdentifier> itr = ds.getAllIdentifiers();
        List<DataIdentifier> list = new ArrayList<DataIdentifier>();
        list.add(rec1.getIdentifier());
        list.add(rec3.getIdentifier());
        list.add(rec4.getIdentifier());
        while (itr.hasNext()) {
            assertTrue("record found on list", list.remove(itr.next()));
        }

        assertEquals("touched records found", 0, list.size());
        assertEquals("rec1 touched", true,
            ds.getLastModified(rec1.getIdentifier()) > updateTime);
        assertEquals("rec3 touched", true,
            ds.getLastModified(rec3.getIdentifier()) > updateTime);
        assertEquals("rec4 touched", true,
            ds.getLastModified(rec4.getIdentifier()) > updateTime);
        ds.close();

    }
View Full Code Here

Examples of org.fieldapi.DataRecord

    @Override
    public DataRecord getLatestDataRecordForChannel(ObjectType objectType, String channelUri)
    {
        // Create invalid data record.
        DataRecord dataRecord = new DataRecord();

        // We need a working REST client.
        if (!isClientReady())
            return dataRecord;

        try
        {
            // Call the REST Webservice method GET on the resource "<objectType>/<objectUri>".
            //
            // The request message body is empty, the response message body should contain a data record encoded in
            // JSON as follows:
            //
            // {
            //   "value" : <value as float>,
            //   "timestamp" : <timestamp as epoch in ms>,
            //   "quality" : "<quality>"
            // }
            //
            // The quality quantifier must be one of the enums Quality's enumerators string representations.
            //
            // A status of 200 is considered as success, all other values are considered as error or the fact that
            // there is no data record.
            //
            Response response = client.target(baseUrl).path(objectType.toString()).path(channelUri).request()
                                      .accept(MediaType.APPLICATION_JSON_TYPE).get();

            // Status needs to be 200.
            if (!isStatusEqualTo(response, 200))
                return dataRecord;

            // Content type needs to be application/json.
            if (!isContentTypeEqualTo(response, "application/json"))
                return dataRecord;

            // Read the data record object and if it did not worked, create a defaul data record to return.
            dataRecord = response.readEntity(DataRecord.class);
            if (dataRecord == null)
                dataRecord = new DataRecord();

            // Finally return the data record.
            return dataRecord;
        }
        catch (Exception e)
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.