Search in sources :

Example 6 with AvpSet

use of org.jdiameter.api.AvpSet in project jain-slee.diameter by RestComm.

the class ShClientMessageFactoryImpl method createMessage.

protected Message createMessage(DiameterHeader header, DiameterAvp[] avps, int commandCode) throws AvpNotAllowedException {
    try {
        Message msg = createRawMessage(header, commandCode);
        AvpSet set = msg.getAvps();
        for (DiameterAvp avp : avps) {
            addAvp(avp, set);
        }
        return msg;
    } catch (Exception e) {
        logger.error("Unexpected failure trying to create Sh Message.", e);
    }
    return null;
}
Also used : Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) AvpSet(org.jdiameter.api.AvpSet) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) InternalException(org.jdiameter.api.InternalException) IllegalDiameterStateException(org.jdiameter.api.IllegalDiameterStateException) NoSuchAvpException(net.java.slee.resource.diameter.base.NoSuchAvpException)

Example 7 with AvpSet

use of org.jdiameter.api.AvpSet in project jain-slee.diameter by RestComm.

the class AvpUtilities method getAvpsAsUnsigned32.

public static long[] getAvpsAsUnsigned32(int avpCode, long vendorId, AvpSet set) {
    try {
        AvpSet avpSet = set.getAvps(avpCode, vendorId);
        long[] values = new long[avpSet.size()];
        int i = 0;
        for (Avp avp : avpSet) {
            values[i++] = avp.getUnsigned32();
        }
        return values;
    } catch (AvpDataException e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Failed to obtain AVP with code " + avpCode + " and Vendor-Id " + vendorId + " as type Unsigned32.", e);
        }
        return new long[0];
    }
}
Also used : AvpDataException(org.jdiameter.api.AvpDataException) AvpSet(org.jdiameter.api.AvpSet) Avp(org.jdiameter.api.Avp)

Example 8 with AvpSet

use of org.jdiameter.api.AvpSet in project jain-slee.diameter by RestComm.

the class AvpUtilities method getAvpsAsInteger32.

public static int[] getAvpsAsInteger32(int avpCode, AvpSet set) {
    try {
        AvpSet avpSet = set.getAvps(avpCode);
        int[] values = new int[avpSet.size()];
        int i = 0;
        for (Avp avp : avpSet) {
            values[i++] = avp.getInteger32();
        }
        return values;
    } catch (AvpDataException e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Failed to obtain AVP with code " + avpCode + " as type Integer32.", e);
        }
        return new int[0];
    }
}
Also used : AvpDataException(org.jdiameter.api.AvpDataException) AvpSet(org.jdiameter.api.AvpSet) Avp(org.jdiameter.api.Avp)

Example 9 with AvpSet

use of org.jdiameter.api.AvpSet in project jain-slee.diameter by RestComm.

the class AvpUtilities method getAvpsAsOctetString.

public static byte[][] getAvpsAsOctetString(int avpCode, AvpSet set) {
    try {
        AvpSet avpSet = set.getAvps(avpCode);
        byte[][] values = new byte[avpSet.size()][];
        int i = 0;
        for (Avp avp : avpSet) {
            values[i++] = avp.getOctetString();
        }
        return values;
    } catch (AvpDataException e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Failed to obtain AVP with code " + avpCode + " as type OctetString.", e);
        }
        return new byte[0][];
    }
}
Also used : AvpDataException(org.jdiameter.api.AvpDataException) AvpSet(org.jdiameter.api.AvpSet) Avp(org.jdiameter.api.Avp)

Example 10 with AvpSet

use of org.jdiameter.api.AvpSet in project jain-slee.diameter by RestComm.

the class AvpUtilities method getAvpsAsUnsigned64.

public static long[] getAvpsAsUnsigned64(int avpCode, AvpSet set) {
    try {
        AvpSet avpSet = set.getAvps(avpCode);
        long[] values = new long[avpSet.size()];
        int i = 0;
        for (Avp avp : avpSet) {
            values[i++] = avp.getUnsigned64();
        }
        return values;
    } catch (AvpDataException e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Failed to obtain AVP with code " + avpCode + " as type Unsigned64.", e);
        }
        return new long[0];
    }
}
Also used : AvpDataException(org.jdiameter.api.AvpDataException) AvpSet(org.jdiameter.api.AvpSet) Avp(org.jdiameter.api.Avp)

Aggregations

AvpSet (org.jdiameter.api.AvpSet)48 Avp (org.jdiameter.api.Avp)30 AvpDataException (org.jdiameter.api.AvpDataException)26 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)20 GroupedAvp (net.java.slee.resource.diameter.base.events.avp.GroupedAvp)10 Message (org.jdiameter.api.Message)8 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 URISyntaxException (java.net.URISyntaxException)4 ParseException (org.jdiameter.client.api.parser.ParseException)4 ArrayList (java.util.ArrayList)3 NoSuchAvpException (net.java.slee.resource.diameter.base.NoSuchAvpException)3 AvpRepresentation (org.mobicents.diameter.dictionary.AvpRepresentation)3 Constructor (java.lang.reflect.Constructor)2 Date (java.util.Date)2 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)2 IllegalDiameterStateException (org.jdiameter.api.IllegalDiameterStateException)2 InternalException (org.jdiameter.api.InternalException)2 AvpRepresentation (org.jdiameter.api.validation.AvpRepresentation)2 ExperimentalResultAvp (net.java.slee.resource.diameter.base.events.avp.ExperimentalResultAvp)1