001/* 002 * (C) Copyright 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 * Funsho David 018 * 019 */ 020 021package org.nuxeo.directory.mongodb; 022 023import org.nuxeo.common.xmap.annotation.XNodeList; 024import org.nuxeo.common.xmap.annotation.XObject; 025import org.nuxeo.ecm.directory.BaseDirectoryDescriptor; 026 027/** 028 * @since 9.1 029 */ 030@XObject("directory") 031public class MongoDBDirectoryDescriptor extends BaseDirectoryDescriptor { 032 033 @XNodeList(value = "references/reference", type = MongoDBReferenceDescriptor[].class, componentType = MongoDBReferenceDescriptor.class) 034 public MongoDBReferenceDescriptor[] mongodbReferences; 035 036 public MongoDBReferenceDescriptor[] getMongoDBReferences() { 037 return mongodbReferences; 038 } 039 040 @Override 041 public void merge(BaseDirectoryDescriptor other) { 042 super.merge(other); 043 if (other instanceof MongoDBDirectoryDescriptor) { 044 merge((MongoDBDirectoryDescriptor) other); 045 } 046 } 047 048 protected void merge(MongoDBDirectoryDescriptor other) { 049 if (other.mongodbReferences != null && mongodbReferences.length != 0) { 050 mongodbReferences = other.mongodbReferences; 051 } 052 } 053 054 @Override 055 public MongoDBDirectoryDescriptor clone() { 056 MongoDBDirectoryDescriptor clone = (MongoDBDirectoryDescriptor) super.clone(); 057 if (mongodbReferences != null) { 058 clone.mongodbReferences = new MongoDBReferenceDescriptor[mongodbReferences.length]; 059 for (int i = 0; i < mongodbReferences.length; i++) { 060 clone.mongodbReferences[i] = mongodbReferences[i].clone(); 061 } 062 } 063 return clone; 064 } 065 066 @Override 067 public MongoDBDirectory newDirectory() { 068 return new MongoDBDirectory(this); 069 } 070 071}