001/*
002 * (C) Copyright 2006-2007 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 *     Nuxeo - initial API and implementation
018 *
019 * $Id$
020 */
021
022package org.nuxeo.ecm.platform.filemanager.service.extension;
023
024import java.util.ArrayList;
025import java.util.List;
026
027import org.nuxeo.common.xmap.annotation.XNode;
028import org.nuxeo.common.xmap.annotation.XNodeList;
029import org.nuxeo.common.xmap.annotation.XObject;
030import org.nuxeo.runtime.model.Descriptor;
031
032@XObject("unicitySettings")
033public class UnicityExtension implements Descriptor {
034
035    public static final List<String> DEFAULT_FIELDS = new ArrayList<>();
036
037    @XNode("algo")
038    protected String algo;
039
040    @XNode("enabled")
041    protected Boolean enabled;
042
043    @XNode("computeDigest")
044    protected Boolean computeDigest = Boolean.FALSE;
045
046    @XNodeList(value = "field", type = ArrayList.class, componentType = String.class)
047    protected List<String> fields = DEFAULT_FIELDS;
048
049    public String getAlgo() {
050        return algo;
051    }
052
053    public Boolean getEnabled() {
054        return enabled;
055    }
056
057    public List<String> getFields() {
058        return fields;
059    }
060
061    public Boolean getComputeDigest() {
062        if (Boolean.TRUE.equals(enabled)) {
063            return enabled;
064        }
065        return computeDigest;
066    }
067
068    @Override
069    public String getId() {
070        return toString();
071    }
072}