RepositoryDescriptor { public void merge(RepositoryDescriptor other) { if (other.name != null) { name = other.name; } if (other.label != null) { label = other.label; } if (other.isDefault != null) { isDefault = other.isDefault; } if (other.repositoryFactoryClass != null) { repositoryFactoryClass = other.repositoryFactoryClass; } if (other.pool != null) { pool = new NuxeoConnectionManagerConfiguration(other.pool); } if (other.backendClass != null) { backendClass = other.backendClass; } if (other.cachingMapperClass != null) { cachingMapperClass = other.cachingMapperClass; } if (other.cachingMapperEnabled != null) { cachingMapperEnabled = other.cachingMapperEnabled; } cachingMapperProperties.putAll(other.cachingMapperProperties); if (other.noDDL != null) { noDDL = other.noDDL; } sqlInitFiles.addAll(other.sqlInitFiles); if (other.softDeleteEnabled != null) { softDeleteEnabled = other.softDeleteEnabled; } if (other.proxiesEnabled != null) { proxiesEnabled = other.proxiesEnabled; } if (other.idType != null) { idType = other.idType; } if (other.clusteringEnabled != null) { clusteringEnabled = other.clusteringEnabled; } if (other.clusteringDelay != null) { clusteringDelay = other.clusteringDelay; } for (FieldDescriptor of : other.schemaFields) { boolean append = true; for (FieldDescriptor f : schemaFields) { if (f.field.equals(of.field)) { f.merge(of); append = false; break; } } if (append) { schemaFields.add(of); } } if (other.arrayColumns != null) { arrayColumns = other.arrayColumns; } if (other.fulltextDisabled != null) { fulltextDisabled = other.fulltextDisabled; } if (other.fulltextAnalyzer != null) { fulltextAnalyzer = other.fulltextAnalyzer; } if (other.fulltextParser != null) { fulltextParser = other.fulltextParser; } if (other.fulltextCatalog != null) { fulltextCatalog = other.fulltextCatalog; } for (FulltextIndexDescriptor oi : other.fulltextIndexes) { boolean append = true; for (FulltextIndexDescriptor i : fulltextIndexes) { if (ObjectUtils.equals(i.name, oi.name)) { i.merge(oi); append = false; break; } } if (append) { fulltextIndexes.add(oi); } } fulltextExcludedTypes.addAll(other.fulltextExcludedTypes); fulltextIncludedTypes.addAll(other.fulltextIncludedTypes); neverPerInstanceMixins.addAll(other.neverPerInstanceMixins); if (other.pathOptimizationsEnabled != null) { pathOptimizationsEnabled = other.pathOptimizationsEnabled; } if (other.pathOptimizationsVersion != null) { pathOptimizationsVersion = other.pathOptimizationsVersion; } if (other.aclOptimizationsEnabled != null) { aclOptimizationsEnabled = other.aclOptimizationsEnabled; } if (other.readAclMaxSize != null) { readAclMaxSize = other.readAclMaxSize; } if (other.binaryManagerClass != null) { binaryManagerClass = other.binaryManagerClass; } if (other.binaryManagerKey != null) { binaryManagerKey = other.binaryManagerKey; } if (other.binaryStorePath != null) { binaryStorePath = other.binaryStorePath; } sendInvalidationEvents = other.sendInvalidationEvents; if (other.usersSeparatorKey != null) { usersSeparatorKey = other.usersSeparatorKey; } if (other.xaDataSourceName != null) { xaDataSourceName = other.xaDataSourceName; } properties.putAll(other.properties); } RepositoryDescriptor();  RepositoryDescriptor(RepositoryDescriptor other); @XNode("@name") void setName(String name); Boolean isDefault(); Class<? extends RepositoryFactory> getRepositoryFactoryClass(); void setRepositoryFactoryClass(Class<? extends RepositoryFactory> klass); @XNode("pool") void setPool(NuxeoConnectionManagerConfiguration pool); boolean getCachingMapperEnabled(); boolean getNoDDL(); boolean getSoftDeleteEnabled(); boolean getProxiesEnabled(); boolean getClusteringEnabled(); long getClusteringDelay(); boolean getArrayColumns(); void setArrayColumns(boolean enabled); boolean getFulltextDisabled(); void setFulltextDisabled(boolean disabled); @XNode("indexing/queryMaker@class") void setQueryMakerDeprecated(String klass); boolean getPathOptimizationsEnabled(); int getPathOptimizationsVersion(); boolean getAclOptimizationsEnabled(); int getReadAclMaxSize(); void merge(RepositoryDescriptor other); static final int DEFAULT_READ_ACL_MAX_SIZE; static final int DEFAULT_PATH_OPTIM_VERSION; public String name; @XNode("@label")
    public String label; @XNode("repository")
    public RepositoryDescriptor repositoryDescriptor; public NuxeoConnectionManagerConfiguration pool; @XNode("backendClass")
    public Class<? extends RepositoryBackend> backendClass; @XNode("cachingMapper@class")
    public Class<? extends CachingMapper> cachingMapperClass; @XNodeMap(value = "cachingMapper/property", key = "@name", type = HashMap.class, componentType = String.class)
    public Map<String, String> cachingMapperProperties; @XNodeList(value = "sqlInitFile", type = ArrayList.class, componentType = String.class)
    public List<String> sqlInitFiles; @XNode("idType")
    public String idType; @XNodeList(value = "schema/field", type = ArrayList.class, componentType = FieldDescriptor.class)
    public List<FieldDescriptor> schemaFields; @XNode("indexing/fulltext@analyzer")
    public String fulltextAnalyzer; @XNode("indexing/fulltext@parser")
    public String fulltextParser; @XNode("indexing/fulltext@catalog")
    public String fulltextCatalog; @XNodeList(value = "indexing/fulltext/index", type = ArrayList.class, componentType = FulltextIndexDescriptor.class)
    public List<FulltextIndexDescriptor> fulltextIndexes; @XNodeList(value = "indexing/excludedTypes/type", type =  HashSet.class, componentType = String.class)
    public Set<String> fulltextExcludedTypes; @XNodeList(value = "indexing/includedTypes/type", type =  HashSet.class, componentType = String.class)
    public Set<String> fulltextIncludedTypes; @XNodeList(value = "indexing/neverPerDocumentFacets/facet", type = HashSet.class, componentType = String.class)
    public Set<String> neverPerInstanceMixins; @XNode("binaryManager@class")
    public Class<? extends BinaryManager> binaryManagerClass; @XNode("binaryManager@key")
    public String binaryManagerKey; @XNode("binaryStore@path")
    public String binaryStorePath; @XNode("@sendInvalidationEvents")
    public boolean sendInvalidationEvents; @XNode("usersSeparator@key")
    public String usersSeparatorKey; @XNode("xa-datasource")
    public String xaDataSourceName; @XNodeMap(value = "property", key = "@name", type = HashMap.class, componentType = String.class)
    public Map<String, String> properties; }
@Test public void testMerge() throws Exception { RepositoryDescriptor desc2 = (RepositoryDescriptor) xmap.load(getResource("test-repository-descriptor2.xml")); desc.merge(desc2); assertEquals("/foo/bar2", desc.binaryStorePath); assertFalse(desc.getClusteringEnabled()); assertEquals(Arrays.asList("file1", "file2", "file3"), desc.sqlInitFiles); assertTrue(desc.getPathOptimizationsEnabled()); assertEquals(2, desc.getPathOptimizationsVersion()); assertNotNull(desc.schemaFields); assertEquals(4, desc.schemaFields.size()); FieldDescriptor fd; fd = desc.schemaFields.get(0); assertEquals("my:bignote", fd.field); assertEquals("other", fd.type); fd = desc.schemaFields.get(1); assertEquals("foo", fd.field); assertEquals("xyz", fd.type); fd = desc.schemaFields.get(2); assertEquals("bar", fd.field); assertEquals("bartype2", fd.type); assertEquals("bartable2", fd.table); assertEquals("barcol2", fd.column); fd = desc.schemaFields.get(3); assertEquals("def", fd.field); assertEquals("abc", fd.type); assertEquals("english", desc.fulltextAnalyzer); assertEquals("nuxeo", desc.fulltextCatalog); assertEquals(5, desc.fulltextIndexes.size()); FulltextIndexDescriptor fti; fti = desc.fulltextIndexes.get(0); assertNull(fti.name); assertNull(fti.fieldType); assertEquals(new HashSet<String>(), fti.fields); assertEquals(Collections.singleton("dc:creator"), fti.excludeFields); fti = desc.fulltextIndexes.get(1); assertEquals("titraille", fti.name); assertNull(fti.fieldType); assertEquals( new HashSet<String>(Arrays.asList("dc:title", "dc:description", "my:desc")), fti.fields); assertEquals(new HashSet<String>(), fti.excludeFields); fti = desc.fulltextIndexes.get(2); assertEquals("blobs", fti.name); assertEquals("blob", fti.fieldType); assertEquals(new HashSet<String>(), fti.fields); assertEquals(Collections.singleton("foo:bar"), fti.excludeFields); fti = desc.fulltextIndexes.get(3); assertEquals("pictures", fti.name); assertNull(fti.fieldType); assertEquals(Collections.singleton("picture:views/*/filename"), fti.fields); assertEquals(new HashSet<String>(), fti.excludeFields); assertEquals("venusian", fti.analyzer); assertEquals("other", fti.catalog); fti = desc.fulltextIndexes.get(4); assertEquals("other", fti.name); assertNull(fti.fieldType); assertEquals(Collections.singleton("my:other"), fti.fields); assertEquals(new HashSet<String>(), fti.excludeFields); assertEquals( new HashSet<String>(Arrays.asList("Folder", "Workspace", "OtherExcluded")), desc.fulltextExcludedTypes); assertEquals( new HashSet<String>(Arrays.asList("Note", "File", "OtherIncluded")), desc.fulltextIncludedTypes); }