001/*
002 * (C) Copyright 2006-2014 Nuxeo SA (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 *     Bogdan Stefanescu
018 *     Florent Guillaume
019 */
020package org.nuxeo.ecm.core.api.repository;
021
022import java.util.concurrent.Callable;
023
024import org.nuxeo.common.xmap.annotation.XNode;
025import org.nuxeo.common.xmap.annotation.XObject;
026import org.nuxeo.ecm.core.api.CoreSession;
027
028/**
029 * A high-level repository descriptor, from which you get a {@link CoreSession} when calling {@link #open}.
030 * <p>
031 * This is obsolete as an extension point, use org.nuxeo.ecm.core.storage.sql.RepositoryService instead. Descriptor kept
032 * for backward-compatibility.
033 * <p>
034 * Note that this is still use as an object returned by the core api RepositoryManager.
035 */
036@XObject("repository")
037public class Repository {
038
039    @XNode("@name")
040    private String name;
041
042    @XNode("@label")
043    private String label;
044
045    @XNode("@isDefault")
046    private Boolean isDefault;
047
048    /**
049     * Factory to used to create the low-level repository.
050     */
051    private Callable<Object> repositoryFactory;
052
053    public Repository() {
054    }
055
056    public Repository(String name, String label, Boolean isDefault, Callable<Object> repositoryFactory) {
057        this.name = name;
058        this.label = label;
059        this.isDefault = isDefault;
060        this.repositoryFactory = repositoryFactory;
061    }
062
063    public void setLabel(String label) {
064        this.label = label;
065    }
066
067    public void setDefault(Boolean isDefault) {
068        this.isDefault = isDefault;
069    }
070
071    public String getName() {
072        return name;
073    }
074
075    public String getLabel() {
076        return label;
077    }
078
079    public Boolean getDefault() {
080        return isDefault;
081    }
082
083    public boolean isDefault() {
084        return Boolean.TRUE.equals(isDefault);
085    }
086
087    public Callable<Object> getRepositoryFactory() {
088        return repositoryFactory;
089    }
090
091    @Override
092    public String toString() {
093        return getClass().getSimpleName() + " {name=" + name + ", label=" + label + '}';
094    }
095
096}