Example usage for java.lang SecurityException getMessage

List of usage examples for java.lang SecurityException getMessage

Introduction

In this page you can find the example usage for java.lang SecurityException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.lmn.fc.common.datatranslators.DataExporter.java

/***********************************************************************************************
 * exportImage().//  w ww .  j  av  a  2  s . c  o  m
 *
 * @param image
 * @param filename
 * @param timestamp
 * @param type
 * @param log
 * @param clock
 *
 * @return boolean
 */

public static boolean exportImage(final Image image, final String filename, final boolean timestamp,
        final String type, final Vector<Vector> log, final ObservatoryClockInterface clock) {
    final String SOURCE = "DataExporter.exportImage()";
    boolean boolSuccess;

    boolSuccess = false;

    if ((image != null) && (image instanceof RenderedImage) && (filename != null)
            && (!EMPTY_STRING.equals(filename)) && (type != null) && (!EMPTY_STRING.equals(type))
            && (log != null) && (clock != null)
            && (Arrays.asList(ImageIO.getWriterFormatNames()).contains(type))) {
        try {
            final File file;

            file = new File(FileUtilities.buildFullFilename(filename, timestamp, type));
            FileUtilities.overwriteFile(file);

            // Support all current formats
            if ((FileUtilities.png.equalsIgnoreCase(type)) || (FileUtilities.jpg.equalsIgnoreCase(type))
                    || (FileUtilities.gif.equalsIgnoreCase(type))) {
                LOGGER.debugTimedEvent(LOADER_PROPERTIES.isTimingDebug(),
                        "DataExporter.exportImage() writing [file " + file.getAbsolutePath() + "]");
                // Export the image
                ImageIO.write((RenderedImage) image, type, file);
                boolSuccess = true;

                SimpleEventLogUIComponent
                        .logEvent(
                                log, EventStatus.INFO, METADATA_TARGET_IMAGE + METADATA_ACTION_EXPORT
                                        + METADATA_FILENAME + file.getAbsolutePath() + TERMINATOR,
                                SOURCE, clock);
            } else {
                SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL, METADATA_TARGET_IMAGE
                        + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_INVALID_FORMAT + TERMINATOR, SOURCE,
                        clock);
            }
        }

        catch (SecurityException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET_IMAGE + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_ACCESS_DENIED
                            + TERMINATOR + SPACE + METADATA_EXCEPTION + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }

        catch (FileNotFoundException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET_IMAGE + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_FILE_NOT_FOUND
                            + TERMINATOR + SPACE + METADATA_EXCEPTION + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }

        catch (IOException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET_IMAGE + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_FILE_SAVE
                            + TERMINATOR + SPACE + METADATA_EXCEPTION + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }
    } else {
        SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                METADATA_TARGET_IMAGE + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_IMAGE + TERMINATOR,
                SOURCE, clock);
    }

    return (boolSuccess);
}

From source file:org.lmn.fc.common.datatranslators.DataExporter.java

/***********************************************************************************************
 * exportChart()./*from   w  ww.jav  a 2  s .  c om*/
 * This variant uses a fully specified filename.
 *
 * @param dao
 * @param chartui
 * @param metadatalist
 * @param fullfilename
 * @param type
 * @param width
 * @param height
 * @param log
 * @param clock
 * @param verbose
 *
 * @return boolean
 */

public static boolean exportChartUsingFilename(final ObservatoryInstrumentDAOInterface dao,
        final ChartUIComponentPlugin chartui, final List<Metadata> metadatalist, final String fullfilename,
        final String type, final int width, final int height, final Vector<Vector> log,
        final ObservatoryClockInterface clock, final boolean verbose) {
    final String SOURCE = "DataExporter.exportChartUsingFilename() ";
    final boolean boolDebug;
    boolean boolSuccess;

    boolDebug = (LOADER_PROPERTIES.isChartDebug() || LOADER_PROPERTIES.isMetadataDebug()
            || LOADER_PROPERTIES.isStaribusDebug() || LOADER_PROPERTIES.isStarinetDebug());

    boolSuccess = false;

    // Let the User know the Chart must have data!
    if ((fullfilename != null) && (!EMPTY_STRING.equals(fullfilename)) && (type != null)
            && (!EMPTY_STRING.equals(type)) && (chartui != null) && (log != null) && (clock != null)) {
        try {
            final File file;

            file = new File(fullfilename);
            FileUtilities.overwriteFile(file);

            // Force the Chart to be generated, even if not visible
            // This calls ChartHelper.associateChartUIWithDAO()
            chartui.refreshChart(dao, true, SOURCE);

            if ((chartui.getChartPanel() != null) && (chartui.getChartPanel().getChart() != null)) {
                if (FileUtilities.jpg.equalsIgnoreCase(type)) {
                    LOGGER.debug(boolDebug, SOURCE + "writing [file " + file.getAbsolutePath() + "] [width="
                            + width + "] [height" + height + "]");
                    ChartUtilities.saveChartAsJPEG(file, chartui.getChartPanel().getChart(), width, height);
                    boolSuccess = true;

                    if (verbose) {
                        SimpleEventLogUIComponent.logEvent(
                                log, EventStatus.INFO, METADATA_TARGET_CHART + METADATA_ACTION_EXPORT
                                        + METADATA_FILENAME + file.getAbsolutePath() + TERMINATOR,
                                SOURCE, clock);
                    }
                } else if (FileUtilities.png.equalsIgnoreCase(type)) {
                    LOGGER.debug(boolDebug, SOURCE + "writing [file " + file.getAbsolutePath() + "] [width="
                            + width + "] [height" + height + "]");
                    ChartUtilities.saveChartAsPNG(file, chartui.getChartPanel().getChart(), width, height);
                    boolSuccess = true;

                    if (verbose) {
                        SimpleEventLogUIComponent.logEvent(
                                log, EventStatus.INFO, METADATA_TARGET_CHART + METADATA_ACTION_EXPORT
                                        + METADATA_FILENAME + file.getAbsolutePath() + TERMINATOR,
                                SOURCE, clock);
                    }
                } else {
                    SimpleEventLogUIComponent
                            .logEvent(
                                    log, EventStatus.FATAL, METADATA_TARGET_CHART + METADATA_ACTION_EXPORT
                                            + METADATA_RESULT + ERROR_INVALID_FORMAT + TERMINATOR,
                                    SOURCE, clock);
                }
            }
        }

        catch (SecurityException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET_CHART + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_ACCESS_DENIED
                            + TERMINATOR + SPACE + METADATA_EXCEPTION + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }

        catch (FileNotFoundException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET_CHART + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_FILE_NOT_FOUND
                            + TERMINATOR + SPACE + METADATA_EXCEPTION + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }

        catch (IOException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET_CHART + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_FILE_SAVE
                            + TERMINATOR + SPACE + METADATA_EXCEPTION + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }
    } else {
        //            System.out.println("FILENAME=" + ((fullfilename != null) && (!EMPTY_STRING.equals(fullfilename))));
        //            System.out.println("TYPE=" + ((type != null) && (!EMPTY_STRING.equals(type))));
        //            System.out.println("CHART=" + (chart != null));
        //            System.out.println("LOG=" + (log != null));
        //            System.out.println("CLOCK=" + (clock != null));
        SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                METADATA_TARGET_CHART + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_CHART + TERMINATOR,
                SOURCE, clock);
    }

    return (boolSuccess);
}

From source file:org.lmn.fc.common.datatranslators.DataExporter.java

/***********************************************************************************************
 * exportStringBuffer()./*from   w w w . j  a  v  a 2  s.  c om*/
 * Saves the StringBuffer at the specified location.
 *
 * @param filename
 * @param timestamp
 * @param format
 * @param buffer
 * @param log
 * @param clock
 *
 * @return boolean
 */

public static boolean exportStringBuffer(final String filename, final boolean timestamp,
        final DataFormat format, final StringBuffer buffer, final Vector<Vector> log,
        final ObservatoryClockInterface clock) {
    final String SOURCE = "DataExporter.exportStringBuffer()";
    boolean boolSuccess;

    boolSuccess = false;

    if ((filename != null) && (!EMPTY_STRING.equals(filename)) && (format != null) && (buffer != null)
            && (buffer.length() > 0) && (log != null) && (clock != null)) {
        try {
            final File file;
            final OutputStream outputStream;

            file = new File(FileUtilities.buildFullFilename(filename, timestamp, format));
            FileUtilities.overwriteFile(file);
            outputStream = new FileOutputStream(file);

            outputStream.write(buffer.toString().getBytes());

            boolSuccess = true;

            // Tidy up
            outputStream.flush();
            outputStream.close();

            SimpleEventLogUIComponent.logEvent(
                    log, EventStatus.INFO, METADATA_TARGET + format.getFileExtension() + TERMINATOR
                            + METADATA_ACTION_EXPORT + METADATA_FILENAME + file.getAbsolutePath() + TERMINATOR,
                    SOURCE, clock);
        }

        catch (SecurityException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET + format.getFileExtension() + TERMINATOR + METADATA_ACTION_EXPORT
                            + METADATA_RESULT + ERROR_ACCESS_DENIED + TERMINATOR + SPACE + METADATA_EXCEPTION
                            + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }

        catch (FileNotFoundException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET + format.getFileExtension() + TERMINATOR + METADATA_ACTION_EXPORT
                            + METADATA_RESULT + ERROR_FILE_NOT_FOUND + TERMINATOR + SPACE + METADATA_EXCEPTION
                            + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }

        catch (IOException exception) {
            SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL,
                    METADATA_TARGET + format.getFileExtension() + TERMINATOR + METADATA_ACTION_EXPORT
                            + METADATA_RESULT + ERROR_FILE_SAVE + TERMINATOR + SPACE + METADATA_EXCEPTION
                            + exception.getMessage() + TERMINATOR,
                    SOURCE, clock);
        }
    } else {
        SimpleEventLogUIComponent
                .logEvent(
                        log, EventStatus.FATAL, METADATA_TARGET + format.getFileExtension() + TERMINATOR
                                + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_XML + TERMINATOR,
                        SOURCE, clock);
    }

    return (boolSuccess);
}

From source file:org.ofbiz.base.util.ObjectType.java

public static Class<?> loadInfoClass(String typeName, ClassLoader loader) {
    //Class infoClass = null;
    try {/* w ww .  jav a 2 s.  co m*/
        return ObjectType.loadClass(typeName, loader);
    } catch (SecurityException se1) {
        throw new IllegalArgumentException(
                "Problems with classloader: security exception (" + se1.getMessage() + ")");
    } catch (ClassNotFoundException e1) {
        try {
            return ObjectType.loadClass(LANG_PACKAGE + typeName, loader);
        } catch (SecurityException se2) {
            throw new IllegalArgumentException(
                    "Problems with classloader: security exception (" + se2.getMessage() + ")");
        } catch (ClassNotFoundException e2) {
            try {
                return ObjectType.loadClass(SQL_PACKAGE + typeName, loader);
            } catch (SecurityException se3) {
                throw new IllegalArgumentException(
                        "Problems with classloader: security exception (" + se3.getMessage() + ")");
            } catch (ClassNotFoundException e3) {
                throw new IllegalArgumentException("Cannot find and load the class of type: " + typeName
                        + " or of type: " + LANG_PACKAGE + typeName + " or of type: " + SQL_PACKAGE + typeName
                        + ":  (" + e3.getMessage() + ")");
            }
        }
    }
}

From source file:eu.crisis_economics.abm.model.ModelUtils.java

/**
  * Get a list of subconfiguration objects for a class instance (<code>X</code>). This 
  * method will do the following:/*from  www. ja  v a 2s . co  m*/
  * 
  * <ul>
  *   <li> Identify any fields in the input <code>X</code> which carry the
  *        <code>@Parameter</code> and <code>@Submodel</code> annotations.
  *   <li> If <code>X</code> is an instance of {@link ComponentConfiguration}, and
  *        the ID of the accompanying <code>@Parameter</code> annotation is nonempty,
  *        set the scope string of the field to the parameter ID.
  *   <li> Add a reference to the field to a list <code>L</code>.
  *   <li> Repeat the above steps depth-first recursively for each field in <code>X</code>.
  *   <li> Return <code>L</code>
  * </ul>
  * 
  * @param on <br>
  *        The class instance <code>X</code> to search.
  */
public static List<ComponentConfiguration> getSubconfigurators(final Object on) {
    final Class<?> objClass = Preconditions.checkNotNull(on).getClass();
    final List<ComponentConfiguration> result = new ArrayList<ComponentConfiguration>();
    for (Class<?> typeToSearch = objClass; typeToSearch != null; typeToSearch = typeToSearch.getSuperclass()) {
        for (final Field field : typeToSearch.getDeclaredFields()) {
            if (!ComponentConfiguration.class.isAssignableFrom(field.getType()))
                continue;
            field.setAccessible(true);
            try {
                Annotation drilldownAnnotation = null, modelParameterAnnotation = null;
                for (final Annotation element : field.getAnnotations()) {
                    if (element.annotationType().getName() == Submodel.class.getName()) { // Proxies
                        drilldownAnnotation = element;
                        continue;
                    } else if (element.annotationType().getName() == Parameter.class.getName()) { // Proxies
                        modelParameterAnnotation = element;
                        continue;
                    } else
                        continue;
                }
                if (modelParameterAnnotation != null && drilldownAnnotation != null) {
                    final Object value = field.get(on);
                    if (value == null)
                        throw new IllegalStateException(on.getClass().getSimpleName()
                                + ": the value of a configurator member field" + " in "
                                + (on.getClass().getSimpleName() + on.hashCode()) + " is null.");
                    result.add((ComponentConfiguration) value);
                    final boolean isScoped = (Boolean) modelParameterAnnotation.annotationType()
                            .getMethod("Scoped").invoke(modelParameterAnnotation);
                    if (!isScoped)
                        continue;
                    final String id = (String) modelParameterAnnotation.annotationType().getMethod("ID")
                            .invoke(modelParameterAnnotation);
                    if (id.isEmpty())
                        continue;
                    ((ComponentConfiguration) value).setScope(id);
                }
            } catch (final SecurityException e) {
                throw new IllegalStateException(on.getClass().getSimpleName()
                        + ": a security exception was raised when testing a field with name " + field.getName()
                        + " for model parameter annotations. Details follow: " + e.getMessage() + ".");
            } catch (final IllegalArgumentException e) {
                throw new IllegalStateException(on.getClass().getSimpleName()
                        + "search: an illegal argument exception was raised when testing a field with name "
                        + field.getName() + " for model parameter annotations. Details follow: "
                        + e.getMessage() + ".");
            } catch (final IllegalAccessException e) {
                throw new IllegalStateException(on.getClass().getSimpleName()
                        + "search: a security exception was raised when testing a field with name "
                        + field.getName() + " for model parameter annotations. Details follow: "
                        + e.getMessage() + ".");
            } catch (final InvocationTargetException e) {
                throw new IllegalStateException(on.getClass().getSimpleName()
                        + "search: an invokation target exception was raised when testing a field with"
                        + " name " + field.getName() + " for model parameter annotations. Details follow: "
                        + e.getMessage() + ".");
            } catch (final NoSuchMethodException e) {
                throw new IllegalStateException(on.getClass().getSimpleName()
                        + "search: a missing-method exception was raised when testing a field with name "
                        + field.getName() + " for model parameter annotations. Details follow: "
                        + e.getMessage() + ".");
            }
        }
    }
    return result;
}

From source file:com.cottsoft.thrift.framework.server.RunServer.java

@Override
public void run() {
    try {//  w w  w.  j a v  a2s .c om
        new ClassPathXmlApplicationContext(new String[] { "config/app.xml" });
    } catch (SecurityException e) {
        logger.debug(e.getMessage());
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        logger.debug(e.getMessage());
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:eu.crisis_economics.abm.model.ModelUtils.java

/**
  * A depth-first recursive parameter search tool. This function accepts an object
  * ({@code X}) and a {@link String} ID ({@code P}) of a parameter to search for.<br><br>
  * //ww  w  . ja  v  a 2 s  .  c  om
  * Any object {@code O} in the configuration hierarchy of {@code X} which possesses a field with
  * a) the appropriate annotation and b) parameter ID is identified and returned.
  * This method will search for member fields {@code F} (with any modifer) which satisfy:
  * 
  * <ul>
  *   <li> {@code F} carries a {@link Parameter} {@link Annotation}.
  *   <li> The {@code ID} of this {@link Parameter} is equal to {@code P}.
  *   <li> {@code F} does not itself belongs to a {@link Submodel} field that satisfies the
  *        above two conditions.
  * </ul>
  * 
  * This search operates as follows:<br><br>
  * 
  * <ul>
  *   <li> If {@code X} contains a member field {@code F} satisfying the above conditions, 
  *        {@code F} is accepted and returned.
  *   <li> Otherwise, each supertype in the inheritance hierarchy of {@code X} is searched.
  *   <li> Apply the above steps recursively (depth-first) to every field {@code F}
  *        in {@code X} annotated with {@link Submodel}, unless {@code F} itself
  *        satisfies the above conditions, in which case {@code F} is accepted and returned.
  * </ul>
  * 
  * This method returns a {@link List} of {@link ConfigurationModifier} objects. Each element
  * in this list corresponds to a field {@code F} somewhere in the inheritance hierarchy of
  * {@code X} which satisfied the above search conditions. {@link ConfigurationModifier}
  * objects facilitate direct changes to the value of each such {@code F}.<br><br>
  * 
  * @param on (<code>X</code>) <br>
  *        The object to search.
  * @param parameterIdToFind on (<code>P</code>) <br>
  *        The ID of the {@link Parameter} to search for.
  */
public static List<ConfigurationModifier> search(final Object on, final String parameterIdToFind) {
    if (on == null)
        throw new IllegalArgumentException("search: object to search is null.");
    if (parameterIdToFind == null || parameterIdToFind.isEmpty())
        throw new IllegalArgumentException("search: parameter name is empty or null.");
    if (VERBOSE_MODE)
        System.out.println("search: searching object " + on.getClass().getSimpleName() + on.hashCode()
                + " for parameters of type " + parameterIdToFind + ".");
    final Class<?> objClass = on.getClass();
    final List<ConfigurationModifier> methodsIdentified = new ArrayList<ConfigurationModifier>();
    for (Class<?> typeToSearch = objClass; typeToSearch != null; typeToSearch = typeToSearch.getSuperclass()) {
        for (final Field field : typeToSearch.getDeclaredFields()) {
            field.setAccessible(true);
            if (VERBOSE_MODE)
                System.out.println("inspecting field with name: " + field.getName() + ".");
            try {
                Annotation drilldownAnnotation = null, modelParameterAnnotation = null;
                for (final Annotation element : field.getAnnotations()) {
                    if (element.annotationType().getName() == Submodel.class.getName()) { // Proxies
                        drilldownAnnotation = element;
                        if (VERBOSE_MODE)
                            System.out.println("field " + field.getName() + " is a subconfiguration.");
                        continue;
                    } else if (element.annotationType().getName() == Parameter.class.getName()) { // Proxies
                        final Class<? extends Annotation> type = element.annotationType();
                        final String id = (String) type.getMethod("ID").invoke(element);
                        if (parameterIdToFind.equals(id)) {
                            modelParameterAnnotation = element;
                            if (VERBOSE_MODE)
                                System.out.println("* field is valid.");
                            continue;
                        } else if (VERBOSE_MODE)
                            System.out.println("field ID [" + id + "] does not match the required ID: "
                                    + parameterIdToFind + ".");
                        continue;
                    } else
                        continue;
                }
                if (modelParameterAnnotation != null) {
                    final ConfigurationModifier fieldWithMutators = findGetterSetterMethods(field, on,
                            parameterIdToFind);
                    methodsIdentified.add(fieldWithMutators);
                    continue;
                } else if (drilldownAnnotation != null) {
                    if (VERBOSE_MODE)
                        System.out.println("descending into subconfiguration: " + field.getName());
                    final Object fieldValue = field.get(on);
                    methodsIdentified.addAll(search(fieldValue, parameterIdToFind));
                    continue;
                }
                if (VERBOSE_MODE)
                    System.out.println("rejecting parameter: " + field.getName());
            } catch (final SecurityException e) {
                throw new IllegalStateException(
                        "search: a security exception was raised when testing a field with name "
                                + field.getName() + " for model parameter annotations. Details follow: "
                                + e.getMessage() + ".");
            } catch (final IllegalArgumentException e) {
                throw new IllegalStateException(
                        "search: an illegal argument exception was raised when testing a field with name "
                                + field.getName() + " for model parameter annotations. Details follow: "
                                + e.getMessage() + ".");
            } catch (final IllegalAccessException e) {
                throw new IllegalStateException(
                        "search: a security exception was raised when testing a field with name "
                                + field.getName() + " for model parameter annotations. Details follow: "
                                + e.getMessage() + ".");
            } catch (final InvocationTargetException e) {
                throw new IllegalStateException(
                        "search: an invokation target exception was raised when testing a field with" + " name "
                                + field.getName() + " for model parameter annotations. Details follow: "
                                + e.getMessage() + ".");
            } catch (final NoSuchMethodException e) {
                throw new IllegalStateException(
                        "search: a missing-method exception was raised when testing a field with name "
                                + field.getName() + " for model parameter annotations. Details follow: "
                                + e.getMessage() + ".");
            }
        }
    }
    if (VERBOSE_MODE)
        System.out.println("searched: " + on.getClass().getSimpleName() + on.hashCode()
                + " for parameters of type " + parameterIdToFind + ".");
    return methodsIdentified;
}

From source file:de.contentreich.alfresco.Log4JRepoHierarchyInit.java

@Override
public void init() {
    super.init();
    try {/*from   w w  w.  j  a v a  2  s .c o m*/
        log4jInit.init(extraLog4jXmlUrls, resolver);
    } catch (SecurityException e) {
        logger.error(e.getMessage(), e);
    } catch (ClassNotFoundException e) {
        logger.error(e.getMessage(), e);
    }
}

From source file:com.moneydance.modules.features.importlist.io.DirectoryValidator.java

@Override
public boolean accept(final File file) {
    try {//from ww w.j  a  va 2s.  c om
        return FileFilterUtils.and(CanReadFileFilter.CAN_READ, FileFilterUtils.directoryFileFilter())
                .accept(file);
    } catch (SecurityException e) {
        LOG.log(Level.WARNING, e.getMessage(), e);
        return false;
    }
}

From source file:com.moneydance.modules.features.importlist.io.DefaultDirectoryChooser.java

@Override
void chooseBaseDirectory() {
    final JFileChooser fileChooser = new JFileChooser();
    fileChooser.setDialogTitle(this.getLocalizable().getDirectoryChooserTitle());
    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    // disable the "All files" option.
    fileChooser.setAcceptAllFileFilterUsed(false);

    try {//w  ww  .  ja v a 2s  .c o m
        fileChooser.setCurrentDirectory(FileUtils.getUserDirectory());
    } catch (SecurityException e) {
        LOG.log(Level.WARNING, e.getMessage(), e);
    }

    if (this.getBaseDirectory() != null) {
        final File parentDirectory = this.getBaseDirectory().getParentFile();
        fileChooser.setCurrentDirectory(parentDirectory);
    }

    if (fileChooser.showOpenDialog(null) != JFileChooser.APPROVE_OPTION) {
        return;
    }

    this.getPrefs().setBaseDirectory(fileChooser.getSelectedFile().getAbsolutePath());

    LOG.info(String.format("Base directory is %s", this.getPrefs().getBaseDirectory()));
}