import java.util.Date;
import java.util.TimeZone;
-
public class ActionUtil {
private static final String UTC_DATE_FORMAT = "dd MMM yyyy kk:mm:ss z";
/**
* Get Current Timestamp in UTC format.
*
- * @return Current Timestamp in UTC format.
+ * @return Current Timestamp in UTC format
*/
public static Date getCurrentTimeStampUtc() {
return Date.from(java.time.ZonedDateTime.now(ZoneOffset.UTC).toInstant());
/**
* Convert timestamp to UTC format date string.
*
- * @param timeStamp UTC timestamp to be converted to the UTC Date format.
- * @return UTC formatted Date string from timestamp.
+ * @param timeStamp UTC timestamp to be converted to the UTC Date format
+ * @return UTC formatted Date string from timestamp
*/
public static String getUtcDateStringFromTimestamp(Date timeStamp) {
DateFormat df = new SimpleDateFormat(UTC_DATE_FORMAT);
/**
* Convert timestamp to UTC format date string.
*
- * @param timeStamp UTC timestamp to be converted to the UTC Date format.
- * @return UTC formatted Date string from timestamp.
+ * @param timeStamp UTC timestamp to be converted to the UTC Date format
+ * @return UTC formatted Date string from timestamp
*/
public static String getLogUtcDateStringFromTimestamp(Date timeStamp) {
DateFormat df = new SimpleDateFormat(LOG_UTC_DATE_FORMAT);
/**
* Method to set up specific attributes MDC for the current logging operation.
*
- * @param subOperation Request Name.
+ * @param subOperation Request Name
*/
public static void actionLogPreProcessor(ActionSubOperation subOperation, String targetEntity) {
MDC.put(BEGIN_TIMESTAMP, String.valueOf(System.currentTimeMillis()));
/**
* Method to enhance the MDC after the logging operation for Metrics and Audit logs.
*
- * @param statusCode Response code for the current operation.
+ * @param statusCode Response code for the current operation
*/
public static void actionLogPostProcessor(StatusCode statusCode) {
actionLogPostProcessor(statusCode, false);
}
/**
- * Method to enhance the MDC after the logging operation for Metrics and Audit logs.
+ * Action log post processor.
*
- * @param statusCode Response code for the current operation.
+ * @param statusCode the status code
+ * @param responseCode the response code
+ * @param responseDescription the response description
+ * @param isServiceMetricLog the is service metric log
*/
-
public static void actionLogPostProcessor(StatusCode statusCode, String responseCode,
String responseDescription,
boolean isServiceMetricLog) {
/**
* Action Library Error logging Helper.
*
- * @param errorCategory WARN or ERROR.
- * @param errorCode Action Library exception code.
- * @param errorDescription Description of the error.
+ * @param errorCategory WARN or ERROR
+ * @param errorCode Action Library exception code
+ * @param errorDescription Description of the error
*/
public static void actionErrorLogProcessor(CategoryLogLevel errorCategory, String errorCode,
String errorDescription) {
errorType = "F";
break;
default:
- break;
}
MDC.put(ERROR_CODE, getLogResponseCode(errorCode) + errorType);
}
}
/**
- * Method to convert Action Library exception codes to OPENECOMP Audit codes in {@link.
- * ActionLogResponseCode} e.g: ACT1060 --> 201.
+ * Method to convert Action Library exception codes to OPENECOMP Audit codes in {@link
+ * ActionLogResponseCode} e.g: ACT1060 --> 201
*
- * @param errorCode Action library exception code.
- * @return Audit log code corresponding to the Action Library exception.
+ * @param errorCode Action library exception code
+ * @return Audit log code corresponding to the Action Library exception
*/
public static int getLogResponseCode(String errorCode) {
ActionLogResponseCode responseCode = INTERNAL_SERVER_ERROR;
responseCode = QUERY_FAILURE;
break;
default:
- break;
}
return responseCode.getValue();
}