/protocols/ss7/m3ua/impl/src/main/java/org/mobicents/protocols/ss7/m3ua/impl/sg/RemAsTransInactToInact.java
Java | 83 lines | 46 code | 16 blank | 21 comment | 4 complexity | e862b59fc0a1010d3a8f918b0b368185 MD5 | raw file
Possible License(s): LGPL-3.0, GPL-3.0, LGPL-2.1, GPL-2.0, CC-BY-SA-3.0, CC0-1.0, Apache-2.0, BSD-3-Clause
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.sg; 24 25import org.apache.log4j.Logger; 26import org.mobicents.protocols.ss7.m3ua.impl.fsm.FSM; 27import org.mobicents.protocols.ss7.m3ua.impl.fsm.State; 28import org.mobicents.protocols.ss7.m3ua.impl.fsm.TransitionHandler; 29import org.mobicents.protocols.ss7.m3ua.message.MessageClass; 30import org.mobicents.protocols.ss7.m3ua.message.MessageType; 31import org.mobicents.protocols.ss7.m3ua.message.mgmt.Notify; 32import org.mobicents.protocols.ss7.m3ua.parameter.Status; 33 34public class RemAsTransInactToInact implements TransitionHandler { 35 36 private static final Logger logger = Logger.getLogger(RemAsTransInactToInact.class); 37 38 private RemAsImpl as = null; 39 private FSM fsm; 40 41 public RemAsTransInactToInact(RemAsImpl as, FSM fsm) { 42 this.as = as; 43 this.fsm = fsm; 44 } 45 46 public boolean process(State state) { 47 try { 48 49 RemAspImpl remAsp = (RemAspImpl) this.fsm.getAttribute(RemAsImpl.ATTRIBUTE_ASP); 50 51 if (remAsp == null) { 52 logger.error(String.format("No ASP found. %s", this.fsm.toString())); 53 return false; 54 } 55 56 Notify msg = createNotify(remAsp); 57 remAsp.getAspFactory().write(msg); 58 return true; 59 } catch (Exception e) { 60 logger.error(String.format("Error while translating Rem AS to INACTIVE message. %s", this.fsm.toString()), 61 e); 62 } 63 return false; 64 } 65 66 private Notify createNotify(RemAspImpl remAsp) { 67 Notify msg = (Notify) this.as.getM3UAProvider().getMessageFactory().createMessage(MessageClass.MANAGEMENT, 68 MessageType.NOTIFY); 69 70 Status status = this.as.getM3UAProvider().getParameterFactory().createStatus(Status.STATUS_AS_State_Change, 71 Status.INFO_AS_INACTIVE); 72 msg.setStatus(status); 73 74 if (remAsp.getASPIdentifier() != null) { 75 msg.setASPIdentifier(remAsp.getASPIdentifier()); 76 } 77 78 msg.setRoutingContext(this.as.getRoutingContext()); 79 80 return msg; 81 } 82 83}