Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 上载文件未存储_Java_Oracle - Fatal编程技术网

Java 上载文件未存储

Java 上载文件未存储,java,oracle,Java,Oracle,我试图存储在后端的文件不是有效的目录。。我认为代码有一个Unix目录配置,我需要更改它才能在您的windows中工作。 如何识别文件试图存储的目录。 我得到以下错误 [com.keenan.oacommon.forms.services.FormServiceImpl] [checkFileDtlPathCreateIfNotExists] - strFileMstPath is not valid [INFO ] [java.lang.Class] [processListFiles] -

我试图存储在后端的文件不是有效的目录。。我认为代码有一个Unix目录配置,我需要更改它才能在您的windows中工作。 如何识别文件试图存储的目录。 我得到以下错误

[com.keenan.oacommon.forms.services.FormServiceImpl] [checkFileDtlPathCreateIfNotExists]  - strFileMstPath is not valid
[INFO ] [java.lang.Class] [processListFiles]  - strFinalUploadPath []
[INFO ] [com.keenan.oacommon.forms.services.FormServiceImpl] [verifyFilePath]  - Validating path []
[ERROR] [com.keenan.oacommon.forms.services.FormServiceImpl] [verifyFilePath]  - strFilePath is NULL
[ERROR] [java.lang.Class] [processListFiles]  - File upload path is not valid
这是我的java代码

@Override
public boolean verifyFilePath(String inFilePath) {
    boolean isFilePathValid = false;
    String strFilePath = inFilePath;

    logger.info("Validating path [" + strFilePath + "]");

    if (strFilePath == null || strFilePath.equalsIgnoreCase("")) {
        logger.error("strFilePath is NULL");
        isFilePathValid = false;
    } else {
        try {
            File fileUploadDir = new File(strFilePath);
            if (fileUploadDir.exists() && fileUploadDir.isDirectory()) {
                logger.error("File Path [" + strFilePath + "] is good");
                isFilePathValid = true;
            } else {
                logger.warn("File Path [" + strFilePath + "] is not valid");
                isFilePathValid = false;
            }
        } catch (Exception e) {
            isFilePathValid = false;
            logger.error("Exception while validating File Path [" + strFilePath + "] - " + e.getMessage(), e);
        }
    }

    return isFilePathValid;
}

@Override
public String checkFileDtlPathCreateIfNotExists(String inFilePath, String inAppSeqNo, String inUploadSeqNo) {
    boolean isFilePathValid = false;
    /* Main directory (all file uploads) */
    String strFileMstPath = null;
    File fileUploadMstDir = null;
    /* Sub directory (file uploads per application) */
    String strFileDtlAppPath = null;
    File fileUploadDtlAppDir = null;
    /* Sub-sub directory (file uploads per upload request) */
    String strFileDtlAppUploadPath = null;
    File fileUploadDtlAppUploadDir = null;

    boolean fileDirExists = false;
    String strFinalReturnPath = null;

    if (inFilePath == null || inFilePath.equalsIgnoreCase("")) {
        logger.error("inFilePath is NULL");
        isFilePathValid = false;
    } else {
        try {
            if (!inFilePath.endsWith("/"))
                strFileMstPath = inFilePath + "/";
            else
                strFileMstPath = inFilePath;

            fileUploadMstDir = new File(strFileMstPath);

            if (fileUploadMstDir.exists() && fileUploadMstDir.isDirectory()) {
                logger.error("strFileMstPath is good");

                strFileDtlAppPath = strFileMstPath + inAppSeqNo + "/";
                fileUploadDtlAppDir = new File(strFileDtlAppPath);
                if (fileUploadDtlAppDir.exists() && fileUploadDtlAppDir.isDirectory()) {
                    fileDirExists = true;
                    logger.debug("fileUploadDtlAppDir [" + fileUploadDtlAppDir.toString() + "] exists and is a dir");
                } else {
                    fileDirExists = fileUploadDtlAppDir.mkdir();
                }

                if (fileDirExists) {
                    /* Set fileDirExists to false for the next check */
                    fileDirExists = false;

                    strFileDtlAppUploadPath = strFileDtlAppPath + inUploadSeqNo + "/";
                    fileUploadDtlAppUploadDir = new File(strFileDtlAppUploadPath);

                    if (fileUploadDtlAppUploadDir.exists() && fileUploadDtlAppUploadDir.isDirectory()) {
                        fileDirExists = true;
                        logger.debug("fileUploadDtlAppUploadDir [" + fileUploadDtlAppUploadDir.toString()
                                + "] exists and is a dir");
                    } else {
                        fileDirExists = fileUploadDtlAppUploadDir.mkdir();
                    }

                    strFinalReturnPath = strFileDtlAppUploadPath;
                } else
                    logger.error("Could not create strFileDtlAppPath [" + strFileDtlAppPath
                            + "] - not attempting to create strFileDtlAppUploadPath [" + strFileDtlAppUploadPath + "]");

                if (fileDirExists)
                    isFilePathValid = true;
                else
                    isFilePathValid = false;
            } else {
                logger.info("strFileMstPath is not valid");
                isFilePathValid = false;
            }
        } catch (Exception e) {
            isFilePathValid = false;
            logger.error("Exception while validating filePath - " + e.getMessage(), e);
        }
    }

    if (isFilePathValid)
        return strFinalReturnPath;
    else
        return "";
}

@Override
@Transactional(readOnly = true)
public FileUpload getUploadedFileBySeqNo(int inFileSeqNo) {
    FileUpload fileUploadInstance = null;
    try {
        logger.debug("Fetching FileUpload for inFileUploadSeqNo [" + inFileSeqNo + "]");
        fileUploadInstance = FormsHelper.getFormDAO().getUploadedFileDetailsBySeqNo(inFileSeqNo);
        logger.debug("FileUpload for inFileUploadSeqNo[" + inFileSeqNo + "] is [" + fileUploadInstance.toString() + "]");
    } catch (Exception e) {
        logger.error("Exceoption while fetching FileUpload for inFileUploadSeqNo [" + inFileSeqNo + "] - " + e.getMessage(), e);
        fileUploadInstance = null;
    }
    return fileUploadInstance;
}

@Override
@Transactional(readOnly = true)
public FileUpload getUploadedFileByName(String inFileName, String inUploadSeqNo, String inAppSeqNo) {
    FileUpload fileUploadInstance = null;
    int uploadSeqNo = 0;
    int appSeqNo = 0;

    try {
        uploadSeqNo = Integer.parseInt(inUploadSeqNo);
        appSeqNo = Integer.parseInt(inAppSeqNo);
        logger.debug("Fetching FileUpload for inFileName [" + inFileName + "]");
        fileUploadInstance = FormsHelper.getFormDAO().getUploadedFileDetailsByName(inFileName, uploadSeqNo, appSeqNo);
        logger.debug("FileUpload for inFileName [" + inFileName + "] is [" + fileUploadInstance.toString() + "]");
    } catch (Exception e) {
        logger.error("Exception while fetching FileUpload for inFileName [" + inFileName + "] - " + e.getMessage(), e);
        fileUploadInstance = null;
    }
    return fileUploadInstance;
}

@Override
@Transactional(readOnly = false)
public boolean saveUploadedFileInfo(FileUpload inFileUpload) {
    boolean fileUploadInfoSavedSuccessfully = false;
    try {
        if (inFileUpload == null) {
            logger.error("inFileUpload is NULL / Blank");
            fileUploadInfoSavedSuccessfully = false;
        } else {
            FormsHelper.getFormDAO().saveUploadedFileInfo(inFileUpload);
            fileUploadInfoSavedSuccessfully = true;
        }
    } catch (Exception e) {
        logger.error("Exception while saving FileUpload - " + e.getMessage(), e);
        fileUploadInfoSavedSuccessfully = false;
    }

    return fileUploadInfoSavedSuccessfully;
}

@Override
@Transactional(readOnly = true)
public List<FileUpload> getUploadedFilesList(int inUploadSeqNo) {
    List<FileUpload> uploadedFilesList = null;
    try {
        logger.debug("Fetching FileUpload for inFileUploadSeqNo [" + inUploadSeqNo + "]");
        uploadedFilesList = FormsHelper.getFormDAO().getUploadedFilesList(inUploadSeqNo);
        logger.debug("FileUpload for inUploadSeqNo [" + inUploadSeqNo + "]");
    } catch (Exception e) {
        logger.error("Exceoption while fetching FileUpload for inUploadSeqNo [" + inUploadSeqNo + "] - " + e.getMessage(), e);
        uploadedFilesList = null;
    }
    return uploadedFilesList;
}

@Override
public Map<String, String> getUserNUploadDetailsForMail(int appSeqNo, String emailAddress) {
    Map<String, String> details = new HashMap<String, String>();
    try {
        logger.debug("Fetching getUserNUploadDetailsForMail appSeqNo =[" + appSeqNo + "]" + "and emailAddress = [" + emailAddress
                + "]");
        details = FormsHelper.getFormDAO().getUserNUploadDetailsForMail(appSeqNo, emailAddress);
        logger.debug("Fetched details [" + details + "]");
    } catch (Exception e) {
        logger.error("Exceoption while fetching getUserNUploadDetailsForMail " + e.getMessage(), e);
    }
    return details;
}
@覆盖
公共布尔值验证文件路径(字符串填充路径){
布尔值isFilePathValid=false;
字符串strFilePath=inFilePath;
info(“验证路径[“+strFilePath+”]”);
if(strFilePath==null | | strFilePath.equalsIgnoreCase(“”){
logger.error(“strFilePath为NULL”);
isFilePathValid=false;
}否则{
试一试{
File fileUploadDir=新文件(strFilePath);
if(fileUploadDir.exists()&&fileUploadDir.isDirectory()){
logger.error(“文件路径[“+strFilePath+”]良好”);
isFilePathValid=true;
}否则{
logger.warn(“文件路径[“+strFilePath+”]无效”);
isFilePathValid=false;
}
}捕获(例外e){
isFilePathValid=false;
logger.error(“验证文件路径[“+strFilePath+”]-“+e.getMessage(),e时出现异常”);
}
}
返回isFilePathValid;
}
@凌驾
公共字符串checkFileDtlPathCreateIfNotExists(字符串inFilePath、字符串inAppSeqNo、字符串inUpLodSeqNo){
布尔值isFilePathValid=false;
/*主目录(所有文件上载)*/
字符串strFileMstPath=null;
文件fileUploadMstDir=null;
/*子目录(每个应用程序的文件上载)*/
字符串strfiledtlappath=null;
文件fileUploadDtlAppDir=null;
/*子目录(每个上载请求上载文件)*/
字符串strFileDtlAppUploadPath=null;
文件fileUploadDtlAppUploadDir=null;
布尔fileDirExists=false;
字符串strFinalReturnPath=null;
if(inFilePath==null | | inFilePath.equalsIgnoreCase(“”){
logger.error(“inFilePath为空”);
isFilePathValid=false;
}否则{
试一试{
如果(!inFilePath.endsWith(“/”))
strFileMstPath=填充路径+“/”;
其他的
strFileMstPath=填充路径;
fileUploadMstDir=新文件(strFileMstPath);
if(fileUploadMstDir.exists()&&fileUploadMstDir.isDirectory()){
logger.error(“strFileMstPath是好的”);
strfiledtlappath=strFileMstPath+inAppSeqNo+“/”;
fileUploadDtlAppDir=新文件(strfiledtlappath);
if(fileUploadDtlAppDir.exists()&&fileUploadDtlAppDir.isDirectory()){
fileDirExists=true;
debug(“fileUploadDtlAppDir[“+fileUploadDtlAppDir.toString()+”]存在并且是一个dir”);
}否则{
fileDirExists=fileUploadDtlAppDir.mkdir();
}
if(fileDirExists){
/*将fileDirExists设置为false以进行下一次检查*/
fileDirExists=false;
strfledtlappuploadpath=strfledtlappath+inUploadSeqNo+“/”;
fileUploadDtlAppUploadDir=新文件(strFileDtlAppUploadPath);
if(fileUploadDtlAppUploadDir.exists()&&fileUploadDtlAppUploadDir.isDirectory()){
fileDirExists=true;
debug(“fileUploadDtlAppUploadDir[”+fileUploadDtlAppUploadDir.toString()
+“]存在并且是目录”);
}否则{
fileDirExists=fileUploadDtlAppUploadDir.mkdir();
}
strFinalReturnPath=strFileDtlAppUploadPath;
}否则
logger.error(“无法创建strfiledtlappath[”+strfiledtlappath
+“]-未尝试创建strFileDtlAppUploadPath[“+strFileDtlAppUploadPath+”]”;
if(fileDirExists)
isFilePathValid=true;
其他的
isFilePathValid=false;
}否则{
logger.info(“strFileMstPath无效”);
isFilePathValid=false;
}
}捕获(例外e){
isFilePathValid=false;
logger.error(“验证文件路径时出现异常-”+e.getMessage(),e);
}
}
如果(isFilePathValid)
返回strFinalReturnPath;
其他的
返回“”;
}
@凌驾
@事务(只读=真)
公共文件上载getUploadedFileBySeqNo(int-inFileSeqNo){
FileUpload fileUploadInstance=null;
试一试{
debug(“为inFileUploadSeqNo[“+inFileSeqNo+”])获取文件上载;
fileUploadInstance=FormsHelper.getFormDAO().getUploadedFileDetailsBySeqNo(inFileSeqNo);
debug(“inFileUploadSeqNo[“+inFileSeqNo+”]的文件上载为[“+fileUploadInstance.toString()+”]”);
}捕获(例外e){
logger.error(“为inFileUploadSeqNo[“+inFileSeqNo+”]-“+e.getMessage(),e获取文件上载时出现异常选项”);
fileUploadInstance=null;
}
返回fileUploadInstance;
}
@凌驾
@事务(只读=真)
公共文件上载getUploadedFileByName(字符串inFileName、字符串inuploadesEqno、字符串inAppSeqNo){
FileUpload fileUploadInstance=null;
int uploadSeqNo=0;
int-appSeqNo=0;
试一试{
uploadSeqNo=Integer.parseInt(inUploadSeqNo);
appSeqNo=Integer.parseInt(inAppSeqNo);
debug(“获取inFileName[“+inFileName+”]”的文件上载”;
fileUploadInstance=FormsHelper.getFormDAO().getUploadedFileDetailsByName(inFileName、uploadSeqNo、appSeqNo);
debug(“inFileName[“+inFileName+”]的文件上载为[“+fileUploadInstance.toString()+”]);
}捕获(例外e){
记录器错误(“例外