All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mobicents.metadata.sip.spec.SipResourceCollectionMetaData Maven / Gradle / Ivy

There is a newer version: 4.0.128
Show newest version
/*
 * TeleStax, Open Source Cloud Communications
 * Copyright 2011-2015, Telestax Inc and individual contributors
 * by the @authors tag.
 *
 * This program is free software: you can redistribute it and/or modify
 * under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation; either version 3 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see 
 */
package org.mobicents.metadata.sip.spec;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import org.jboss.metadata.javaee.support.NamedMetaDataWithDescriptions;

/**
 * @author [email protected]
 * @version $Revision$
 *
 *          This class is based on the contents of org.mobicents.metadata.sip.spec package from jboss-as7-mobicents project,
 *          re-implemented for jboss as10 (wildfly) by:
 * @author [email protected]
 */
public class SipResourceCollectionMetaData extends NamedMetaDataWithDescriptions {
    private static final long serialVersionUID = 1;

    /** The set of all sip methods: */
    public static final Set ALL_SIP_METHODS;
    public static final String[] ALL_SIP_METHOD_NAMES;

    static {
        TreeSet tmp = new TreeSet();
        tmp.add("INVITE");
        tmp.add("ACK");
        tmp.add("BYE");
        tmp.add("MESSAGE");
        tmp.add("INFO");
        tmp.add("OPTIONS");
        tmp.add("SUBSCRIBE");
        tmp.add("PUBLISH");
        tmp.add("REFER");
        tmp.add("PRACK");
        ALL_SIP_METHODS = Collections.unmodifiableSortedSet(tmp);
        ALL_SIP_METHOD_NAMES = new String[ALL_SIP_METHODS.size()];
        ALL_SIP_METHODS.toArray(ALL_SIP_METHOD_NAMES);
    }

    private List servletNames = new ArrayList();
    private List sipMethods = new ArrayList();

    /**
     * Get sip methods in ALL_SIP_METHODS not in the argument sipMethods.
     *
     * @param sipMethods a set of sip method names
     * @return possibly empty sip methods in ALL_SIP_METHODS not in sipMethods.
     */
    public static String[] getMissingSipMethods(Collection sipMethods) {
        String[] methods = {};
        if (sipMethods.size() > 0 && sipMethods.containsAll(ALL_SIP_METHODS) == false) {
            HashSet missingMethods = new HashSet(ALL_SIP_METHODS);
            missingMethods.removeAll(sipMethods);
            methods = new String[missingMethods.size()];
            missingMethods.toArray(methods);
        }
        return methods;
    }

    public String getResourceName() {
        return getName();
    }

    public void setResourceName(String ResourceName) {
        super.setName(ResourceName);
    }

    public List getServletNames() {
        return servletNames;
    }

    public void setServletNames(List servletNames) {
        this.servletNames = servletNames;
    }

    public List getSipMethods() {
        return sipMethods;
    }

    public void setSipMethods(List sipMethods) {
        this.sipMethods = sipMethods;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy