PageRenderTime 27ms CodeModel.GetById 11ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 0ms

/protocols/ss7/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/TransitionState.java

http://mobicents.googlecode.com/
Java | 157 lines | 95 code | 29 blank | 33 comment | 2 complexity | 4f48c236174db7063424a3809ce6d12b MD5 | raw file
  1/*
  2 * JBoss, Home of Professional Open Source
  3 * Copyright 2011, Red Hat, Inc. and individual contributors
  4 * by the @authors tag. See the copyright.txt in the distribution for a
  5 * full listing of individual contributors.
  6 *
  7 * This is free software; you can redistribute it and/or modify it
  8 * under the terms of the GNU Lesser General Public License as
  9 * published by the Free Software Foundation; either version 2.1 of
 10 * the License, or (at your option) any later version.
 11 *
 12 * This software is distributed in the hope that it will be useful,
 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 15 * Lesser General Public License for more details.
 16 *
 17 * You should have received a copy of the GNU Lesser General Public
 18 * License along with this software; if not, write to the Free
 19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 21 */
 22
 23package org.mobicents.protocols.ss7.m3ua.impl;
 24
 25import java.util.HashMap;
 26
 27import org.mobicents.protocols.ss7.m3ua.message.M3UAMessage;
 28import org.mobicents.protocols.ss7.m3ua.message.MessageClass;
 29import org.mobicents.protocols.ss7.m3ua.message.MessageType;
 30import org.mobicents.protocols.ss7.m3ua.message.mgmt.Notify;
 31import org.mobicents.protocols.ss7.m3ua.parameter.ErrorCode;
 32import org.mobicents.protocols.ss7.m3ua.parameter.Status;
 33
 34/**
 35 * 
 36 * @author amit bhayani
 37 *
 38 */
 39public class TransitionState {
 40    public static final String COMM_UP = "commup";
 41    public static final String COMM_DOWN = "commdown";
 42    public static final String PAYLOAD = "payload";
 43
 44    public static final String DUNA = "duna";
 45    public static final String DAVA = "dava";
 46    public static final String DAUD = "daud";
 47    public static final String SCON = "scon";
 48    public static final String DUPU = "dupu";
 49    public static final String DRST = "drst";
 50
 51    public static final String ASP_UP_SENT = "aspupsent";
 52    public static final String ASP_UP = "aspup";
 53    public static final String ASP_UP_ACK = "aspupack";
 54    
 55    public static final String ASP_DOWN_SENT = "aspdownsent";
 56    public static final String ASP_DOWN = "aspdown";
 57    public static final String ASP_DOWN_ACK = "aspdownack";
 58    
 59    public static final String HEARTBEAT = "heartbeat";
 60    public static final String HEARTBEAT_ACK = "heartbeatack";
 61
 62    public static final String ASP_INACTIVE_SENT = "aspinactivesent";
 63    public static final String ASP_INACTIVE = "aspinactive";
 64    public static final String ASP_INACTIVE_ACK = "aspinactiveack";
 65    
 66    public static final String ASP_ACTIVE = "aspactive";
 67    public static final String ASP_ACTIVE_SENT = "aspactivesent";
 68    public static final String ASP_ACTIVE_ACK = "aspactiveack";
 69
 70    public static final String AS_DOWN = "asdown";
 71    public static final String AS_INACTIVE = "asinactive";
 72
 73    public static final String AS_STATE_CHANGE_RESERVE = "ntfyreserve";
 74    public static final String AS_STATE_CHANGE_INACTIVE = "ntfyasinactive";
 75    public static final String AS_STATE_CHANGE_ACTIVE = "ntfyasactive";
 76    public static final String AS_STATE_CHANGE_PENDING = "ntfyaspending";
 77
 78    public static final String OTHER_INSUFFICIENT_ASP = "ntfyinsuffasp";
 79    public static final String OTHER_ALTERNATE_ASP_ACTIVE = "ntfyaltaspact";
 80    public static final String OTHER_ALTERNATE_ASP_FAILURE = "ntfyaltaspfail";
 81
 82    public static final String INVALID_RC = "invalidrc";
 83
 84    private static HashMap<Integer, HashMap<Integer, String>> transContainer = new HashMap<Integer, HashMap<Integer, String>>();
 85
 86    static {
 87
 88        // Transfer
 89        HashMap<Integer, String> trfrTransCont = new HashMap<Integer, String>();
 90        trfrTransCont.put(MessageType.PAYLOAD, PAYLOAD);
 91
 92        transContainer.put(MessageClass.TRANSFER_MESSAGES, trfrTransCont);
 93
 94        // SSNM
 95        HashMap<Integer, String> ssnmTransCont = new HashMap<Integer, String>();
 96        ssnmTransCont.put(MessageType.DESTINATION_UNAVAILABLE, DUNA);
 97        ssnmTransCont.put(MessageType.DESTINATION_AVAILABLE, DAVA);
 98        ssnmTransCont.put(MessageType.DESTINATION_STATE_AUDIT, DAUD);
 99        ssnmTransCont.put(MessageType.SIGNALING_CONGESTION, SCON);
100        ssnmTransCont.put(MessageType.DESTINATION_USER_PART_UNAVAILABLE, DUPU);
101        ssnmTransCont.put(MessageType.DESTINATION_RESTRICTED, DRST);
102
103        transContainer.put(MessageClass.SIGNALING_NETWORK_MANAGEMENT, ssnmTransCont);
104
105        // ASPSM
106        HashMap<Integer, String> aspsmTransCont = new HashMap<Integer, String>();
107        aspsmTransCont.put(MessageType.ASP_UP, ASP_UP);
108        aspsmTransCont.put(MessageType.ASP_UP_ACK, ASP_UP_ACK);
109        aspsmTransCont.put(MessageType.ASP_DOWN, ASP_DOWN);
110        aspsmTransCont.put(MessageType.ASP_DOWN_ACK, ASP_DOWN_ACK);
111        aspsmTransCont.put(MessageType.HEARTBEAT, HEARTBEAT);
112        aspsmTransCont.put(MessageType.HEARTBEAT_ACK, HEARTBEAT_ACK);
113
114        transContainer.put(MessageClass.ASP_STATE_MAINTENANCE, aspsmTransCont);
115
116        // ASPTM
117        HashMap<Integer, String> asptmTransCont = new HashMap<Integer, String>();
118        asptmTransCont.put(MessageType.ASP_ACTIVE, ASP_ACTIVE);
119        asptmTransCont.put(MessageType.ASP_ACTIVE_ACK, ASP_ACTIVE_ACK);
120        asptmTransCont.put(MessageType.ASP_INACTIVE, ASP_INACTIVE);
121        asptmTransCont.put(MessageType.ASP_INACTIVE_ACK, ASP_INACTIVE_ACK);
122
123        transContainer.put(MessageClass.ASP_TRAFFIC_MAINTENANCE, asptmTransCont);
124
125        // MGMT
126        HashMap<Integer, String> mgmtTransCont = new HashMap<Integer, String>();
127
128        // NTFY
129        mgmtTransCont.put((Status.STATUS_AS_State_Change << 16 | Status.INFO_Reserved), AS_STATE_CHANGE_RESERVE);
130        mgmtTransCont.put((Status.STATUS_AS_State_Change << 16 | Status.INFO_AS_INACTIVE), AS_STATE_CHANGE_INACTIVE);
131        mgmtTransCont.put((Status.STATUS_AS_State_Change << 16 | Status.INFO_AS_ACTIVE), AS_STATE_CHANGE_ACTIVE);
132        mgmtTransCont.put((Status.STATUS_AS_State_Change << 16 | Status.INFO_AS_PENDING), AS_STATE_CHANGE_PENDING);
133
134        mgmtTransCont.put((Status.STATUS_Other << 16 | Status.INFO_Insufficient_ASP_Resources_Active),
135                OTHER_INSUFFICIENT_ASP);
136        mgmtTransCont.put((Status.STATUS_Other << 16 | Status.INFO_Alternate_ASP_Active), OTHER_ALTERNATE_ASP_ACTIVE);
137        mgmtTransCont.put((Status.STATUS_Other << 16 | Status.INFO_Alternate_ASP_Failure), OTHER_ALTERNATE_ASP_FAILURE);
138        // Err cde
139        mgmtTransCont.put(ErrorCode.Invalid_Routing_Context, INVALID_RC);
140
141        transContainer.put(MessageClass.MANAGEMENT, mgmtTransCont);
142    }
143
144    public static String getTransition(M3UAMessage message) {
145        switch (message.getMessageClass()) {
146        case MessageClass.MANAGEMENT:
147            switch (message.getMessageType()) {
148            case MessageType.ERROR:
149            case MessageType.NOTIFY:
150                Status status = ((Notify) message).getStatus();
151                return transContainer.get(message.getMessageClass()).get((status.getType() << 16 | status.getInfo()));
152            }
153        default:
154            return transContainer.get(message.getMessageClass()).get(message.getMessageType());
155        }
156    }
157}