Package org.infinispan.schematic.document

Examples of org.infinispan.schematic.document.Document


                                                  chunkSize);
            } else if (type.equalsIgnoreCase("composite")) {

                Map<String, BinaryStore> binaryStores = new LinkedHashMap<String, BinaryStore>();

                Document binaryStoresConfiguration = binaryStorage.getDocument(FieldName.COMPOSITE_STORE_NAMED_BINARY_STORES);

                for (String sourceName : binaryStoresConfiguration.keySet()) {
                    Document binaryStoreConfig = binaryStoresConfiguration.getDocument(sourceName);
                    binaryStores.put(sourceName, new BinaryStorage(binaryStoreConfig).getBinaryStore());
                }

                // must have at least one named store
                if (binaryStores.isEmpty()) {
View Full Code Here


    }

    @FixFor( "MODE-1988" )
    @Test
    public void shouldEnableDocumentOptimizationWithValidChildCountTargetAndToleranceValues() {
        Document docOpt = Schematic.newDocument(FieldName.OPTIMIZATION_CHILD_COUNT_TARGET, 500,
                                                FieldName.OPTIMIZATION_CHILD_COUNT_TOLERANCE, 10);
        Document doc = Schematic.newDocument(FieldName.NAME, "repoName", FieldName.STORAGE,
                                             Schematic.newDocument(FieldName.DOCUMENT_OPTIMIZATION, docOpt));
        RepositoryConfiguration config = new RepositoryConfiguration(doc, "repoName");
        DocumentOptimization opt = config.getDocumentOptimization();
        assertThat(opt, is(notNullValue()));
        assertThat(opt.isEnabled(), is(true));
View Full Code Here

    }

    @FixFor( "MODE-1988" )
    @Test
    public void shouldDisableDocumentOptimizationWithoutValidChildCountTargetValue() {
        Document docOpt = Schematic.newDocument(FieldName.OPTIMIZATION_CHILD_COUNT_TOLERANCE, 10);
        Document doc = Schematic.newDocument(FieldName.NAME, "repoName", FieldName.STORAGE,
                                             Schematic.newDocument(FieldName.DOCUMENT_OPTIMIZATION, docOpt));
        RepositoryConfiguration config = new RepositoryConfiguration(doc, "repoName");
        DocumentOptimization opt = config.getDocumentOptimization();
        assertThat(opt, is(notNullValue()));
        assertThat(opt.isEnabled(), is(false));
View Full Code Here

            if (isIncludedInCustomProviders(JaasProvider.class.getName())) {
                // It's in the custom provider, so don't expose it.
                // (this enables easily turning off JAAS without setting a blank policy name) ...
                return null;
            }
            Document jaas = security.getDocument(FieldName.JAAS);
            return jaas != null ? new JaasSecurity(jaas) : null;
        }
View Full Code Here

         * Get the configuration information for the anonymous authentication provider.
         *
         * @return the anonymous provider configuration information; null if anonymous users are not allowed
         */
        public AnonymousSecurity getAnonymous() {
            Document anonymous = security.getDocument(FieldName.ANONYMOUS);
            if (anonymous != null && anonymous.size() == 1) {
                // Check the 'roleNames' field ...
                List<?> roles = anonymous.getArray(FieldName.ANONYMOUS_ROLES);
                if (roles != null && roles.isEmpty()) {
                    // Specified empty roles, so this is disabling anonymous logins ...
                    return null;
                }
            }
View Full Code Here

            return indexes == null ? null : indexes.getDocument(name);
        }

        public IndexDefinition getIndex( final String name ) {
            if (name == null) return null;
            final Document doc = getRawIndex(name);
            if (doc == null) return null;
            return new IndexDefinition() {
                private List<IndexColumnDefinition> columns;
                private Map<String, Object> properties;

                @Override
                public String getName() {
                    return name;
                }

                @Override
                public String getProviderName() {
                    return doc.getString(FieldName.PROVIDER_NAME);
                }

                @Override
                public String getDescription() {
                    return doc.getString(FieldName.DESCRIPTION);
                }

                @Override
                public IndexKind getKind() {
                    String kindStr = doc.getString(FieldName.KIND, Default.KIND);
                    if (FieldValue.KIND_VALUE.equalsIgnoreCase(kindStr)) {
                        return IndexKind.VALUE;
                    }
                    if (FieldValue.KIND_UNIQUE.equalsIgnoreCase(kindStr)) {
                        return IndexKind.UNIQUE_VALUE;
                    }
                    if (FieldValue.KIND_ENUMERATED.equalsIgnoreCase(kindStr)) {
                        return IndexKind.ENUMERATED_VALUE;
                    }
                    if (FieldValue.KIND_TEXT.equalsIgnoreCase(kindStr)) {
                        return IndexKind.TEXT;
                    }
                    if (FieldValue.KIND_NODE_TYPE.equalsIgnoreCase(kindStr)) {
                        return IndexKind.NODE_TYPE;
                    }
                    return IndexKind.VALUE;
                }

                @Override
                public String getNodeTypeName() {
                    return doc.getString(FieldName.NODE_TYPE, Default.NODE_TYPE);
                }

                @Override
                public WorkspaceMatchRule getWorkspaceMatchRule() {
                    String rule = doc.getString(FieldName.WORKSPACES, Default.WORKSPACES);
                    return RepositoryIndexDefinition.workspaceMatchRule(rule);
                }

                @Override
                public boolean isSynchronous() {
                    return doc.getBoolean(FieldName.SYNCHRONOUS, Default.SYNCHRONOUS);
                }

                @Override
                public boolean isEnabled() {
                    return true;
                }

                @Override
                public int size() {
                    return columns().size();
                }

                @Override
                public boolean appliesToProperty( String propertyName ) {
                    for (IndexColumnDefinition defn : columns()) {
                        if (defn.getPropertyName().equals(propertyName)) return true;
                    }
                    return false;
                }

                @Override
                public IndexColumnDefinition getColumnDefinition( int position ) throws NoSuchElementException {
                    return columns().get(position);
                }

                @Override
                public boolean hasSingleColumn() {
                    return size() == 1;
                }

                @Override
                public Iterator<IndexColumnDefinition> iterator() {
                    return columns.iterator();
                }

                @Override
                public Object getIndexProperty( String propertyName ) {
                    return doc.get(name);
                }

                @Override
                public Map<String, Object> getIndexProperties() {
                    if (properties == null) {
                        // Read in the properties ...
                        properties = new HashMap<>();
                        for (Field field : doc.fields()) {
                            if (INDEX_PROVIDER_FIELDS.contains(field.getName())) continue;
                            properties.put(field.getName(), field.getValue());
                        }
                    }
                    return properties;
                }

                protected List<IndexColumnDefinition> columns() {
                    if (columns == null) {
                        columns = new ArrayList<>();
                        String columnDefnsStr = doc.getString(FieldName.COLUMNS);
                        if (columnDefnsStr != null) {
                            for (String columnDefn : columnDefnsStr.split(",")) {
                                if (columnDefn.trim().length() == 0) continue;
                                try {
                                    Matcher matcher = COLUMN_DEFN_PATTERN.matcher(columnDefn);
View Full Code Here

        return literal;
    }

    @Override
    public SchematicEntry put( Document entryDocument ) {
        Document metadata = entryDocument.getDocument(FieldName.METADATA);
        Object content = entryDocument.get(FieldName.CONTENT);
        if (metadata == null || content == null) {
            throw new IllegalArgumentException("The supplied document is not of the required format");
        }
        String key = metadata.getString(FieldName.ID);
        if (key == null) {
            throw new IllegalArgumentException("The supplied document is not of the required format");
        }
        SchematicEntry newEntry = null;
        if (content instanceof Document) {
View Full Code Here

        assert this.value != null;
    }

    public SchematicEntryLiteral( String key,
                                  Document content ) {
        Document metadata = new BasicDocument(FieldName.ID, key);
        value = new BasicDocument(FieldName.METADATA, metadata, FieldName.CONTENT, unwrap(content));
    }
View Full Code Here

    protected void setMetadata( Document metadata ) {
        if (metadata != null) {
            if (metadata instanceof EditableDocument) metadata = ((EditableDocument)metadata).unwrap();

            // Copy all the metadata into the entry's metadata ...
            Document existingMetadata = getMetadata();
            MutableDocument newMetadata = new BasicDocument(metadata.size() + 1);
            newMetadata.put(FieldName.ID, existingMetadata.get(FieldName.ID));
            for (Field field : metadata.fields()) {
                String fieldName = field.getName();
                if (fieldName.equals(FieldName.ID)) continue;
                newMetadata.put(fieldName, field.getValue());
            }
View Full Code Here

        // Now apply all of the conversions for the nested documents,
        // getting the results and storing them in the 'changedFields' ...
        for (Map.Entry<String, LinkedList<Conversion>> entry : nextLevelConversionsBySegment.entrySet()) {
            String segment = entry.getKey();
            LinkedList<Conversion> nestedConversions = entry.getValue();
            Document nested = original.getDocument(segment);
            Document newDoc = convertValuesWithMismatchedTypes(nested, nextLevel, nestedConversions);
            changedFields.put(segment, newDoc);
        }

        // Now create a copy of the original document but with the changed fields ...
        return original.with(changedFields);
View Full Code Here

TOP

Related Classes of org.infinispan.schematic.document.Document

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.