<commit_before>package org.opencps.dossiermgt.action.util;

import org.opencps.dossiermgt.model.Dossier;
import org.opencps.dossiermgt.model.DossierFile;
import org.opencps.dossiermgt.model.PaymentFile;

import com.liferay.document.library.kernel.model.DLFileVersion;
import com.liferay.document.library.kernel.service.DLAppLocalServiceUtil;
import com.liferay.document.library.kernel.service.DLFileVersionLocalServiceUtil;
import com.liferay.portal.kernel.json.JSONArray;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.repository.model.FileEntry;

public class DossierLogUtils {
	public static String createPayload(DossierFile dossierFile, PaymentFile paymentFile, Dossier dossier){
		String fileType = "";
        String fileUrl = "";

        if (dossierFile.getDossierFileId() > 0) {
            try {
                FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(
                    dossierFile.getFileEntryId());
                DLFileVersion dlFileVersion =
                    DLFileVersionLocalServiceUtil.getLatestFileVersion(
                        fileEntry.getFileEntryId(), true);

                fileType = dlFileVersion.getExtension();
                fileUrl = dlFileVersion.getTreePath();
                 
            }
            catch (Exception e) {	
            	e.printStackTrace();
            }
        }
		JSONObject obj = JSONFactoryUtil.createJSONObject();
		JSONArray arr = JSONFactoryUtil.createJSONArray();
		
		if(dossierFile != null){
			JSONObject item = JSONFactoryUtil.createJSONObject();
			obj.put("jobposTitle", "");
			obj.put("briefNote", "");
			
			item.put("referenceUid", dossierFile.getReferenceUid());
			item.put("fileType", fileType);
			item.put("fileUrl", fileUrl);
			item.put("displayName", dossierFile.getDisplayName());
			item.put("status", "");
			arr.put(item);
			
			obj.put("dossierFiles", arr);
		}
		
		if(paymentFile != null){
			JSONObject item = JSONFactoryUtil.createJSONObject();
			obj.put("jobposTitle", "");
			obj.put("briefNote", "");
			
			item.put("referenceUid", paymentFile.getReferenceUid());
			item.put("fileType", fileType);
			item.put("fileUrl", fileUrl);
			item.put("displayName", "");
			item.put("paymentRequestDate", paymentFile.getCreateDate());
			item.put("paymentStatus", paymentFile.getPaymentStatus());
			arr.put(item);
			
			obj.put("dossierFiles", arr);
		}
		
		if(dossier != null){
			JSONObject item = JSONFactoryUtil.createJSONObject();
			obj.put("jobposTitle", "");
			obj.put("briefNote", "");
			
			item.put("referenceUid", dossier.getReferenceUid());
			item.put("fileType", fileType);
			item.put("fileUrl", fileUrl);
			item.put("displayName", "");
			arr.put(item);
			
			obj.put("dossierFiles", arr);
		}
		return obj.toString();
	}
	
	
}<commit_msg>fix DossierLogUtils<commit_after>package org.opencps.dossiermgt.action.util;

import org.opencps.dossiermgt.model.Dossier;
import org.opencps.dossiermgt.model.DossierFile;
import org.opencps.dossiermgt.model.PaymentFile;

import com.liferay.document.library.kernel.model.DLFileVersion;
import com.liferay.document.library.kernel.service.DLAppLocalServiceUtil;
import com.liferay.document.library.kernel.service.DLFileVersionLocalServiceUtil;
import com.liferay.portal.kernel.json.JSONArray;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.repository.model.FileEntry;

public class DossierLogUtils {
	public static String createPayload(DossierFile dossierFile, PaymentFile paymentFile, Dossier dossier) {
		String fileType = "";
		String fileUrl = "";
		if (dossierFile != null){
			if (dossierFile.getDossierFileId() > 0) {
				try {
					FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(dossierFile.getFileEntryId());
					DLFileVersion dlFileVersion = DLFileVersionLocalServiceUtil
							.getLatestFileVersion(fileEntry.getFileEntryId(), true);

					fileType = dlFileVersion.getExtension();
					fileUrl = dlFileVersion.getTreePath();

				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
		
		JSONObject obj = JSONFactoryUtil.createJSONObject();
		JSONArray arr = JSONFactoryUtil.createJSONArray();

		if (dossierFile != null) {
			JSONObject item = JSONFactoryUtil.createJSONObject();
			obj.put("jobposTitle", "");
			obj.put("briefNote", "");

			item.put("referenceUid", dossierFile.getReferenceUid());
			item.put("fileType", fileType);
			item.put("fileUrl", fileUrl);
			item.put("displayName", dossierFile.getDisplayName());
			item.put("status", "");
			arr.put(item);

			obj.put("dossierFiles", arr);
		}

		if (paymentFile != null) {
			JSONObject item = JSONFactoryUtil.createJSONObject();
			obj.put("jobposTitle", "");
			obj.put("briefNote", "");

			item.put("referenceUid", paymentFile.getReferenceUid());
			item.put("fileType", fileType);
			item.put("fileUrl", fileUrl);
			item.put("displayName", "");
			item.put("paymentRequestDate", paymentFile.getCreateDate());
			item.put("paymentStatus", paymentFile.getPaymentStatus());
			arr.put(item);

			obj.put("dossierFiles", arr);
		}

		if (dossier != null) {
			JSONObject item = JSONFactoryUtil.createJSONObject();
			obj.put("jobposTitle", "");
			obj.put("briefNote", "");

			item.put("referenceUid", dossier.getReferenceUid());
			item.put("fileType", fileType);
			item.put("fileUrl", fileUrl);
			item.put("displayName", "");
			arr.put(item);

			obj.put("dossierFiles", arr);
		}
		return obj.toString();
	}

}
{'fraction_non_alphanumeric': 0.14188462916517378, 'fraction_numerical': 0.00035829451809387314, 'mean_word_length': 4.025202520252026, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6005974', 'n_tokens_mistral': 1978, 'n_tokens_neox': 1755, 'n_words': 254}