Examples of LRepository


Examples of org.lilyproject.repository.api.LRepository

    @Override
    public ByteBuffer create(AvroAuthzContext authzContext, ByteBuffer record, String repositoryName, String tableName)
            throws AvroRepositoryException, AvroInterruptedException {
        try {
            AuthorizationContextHolder.setCurrentContext(converter.convert(authzContext));
            LRepository repository = repositoryManager.getRepository(repositoryName);
            LTable table = repository.getTable(tableName);
            return converter.convert(table.create(converter.convertRecord(record, repository)), repository);
        } catch (RepositoryException e) {
            throw converter.convert(e);
        } catch (InterruptedException e) {
            throw converter.convert(e);
View Full Code Here

Examples of org.lilyproject.repository.api.LRepository

    public ByteBuffer createOrUpdate(AvroAuthzContext authzContext, ByteBuffer record, String repositoryName,
            String tableName, boolean useLatestRecordType)
            throws AvroRepositoryException, AvroInterruptedException {
        try {
            AuthorizationContextHolder.setCurrentContext(converter.convert(authzContext));
            LRepository repository = repositoryManager.getRepository(repositoryName);
            LTable table = repository.getTable(tableName);
            return converter.convert(
                    table.createOrUpdate(converter.convertRecord(record, repository), useLatestRecordType), repository);
        } catch (RepositoryException e) {
            throw converter.convert(e);
        } catch (InterruptedException e) {
View Full Code Here

Examples of org.lilyproject.repository.api.LRepository

    public ByteBuffer delete(AvroAuthzContext authzContext, ByteBuffer recordId, String repositoryName,
            String tableName, List<AvroMutationCondition> conditions, Map<String,String> attributes)
            throws AvroRepositoryException, AvroInterruptedException {
        try {
            AuthorizationContextHolder.setCurrentContext(converter.convert(authzContext));
            LRepository repository = repositoryManager.getRepository(repositoryName);
            LTable table = repository.getTable(tableName);
            RecordId decodedRecordId = converter.convertAvroRecordId(recordId, repository);
            Record record = null;
            if (attributes == null) {
                record = table.delete(decodedRecordId, converter.convertFromAvro(conditions, repository));
            } else if (conditions == null) {
View Full Code Here

Examples of org.lilyproject.repository.api.LRepository

    public ByteBuffer update(AvroAuthzContext authzContext, ByteBuffer record, String repositoryName, String tableName,
            boolean updateVersion, boolean useLatestRecordType, List<AvroMutationCondition> conditions)
            throws AvroRemoteException {
        try {
            AuthorizationContextHolder.setCurrentContext(converter.convert(authzContext));
            LRepository repository = repositoryManager.getRepository(repositoryName);
            LTable table = repository.getTable(tableName);
            return converter.convert(table.update(converter.convertRecord(record, repository), updateVersion,
                    useLatestRecordType, converter.convertFromAvro(conditions, repository)), repository);
        } catch (RepositoryException e) {
            throw converter.convert(e);
        } catch (InterruptedException e) {
View Full Code Here

Examples of org.lilyproject.repository.api.LRepository

    @Override
    public List<String> getVariants(AvroAuthzContext authzContext, ByteBuffer recordId, String repositoryName,
            String tableName) throws AvroRepositoryException, AvroInterruptedException {
        try {
            AuthorizationContextHolder.setCurrentContext(converter.convert(authzContext));
            LRepository repository = repositoryManager.getRepository(repositoryName);
            LTable table = repository.getTable(tableName);
            return converter.convert(table.getVariants(converter.convertAvroRecordId(recordId, repository)));
        } catch (RepositoryException e) {
            throw converter.convert(e);
        } catch (InterruptedException e) {
            throw converter.convert(e);
View Full Code Here

Examples of org.lilyproject.repository.api.LRepository

        if (conditions == null) {
            return null;
        }

        // Multiple repositories: ok to use public repo since only non-repository-specific things are needed
        LRepository repository = repositoryMgr.getDefaultRepository();

        List<MutationCondition> result = new ArrayList<MutationCondition>();
        SystemFields systemFields = SystemFields.getInstance(repository.getTypeManager(), repository.getIdGenerator());

        for (int i = 0; i < conditions.size(); i++) {
            JsonNode conditionNode = conditions.get(i);
            if (!conditionNode.isObject()) {
                throw new JsonFormatException("Each element in the conditions array should be an object.");
            }

            QName fieldName = QNameConverter.fromJson(JsonUtil.getString(conditionNode, "field"), namespaces);

            JsonNode valueNode = conditionNode.get("value");
            Object value = null;
            if (!valueNode.isNull()) {
                FieldType fieldType = systemFields.isSystemField(fieldName) ? systemFields.get(fieldName) :
                        repository.getTypeManager().getFieldTypeByName(fieldName);
                value = RecordReader.INSTANCE.readValue(
                        new RecordReader.ValueHandle(valueNode, "value", fieldType.getValueType()),
                        new RecordReader.ReadContext(repositoryMgr.getDefaultRepository(), namespaces,linkTransformer));
            }
View Full Code Here

Examples of org.lilyproject.repository.api.LRepository

    /**
     * Trying to get a non-existing table should fail.
     */
    @Test(expected = TableNotFoundException.class)
    public void testTableCreationIsRequired() throws Exception {
        LRepository repository = repositoryManager.getDefaultRepository();
        repository.getTable("aNonExistingTable");
    }
View Full Code Here

Examples of org.lilyproject.repository.api.LRepository

                .create();

        List<String> repositories = Lists.newArrayList("company1", "company2", "default");

        for (String repoName : repositories) {
            LRepository repo = repositoryManager.getRepository(repoName);
            repo.getTableManager().createTable("mytable");
            LTable table = repo.getTable("mytable");
            table.recordBuilder()
                    .id("id1")
                    .recordType(recordType1.getName())
                    .field(fieldType1.getName(), repoName + "-value1")
                    .create();
        }

        for (String repoName : repositories) {
            LRepository repo = repositoryManager.getRepository(repoName);
            IdGenerator idGenerator = repo.getIdGenerator();
            LTable table = repo.getTable("mytable");
            assertEquals(repoName + "-value1", table.read(idGenerator.newRecordId("id1")).getField(fieldType1.getName()));
        }
    }
View Full Code Here

Examples of org.lilyproject.repository.api.LRepository

        String repositoryName = "tablemgmttest";
        RepositoryModel repositoryModel = repoSetup.getRepositoryModel();
        repositoryModel.create(repositoryName);
        assertTrue(repositoryModel.waitUntilRepositoryInState(repositoryName, RepositoryDefinition.RepositoryLifecycleState.ACTIVE, 60000L));

        LRepository repository = repositoryManager.getRepository(repositoryName);
        TableManager tableManager = repository.getTableManager();

        List<RepositoryTable> tables = tableManager.getTables();
        assertEquals(1, tables.size());
        assertEquals("record", tables.get(0).getName());

        tableManager.createTable("foo");

        assertEquals(2, tableManager.getTables().size());

        assertTrue(tableManager.tableExists("foo"));

        repository.getTable("foo");

        tableManager.dropTable("foo");

        assertEquals(1, tableManager.getTables().size());
    }
View Full Code Here

Examples of org.lilyproject.repository.api.LRepository

        }
    }
   
    public void processEvent(LilySepEvent event) {

        LRepository repository = null;
        try {
            repository = repositoryManager.getDefaultRepository();
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new RuntimeException(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.