001/* 002 * (C) Copyright 2016-2017 Nuxeo (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Kevin Leturc 018 */ 019package org.nuxeo.ecm.core.storage.marklogic; 020 021import java.util.ArrayList; 022import java.util.List; 023import java.util.stream.Collectors; 024 025import org.nuxeo.common.xmap.annotation.XNode; 026import org.nuxeo.common.xmap.annotation.XNodeList; 027import org.nuxeo.common.xmap.annotation.XObject; 028import org.nuxeo.ecm.core.storage.dbs.DBSRepositoryDescriptor; 029 030/** 031 * MarkLogic Repository Descriptor. 032 * 033 * @since 8.3 034 */ 035@XObject(value = "repository") 036public class MarkLogicRepositoryDescriptor extends DBSRepositoryDescriptor { 037 038 public MarkLogicRepositoryDescriptor() { 039 } 040 041 @XNode("host") 042 public String host; 043 044 @XNode("port") 045 public Integer port; 046 047 @XNode("user") 048 public String user; 049 050 @XNode("password") 051 public String password; 052 053 @XNode("dbname") 054 public String dbname; 055 056 /** 057 * @since 9.2 058 */ 059 @XNode("ssl@enabled") 060 public boolean sslEnabled; 061 062 @XNodeList(value = "range-element-indexes/range-element-index", type = ArrayList.class, componentType = MarkLogicRangeElementIndexDescriptor.class) 063 public List<MarkLogicRangeElementIndexDescriptor> rangeElementIndexes = new ArrayList<>(0); 064 065 @Override 066 public MarkLogicRepositoryDescriptor clone() { 067 MarkLogicRepositoryDescriptor clone = (MarkLogicRepositoryDescriptor) super.clone(); 068 clone.rangeElementIndexes = rangeElementIndexes.stream().map(MarkLogicRangeElementIndexDescriptor::new).collect( 069 Collectors.toList()); 070 return clone; 071 } 072 073 public void merge(MarkLogicRepositoryDescriptor other) { 074 super.merge(other); 075 if (other.host != null) { 076 host = other.host; 077 } 078 if (other.port != null) { 079 port = other.port; 080 } 081 if (other.password != null) { 082 password = other.password; 083 } 084 if (other.dbname != null) { 085 dbname = other.dbname; 086 } 087 for (MarkLogicRangeElementIndexDescriptor regi : other.rangeElementIndexes) { 088 rangeElementIndexes.add(new MarkLogicRangeElementIndexDescriptor(regi)); 089 } 090 } 091 092}