001/*
002 * (C) Copyright 2006-2018 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 *     Thomas Roger <troger@nuxeo.com>
018 */
019
020package org.nuxeo.ecm.multi.tenant;
021
022import static org.nuxeo.ecm.core.api.security.SecurityConstants.EVERYONE;
023
024import java.util.ArrayList;
025import java.util.Arrays;
026import java.util.List;
027
028import org.apache.commons.lang3.builder.EqualsBuilder;
029import org.apache.commons.lang3.builder.HashCodeBuilder;
030import org.apache.commons.lang3.builder.ToStringBuilder;
031import org.nuxeo.common.xmap.annotation.XNode;
032import org.nuxeo.common.xmap.annotation.XNodeList;
033import org.nuxeo.common.xmap.annotation.XObject;
034import org.nuxeo.ecm.core.api.security.SecurityConstants;
035
036/**
037 * @author <a href="mailto:troger@nuxeo.com">Thomas Roger</a>
038 * @since 5.6
039 */
040@XObject("configuration")
041public class MultiTenantConfiguration {
042
043    @XNode("tenantDocumentType")
044    protected String tenantDocumentType;
045
046    @XNode("membersGroupPermission")
047    protected String membersGroupPermission = SecurityConstants.READ;
048
049    @XNode("enabledByDefault")
050    protected boolean enabledByDefault = false;
051
052    @XNodeList(value = "prohibitedGroups/group", type = ArrayList.class, componentType = String.class)
053    private List<String> prohibitedGroups = new ArrayList<>(Arrays.asList("members", EVERYONE));
054
055    public String getTenantDocumentType() {
056        return tenantDocumentType;
057    }
058
059    public String getMembersGroupPermission() {
060        return membersGroupPermission;
061    }
062
063    public boolean isEnabledByDefault() {
064        return enabledByDefault;
065    }
066
067    @Override
068    public int hashCode() {
069        return HashCodeBuilder.reflectionHashCode(this);
070    }
071
072    @Override
073    public boolean equals(Object obj) {
074        return EqualsBuilder.reflectionEquals(this, obj);
075    }
076
077    @Override
078    public String toString() {
079        return ToStringBuilder.reflectionToString(this);
080    }
081
082    public List<String> getProhibitedGroups() {
083        return prohibitedGroups;
084    }
085
086}