1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 ******************************************************************************/
16-
1716package com .wso2telco .logging ;
1817
1918import org .apache .axiom .om .impl .llom .OMTextImpl ;
2524import org .apache .synapse .mediators .AbstractMediator ;
2625import org .json .XML ;
2726
28- import java .util .TreeMap ;
29-
3027public class PropertyLogHandler extends AbstractMediator {
3128
3229 private static final String REGISTRY_PATH = "gov:/apimgt/" ;
@@ -40,11 +37,8 @@ public class PropertyLogHandler extends AbstractMediator {
4037 private static final String RESPONSE = "response" ;
4138 private static final String API_VERSION = "SYNAPSE_REST_API_VERSION" ;
4239 private static final String API_CONTEXT = "api.ut.context" ;
43- private static final String USER_ID = "api.ut.userId" ;
44- private static final String JWT = "X-JWT-Assertion" ;
4540 private static final String UUID = "MESSAGE_ID" ;
4641 private static final String ERROR = "error" ;
47- private static final String REQUEST_ID = "mife.prop.requestId" ;
4842 private static final String APPLICATION_NAME = "api.ut.application.name" ;
4943 private static final String REST_FULL_REQUEST_PATH = "REST_FULL_REQUEST_PATH" ;
5044 private static final String REST_SUB_REQUEST_PATH = "REST_SUB_REQUEST_PATH" ;
@@ -82,10 +76,7 @@ public boolean mediate(MessageContext messageContext) {
8276 }
8377
8478 private void logRequestProperties (MessageContext messageContext , org .apache .axis2 .context .MessageContext axis2MessageContext , boolean isPayloadLoggingEnabled ) {
85- TreeMap <String , String > headers = (TreeMap <String , String >) axis2MessageContext .getProperty (org .apache .axis2 .context .MessageContext .TRANSPORT_HEADERS );
86- //String jwtToken = headers.get(JWT);
8779 if (isPayloadLoggingEnabled ) {
88- // String requestPayload = messageContext.getEnvelope().getBody().toString();
8980 String requestPayload = handleAndReturnPayload (messageContext );
9081 logHandler .info ("TRANSACTION:request,API_REQUEST_ID:" + messageContext .getProperty (UUID ) + "" +
9182 ",API_NAME:" + messageContext .getProperty (API_NAME ) + "" +
@@ -98,7 +89,6 @@ private void logRequestProperties(MessageContext messageContext, org.apache.axis
9889 ",CONSUMER_KEY:" + messageContext .getProperty (CONSUMER_KEY ) +
9990 ",API_RESOURCE_PATH:" + messageContext .getProperty (REST_SUB_REQUEST_PATH ) +
10091 ",METHOD:" + messageContext .getProperty (METHOD ) +
101- //",JWT_TOKEN:" + jwtToken + "" + /*removed the JWT token from the log*/
10292 ",BODY:" + requestPayload .replaceAll ("\n " , "" ) +
10393 ",BIZAO_TOKEN:" +messageContext .getProperty (BIZAO_TOKEN ) +
10494 ",BIZAO_ALIAS:" +messageContext .getProperty (BIZAO_ALIAS )
@@ -108,7 +98,6 @@ private void logRequestProperties(MessageContext messageContext, org.apache.axis
10898
10999 private void logResponseProperties (MessageContext messageContext , org .apache .axis2 .context .MessageContext axis2MessageContext , boolean isPayloadLoggingEnabled ) {
110100 if (isPayloadLoggingEnabled ) {
111- // String responsePayload = messageContext.getEnvelope().getBody().toString();
112101 String responsePayload = handleAndReturnPayload (messageContext );
113102 logHandler .info ("TRANSACTION:response," +
114103 "API_REQUEST_ID:" + messageContext .getProperty (UUID ) + "" +
@@ -120,10 +109,9 @@ private void logResponseProperties(MessageContext messageContext, org.apache.axi
120109 }
121110
122111 private void logErrorProperties (MessageContext messageContext , org .apache .axis2 .context .MessageContext axis2MessageContext , boolean isPayloadLoggingEnabled ) {
123- UniqueIDGenerator .generateAndSetUniqueID ("EX" , axis2MessageContext );
124112 if (isPayloadLoggingEnabled ) {
125- logHandler .info ("TRANSACTION:errorResponse, " +
126- ",API_REQUEST_ID:" + axis2MessageContext .getProperty (REQUEST_ID ) +
113+ logHandler .info ("TRANSACTION:errorResponse" +
114+ ",API_REQUEST_ID:" + messageContext .getProperty (UUID ) +
127115 ",REQUEST_BODY:" + messageContext .getEnvelope ().getBody ().toString () +
128116 ",REST_FULL_REQUEST_PATH:" + messageContext .getProperty (REST_FULL_REQUEST_PATH ) +
129117 ",SYNAPSE_REST_API:" + messageContext .getProperty (SYNAPSE_REST_API ) +
@@ -185,6 +173,7 @@ private String handleAndReturnPayload(MessageContext messageContext) {
185173 /**
186174 * this method can be used if we need to get extract only json as body
187175 **/
176+ @ SuppressWarnings ("unused" )
188177 private String getPayloadSting (MessageContext messageContext , org .apache .axis2 .context .MessageContext axis2MessageContext ) {
189178 String payload ;
190179 if (axis2MessageContext .getProperty (CONTENT_TYPE ).equals ("application/json" )) {
0 commit comments