public static DiameterMessage processRequest(DiameterPeer diameterPeer, DiameterMessage request) { DiameterMessage response = diameterPeer.newResponse(request); Session session = null; boolean dbException = false; try { if (request.flagProxiable == false) { logger.warn("You should notice that the Proxiable flag for UDR request was not set!"); } // set the proxiable flag for the response response.flagProxiable = true; // add Auth-Session-State and Vendor-Specific-Application-ID to Response UtilAVP.addAuthSessionState(response, DiameterConstants.AVPValue.ASS_No_State_Maintained); UtilAVP.addVendorSpecificApplicationID( response, DiameterConstants.Vendor.V3GPP, DiameterConstants.Application.Sh); // -0- check for mandatory fields in the message String vendor_specific_ID = UtilAVP.getVendorSpecificApplicationID(request); String auth_session_state = UtilAVP.getAuthSessionState(request); String origin_host = UtilAVP.getOriginatingHost(request); String origin_realm = UtilAVP.getOriginatingRealm(request); String dest_realm = UtilAVP.getDestinationRealm(request); String user_identity = UtilAVP.getShUserIdentity(request); Vector data_ref_vector = UtilAVP.getAllDataReference(request); String server_name = UtilAVP.getServerName(request); String dsai_tag = UtilAVP.getDSAITag(request); Vector service_indication_vector = UtilAVP.getAllServiceIndication(request); if (vendor_specific_ID == null || auth_session_state == null || origin_host == null || origin_realm == null || dest_realm == null || user_identity == null || data_ref_vector == null || data_ref_vector.size() == 0) { throw new ShExperimentalResultException(DiameterConstants.ResultCode.DIAMETER_MISSING_AVP); } session = HibernateUtil.getCurrentSession(); HibernateUtil.beginTransaction(); // -1- ApplicationServer as = ApplicationServer_DAO.get_by_Diameter_Address(session, origin_host); if (as == null) { throw new ShExperimentalResultException( DiameterConstants.ResultCode.RC_IMS_DIAMETER_ERROR_USER_DATA_CANNOT_BE_READ); } if (as.getUdr() == 0) { throw new ShExperimentalResultException( DiameterConstants.ResultCode.RC_IMS_DIAMETER_ERROR_USER_DATA_CANNOT_BE_READ); } for (int i = 0; i < data_ref_vector.size(); i++) { int crt_data_ref = (Integer) data_ref_vector.get(i); if ((crt_data_ref == ShConstants.Data_Ref_Repository_Data && as.getUdr_rep_data() == 0) || (crt_data_ref == ShConstants.Data_Ref_IMS_Public_Identity && as.getUdr_impu() == 0) || (crt_data_ref == ShConstants.Data_Ref_IMS_User_State && as.getUdr_ims_user_state() == 0) || (crt_data_ref == ShConstants.Data_Ref_SCSCF_Name && as.getUdr_scscf_name() == 0) || (crt_data_ref == ShConstants.Data_Ref_iFC && as.getUdr_ifc() == 0) || (crt_data_ref == ShConstants.Data_Ref_Location_Info && as.getUdr_location() == 0) || (crt_data_ref == ShConstants.Data_Ref_User_State && as.getUdr_user_state() == 0) || (crt_data_ref == ShConstants.Data_Ref_Charging_Info && as.getUdr_charging_info() == 0) || (crt_data_ref == ShConstants.Data_Ref_MSISDN && as.getUdr_msisdn() == 0) || (crt_data_ref == ShConstants.Data_Ref_PSI_Activation && as.getUdr_psi_activation() == 0) || (crt_data_ref == ShConstants.Data_Ref_DSAI && as.getUdr_dsai() == 0) || (crt_data_ref == ShConstants.Data_Ref_Aliases_Repository_Data && as.getUdr_aliases_rep_data() == 0)) { throw new ShExperimentalResultException( DiameterConstants.ResultCode.RC_IMS_DIAMETER_ERROR_USER_DATA_CANNOT_BE_READ); } // check if the service_indication is present in the request (only for RepositoryData) if ((crt_data_ref == ShConstants.Data_Ref_Aliases_Repository_Data || crt_data_ref == ShConstants.Data_Ref_Repository_Data) && (service_indication_vector == null || service_indication_vector.size() == 0)) { throw new ShExperimentalResultException( DiameterConstants.ResultCode.DIAMETER_MISSING_AVP); } // check if the server_name is present in the request (only for DSAI) if ((crt_data_ref == ShConstants.Data_Ref_DSAI) && (server_name == null)) { throw new ShFinalResultException(DiameterConstants.ResultCode.DIAMETER_MISSING_AVP); } // TODO MSISDN } // -2- check for user identity existence IMPU impu = IMPU_DAO.get_by_Identity(session, user_identity); if (impu == null) { throw new ShExperimentalResultException(DiameterConstants.ResultCode.DIAMETER_USER_UNKNOWN); } // -3- // check if the user identity apply to the Data Reference according to table 7.6.1 // -3a- // [to be completed] // -4- check for simultaneous update // [to be completed] // -5- include the data pertinent to the requested Data Reference // ShDataElement shData = new ShDataElement(); for (int i = 0; i < data_ref_vector.size(); i++) { int crt_data_ref = (Integer) data_ref_vector.get(i); String crt_service_indication = UtilAVP.getServiceIndication(request); if (crt_data_ref == ShConstants.Data_Ref_Repository_Data && crt_service_indication == null) { throw new ShExperimentalResultException( DiameterConstants.ResultCode.DIAMETER_MISSING_AVP); } // get identitySet int identitySet = -1; if (crt_data_ref == ShConstants.Data_Ref_IMS_Public_Identity) { identitySet = UtilAVP.getIdentitySet(request); if (identitySet == -1) { identitySet = ShConstants.Identity_Set_All_Identities; } } if (crt_data_ref == ShConstants.Data_Ref_DSAI) { dsai_tag = UtilAVP.getDSAITag(request); DSAI dsai = DSAI_DAO.get_by_Dsai_tag(session, dsai_tag); if (dsai == null) { new ShExperimentalResultException( DiameterConstants.ResultCode.RC_IMS_DIAMETER_ERROR_DSAI_NOT_AVAILABLE); } } // add the Sh-Data to the shData object addShData( shData, crt_data_ref, impu, crt_service_indication, server_name, identitySet, dsai_tag); } // add the Sh-Data and send the result UtilAVP.addShData(response, shData.toString()); UtilAVP.addResultCode(response, DiameterConstants.ResultCode.DIAMETER_SUCCESS.getCode()); } catch (HibernateException e) { dbException = true; UtilAVP.addResultCode( response, DiameterConstants.ResultCode.DIAMETER_UNABLE_TO_COMPLY.getCode()); e.printStackTrace(); } catch (ShExperimentalResultException e) { UtilAVP.addExperimentalResultCode(response, e.getErrorCode(), e.getVendor()); e.printStackTrace(); } catch (ShFinalResultException e) { UtilAVP.addResultCode(response, e.getErrorCode()); e.printStackTrace(); } finally { // commit transaction only when a Database doesn't occured if (!dbException) { HibernateUtil.commitTransaction(); } HibernateUtil.closeSession(); } return response; }