package com.bankaudit.template.rest.controller;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.jboss.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import com.bankaudit.constants.BankAuditConstant;
import com.bankaudit.process.model.AuditDocumentDetails;
import com.bankaudit.service.BusinessDateService;
import com.bankaudit.template.rest.service.DocUploadDownloadService;
import com.bankaudit.util.BankAuditUtil;
import com.bankaudit.util.ServiceStatus;



@RestController

@RequestMapping("/api/docUploadDownload")
public class DocUploadDownloadController {
	
	@Autowired
	BusinessDateService businessDateService;
	
	@Autowired
	DocUploadDownloadService docUploadDownloadService;
	
	static final Logger logger = Logger.getLogger(DocUploadDownloadController.class);

	
@RequestMapping(value="/getAuditDocumentDetails" ,method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus getAuditDocumentDetails(
			@RequestParam(value="legalEntityCode")Integer legalEntityCode,
			@RequestParam(value="auditTypeCode")String auditTypeCode,
			@RequestParam(value="planId" , required=false)String planId,
			@RequestParam(value="auditId", required=false)String auditId,
			@RequestParam(value="observationId", required=false)String observationId,
			@RequestParam(value="documentType", required=false)String documentType,
			@RequestParam(value="documentSubType", required=false)String documentSubType,
			@RequestParam(value="status")String  status,
			@RequestParam(required=false,value="documentName")String  documentName
			){
	
		ServiceStatus serviceStatus=new ServiceStatus();		
		try {			
			List<AuditDocumentDetails> auditDocumentDetails=docUploadDownloadService.getAuditDocumentDetails(legalEntityCode,auditTypeCode,planId,
					auditId,observationId,documentType,documentSubType,status, documentName);			
			if(auditDocumentDetails!=null && !auditDocumentDetails.isEmpty()){
				serviceStatus.setResult(auditDocumentDetails);
				serviceStatus.setStatus("success");
				serviceStatus.setMessage("successfully got the result ");				
			}else {
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("No docs found ");
			}
			
		} catch (Exception e) {
			logger.error(e.getStackTrace());
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("failure");
		}
		return serviceStatus;
	}
	
	
@RequestMapping(value="/uploadAuditDocument" ,method=RequestMethod.POST,consumes=MediaType.MULTIPART_FORM_DATA_VALUE,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus  uploadAuditDocument(
			@RequestParam(value="maker")String maker,
			@RequestParam(value="role")String role,
			@RequestParam(value="files")CommonsMultipartFile[] files,
			@RequestParam(value="legalEntityCode")Integer legalEntityCode,
			@RequestParam(value="auditTypeCode")String auditTypeCode,
			@RequestParam(value="planId")String planId,
			@RequestParam(value="auditId")String auditId,
			@RequestParam(value="documentType")String documentType,
			@RequestParam(value="documentSubType")String documentSubType,
			@RequestParam(required=false,value="observationId")String observationId,
			@RequestParam(required=false,value="checker")String checker,
			@RequestParam(required=false,value="warningCheck")String warningCheck,
			@RequestParam(value="entityStatus")String entityStatus,
			@RequestParam(required=false,value="documentName")String  documentName )  {
		
		ServiceStatus serviceStatus=new ServiceStatus();
		Map<String, Object> result=new HashMap<>();
		try {
			if(files!=null && !BankAuditUtil.isEmptyString(auditTypeCode) && !BankAuditUtil.isEmptyString(entityStatus)){					
				
				List<AuditDocumentDetails> listAuditDocumentDetails= null;
				if(("yes").equalsIgnoreCase(warningCheck) || ("del").equalsIgnoreCase(warningCheck) ){
					listAuditDocumentDetails = docUploadDownloadService.getAuditDocumentDetails(legalEntityCode, auditTypeCode, planId, auditId,
							observationId, documentType, documentSubType, entityStatus, documentName);					
				}
				result.put("observationId",observationId);  			
				String fileName=legalEntityCode.toString()+auditTypeCode+planId+auditId+role+documentType;
				
				Boolean isWarning=false;
				String duplicateFileNames="";
				List<Integer> duplicateDocIds=new ArrayList<>(); 
						
				for (CommonsMultipartFile commonsMultipartFile : files) {
					
					if(!BankAuditUtil.validateFileType(commonsMultipartFile, BankAuditConstant.DOC_TYPES)){
						serviceStatus.setStatus("failure");
						serviceStatus.setMessage("file type : "+BankAuditUtil.getFileExtension(commonsMultipartFile.getOriginalFilename()) +" not supported");
						return serviceStatus;
					}
					
					/*if(warningCheck.equalsIgnoreCase("yes") && listAuditDocumentDetails!=null){							
						for (AuditDocumentDetails auditDocumentDetail : listAuditDocumentDetails) {			                  
							if(auditDocumentDetail.getReferencePath().contains(fileName+"_"+commonsMultipartFile.getOriginalFilename())){									
								isWarning=true;
								duplicateFileNames=duplicateFileNames+" "+commonsMultipartFile.getOriginalFilename();
								duplicateDocIds.add(auditDocumentDetail.getId());
							}								
						}							
					}*/	
					
					if(("yes").equalsIgnoreCase(warningCheck) && listAuditDocumentDetails!=null && listAuditDocumentDetails.size()>0){							
						for (AuditDocumentDetails auditDocumentDetail : listAuditDocumentDetails) {			                  
							if(auditDocumentDetail.getFileName().contains(commonsMultipartFile.getOriginalFilename())){									
								isWarning=true;
								duplicateFileNames=duplicateFileNames+" "+commonsMultipartFile.getOriginalFilename();
								duplicateDocIds.add(auditDocumentDetail.getId());
							}
							/*else if(auditDocumentDetail.getDocumentName().contains("Board Resolution")){
								isWarning=true;
								duplicateFileNames=duplicateFileNames+" "+commonsMultipartFile.getOriginalFilename();
								duplicateDocIds.add(auditDocumentDetail.getId());
							}*/
							
						}							
					}else if(("del").equalsIgnoreCase(warningCheck) && listAuditDocumentDetails!=null && listAuditDocumentDetails.size()>0){
						/*for (AuditDocumentDetails auditDocumentDetail : listAuditDocumentDetails) {			                    
								docUploadDownloadService.deleteDocumentById(legalEntityCode, auditDocumentDetail.getId(), status);							 								
						}*/
						for (AuditDocumentDetails auditDocumentDetail : listAuditDocumentDetails) {			                  
							if(auditDocumentDetail.getFileName().contains(commonsMultipartFile.getOriginalFilename())){									
								docUploadDownloadService.deleteDocumentById(legalEntityCode, auditDocumentDetail.getId(), entityStatus);	
							}
							/*else if(auditDocumentDetail.getDocumentName().contains("Board Resolution")){
								docUploadDownloadService.deleteDocumentById(legalEntityCode, auditDocumentDetail.getId(), entityStatus);	
							}*/							
						}
					}			
					
				}
				
				if(isWarning){
					serviceStatus.setStatus("warning");
				    serviceStatus.setMessage("file " + duplicateFileNames + "  already exist do you want to replace  ");
				    serviceStatus.setResult(duplicateDocIds);
				    return serviceStatus;
				}
				
				//result.put("documentUploadId", auditObservationService.uploadDocument(maker,role,files,fileName));
				AuditDocumentDetails auditDocumentDetails =  new AuditDocumentDetails();
				auditDocumentDetails.setLegalEntityCode(legalEntityCode);
				auditDocumentDetails.setAuditTypeCode(auditTypeCode);
				auditDocumentDetails.setPlanId(planId);
				auditDocumentDetails.setAuditId(auditId);
				auditDocumentDetails.setDocumentType(documentType);
				auditDocumentDetails.setEntityStatus(entityStatus);
				auditDocumentDetails.setObservationId(observationId);
				auditDocumentDetails.setMaker(maker);
				auditDocumentDetails.setChecker(checker);
				auditDocumentDetails.setStatus(BankAuditConstant.STATUS_ACTIVE);			
				auditDocumentDetails.setSysdateTimestamp(new Timestamp(System.currentTimeMillis()));
				auditDocumentDetails.setMakerTimestamp(new Timestamp(System.currentTimeMillis()));
				auditDocumentDetails.setRole(role);
				auditDocumentDetails.setDocumentName(documentName);
				auditDocumentDetails.setDocumentSubType(documentSubType); 
				result.put("documentUploadId", docUploadDownloadService.uploadDocument(auditDocumentDetails, files, fileName));
				
				serviceStatus.setResult(result);
				serviceStatus.setStatus("success");
				serviceStatus.setMessage("successfully uploaded");
			}else {
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("Invalid payload");
			}
			
		} catch (Exception e) {
			e.printStackTrace(System.out); // logger.error(e.getStackTrace());
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("failure");
		}
		return serviceStatus;
	}
	
	
@RequestMapping(value="/deleteDocumentById" ,method=RequestMethod.DELETE,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus  deleteDocumentById(				 
			@RequestParam(value="id",required=true)Integer documentId,
			@RequestParam(value="legalEntityCode",required=true)Integer legalEntityCode,
			@RequestParam(value="status",required=true)String status)  {
		ServiceStatus serviceStatus=new ServiceStatus();
		
		if(documentId != null && documentId>0){
			try{
			   String statusMsg =	docUploadDownloadService.deleteDocumentById(legalEntityCode, documentId, status);
				if(statusMsg.equals(BankAuditConstant.SUCCESS)){
					serviceStatus.setStatus("success");
					serviceStatus.setMessage("successfully deleted the selected document");
				}else{
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("failed to delete the selected document");
				}
			}catch (Exception e) {
				logger.error(e.getStackTrace());
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("failure");
			}
		}else{
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("missing parameter value document id");
		} 			
		
		return serviceStatus;
	}
	
	
@RequestMapping(value="/deleteAllDocumentBy" ,method=RequestMethod.DELETE, produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus deleteAllDocumentBy(
			@RequestParam(value="legalEntityCode")Integer legalEntityCode,
			@RequestParam(value="auditTypeCode")String auditTypeCode,
			@RequestParam(value="planId")String planId,
			@RequestParam(value="auditId")String auditId,
			@RequestParam(required=false,value="observationId")String observationId,
			@RequestParam(value="documentType")String documentType,
			@RequestParam(value="documentSubType")String documentSubType
			){
	
		ServiceStatus serviceStatus=new ServiceStatus();
		
		try {			
			String status = docUploadDownloadService.deleteAllDocumentBy(legalEntityCode, auditTypeCode, planId, auditId, observationId, documentType, documentSubType);
			
			if(status.equals(BankAuditConstant.SUCCESS)){
				serviceStatus.setStatus("success");
				serviceStatus.setMessage("successfully deleted all the documents");
			}else{
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("failed to delete  documents");
			}
			
		} catch (Exception e) {
			logger.error(e.getStackTrace());
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("failure");
		}
		return serviceStatus;
	}
	
	/*
@RequestMapping(value="/uploadAuditDocumentCompliance" ,method=RequestMethod.POST,consumes=MediaType.MULTIPART_FORM_DATA_VALUE,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus  uploadAuditDocumentCompliance(
			@RequestParam(value="maker")String maker,
			@RequestParam(value="role")String role,
			@RequestParam(value="files")CommonsMultipartFile[] files,
			@RequestParam(value="legalEntityCode")Integer legalEntityCode,
			@RequestParam(value="auditTypeCode")String auditTypeCode,
			@RequestParam(value="planId")String planId,
			@RequestParam(value="auditId")String auditId,
			@RequestParam(value="documentType")String documentType,
			@RequestParam(required=false,value="observationId")String observationId,
			@RequestParam(required=false,value="checker")String checker,
			@RequestParam(required=false,value="warningCheck")String warningCheck,
			@RequestParam(required=false,value="entityStatus")String entityStatus,
			@RequestParam(value="documentName")String  documentName,
			@RequestParam(value="documentSubType", required=false)String documentSubType)  {
		
		ServiceStatus serviceStatus=new ServiceStatus();
		Map<String, Object> result=new HashMap<>();
		try {
			if(files!=null && auditId!=null){					
				
				List<AuditDocumentDetails> listAuditDocumentDetails=docUploadDownloadService.getAuditDocumentDetailCompliance(legalEntityCode, auditTypeCode,
						planId, auditId, observationId, documentType, documentName, documentSubType);					
							 
				result.put("observationId",observationId);  			
				String uploadfileName=(legalEntityCode.toString()+auditTypeCode+planId+auditId+role+documentType+documentName).replaceAll(" ", "");
				
				Boolean isWarning=false;
				String duplicateFileNames="";
				List<Integer> duplicateDocIds=new ArrayList<>(); 
						
				for (CommonsMultipartFile commonsMultipartFile : files) {
					
					if(!BankAuditUtil.validateFileType(commonsMultipartFile, BankAuditConstant.DOC_TYPES)){
						serviceStatus.setStatus("failure");
						serviceStatus.setMessage("file type : "+BankAuditUtil.getFileExtension(commonsMultipartFile.getOriginalFilename()) +" not supported");
						return serviceStatus;
					}
					
					if(warningCheck.equalsIgnoreCase("yes") && listAuditDocumentDetails!=null){							
						for (AuditDocumentDetails auditDocumentDetail : listAuditDocumentDetails) {			                  
							//if(auditDocumentDetail.getReferencePath().contains(uploadfileName+"_"+commonsMultipartFile.getOriginalFilename())){									
								isWarning=true;
								duplicateFileNames=duplicateFileNames+" "+commonsMultipartFile.getOriginalFilename();
								duplicateDocIds.add(auditDocumentDetail.getId());
							//}								
						}							
					}else if(warningCheck.equalsIgnoreCase("no") && listAuditDocumentDetails!=null){
						for (AuditDocumentDetails auditDocumentDetail : listAuditDocumentDetails) {			                    
								docUploadDownloadService.deleteDocumentById(auditDocumentDetail.getId());							 								
						}
					}						
				}
				
				if(isWarning){
					serviceStatus.setStatus("warning");
				    serviceStatus.setMessage("file " + duplicateFileNames + "  already exist do you want to replace  ");
				    serviceStatus.setResult(duplicateDocIds);
				    return serviceStatus;
				}
				
				//result.put("documentUploadId", auditObservationService.uploadDocument(maker,role,files,fileName));
				AuditDocumentDetails auditDocumentDetails =  new AuditDocumentDetails();
				auditDocumentDetails.setLegalEntityCode(legalEntityCode);
				auditDocumentDetails.setAuditTypeCode(auditTypeCode);
				auditDocumentDetails.setPlanId(planId);
				auditDocumentDetails.setAuditId(auditId);
				auditDocumentDetails.setDocumentType(documentType);
				auditDocumentDetails.setEntityStatus(entityStatus);
				auditDocumentDetails.setObservationId(observationId);
				auditDocumentDetails.setMaker(maker);
				auditDocumentDetails.setChecker(checker);
				auditDocumentDetails.setStatus(BankAuditConstant.STATUS_ACTIVE);			
				auditDocumentDetails.setSysdateTimestamp(new Timestamp(System.currentTimeMillis()));
				auditDocumentDetails.setMakerTimestamp(new Timestamp(System.currentTimeMillis()));
				auditDocumentDetails.setRole(role);
				auditDocumentDetails.setDocumentName(documentName);				 
				result.put("documentUploadId", docUploadDownloadService.uploadDocument(auditDocumentDetails, files, uploadfileName));
				
				serviceStatus.setResult(result);
				serviceStatus.setStatus("success");
				serviceStatus.setMessage("successfully uploaded");
			}else {
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("Invalid payload");
			}
			
		} catch (Exception e) {
			logger.error(e.getStackTrace());
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("failure");
		}
		return serviceStatus;
	}*/
	
	
@RequestMapping(value="/downloadAuditDocument",method = RequestMethod.GET)
    public void  downloadAuditDocument(
    		@RequestParam(value="id",required=true)Integer id,
    		@RequestParam(value="legalEntityCode",required=true)Integer legalEntityCode,
    		@RequestParam(value="status",required=true)String status,
    		@RequestParam(value="auditId",required=false)String auditId, 
    		HttpServletRequest request,
            HttpServletResponse response) throws IOException {    	
    	
    	ServletContext context=request.getServletContext();
    	String filePath =docUploadDownloadService.getReferencePathById(legalEntityCode, id, status, auditId);
    	logger.info("file path .."+filePath);
    	try {
    		if(!BankAuditUtil.isEmptyString(filePath)){
		    		File file=new File(filePath);
		    		if(file.isFile()){
		    			
		    			 int BUFFER_SIZE = 4096;
		    			 FileInputStream inputStream = new FileInputStream(file);

		    			 String mimeType = context.getMimeType(filePath); // get MIME type of the file
		                 
		                 if (mimeType == null) {
		                     mimeType = "application/octet-stream"; // set to binary type if MIME mapping not found
		                 }
		              
		                 // set content attributes for the response
		                 response.setContentType(mimeType);
		                 response.setContentLength((int) file.length());
		          
		                 // set headers for the response
		                 String headerKey = "Content-Disposition";
		                 String headerValue = String.format("attachment; filename=\"%s\"",file.getName());
		                 response.setHeader(headerKey, headerValue);
		          
		                 // get output stream of the response
		                 OutputStream outStream = response.getOutputStream();
		          
		                 byte[] buffer = new byte[BUFFER_SIZE];
		                 int bytesRead = -1;
		          
		                 // write bytes read from the input stream into the output stream
		                 while ((bytesRead = inputStream.read(buffer)) != -1) {
		                     outStream.write(buffer, 0, bytesRead);
		                 }
		                 inputStream.close();
		                 outStream.close();                  
		        	}else {
		    			 response.getWriter().print("Document not exist");
					}
		    }else {
   			 response.getWriter().print("Document not exist");
			}
    	}catch(Exception e) {
    		e.printStackTrace(System.out);
    	}
   	}
	
	//public AuditDocumentDetails getAuditTypeDocumentDetailById(Integer legalEntityCode, Integer Id, String status)
	
	
@RequestMapping(value="/getAuditTypeDocumentDetailById",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus getAuditTypeDocumentDetailById(
		@RequestParam(value="id",required=true)Integer id,
		@RequestParam(value="legalEntityCode",required=true)Integer legalEntityCode,
		@RequestParam(value="status",required=true)String status){
		
			ServiceStatus serviceStatus=new ServiceStatus();
			if(legalEntityCode!=null && id!=null){
			
				try {
				    AuditDocumentDetails auditTypeDocumentDetails=docUploadDownloadService.getAuditTypeDocumentDetailById(legalEntityCode,id, status);
				    if(auditTypeDocumentDetails!=null){
				    	serviceStatus.setResult(auditTypeDocumentDetails);
					    serviceStatus.setStatus("success");
					    serviceStatus.setMessage("successfully retrieved ");	
				    }else {
						serviceStatus.setStatus("failure");
						serviceStatus.setMessage("maintAuditActivity not found");
					}
					
				} catch (Exception e) {
					e.printStackTrace();
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("failure");
				}
				
			}else {
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("invalid payload ");
			}
		
		return serviceStatus;
	}
	
	
@RequestMapping(value="/getCountOfDocuments" ,method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus getCountOfDocuments(
			@RequestParam(value="legalEntityCode")Integer legalEntityCode,
			@RequestParam(value="auditTypeCode")String auditTypeCode,
			@RequestParam(value="planId" , required=false)String planId,
			@RequestParam(value="auditId", required=false)String auditId,
			@RequestParam(value="observationId", required=false)String observationId,
			@RequestParam(value="documentType", required=false)String documentType,
			@RequestParam(value="documentSubType", required=false)String documentSubType,
			@RequestParam(value="status")String  status,
			@RequestParam(required=false,value="documentName")String  documentName
			){
	
		ServiceStatus serviceStatus=new ServiceStatus();		
		try {			
			String countOfDocuments=docUploadDownloadService.getCountOfDocuments(legalEntityCode, auditTypeCode, planId,
					auditId, observationId, documentType, documentSubType, status, documentName);
			if(!countOfDocuments.equalsIgnoreCase(BankAuditConstant.FAILED)){
				serviceStatus.setResult(countOfDocuments);
				serviceStatus.setStatus("success");
				serviceStatus.setMessage("successfully got the result ");				
			}else {
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("failure");
			}
			
		} catch (Exception e) {
			logger.error(e.getStackTrace());
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("failure");
		}
		return serviceStatus;
	}
	
	
@RequestMapping(value="/submitObservationDocuments" ,method=RequestMethod.PUT, produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus  submitObservationDocuments( 			
			@RequestParam(value="legalEntityCode")Integer legalEntityCode,
			@RequestParam(value="auditTypeCode")String auditTypeCode,
			@RequestParam(value="planId")String planId,
			@RequestParam(value="auditId")String auditId,
			@RequestParam(value="role")String role, 
			@RequestParam(value="documentType")String documentType,
			@RequestParam(value="documentSubType")String documentSubType,
			@RequestParam(required=false, value="observationId")String observationId )  {
		
		ServiceStatus serviceStatus=new ServiceStatus(); 
		try { 
			String status = docUploadDownloadService.submitObservationDocuments(legalEntityCode, auditTypeCode, planId, auditId, role,
					documentType, documentSubType, observationId);
			if(status.equals(BankAuditConstant.SUCCESS)){
				serviceStatus.setStatus("success");
				serviceStatus.setMessage("successfully submitted documents");
			}else{
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("failed to submit documents");
			}
			
		} catch (Exception e) {
			logger.error(e.getStackTrace());
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("failure");
		}
		return serviceStatus;
	}
	
	
	/*
@RequestMapping(value="/getAuditDocumentDetailCompliance" ,method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus getAuditDocumentDetailCompliance(
			@RequestParam(value="legalEntityCode")Integer legalEntityCode,
			@RequestParam(value="auditTypeCode")String auditTypeCode,
			@RequestParam(value="planId")String planId,
			@RequestParam(value="auditId")String auditId,
			@RequestParam(value="observationId", required=false) String observationId,
			@RequestParam(value="documentType")String documentType,
			@RequestParam(value="documentName")String  documentName,
			@RequestParam(value="documentSubType", required=false) String documentSubType
			){
	
		ServiceStatus serviceStatus=new ServiceStatus();
		
		try { 
			
			List<AuditDocumentDetails> listAuditDocumentDetails=docUploadDownloadService.getAuditDocumentDetailCompliance(legalEntityCode, auditTypeCode, 
					planId, auditId, observationId, documentType, documentName, documentSubType);		
			
			if(listAuditDocumentDetails!=null && !listAuditDocumentDetails.isEmpty()){
				serviceStatus.setResult(listAuditDocumentDetails);
				serviceStatus.setStatus("success");
				serviceStatus.setMessage("successfully got the result ");				
			}else {
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("No docs found ");
			}
			
		} catch (Exception e) {
			logger.error(e.getStackTrace());
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("failure");
		}
		return serviceStatus;
	}*/
	 
}
