Example usage for java.io FileNotFoundException getMessage

List of usage examples for java.io FileNotFoundException getMessage

Introduction

In this page you can find the example usage for java.io FileNotFoundException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.polyvi.xface.extension.advancedfiletransfer.XAdvancedFileTransferExt.java

@Override
public XExtensionResult exec(String action, JSONArray args, XCallbackContext callbackCtx) throws JSONException {
    String source = null;/*from ww w.  j a  va  2  s  .  c o  m*/
    String target = null;
    String appId = mWebContext.getApplication().getAppId();
    try {
        if (action.equals(COMMAND_DOWNLOAD)) {
            source = args.getString(0);
            target = args.getString(1);
            download(mWebContext, source, target, callbackCtx);
            XLog.d(CLASS_NAME, "*** About to return a result from download");
            return new XExtensionResult(XExtensionResult.Status.NO_RESULT);
        } else if (action.equals(COMMAND_UPLOAD)) {
            source = args.getString(0);
            target = args.getString(1);
            upload(mWebContext, source, target, callbackCtx);
            XLog.d(CLASS_NAME, "*** About to return a result from upload");
            return new XExtensionResult(XExtensionResult.Status.NO_RESULT);
        } else if (action.equals(COMMAND_PAUSE)) {
            source = args.getString(0);
            mFileTransferManager.pause(appId, source);
            return new XExtensionResult(XExtensionResult.Status.OK);
        } else if (action.equals(COMMAND_CANCEL)) {
            source = args.getString(0);
            target = args.getString(1);
            boolean isUpload = args.getBoolean(2);
            if (isUpload) {
                mFileTransferManager.cancel(appId, source, null, COMMAND_UPLOAD);
            } else {
                target = new File(mWebContext.getWorkSpace(), target).getAbsolutePath();
                mFileTransferManager.cancel(mWebContext.getApplication().getAppId(), source, target,
                        COMMAND_DOWNLOAD);
            }
            return new XExtensionResult(XExtensionResult.Status.OK);
        }

    } catch (FileNotFoundException e) {
        XLog.e(CLASS_NAME, e.getMessage());
        JSONObject error = createFileTransferError(FILE_NOT_FOUND_ERR, source, target);
        return new XExtensionResult(XExtensionResult.Status.ERROR, error);
    } catch (IllegalArgumentException e) {
        XLog.e(CLASS_NAME, e.getMessage());
        JSONObject error = createFileTransferError(INVALID_URL_ERR, source, target);
        return new XExtensionResult(XExtensionResult.Status.ERROR, error);
    } catch (IOException e) {
        XLog.e(CLASS_NAME, e.getMessage());
        JSONObject error = createFileTransferError(CONNECTION_ERR, source, target);
        return new XExtensionResult(XExtensionResult.Status.ERROR, error);
    } catch (JSONException e) {
        XLog.e(CLASS_NAME, e.getMessage(), e);
        return new XExtensionResult(XExtensionResult.Status.JSON_EXCEPTION);
    }
    return new XExtensionResult(XExtensionResult.Status.INVALID_ACTION);
}

From source file:com.aleerant.tnssync.PropertiesHandler.java

private void getLdapOraProperties() throws AppException {
    String ldaporaFile = Paths.get(mTnsAdminPathString, APP_LDAPORA_FILENAME).toString();
    Properties ldapOraProperties = new Properties();
    try {/*  ww w .  ja  v a2  s. com*/
        ldapOraProperties.load(new FileInputStream(ldaporaFile));
    } catch (FileNotFoundException e) {
        throw new AppException(APP_LDAPORA_FILENAME + " file is missing (" + ldaporaFile + "), error message: "
                + e.getMessage() + ", caused by:" + e.getCause());
    } catch (IOException e) {
        throw new AppException("can not read " + APP_LDAPORA_FILENAME + " file (" + ldaporaFile
                + "), error message: " + e.getMessage() + ", caused by:" + e.getCause());
    }

    this.mDefaultAdminContext = ldapOraProperties.getProperty("DEFAULT_ADMIN_CONTEXT").replaceAll("[()\\s]",
            "");
    if (this.mDefaultAdminContext == null) {
        throw new IllegalArgumentException("Missing parameter: DEFAULT_ADMIN_CONTEXT");
    }
    this.mDirectoryServers = ldapOraProperties.getProperty("DIRECTORY_SERVERS", "").replaceAll("[()\\s]", "");
}

From source file:info.magnolia.filesystembrowser.app.contentconnector.FileContentProperty.java

private byte[] getBytes(File file) {
    if (file.exists()) {
        FileInputStream fis = null;
        try {//from   ww  w .j  av  a2s  .  c  o  m
            fis = new FileInputStream(file);
            return IOUtils.toByteArray(fis);
        } catch (FileNotFoundException e) {
            log.error("File not {1} found: ", file.getPath());
        } catch (IOException e) {
            log.error("I/O issue {1} encountered: ", e.getMessage());
        } finally {
            IOUtils.closeQuietly(fis);
        }
    }
    return new byte[0];
}

From source file:info.magnolia.filesystembrowser.app.contentconnector.FileContentProperty.java

@Override
public void commit() {
    if (transactionInitialized) {
        FileOutputStream fos = null;
        try {/*w  ww.  ja  v a  2s.  c  om*/
            fos = new FileOutputStream(file);
            fos.write(getValue());
        } catch (FileNotFoundException e) {
            log.error("File not {1} found: ", file.getPath());
        } catch (IOException e) {
            log.error("I/O issue {1} encountered: ", e.getMessage());
        } finally {
            IOUtils.closeQuietly(fos);
            startTransaction();
        }
    }
}

From source file:info.magnolia.filesystembrowser.app.contentconnector.FileContentProperty.java

@Override
public void rollback() {
    FileOutputStream fos = null;//from w w w.jav  a 2 s  .  co  m
    if (transactionInitialized) {
        try {
            fos = new FileOutputStream(file);
            fos.write(bufferedValue);
        } catch (FileNotFoundException e) {
            log.error("File not {1} found: ", file.getPath());
        } catch (IOException e) {
            log.error("I/O issue {1} encountered: ", e.getMessage());
        } finally {
            IOUtils.closeQuietly(fos);
            startTransaction();
        }
    }
}

From source file:com.impetus.ankush.agent.action.impl.YAMLManipulator.java

/**
 * Edits the conf value./*from ww  w  . j ava2s  . c  om*/
 * 
 * @param file
 *            the file
 * @param propertyName
 *            the property name
 * @param newPropertyValue
 *            the new property value
 * @return true, if successful
 */
public boolean editConfValue(String file, String propertyName, String newPropertyValue) {

    boolean isInteger = checkNumber((String) newPropertyValue);
    boolean isBoolean = false;

    if (String.valueOf(newPropertyValue).equalsIgnoreCase("true")
            || String.valueOf(newPropertyValue).equalsIgnoreCase("false")) {
        isBoolean = true;
    }

    List<Object> newPropertyValueList = new ArrayList<Object>();
    if (String.valueOf(newPropertyValue).contains(",")) {
        List<Object> list = new ArrayList<Object>(Arrays.asList(String.valueOf(newPropertyValue).split(",")));
        for (Object val : list) {
            if (isInteger) {
                newPropertyValueList.add(Integer.valueOf((String) val));
            } else if (isBoolean) {
                newPropertyValueList.add(Boolean.valueOf((String) val));
            } else {
                newPropertyValueList.add((String) val);
            }
        }
    } else {
        if (isInteger) {
            newPropertyValueList.add(Integer.valueOf((String) newPropertyValue));
        } else if (isBoolean) {
            newPropertyValueList.add(Boolean.valueOf((String) newPropertyValue));
        } else {
            newPropertyValueList.add((String) newPropertyValue);
        }
    }

    Yaml yaml = new Yaml();
    try {
        InputStream fis = new FileInputStream(file);
        Object javaObject = yaml.load(fis);
        Map<Object, Object> map = (Map<Object, Object>) javaObject;

        Object propertyValue = new Object();

        if (newPropertyValueList.size() > 1) {
            propertyValue = (List<Object>) newPropertyValueList;
        } else {
            propertyValue = newPropertyValueList.get(0);
        }

        map.put(propertyName, propertyValue);
        fis.close();
        // save to file
        File confFile = new File(file);
        if (!confFile.exists()) {
            System.err.println("File " + file + " does not exists.");
        }

        String dumped = yaml.dumpAsMap(map);
        FileUtils.writeStringToFile(confFile, dumped, false);

        return true;

    } catch (FileNotFoundException e) {
        System.err.println(e.getMessage());
    } catch (IOException e) {
        System.err.println(e.getMessage());
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    return false;
}

From source file:com.jtk.medicalrecord.view.panel.InputMedrecPemeriksaanpendukung.java

private void btnTambahActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTambahActionPerformed
    if (view) {/* w  w w.j av  a2 s.co  m*/
        download();
    } else {
        JFileChooser fileChooser = new JFileChooser();
        int result = fileChooser.showOpenDialog(null);
        if (result == JFileChooser.APPROVE_OPTION) {
            String url = fileChooser.getSelectedFile().getAbsolutePath();
            try {
                InputStream is = new FileInputStream(new File(url));
                String tipeFile = FilenameUtils.getExtension(url);
                String namaFile = FilenameUtils.getBaseName(url);

                PemeriksaanPendukung pp = new PemeriksaanPendukung();
                pp.setPemId(UUID.randomUUID().toString().replace("-", ""));
                pp.setPemNmFile(namaFile);
                pp.setPemTipeFile(tipeFile);
                pp.setPemFile(IOUtils.toByteArray(is));

                pemeriksaanPendukungs.add(pp);

                createTableValue();
            } catch (FileNotFoundException ex) {
                MessageHelper.addErrorMessage("Error add file", ex.getMessage());
                Logger.getLogger(InputMedrecPemeriksaanpendukung.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                MessageHelper.addErrorMessage("Error add file", ex.getMessage());
                Logger.getLogger(InputMedrecPemeriksaanpendukung.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
}

From source file:org.ambraproject.user.action.ImportUsersUploadAction.java

@Override
public String execute() {
    Map<String, Object> session = ServletActionContext.getContext().getSession();

    try {//w  w  w  .j av a2s . co  m
        users = parseCSV();

        log.debug("Parsed {} records", users.size());

        for (ImportedUserView importUserView : users) {
            //Confirm items in list are valid
            ImportedUserView.USER_STATES state = ImportedUserView.USER_STATES.VALID;

            //Confirm email is not already in the database
            if (searchUserService.isEmailInUse(importUserView.getEmail())) {
                state = ImportedUserView.USER_STATES.DUPE_EMAIL;
            }

            //Confirm display name is not already in the database
            if (searchUserService.isDisplayNameInUse(importUserView.getDisplayName())) {
                state = ImportedUserView.USER_STATES.DUPE_DISPLAYNAME;
            }

            //Confirm display and email are unique for the given set
            for (ImportedUserView importUserView2 : users) {
                if (importUserView2.hashCode() != importUserView.hashCode()) {
                    if (importUserView2.getEmail().equals(importUserView.getEmail())) {
                        state = ImportedUserView.USER_STATES.DUPE_EMAIL;
                    }

                    if (importUserView2.getDisplayName().equals(importUserView.getDisplayName())) {
                        state = ImportedUserView.USER_STATES.DUPE_DISPLAYNAME;
                    }
                }
            }

            importUserView.setState(state);
        }

        Collections.sort(users);

        session.put(IMPORT_USER_LIST, users);
    } catch (FileNotFoundException ex) {
        log.error(ex.getMessage(), ex);
        addActionError(ex.getMessage());
        return INPUT;
    } catch (ArrayIndexOutOfBoundsException ex) {
        log.error(ex.getMessage(), ex);
        addActionError("Bad CSV received, wrong number of columns");
        return INPUT;
    } catch (UserProfileParserException ex) {
        log.error(ex.getMessage(), ex);
        addActionError(ex.getMessage());
        return INPUT;
    } catch (IOException ex) {
        log.error(ex.getMessage(), ex);
        addActionError(ex.getMessage());
        return ERROR;
    }

    return SUCCESS;
}

From source file:de.intranda.goobi.plugins.utils.ModsUtils.java

/**
 * Writes the given JDOM document into a file.
 * /*from  w w  w. ja v a  2  s  .  c o  m*/
 * @param folderName Folder in which to write the destination file.
 * @param fileName Name of the destination file.
 * @param doc JDOM document containing the data.
 * @throws FileNotFoundException
 * @throws IOException
 */
public static void writeXmlToFile(String folderName, String fileName, Document doc) {
    try {
        File folder = new File(folderName);
        if (!folder.exists()) {
            folder.mkdirs();
        }
        new XMLOutputter().output(doc,
                new FileOutputStream(folder.getAbsolutePath() + File.separator + fileName));
    } catch (FileNotFoundException e) {
        logger.error(e.getMessage());
    } catch (IOException e) {
        logger.error(e.getMessage());
    }
}

From source file:com.twitter.ambrose.model.hadoop.MapReduceHelper.java

/**
 * Get the configurations at the beginning of the job flow, it will contain information
 * about the map/reduce plan and decoded pig script.
 * @param runningJob//  w  w w  . j  a  v  a 2 s . co  m
 * @return Properties - configuration properties of the job
 */
public void setJobConfFromFile(MapReduceJob job, JobClient jobClient) {
    Properties jobConfProperties = new Properties();
    try {
        RunningJob runningJob = jobClient.getJob(JobID.forName(job.getId()));
        if (runningJob == null) {
            log.warn("Couldn't find job status for jobId: " + job.getId());
        }

        log.info("RunningJob Configuration File location: " + runningJob.getJobFile());
        Path path = new Path(runningJob.getJobFile());

        Configuration conf = new Configuration(false);
        FileSystem fileSystem = FileSystem.get(new Configuration());
        InputStream inputStream = fileSystem.open(path);
        conf.addResource(inputStream);

        Iterator<Map.Entry<String, String>> iter = conf.iterator();
        while (iter.hasNext()) {
            Map.Entry<String, String> entry = iter.next();
            jobConfProperties.put(entry.getKey(), entry.getValue());
        }
    } catch (FileNotFoundException e) {
        log.warn("Configuration file not found for old jobsflows.");
    } catch (Exception e) {
        log.warn("Error occurred when retrieving configuration info." + e.getMessage());
    }
    job.setConfiguration(jobConfProperties);
}