Search in sources :

Example 1 with PAssertedService

use of gov.nist.javax.sip.header.ims.PAssertedService in project XobotOS by xamarin.

the class PAssertedServiceParser method parse.

public SIPHeader parse() throws ParseException {
    if (debug)
        dbg_enter("PAssertedServiceParser.parse");
    try {
        this.lexer.match(TokenTypes.P_ASSERTED_SERVICE);
        this.lexer.SPorHT();
        this.lexer.match(':');
        this.lexer.SPorHT();
        PAssertedService pps = new PAssertedService();
        String urn = this.lexer.getBuffer();
        if (urn.contains(ParameterNamesIms.SERVICE_ID)) {
            if (urn.contains(ParameterNamesIms.SERVICE_ID_LABEL)) {
                String serviceID = urn.split(ParameterNamesIms.SERVICE_ID_LABEL + ".")[1];
                if (serviceID.trim().equals(""))
                    try {
                        throw new InvalidArgumentException("URN should atleast have one sub-service");
                    } catch (InvalidArgumentException e) {
                        e.printStackTrace();
                    }
                else
                    pps.setSubserviceIdentifiers(urn.split(ParameterNamesIms.SERVICE_ID_LABEL)[1]);
            } else if (urn.contains(ParameterNamesIms.APPLICATION_ID_LABEL)) {
                String appID = urn.split(ParameterNamesIms.APPLICATION_ID_LABEL + ".")[1];
                if (appID.trim().equals(""))
                    try {
                        throw new InvalidArgumentException("URN should atleast have one sub-application");
                    } catch (InvalidArgumentException e) {
                        e.printStackTrace();
                    }
                else
                    pps.setApplicationIdentifiers(urn.split(ParameterNamesIms.APPLICATION_ID_LABEL)[1]);
            } else {
                try {
                    throw new InvalidArgumentException("URN is not well formed");
                } catch (InvalidArgumentException e) {
                    e.printStackTrace();
                }
            }
        }
        super.parse();
        return pps;
    } finally {
        if (debug)
            dbg_enter("PAssertedServiceParser.parse");
    }
}
Also used : InvalidArgumentException(javax.sip.InvalidArgumentException) PAssertedService(gov.nist.javax.sip.header.ims.PAssertedService)

Aggregations

PAssertedService (gov.nist.javax.sip.header.ims.PAssertedService)1 InvalidArgumentException (javax.sip.InvalidArgumentException)1