001/*
002 * (C) Copyright 2006-2011 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 *     bstefanescu
018 */
019package org.nuxeo.ecm.automation.server;
020
021import org.nuxeo.common.utils.StringUtils;
022import org.nuxeo.common.xmap.annotation.XNode;
023import org.nuxeo.common.xmap.annotation.XObject;
024
025/**
026 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
027 */
028@XObject("binding")
029public class RestBinding {
030
031    /**
032     * The operation (chain) name
033     */
034    @XNode("@name")
035    protected String name;
036
037    @XNode("@chain")
038    protected boolean chain;
039
040    @XNode("@disabled")
041    protected boolean isDisabled;
042
043    @XNode("secure")
044    protected boolean isSecure;
045
046    @XNode("administrator")
047    protected boolean isAdministrator;
048
049    protected String[] groups;
050
051    public void setName(String name) {
052        this.name = name;
053    }
054
055    public void setDisabled(boolean isDisabled) {
056        this.isDisabled = isDisabled;
057    }
058
059    public void setSecure(boolean isHttps) {
060        this.isSecure = isHttps;
061    }
062
063    public void setAdministrator(boolean isAdministrator) {
064        this.isAdministrator = isAdministrator;
065    }
066
067    public void setGroups(String[] groups) {
068        this.groups = groups;
069    }
070
071    public void setChain(boolean chain) {
072        this.chain = chain;
073    }
074
075    public boolean isChain() {
076        return chain;
077    }
078
079    @XNode("groups")
080    public void setGroups(String list) {
081        list = list.trim();
082        if (list != null && list.length() > 0) {
083            this.groups = StringUtils.split(list, ',', true);
084        }
085    }
086
087    public boolean isDisabled() {
088        return isDisabled;
089    }
090
091    public boolean isAdministrator() {
092        return isAdministrator;
093    }
094
095    public boolean isSecure() {
096        return isSecure;
097    }
098
099    public String[] getGroups() {
100        return groups;
101    }
102
103    public boolean hasGroups() {
104        return groups != null && groups.length > 0;
105    }
106
107    public String getName() {
108        return name;
109    }
110
111}