Example usage for java.lang System lineSeparator

List of usage examples for java.lang System lineSeparator

Introduction

In this page you can find the example usage for java.lang System lineSeparator.

Prototype

String lineSeparator

To view the source code for java.lang System lineSeparator.

Click Source Link

Usage

From source file:net.sf.jabref.preferences.JabRefPreferences.java

private JabRefPreferences() {
    try {/*from   w  w  w.  java 2  s. c o m*/
        if (new File("jabref.xml").exists()) {
            importPreferences("jabref.xml");
        }
    } catch (JabRefException e) {
        LOGGER.warn("Could not import preferences from jabref.xml: " + e.getMessage(), e);
    }

    // load user preferences
    prefs = Preferences.userNodeForPackage(JabRefMain.class);

    defaults.put(TEXMAKER_PATH, JabRefDesktop.getNativeDesktop().detectProgramPath("texmaker", "Texmaker"));
    defaults.put(WIN_EDT_PATH,
            JabRefDesktop.getNativeDesktop().detectProgramPath("WinEdt", "WinEdt Team\\WinEdt"));
    defaults.put(LATEX_EDITOR_PATH, JabRefDesktop.getNativeDesktop().detectProgramPath("LEd", "LEd"));
    defaults.put(TEXSTUDIO_PATH, JabRefDesktop.getNativeDesktop().detectProgramPath("texstudio", "TeXstudio"));

    defaults.put(BIBLATEX_DEFAULT_MODE, false);

    if (OS.OS_X) {
        defaults.put(EMACS_PATH, "emacsclient");
        defaults.put(EMACS_23, true);
        defaults.put(EMACS_ADDITIONAL_PARAMETERS, "-n -e");
        defaults.put(FONT_FAMILY, "SansSerif");
        defaults.put(WIN_LOOK_AND_FEEL, UIManager.getSystemLookAndFeelClassName());

    } else if (OS.WINDOWS) {
        defaults.put(WIN_LOOK_AND_FEEL, "com.jgoodies.looks.windows.WindowsLookAndFeel");
        defaults.put(EMACS_PATH, "emacsclient.exe");
        defaults.put(EMACS_23, true);
        defaults.put(EMACS_ADDITIONAL_PARAMETERS, "-n -e");
        defaults.put(FONT_FAMILY, "Arial");

    } else {
        // Linux
        defaults.put(WIN_LOOK_AND_FEEL, "com.jgoodies.plaf.plastic.Plastic3DLookAndFeel");
        defaults.put(FONT_FAMILY, "SansSerif");

        defaults.put(EMACS_PATH, "gnuclient");
        defaults.put(EMACS_23, false);
        defaults.put(EMACS_ADDITIONAL_PARAMETERS, "-batch -eval");
    }
    defaults.put(PUSH_TO_APPLICATION, "TeXstudio");

    defaults.put(RECENT_FILES, "");
    defaults.put(EXTERNAL_FILE_TYPES, "");
    defaults.put(KEY_PATTERN_REGEX, "");
    defaults.put(KEY_PATTERN_REPLACEMENT, "");

    // Proxy
    defaults.put(PROXY_USE, Boolean.FALSE);
    defaults.put(PROXY_HOSTNAME, "");
    defaults.put(PROXY_PORT, "80");
    defaults.put(PROXY_USE_AUTHENTICATION, Boolean.FALSE);
    defaults.put(PROXY_USERNAME, "");
    defaults.put(PROXY_PASSWORD, "");

    defaults.put(USE_DEFAULT_LOOK_AND_FEEL, Boolean.TRUE);
    defaults.put(LYXPIPE, USER_HOME + File.separator + ".lyx/lyxpipe");
    defaults.put(VIM, "vim");
    defaults.put(VIM_SERVER, "vim");
    defaults.put(POS_X, 0);
    defaults.put(POS_Y, 0);
    defaults.put(SIZE_X, 1024);
    defaults.put(SIZE_Y, 768);
    defaults.put(WINDOW_MAXIMISED, Boolean.FALSE);
    defaults.put(AUTO_RESIZE_MODE, JTable.AUTO_RESIZE_ALL_COLUMNS);
    defaults.put(PREVIEW_PANEL_HEIGHT, 200);
    defaults.put(ENTRY_EDITOR_HEIGHT, 400);
    defaults.put(TABLE_COLOR_CODES_ON, Boolean.FALSE);
    defaults.put(NAMES_AS_IS, Boolean.FALSE); // "Show names unchanged"
    defaults.put(NAMES_FIRST_LAST, Boolean.FALSE); // "Show 'Firstname Lastname'"
    defaults.put(NAMES_NATBIB, Boolean.TRUE); // "Natbib style"
    defaults.put(ABBR_AUTHOR_NAMES, Boolean.TRUE); // "Abbreviate names"
    defaults.put(NAMES_LAST_ONLY, Boolean.TRUE); // "Show last names only"
    // system locale as default
    defaults.put(LANGUAGE, Locale.getDefault().getLanguage());

    // Sorting preferences
    defaults.put(TABLE_PRIMARY_SORT_FIELD, FieldName.AUTHOR);
    defaults.put(TABLE_PRIMARY_SORT_DESCENDING, Boolean.FALSE);
    defaults.put(TABLE_SECONDARY_SORT_FIELD, FieldName.YEAR);
    defaults.put(TABLE_SECONDARY_SORT_DESCENDING, Boolean.TRUE);
    defaults.put(TABLE_TERTIARY_SORT_FIELD, FieldName.TITLE);
    defaults.put(TABLE_TERTIARY_SORT_DESCENDING, Boolean.FALSE);

    defaults.put(REFORMAT_FILE_ON_SAVE_AND_EXPORT, Boolean.FALSE);

    // export order
    defaults.put(EXPORT_IN_ORIGINAL_ORDER, Boolean.FALSE);
    defaults.put(EXPORT_IN_SPECIFIED_ORDER, Boolean.FALSE);

    // export order: if EXPORT_IN_SPECIFIED_ORDER, then use following criteria
    defaults.put(EXPORT_PRIMARY_SORT_FIELD, BibEntry.KEY_FIELD);
    defaults.put(EXPORT_PRIMARY_SORT_DESCENDING, Boolean.FALSE);
    defaults.put(EXPORT_SECONDARY_SORT_FIELD, FieldName.AUTHOR);
    defaults.put(EXPORT_SECONDARY_SORT_DESCENDING, Boolean.FALSE);
    defaults.put(EXPORT_TERTIARY_SORT_FIELD, FieldName.TITLE);
    defaults.put(EXPORT_TERTIARY_SORT_DESCENDING, Boolean.TRUE);

    defaults.put(NEWLINE, System.lineSeparator());

    defaults.put(SIDE_PANE_COMPONENT_NAMES, "");
    defaults.put(SIDE_PANE_COMPONENT_PREFERRED_POSITIONS, "");

    defaults.put(COLUMN_NAMES, "entrytype;author/editor;title;year;journal/booktitle;bibtexkey");
    defaults.put(COLUMN_WIDTHS, "75;300;470;60;130;100");
    defaults.put(PersistenceTableColumnListener.ACTIVATE_PREF_KEY,
            PersistenceTableColumnListener.DEFAULT_ENABLED);
    defaults.put(XMP_PRIVACY_FILTERS, "pdf;timestamp;keywords;owner;note;review");
    defaults.put(USE_XMP_PRIVACY_FILTER, Boolean.FALSE);
    defaults.put(NUMBER_COL_WIDTH, 32);
    defaults.put(WORKING_DIRECTORY, USER_HOME);
    defaults.put(EXPORT_WORKING_DIRECTORY, USER_HOME);
    // Remembers working directory of last import
    defaults.put(IMPORT_WORKING_DIRECTORY, USER_HOME);
    defaults.put(FILE_WORKING_DIRECTORY, USER_HOME);
    defaults.put(AUTO_OPEN_FORM, Boolean.TRUE);
    defaults.put(BACKUP, Boolean.TRUE);
    defaults.put(OPEN_LAST_EDITED, Boolean.TRUE);
    defaults.put(LAST_EDITED, "");
    defaults.put(LAST_FOCUSED, "");
    defaults.put(STRINGS_POS_X, 0);
    defaults.put(STRINGS_POS_Y, 0);
    defaults.put(STRINGS_SIZE_X, 600);
    defaults.put(STRINGS_SIZE_Y, 400);
    defaults.put(DUPLICATES_POS_X, 0);
    defaults.put(DUPLICATES_POS_Y, 0);
    defaults.put(DUPLICATES_SIZE_X, 800);
    defaults.put(DUPLICATES_SIZE_Y, 600);
    defaults.put(MERGEENTRIES_POS_X, 0);
    defaults.put(MERGEENTRIES_POS_Y, 0);
    defaults.put(MERGEENTRIES_SIZE_X, 800);
    defaults.put(MERGEENTRIES_SIZE_Y, 600);
    defaults.put(PREAMBLE_POS_X, 0);
    defaults.put(PREAMBLE_POS_Y, 0);
    defaults.put(PREAMBLE_SIZE_X, 600);
    defaults.put(PREAMBLE_SIZE_Y, 400);
    defaults.put(DEFAULT_SHOW_SOURCE, Boolean.FALSE);
    defaults.put(DEFAULT_AUTO_SORT, Boolean.FALSE);
    defaults.put(SEARCH_CASE_SENSITIVE, Boolean.FALSE);
    defaults.put(SEARCH_MODE_FILTER, Boolean.TRUE);

    defaults.put(SEARCH_REG_EXP, Boolean.FALSE);
    defaults.put(SEARCH_PANE_POS_X, 0);
    defaults.put(SEARCH_PANE_POS_Y, 0);

    defaults.put(MERGE_ENTRIES_DIFF_MODE, 2);

    defaults.put(EDITOR_EMACS_KEYBINDINGS, Boolean.FALSE);
    defaults.put(EDITOR_EMACS_KEYBINDINGS_REBIND_CA, Boolean.TRUE);
    defaults.put(EDITOR_EMACS_KEYBINDINGS_REBIND_CF, Boolean.TRUE);
    defaults.put(AUTO_COMPLETE, Boolean.TRUE);
    AutoCompletePreferences.putDefaults(defaults);
    defaults.put(GROUP_FLOAT_SELECTIONS, Boolean.TRUE);
    defaults.put(GROUP_INTERSECT_SELECTIONS, Boolean.TRUE);
    defaults.put(GROUP_INVERT_SELECTIONS, Boolean.FALSE);
    defaults.put(GROUP_SHOW_OVERLAPPING, Boolean.FALSE);
    defaults.put(GROUPS_DEFAULT_FIELD, FieldName.KEYWORDS);
    defaults.put(GROUP_SHOW_ICONS, Boolean.TRUE);
    defaults.put(GROUP_SHOW_DYNAMIC, Boolean.TRUE);
    defaults.put(GROUP_EXPAND_TREE, Boolean.TRUE);
    defaults.put(GROUP_AUTO_SHOW, Boolean.TRUE);
    defaults.put(GROUP_AUTO_HIDE, Boolean.TRUE);
    defaults.put(GROUP_SHOW_NUMBER_OF_ELEMENTS, Boolean.FALSE);
    defaults.put(AUTO_ASSIGN_GROUP, Boolean.TRUE);
    defaults.put(KEYWORD_SEPARATOR, ", ");
    defaults.put(EDIT_GROUP_MEMBERSHIP_MODE, Boolean.FALSE);
    defaults.put(HIGHLIGHT_GROUPS_MATCHING, "all");
    defaults.put(TOOLBAR_VISIBLE, Boolean.TRUE);
    defaults.put(DEFAULT_ENCODING, StandardCharsets.UTF_8.name());
    defaults.put(GROUPS_VISIBLE_ROWS, 8);
    defaults.put(DEFAULT_OWNER, System.getProperty("user.name"));
    defaults.put(MEMORY_STICK_MODE, Boolean.FALSE);
    defaults.put(RENAME_ON_MOVE_FILE_TO_FILE_DIR, Boolean.TRUE);

    // The general fields stuff is made obsolete by the CUSTOM_TAB_... entries.
    defaults.put(GENERAL_FIELDS, "crossref;keywords;file;doi;url;urldate;" + "pdf;comment;owner");

    defaults.put(FONT_STYLE, java.awt.Font.PLAIN);
    defaults.put(FONT_SIZE, 12);
    defaults.put(OVERRIDE_DEFAULT_FONTS, Boolean.FALSE);
    defaults.put(MENU_FONT_SIZE, 11);
    defaults.put(TABLE_ROW_PADDING, 9);
    defaults.put(TABLE_SHOW_GRID, Boolean.FALSE);
    // Main table color settings:
    defaults.put(TABLE_BACKGROUND, "255:255:255");
    defaults.put(TABLE_REQ_FIELD_BACKGROUND, "230:235:255");
    defaults.put(TABLE_OPT_FIELD_BACKGROUND, "230:255:230");
    defaults.put(TABLE_TEXT, "0:0:0");
    defaults.put(GRID_COLOR, "210:210:210");
    defaults.put(GRAYED_OUT_BACKGROUND, "210:210:210");
    defaults.put(GRAYED_OUT_TEXT, "40:40:40");
    defaults.put(VERY_GRAYED_OUT_BACKGROUND, "180:180:180");
    defaults.put(VERY_GRAYED_OUT_TEXT, "40:40:40");
    defaults.put(MARKED_ENTRY_BACKGROUND0, "255:255:180");
    defaults.put(MARKED_ENTRY_BACKGROUND1, "255:220:180");
    defaults.put(MARKED_ENTRY_BACKGROUND2, "255:180:160");
    defaults.put(MARKED_ENTRY_BACKGROUND3, "255:120:120");
    defaults.put(MARKED_ENTRY_BACKGROUND4, "255:75:75");
    defaults.put(MARKED_ENTRY_BACKGROUND5, "220:255:220");
    defaults.put(VALID_FIELD_BACKGROUND_COLOR, "255:255:255");
    defaults.put(INVALID_FIELD_BACKGROUND_COLOR, "255:0:0");
    defaults.put(ACTIVE_FIELD_EDITOR_BACKGROUND_COLOR, "220:220:255");
    defaults.put(FIELD_EDITOR_TEXT_COLOR, "0:0:0");

    defaults.put(INCOMPLETE_ENTRY_BACKGROUND, "250:175:175");

    defaults.put(CTRL_CLICK, Boolean.FALSE);
    defaults.put(DISABLE_ON_MULTIPLE_SELECTION, Boolean.FALSE);
    defaults.put(URL_COLUMN, Boolean.TRUE);
    defaults.put(PREFER_URL_DOI, Boolean.FALSE);
    defaults.put(FILE_COLUMN, Boolean.TRUE);
    defaults.put(ARXIV_COLUMN, Boolean.FALSE);

    defaults.put(EXTRA_FILE_COLUMNS, Boolean.FALSE);
    defaults.put(LIST_OF_FILE_COLUMNS, "");

    // OpenOffice/LibreOffice
    if (OS.WINDOWS) {
        defaults.put(JabRefPreferences.OO_PATH, OpenOfficePreferences.DEFAULT_WINDOWS_PATH);
        defaults.put(JabRefPreferences.OO_EXECUTABLE_PATH, OpenOfficePreferences.DEFAULT_WINDOWS_PATH
                + OpenOfficePreferences.WINDOWS_EXECUTABLE_SUBPATH + OpenOfficePreferences.WINDOWS_EXECUTABLE);
        defaults.put(JabRefPreferences.OO_JARS_PATH,
                OpenOfficePreferences.DEFAULT_WINDOWS_PATH + OpenOfficePreferences.WINDOWS_JARS_SUBPATH);
    } else if (OS.OS_X) {
        defaults.put(JabRefPreferences.OO_PATH, OpenOfficePreferences.DEFAULT_OSX_PATH);
        defaults.put(JabRefPreferences.OO_EXECUTABLE_PATH, OpenOfficePreferences.DEFAULT_OSX_PATH
                + OpenOfficePreferences.OSX_EXECUTABLE_SUBPATH + OpenOfficePreferences.OSX_EXECUTABLE);
        defaults.put(JabRefPreferences.OO_JARS_PATH,
                OpenOfficePreferences.DEFAULT_OSX_PATH + OpenOfficePreferences.OSX_JARS_SUBPATH);
    } else { // Linux
        defaults.put(JabRefPreferences.OO_PATH, "/opt/openoffice.org3");
        defaults.put(JabRefPreferences.OO_EXECUTABLE_PATH, "/usr/lib/openoffice/program/soffice");
        defaults.put(JabRefPreferences.OO_JARS_PATH, "/opt/openoffice.org/basis3.0");
    }

    defaults.put(JabRefPreferences.OO_SYNC_WHEN_CITING, false);
    defaults.put(JabRefPreferences.OO_SHOW_PANEL, false);
    defaults.put(JabRefPreferences.OO_USE_ALL_OPEN_BASES, true);
    defaults.put(JabRefPreferences.OO_BIBLIOGRAPHY_STYLE_FILE, StyleLoader.DEFAULT_AUTHORYEAR_STYLE_PATH);
    defaults.put(JabRefPreferences.OO_EXTERNAL_STYLE_FILES, "");
    defaults.put(STYLES_POS_X, 0);
    defaults.put(STYLES_POS_Y, 0);
    defaults.put(STYLES_SIZE_X, 600);
    defaults.put(STYLES_SIZE_Y, 400);

    defaults.put(SpecialFieldsUtils.PREF_SPECIALFIELDSENABLED,
            SpecialFieldsUtils.PREF_SPECIALFIELDSENABLED_DEFAULT);
    defaults.put(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRIORITY,
            SpecialFieldsUtils.PREF_SHOWCOLUMN_PRIORITY_DEFAULT);
    defaults.put(SpecialFieldsUtils.PREF_SHOWCOLUMN_QUALITY,
            SpecialFieldsUtils.PREF_SHOWCOLUMN_QUALITY_DEFAULT);
    defaults.put(SpecialFieldsUtils.PREF_SHOWCOLUMN_RANKING,
            SpecialFieldsUtils.PREF_SHOWCOLUMN_RANKING_DEFAULT);
    defaults.put(SpecialFieldsUtils.PREF_SHOWCOLUMN_RELEVANCE,
            SpecialFieldsUtils.PREF_SHOWCOLUMN_RELEVANCE_DEFAULT);
    defaults.put(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRINTED,
            SpecialFieldsUtils.PREF_SHOWCOLUMN_PRINTED_DEFAULT);
    defaults.put(SpecialFieldsUtils.PREF_SHOWCOLUMN_READ, SpecialFieldsUtils.PREF_SHOWCOLUMN_READ_DEFAULT);
    defaults.put(SpecialFieldsUtils.PREF_AUTOSYNCSPECIALFIELDSTOKEYWORDS,
            SpecialFieldsUtils.PREF_AUTOSYNCSPECIALFIELDSTOKEYWORDS_DEFAULT);
    defaults.put(SpecialFieldsUtils.PREF_SERIALIZESPECIALFIELDS,
            SpecialFieldsUtils.PREF_SERIALIZESPECIALFIELDS_DEFAULT);

    defaults.put(USE_OWNER, Boolean.FALSE);
    defaults.put(OVERWRITE_OWNER, Boolean.FALSE);
    defaults.put(DIALOG_WARNING_FOR_DUPLICATE_KEY, Boolean.TRUE);
    defaults.put(DIALOG_WARNING_FOR_EMPTY_KEY, Boolean.TRUE);
    defaults.put(DISPLAY_KEY_WARNING_DIALOG_AT_STARTUP, Boolean.TRUE);
    defaults.put(AVOID_OVERWRITING_KEY, Boolean.FALSE);
    defaults.put(WARN_BEFORE_OVERWRITING_KEY, Boolean.TRUE);
    defaults.put(CONFIRM_DELETE, Boolean.TRUE);
    defaults.put(GRAY_OUT_NON_HITS, Boolean.TRUE);
    defaults.put(SEARCH_MODE_FLOAT, Boolean.FALSE);
    defaults.put(DEFAULT_LABEL_PATTERN, "[auth][year]");
    defaults.put(PREVIEW_ENABLED, Boolean.TRUE);
    defaults.put(ACTIVE_PREVIEW, 0);
    defaults.put(PREVIEW_0, "<font face=\"sans-serif\">"
            + "<b><i>\\bibtextype</i><a name=\"\\bibtexkey\">\\begin{bibtexkey} (\\bibtexkey)</a>"
            + "\\end{bibtexkey}</b><br>__NEWLINE__"
            + "\\begin{author} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\author}<BR>\\end{author}__NEWLINE__"
            + "\\begin{editor} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\editor} "
            + "<i>(\\format[IfPlural(Eds.,Ed.)]{\\editor})</i><BR>\\end{editor}__NEWLINE__"
            + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}<BR>__NEWLINE__"
            + "\\begin{chapter} \\format[HTMLChars]{\\chapter}<BR>\\end{chapter}__NEWLINE__"
            + "\\begin{journal} <em>\\format[HTMLChars]{\\journal}, </em>\\end{journal}__NEWLINE__"
            // Include the booktitle field for @inproceedings, @proceedings, etc.
            + "\\begin{booktitle} <em>\\format[HTMLChars]{\\booktitle}, </em>\\end{booktitle}__NEWLINE__"
            + "\\begin{school} <em>\\format[HTMLChars]{\\school}, </em>\\end{school}__NEWLINE__"
            + "\\begin{institution} <em>\\format[HTMLChars]{\\institution}, </em>\\end{institution}__NEWLINE__"
            + "\\begin{publisher} <em>\\format[HTMLChars]{\\publisher}, </em>\\end{publisher}__NEWLINE__"
            + "\\begin{year}<b>\\year</b>\\end{year}\\begin{volume}<i>, \\volume</i>\\end{volume}"
            + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}__NEWLINE__"
            + "\\begin{abstract}<BR><BR><b>Abstract: </b> \\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__"
            + "\\begin{review}<BR><BR><b>Review: </b> \\format[HTMLChars]{\\review} \\end{review}"
            + "</dd>__NEWLINE__<p></p></font>");
    defaults.put(PREVIEW_1, "<font face=\"sans-serif\">"
            + "<b><i>\\bibtextype</i><a name=\"\\bibtexkey\">\\begin{bibtexkey} (\\bibtexkey)</a>"
            + "\\end{bibtexkey}</b><br>__NEWLINE__"
            + "\\begin{author} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\author}<BR>\\end{author}__NEWLINE__"
            + "\\begin{editor} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\editor} "
            + "<i>(\\format[IfPlural(Eds.,Ed.)]{\\editor})</i><BR>\\end{editor}__NEWLINE__"
            + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}<BR>__NEWLINE__"
            + "\\begin{chapter} \\format[HTMLChars]{\\chapter}<BR>\\end{chapter}__NEWLINE__"
            + "\\begin{journal} <em>\\format[HTMLChars]{\\journal}, </em>\\end{journal}__NEWLINE__"
            // Include the booktitle field for @inproceedings, @proceedings, etc.
            + "\\begin{booktitle} <em>\\format[HTMLChars]{\\booktitle}, </em>\\end{booktitle}__NEWLINE__"
            + "\\begin{school} <em>\\format[HTMLChars]{\\school}, </em>\\end{school}__NEWLINE__"
            + "\\begin{institution} <em>\\format[HTMLChars]{\\institution}, </em>\\end{institution}__NEWLINE__"
            + "\\begin{publisher} <em>\\format[HTMLChars]{\\publisher}, </em>\\end{publisher}__NEWLINE__"
            + "\\begin{year}<b>\\year</b>\\end{year}\\begin{volume}<i>, \\volume</i>\\end{volume}"
            + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}"
            + "</dd>__NEWLINE__<p></p></font>");

    // TODO: Currently not possible to edit this setting:
    defaults.put(PREVIEW_PRINT_BUTTON, Boolean.FALSE);
    defaults.put(DO_NOT_RESOLVE_STRINGS_FOR, FieldName.URL);
    defaults.put(RESOLVE_STRINGS_ALL_FIELDS, Boolean.FALSE);
    defaults.put(NON_WRAPPABLE_FIELDS, "pdf;ps;url;doi;file");
    defaults.put(GENERATE_KEYS_AFTER_INSPECTION, Boolean.TRUE);
    defaults.put(MARK_IMPORTED_ENTRIES, Boolean.TRUE);
    defaults.put(UNMARK_ALL_ENTRIES_BEFORE_IMPORTING, Boolean.TRUE);
    defaults.put(WARN_ABOUT_DUPLICATES_IN_INSPECTION, Boolean.TRUE);
    defaults.put(USE_TIME_STAMP, Boolean.FALSE);
    defaults.put(OVERWRITE_TIME_STAMP, Boolean.FALSE);

    // default time stamp follows ISO-8601. Reason: https://xkcd.com/1179/
    defaults.put(TIME_STAMP_FORMAT, "yyyy-MM-dd");

    defaults.put(TIME_STAMP_FIELD, InternalBibtexFields.TIMESTAMP);
    defaults.put(UPDATE_TIMESTAMP, Boolean.FALSE);

    defaults.put(GENERATE_KEYS_BEFORE_SAVING, Boolean.FALSE);

    defaults.put(RemotePreferences.USE_REMOTE_SERVER, Boolean.TRUE);
    defaults.put(RemotePreferences.REMOTE_SERVER_PORT, 6050);

    defaults.put(PERSONAL_JOURNAL_LIST, "");
    defaults.put(EXTERNAL_JOURNAL_LISTS, "");
    defaults.put(CITE_COMMAND, "\\cite"); // obsoleted by the app-specific ones (not any more?)
    defaults.put(FLOAT_MARKED_ENTRIES, Boolean.TRUE);

    defaults.put(LAST_USED_EXPORT, "");
    defaults.put(SIDE_PANE_WIDTH, -1);

    defaults.put(IMPORT_INSPECTION_DIALOG_WIDTH, 650);
    defaults.put(IMPORT_INSPECTION_DIALOG_HEIGHT, 650);
    defaults.put(SEARCH_DIALOG_WIDTH, 650);
    defaults.put(SEARCH_DIALOG_HEIGHT, 500);
    defaults.put(SHOW_FILE_LINKS_UPGRADE_WARNING, Boolean.TRUE);
    defaults.put(AUTOLINK_EXACT_KEY_ONLY, Boolean.FALSE);
    defaults.put(NUMERIC_FIELDS, "mittnum;author");
    defaults.put(RUN_AUTOMATIC_FILE_SEARCH, Boolean.FALSE);
    defaults.put(USE_LOCK_FILES, Boolean.TRUE);
    defaults.put(AUTO_SAVE, Boolean.TRUE);
    defaults.put(AUTO_SAVE_INTERVAL, 5);
    defaults.put(PROMPT_BEFORE_USING_AUTOSAVE, Boolean.TRUE);
    defaults.put(ENFORCE_LEGAL_BIBTEX_KEY, Boolean.TRUE);
    // Curly brackets ({}) are the default delimiters, not quotes (") as these cause trouble when they appear within the field value:
    // Currently, JabRef does not escape them
    defaults.put(VALUE_DELIMITERS2, 1);
    defaults.put(KEY_GEN_FIRST_LETTER_A, Boolean.TRUE);
    defaults.put(KEY_GEN_ALWAYS_ADD_LETTER, Boolean.FALSE);
    defaults.put(EMAIL_SUBJECT, Localization.lang("References"));
    defaults.put(OPEN_FOLDERS_OF_ATTACHED_FILES, Boolean.FALSE);
    defaults.put(ALLOW_FILE_AUTO_OPEN_BROWSE, Boolean.TRUE);
    defaults.put(WEB_SEARCH_VISIBLE, Boolean.FALSE);
    defaults.put(SELECTED_FETCHER_INDEX, 0);
    defaults.put(BIB_LOC_AS_PRIMARY_DIR, Boolean.FALSE);
    defaults.put(DB_CONNECT_SERVER_TYPE, "MySQL");
    defaults.put(DB_CONNECT_HOSTNAME, "localhost");
    defaults.put(DB_CONNECT_DATABASE, "jabref");
    defaults.put(DB_CONNECT_USERNAME, "root");

    defaults.put(AKS_AUTO_NAMING_PDFS_AGAIN, Boolean.TRUE);
    insertCleanupPreset(defaults, CLEANUP_DEFAULT_PRESET);

    // defaults for DroppedFileHandler UI
    defaults.put(DroppedFileHandler.DFH_LEAVE, Boolean.FALSE);
    defaults.put(DroppedFileHandler.DFH_COPY, Boolean.TRUE);
    defaults.put(DroppedFileHandler.DFH_MOVE, Boolean.FALSE);
    defaults.put(DroppedFileHandler.DFH_RENAME, Boolean.FALSE);

    //defaults.put("lastAutodetectedImport", "");
    //defaults.put("autoRemoveExactDuplicates", Boolean.FALSE);
    //defaults.put("confirmAutoRemoveExactDuplicates", Boolean.TRUE);
    //defaults.put("tempDir", System.getProperty("java.io.tmpdir"));
    LOGGER.debug("Temporary directory: " + System.getProperty("java.io.tempdir"));
    //defaults.put("keyPattern", new LabelPattern(KEY_PATTERN));

    defaults.put(PREF_IMPORT_ALWAYSUSE, Boolean.FALSE);
    defaults.put(PREF_IMPORT_DEFAULT_PDF_IMPORT_STYLE, ImportSettingsTab.DEFAULT_STYLE);

    // use BibTeX key appended with filename as default pattern
    defaults.put(PREF_IMPORT_FILENAMEPATTERN, ImportSettingsTab.DEFAULT_FILENAMEPATTERNS[1]);

    customExports = new CustomExportList(new ExportComparator());
    customImports = new CustomImportList(this);

    updateSpecialFieldHandling();
    WRAPPED_USERNAME = '[' + get(DEFAULT_OWNER) + ']';
    MARKING_WITH_NUMBER_PATTERN = "\\[" + get(DEFAULT_OWNER).replaceAll("\\\\", "\\\\\\\\") + ":(\\d+)\\]";

    String defaultExpression = "**/.*[bibtexkey].*\\\\.[extension]";
    defaults.put(DEFAULT_REG_EXP_SEARCH_EXPRESSION_KEY, defaultExpression);
    defaults.put(REG_EXP_SEARCH_EXPRESSION_KEY, defaultExpression);
    defaults.put(AUTOLINK_USE_REG_EXP_SEARCH_KEY, Boolean.FALSE);
    defaults.put(USE_IEEE_ABRV, Boolean.FALSE);
    defaults.put(USE_CASE_KEEPER_ON_SEARCH, Boolean.TRUE);
    defaults.put(USE_UNIT_FORMATTER_ON_SEARCH, Boolean.TRUE);
    defaults.put(MAX_BACK_HISTORY_SIZE, 10);
    defaults.put(LINE_LENGTH, 65);
    defaults.put(INDENT, 4);

    defaults.put(USE_DEFAULT_CONSOLE_APPLICATION, Boolean.TRUE);
    if (OS.WINDOWS) {
        defaults.put(CONSOLE_COMMAND, "C:\\Program Files\\ConEmu\\ConEmu64.exe /single /dir \"%DIR\"");
    } else {
        defaults.put(CONSOLE_COMMAND, "");
    }

    //versioncheck defaults
    defaults.put(VersionPreferences.VERSION_IGNORED_UPDATE, "");
}

From source file:org.corpus_tools.pepper.connectors.impl.MavenAccessor.java

/**
 * This method checks the provided pepper plugin for updates and triggers
 * the installation process if a newer version is available
 *//*from w w w .ja v  a 2  s .  c om*/
public boolean update(String groupId, String artifactId, String repositoryUrl, boolean isSnapshot,
        boolean ignoreFrameworkVersion, Bundle installedBundle) {
    if (forbiddenFruits.isEmpty() && !initDependencies()) {
        logger.warn("Update could not be performed, because the pepper dependencies could not be listed.");
        return false;
    }

    if (logger.isTraceEnabled()) {
        logger.trace("Starting update process for " + groupId + ", " + artifactId + ", " + repositoryUrl
                + ", isSnapshot=" + isSnapshot + ", ignoreFrameworkVersion=" + ignoreFrameworkVersion
                + ", installedBundle=" + installedBundle);
    } else {
        logger.info("Starting update process for " + artifactId);
    }

    String newLine = System.getProperty("line.separator");

    DefaultRepositorySystemSession session = getNewSession();

    boolean update = true; // MUST be born true!

    /* build repository */

    RemoteRepository repo = getRepo("repo", repositoryUrl);

    /* build artifact */
    Artifact artifact = new DefaultArtifact(groupId, artifactId, "zip", "[0,)");

    try {
        /* version range request */
        VersionRangeRequest rangeRequest = new VersionRangeRequest();
        rangeRequest.addRepository(repo);
        rangeRequest.setArtifact(artifact);
        VersionRangeResult rangeResult = mvnSystem.resolveVersionRange(session, rangeRequest);
        rangeRequest.setArtifact(artifact);

        /* utils needed for request */
        ArtifactRequest artifactRequest = new ArtifactRequest();
        artifactRequest.addRepository(repo);
        ArtifactResult artifactResult = null;

        /* get all pepperModules versions listed in the maven repository */
        List<Version> versions = rangeResult.getVersions();
        Collections.reverse(versions);

        /* utils for version comparison */
        Iterator<Version> itVersions = versions.iterator();
        VersionScheme vScheme = new GenericVersionScheme();
        boolean srcExists = false;
        Version installedVersion = installedBundle == null ? vScheme.parseVersion("0.0.0")
                : vScheme.parseVersion(
                        installedBundle.getVersion().toString().replace(".SNAPSHOT", "-SNAPSHOT"));
        Version newestVersion = null;

        /*
         * compare, if the listed version really exists in the maven
         * repository
         */
        File file = null;
        while (!srcExists && itVersions.hasNext() && update) {
            newestVersion = itVersions.next();
            artifact = new DefaultArtifact(groupId, artifactId, "zip", newestVersion.toString());
            if (!(artifact.isSnapshot() && !isSnapshot)) {
                update = newestVersion.compareTo(installedVersion) > 0;
                artifactRequest.setArtifact(artifact);
                try {
                    artifactResult = mvnSystem.resolveArtifact(session, artifactRequest);
                    artifact = artifactResult.getArtifact();
                    srcExists = update && artifact.getFile().exists();
                    file = artifact.getFile();

                } catch (ArtifactResolutionException e) {
                    logger.warn("Plugin version " + newestVersion
                            + " could not be found in repository. Checking the next lower version ...");
                }
            }
        }
        update &= file != null;// in case of only snapshots in the maven
        // repository vs. isSnapshot=false
        /*
         * if an update is possible/necessary, perform dependency collection
         * and installation
         */
        if (update) {
            /* create list of necessary repositories */
            Artifact pom = new DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), "pom",
                    artifact.getVersion());
            artifactRequest.setArtifact(pom);
            boolean pomReadingErrors = false;
            try {
                artifactResult = null;
                artifactResult = mvnSystem.resolveArtifact(session, artifactRequest);
            } catch (ArtifactResolutionException e1) {
                pomReadingErrors = true;
            }
            List<RemoteRepository> repoList = new ArrayList<RemoteRepository>();
            repoList.add(repos.get(CENTRAL_REPO));
            repoList.add(repos.get(repositoryUrl));
            if (artifactResult != null && artifactResult.getArtifact().getFile().exists()) {
                try {
                    SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
                    saxParser.parse(artifactResult.getArtifact().getFile().getAbsolutePath(),
                            new POMReader(repoList));
                } catch (SAXException | IOException | ParserConfigurationException e) {
                    pomReadingErrors = true;
                }
            }
            if (pomReadingErrors) {
                logger.warn(
                        "Could not determine all relevant repositories, update might fail. Trying to continue ...");
                repoList.add(repos.get(KORPLING_MAVEN_REPO));
            }

            /* remove older version */
            if (installedBundle != null) {
                try {
                    if (!pepperOSGiConnector.remove(installedBundle.getSymbolicName())) {
                        logger.warn("Could not remove older version. Update process aborted.");
                        return false;
                    }
                } catch (BundleException | IOException e) {
                    logger.warn("An error occured while trying to remove OSGi bundle "
                            + installedBundle.getSymbolicName()
                            + ". This may cause update problems. Trying to continue ...");
                }
            }

            /* utils for file-collection */
            List<Artifact> installArtifacts = new ArrayList<Artifact>();
            installArtifacts.add(artifact);

            /* utils for dependency collection */
            CollectRequest collectRequest = new CollectRequest();
            collectRequest.setRoot(new Dependency(artifact, ""));
            collectRequest.setRepositories(repoList);
            CollectResult collectResult = mvnSystem.collectDependencies(session, collectRequest);
            List<Dependency> allDependencies = getAllDependencies(collectResult.getRoot(), true);

            /*
             * we have to remove the dependencies of pepperParent from the
             * dependency list, since they are (sometimes) not already on
             * the blacklist
             */
            String parentVersion = null;
            for (int i = 0; i < allDependencies.size() && parentVersion == null; i++) {
                if (ARTIFACT_ID_PEPPER_FRAMEWORK.equals(allDependencies.get(i).getArtifact().getArtifactId())) {
                    parentVersion = allDependencies.get(i).getArtifact().getVersion();
                }
            }
            if (parentVersion == null) {
                logger.warn(artifactId
                        + ": Could not perform update: pepper-parent version could not be determined.");
                return false;
            }
            VersionRange range = isCompatiblePlugin(parentVersion);
            if (!ignoreFrameworkVersion && range != null) {
                logger.info((new StringBuilder()).append(
                        "No update was performed because of a version incompatibility according to pepper-framework: ")
                        .append(newLine).append(artifactId).append(" only supports ").append(range.toString())
                        .append(", but ").append(pepperOSGiConnector.getFrameworkVersion())
                        .append(" is installed!").append(newLine)
                        .append("You can make pepper ignore this by using \"update")
                        .append(isSnapshot ? " snapshot " : " ").append("iv ").append(artifactId).append("\"")
                        .toString());
                return false;
            }
            allDependencies = cleanDependencies(allDependencies, session, parentVersion);
            Bundle bundle = null;
            Dependency dependency = null;
            // in the following we ignore the first dependency (i=0),
            // because it is the module itself
            for (int i = 1; i < allDependencies.size(); i++) {
                dependency = allDependencies.get(i);
                if (!ARTIFACT_ID_PEPPER_FRAMEWORK.equals(dependency.getArtifact().getArtifactId())) {
                    artifactRequest = new ArtifactRequest();
                    artifactRequest.setArtifact(dependency.getArtifact());
                    artifactRequest.setRepositories(repoList);
                    try {
                        artifactResult = mvnSystem.resolveArtifact(session, artifactRequest);
                        installArtifacts.add(artifactResult.getArtifact());
                    } catch (ArtifactResolutionException e) {
                        logger.warn("Artifact " + dependency.getArtifact().getArtifactId()
                                + " could not be resolved. Dependency will not be installed.");
                        if (!Boolean.parseBoolean(pepperOSGiConnector.getPepperStarterConfiguration()
                                .getProperty("pepper.forceUpdate").toString())) {
                            logger.error("Artifact ".concat(artifact.getArtifactId())
                                    .concat(" will not be installed. Resolution of dependency ")
                                    .concat(dependency.getArtifact().getArtifactId())
                                    .concat(" failed and \"force update\" is disabled in pepper.properties."));
                            return false;
                        }
                    }
                }
            }
            artifact = null;
            Artifact installArtifact = null;
            for (int i = installArtifacts.size() - 1; i >= 0; i--) {
                try {
                    installArtifact = installArtifacts.get(i);
                    logger.info("installing: " + installArtifact);
                    bundle = pepperOSGiConnector.installAndCopy(installArtifact.getFile().toURI());
                    if (i != 0) {// the module itself must not be put on the
                                 // blacklist
                        putOnBlacklist(installArtifact);
                    } else if (installedBundle != null) {
                        pepperOSGiConnector.remove(installedBundle.getSymbolicName());
                        logger.info(
                                "Successfully removed version ".concat(installedBundle.getVersion().toString())
                                        .concat(" of ").concat(artifactId));
                    }
                    if (bundle != null) {
                        bundle.start();
                    }
                } catch (IOException | BundleException e) {
                    if (logger.isTraceEnabled()) {
                        logger.trace("File could not be installed: " + installArtifact + " ("
                                + installArtifact.getFile() + "); " + e.getClass().getSimpleName());
                    } else {
                        logger.warn("File could not be installed: " + installArtifact.getFile());
                    }
                }
            }
            /*
             * btw: root is not supposed to be stored as forbidden
             * dependency. This makes the removal of a module much less
             * complicated. If a pepper module would be put onto the
             * blacklist and the bundle would be removed, we always had to
             * make sure, it its entry on the blacklist would be removed.
             * Assuming the entry would remain on the blacklist, the module
             * could be reinstalled, BUT(!) the dependencies would all be
             * dropped and never being installed again, since the modules
             * node dominates all other nodes in the dependency tree.
             */
            write2Blacklist();
        } else {
            logger.info("No (newer) version of " + artifactId + " could be found.");
        }
    } catch (VersionRangeResolutionException | InvalidVersionSpecificationException
            | DependencyCollectionException e) {
        if (e instanceof DependencyCollectionException) {
            Throwable t = e.getCause();
            while (t.getCause() != null) {
                t = t.getCause();
            }
            if (t instanceof ArtifactNotFoundException) {
                if (logger.isDebugEnabled()) {
                    logger.debug(t.getMessage(), e);
                } else {
                    logger.warn("Update of " + artifactId + " failed, could not resolve dependencies "/*
                                                                                                      * ,
                                                                                                      * e
                                                                                                      */);// TODO
                                                                                                           // decide
                }
            }
            if (t instanceof HttpResponseException) {
                logger.error("Dependency resolution failed!" + System.lineSeparator()
                        + "\tUnsatisfying http response: " + t.getMessage());
            }
        }
        update = false;
    }
    return update;
}

From source file:de.ist.clonto.Ontogui.java

private void runMetricsButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_runMetricsButtonActionPerformed
    String folder = metricName.split(":")[0].toLowerCase();
    String filename = metricName.split(":")[1];
    File metricFile = new File(
            System.getProperty("user.dir") + "/sparql/metrics/" + folder + "/" + filename + ".sparql");

    List<String> lines = null;

    try {//from w w  w.j a  v  a 2s. c om
        lines = Files.readAllLines(metricFile.toPath());
    } catch (IOException ex) {
        Logger.getLogger(Ontogui.class.getName()).log(Level.SEVERE, null, ex);
    }
    String queryString = "";
    for (String line : lines) {
        queryString += line + System.lineSeparator();
    }
    Query query = QueryFactory.create(queryString, Syntax.syntaxARQ);
    queryResultArea.setText("Starting analysis:" + metricName + "\n");
    System.err.println(checkbox1.isEnabled());
    Thread t = new Thread(
            new QueryProcessor(query, new QueryAreaStream(queryResultArea), dataset, checkbox1.getState()));
    t.start();
}

From source file:com.datamelt.nifi.processors.ExecuteRuleEngine.java

/**
 * updates the content of the failure flow file a row of data
 * /*from   www.j  a v  a 2 s.  c  o  m*/
 * @param header         the header row
 * @param headerPresent      indicator from the configuration if a header is present
 * @param context         process context
 * @param session         process session
 * @param someFlowFile      the flow file to update
 * @param content         a row of CSV data
 * @return
 */
private FlowFile updateFailureFlowFileContent(HeaderRow header, boolean headerPresent,
        final ProcessContext context, final ProcessSession session, FlowFile someFlowFile, String content) {
    // write data to output stream
    someFlowFile = session.write(someFlowFile, new OutputStreamCallback() {
        @Override
        public void process(final OutputStream out) throws IOException {
            // buffer to hold the row data/content
            StringBuffer buffer = new StringBuffer();

            // append the header row if present
            if (headerPresent && header != null && header.getNumberOfFields() > 0) {
                String headerRow = header.getFieldNamesWithSeparator();
                buffer.append(headerRow);
                // if the header row does not have a line separator at the end then add it
                if (!headerRow.endsWith(System.lineSeparator())) {
                    buffer.append(System.lineSeparator());
                }
            }

            // append to the buffer
            if (content != null) {
                buffer.append(content);
            }
            final byte[] data = buffer.toString().getBytes();
            out.write(data);
        }
    });
    return someFlowFile;
}

From source file:org.apache.hadoop.yarn.client.cli.TopCLI.java

String getPrintableAppInformation(List<ApplicationInformation> appsInfo) {
    StringBuilder ret = new StringBuilder();
    int limit = terminalHeight - 9;
    List<String> columns = new ArrayList<>();
    for (int i = 0; i < limit; ++i) {
        ret.append(CLEAR_LINE);//from   w w  w .  j  av  a  2 s.co m
        if (i < appsInfo.size()) {
            ApplicationInformation appInfo = appsInfo.get(i);
            columns.clear();
            for (EnumMap.Entry<Columns, ColumnInformation> entry : columnInformationEnumMap.entrySet()) {
                if (entry.getValue().display) {
                    String value = "";
                    if (appInfo.displayStringsMap.containsKey(entry.getKey())) {
                        value = appInfo.displayStringsMap.get(entry.getKey());
                    }
                    columns.add(String.format(entry.getValue().format, value));
                }
            }
            ret.append(limitLineLength((StringUtils.join(columns.toArray(), " ") + System.lineSeparator()),
                    terminalWidth, true));
        } else {
            ret.append(System.lineSeparator());
        }
    }
    return ret.toString();
}

From source file:org.apache.openaz.xacml.pdp.test.TestBase.java

protected void dumpStats() {
    StringBuilder dump = new StringBuilder();
    dump.append(System.lineSeparator());
    dump.append("Permits: " + this.permits + " Expected: " + this.expectedPermits);
    dump.append(System.lineSeparator());
    dump.append("Denies: " + this.denies + " Expected: " + this.expectedDenies);
    dump.append(System.lineSeparator());
    dump.append("NA: " + this.notapplicables + " Expected: " + this.expectedNotApplicables);
    dump.append(System.lineSeparator());
    dump.append("Indeterminates: " + this.indeterminates + " Expected: " + this.expectedIndeterminates);
    dump.append(System.lineSeparator());
    dump.append("Generated Permits: " + this.generatedpermits);
    dump.append(System.lineSeparator());
    dump.append("Generated Denies: " + this.generateddenies);
    dump.append(System.lineSeparator());
    dump.append("Generated NA: " + this.generatednotapplicables);
    dump.append(System.lineSeparator());
    dump.append("Generated Indeterminates: " + this.generatedindeterminates);
    dump.append(System.lineSeparator());
    dump.append("Responses Matched: " + this.responseMatches);
    dump.append(System.lineSeparator());
    dump.append("Responses NOT Matched: " + this.responseNotMatches);

    if (this.permits != this.expectedPermits || this.denies != this.expectedDenies
            || this.notapplicables != this.expectedNotApplicables
            || this.indeterminates != this.expectedIndeterminates || this.responseNotMatches > 0) {
        logger.fatal(dump.toString());//  w  w w . j  a v a2s. co  m
    } else {
        logger.info(dump.toString());
    }
}

From source file:net.certifi.audittablegen.GenericDMR.java

String getDropTriggerSQL(List<DBChangeUnit> op) {

    StringBuilder builder = new StringBuilder();
    String triggerName;/*from w ww .j a va  2  s .c o m*/
    String schema;

    if (verifiedSchema != null) {
        schema = verifiedSchema + ".";
    } else {
        schema = "";
    }

    for (DBChangeUnit unit : op) {
        switch (unit.changeType) {
        case begin:
            //nothing
            break;
        case end:
            //run the sql...
            break;
        case dropTriggers:
            triggerName = unit.tableName + "_audit";
            builder.append("DROP TRIGGER IF EXISTS ").append(triggerName).append(" ON ").append(schema)
                    .append(unit.tableName).append(";").append(System.lineSeparator());
            break;
        default:
            //should not get here if the list is valid, unless a new changetype
            //was added that this DMR does not know about.  If which case - fail.
            logger.error("unimplemented DBChangeUnit {} for drop trigger operation",
                    unit.getChangeType().toString());
            return null;
        }
    }

    return builder.toString();

}

From source file:com.datamelt.nifi.processors.ExecuteRuleEngine.java

/**
 * updates the content of the flow file for each row of data
 * //w w w  .ja v a  2 s  .c  o  m
 * @param header         the header row
 * @param headerPresent      indicator from the configuration if a header is present
 * @param context         process context
 * @param session         process session
 * @param someFlowFile      the flow file to update
 * @param content         the content to write to the flow file
 * @param propertyMap      map of properties of the flow file
 * @return               a flow file
 */
private FlowFile updateFlowFileContent(HeaderRow header, boolean headerPresent, final ProcessContext context,
        final ProcessSession session, FlowFile someFlowFile, RuleEngineRow content) {
    // write data to output stream
    someFlowFile = session.write(someFlowFile, new OutputStreamCallback() {
        @Override
        public void process(final OutputStream out) throws IOException {
            // buffer to hold the row data/content
            StringBuffer buffer = new StringBuffer();

            // append the header row if present
            if (headerPresent && header != null && header.getNumberOfFields() > 0) {
                String headerRow = header.getFieldNamesWithSeparator();
                buffer.append(headerRow);
                // if the header row does not have a line separator at the end then add it
                if (!headerRow.endsWith(System.lineSeparator())) {
                    buffer.append(System.lineSeparator());
                }
            }

            // append to the buffer
            if (content.getRow() != null) {
                buffer.append(content.getRow());
            }
            final byte[] data = buffer.toString().getBytes();
            out.write(data);
        }
    });
    return someFlowFile;
}

From source file:listener.Handler.java

License:asdf

private void help(String[] message) {
    if (acc.hasAccountPrivilege(AccountPrivileges.PERM_CMD_INFO)
            && acc.hasAccountPrivilege(AccountPrivileges.PERM_CMD_HELP)) {
        try {/*from   w  w w . j  a  va 2 s  .  c  o m*/
            StringBuilder info = FileHandler.readStringBuilder("information");
            info.append(FileHandler.readStringBuilder("commandHelp"));
            this.replyMessage(info.toString().replace(System.lineSeparator(), " "));
        } catch (Exception ex) {
            // TODO: find possible exceptions
            String error = "Error when reading help file.";
            Logger.logMessage('E', this, error);
            this.replyMessage(error);
        }
    } else {
        this.noPermAns("help");
    }
}

From source file:fr.univrouen.poste.web.candidat.MyPosteCandidatureController.java

@RequestMapping(params = "find=ByMultiParams", method = RequestMethod.GET)
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_MANAGER')")
public String findPosteCandidatures(HttpServletRequest request, HttpServletResponse response,
        @ModelAttribute("command") PosteCandidatureSearchCriteria searchCriteria, BindingResult bindResult,
        @RequestParam(defaultValue = "off", required = false) Boolean zip,
        @RequestParam(defaultValue = "off", required = false) Boolean mails,
        @RequestParam(defaultValue = "off", required = false) Boolean csv,
        @RequestParam(required = false) Integer page, @RequestParam(required = false) Integer size,
        @RequestParam(required = false) String sortFieldName, @RequestParam(required = false) String sortOrder,
        Model uiModel) throws IOException, SQLException {

    if (zip) {// w w  w .ja va  2 s.  com

        List<PosteCandidature> postecandidatures = PosteCandidature
                .findPostesCandidaturesByPostesAndCandidatAndRecevableAndAuditionnableAndModification(
                        searchCriteria.getPostes(), searchCriteria.getCandidats(),
                        searchCriteria.getReviewStatus(), searchCriteria.getRecevable(),
                        searchCriteria.getAuditionnable(), searchCriteria.getModification(), null, null)
                .getResultList();

        String contentType = "application/zip";
        String baseName = "demat.zip";
        response.setContentType(contentType);
        response.setHeader("Content-Disposition", "attachment; filename=\"" + baseName + "\"");
        zipService.writeZip(postecandidatures, response.getOutputStream());
        return null;
    } else {

        if (mails) {

            List<PosteCandidature> postecandidatures = PosteCandidature
                    .findPostesCandidaturesByPostesAndCandidatAndRecevableAndAuditionnableAndModification(
                            searchCriteria.getPostes(), searchCriteria.getCandidats(),
                            searchCriteria.getReviewStatus(), searchCriteria.getRecevable(),
                            searchCriteria.getAuditionnable(), searchCriteria.getModification(), null, null)
                    .getResultList();
            Set<String> mailAdresses = new HashSet<String>();
            for (PosteCandidature pc : postecandidatures) {
                mailAdresses.add(pc.getEmail());
            }

            List<String> mailAdressesSorted = new ArrayList<String>(mailAdresses);
            Collections.sort(mailAdressesSorted);
            StringBuffer mailAdressesString = new StringBuffer();
            for (String email : mailAdressesSorted) {
                mailAdressesString.append(email).append(System.lineSeparator());
            }

            String contentType = "text/plain";
            String baseName = "emails.txt";
            InputStream inputStream = new ByteArrayInputStream(
                    mailAdressesString.toString().getBytes(StandardCharsets.UTF_8));

            response.setContentType(contentType);
            response.setCharacterEncoding("utf-8");
            response.setHeader("Content-Disposition", "attachment; filename=\"" + baseName + "\"");
            FileCopyUtils.copy(inputStream, response.getOutputStream());

            return null;

        } else if (csv) {

            List<PosteCandidature> posteCandidatures = PosteCandidature
                    .findPostesCandidaturesByPostesAndCandidatAndRecevableAndAuditionnableAndModification(
                            searchCriteria.getPostes(), searchCriteria.getCandidats(),
                            searchCriteria.getReviewStatus(), searchCriteria.getRecevable(),
                            searchCriteria.getAuditionnable(), searchCriteria.getModification(), null, null)
                    .getResultList();

            String contentType = "text/csv";
            String baseName = "candidatures.csv";

            response.setContentType(contentType);
            response.setCharacterEncoding("utf-8");
            response.setHeader("Content-Disposition", "attachment; filename=\"" + baseName + "\"");
            csvService.csvWrite(response.getWriter(), posteCandidatures);

            return null;

        } else {

            if (sortFieldName == null)
                sortFieldName = "o.poste.numEmploi,o.candidat.nom";
            if ("nom".equals(sortFieldName))
                sortFieldName = "candidat.nom";
            if ("email".equals(sortFieldName))
                sortFieldName = "candidat.emailAddress";
            if ("numCandidat".equals(sortFieldName))
                sortFieldName = "candidat.numCandidat";
            if ("managerReviewState".equals(sortFieldName))
                sortFieldName = "managerReview.reviewStatus";

            if (page != null || size != null) {
                int sizeNo = size == null ? 10 : size.intValue();
                final int firstResult = page == null ? 0 : (page.intValue() - 1) * sizeNo;
                uiModel.addAttribute("postecandidatures", PosteCandidature
                        .findPostesCandidaturesByPostesAndCandidatAndRecevableAndAuditionnableAndModification(
                                searchCriteria.getPostes(), searchCriteria.getCandidats(),
                                searchCriteria.getReviewStatus(), searchCriteria.getRecevable(),
                                searchCriteria.getAuditionnable(), searchCriteria.getModification(),
                                sortFieldName, sortOrder)
                        .setFirstResult(firstResult).setMaxResults(sizeNo).getResultList());
                long nbResultsTotal = PosteCandidature
                        .countFindPosteCandidaturesByPostesAndCandidatsAndRecevableAndAuditionnableAndModification(
                                searchCriteria.getPostes(), searchCriteria.getCandidats(),
                                searchCriteria.getReviewStatus(), searchCriteria.getRecevable(),
                                searchCriteria.getAuditionnable(), searchCriteria.getModification());
                uiModel.addAttribute("nbResultsTotal", nbResultsTotal);
                float nrOfPages = (float) nbResultsTotal / sizeNo;
                uiModel.addAttribute("maxPages",
                        (int) ((nrOfPages > (int) nrOfPages || nrOfPages == 0.0) ? nrOfPages + 1 : nrOfPages));
            } else {
                List<PosteCandidature> postecandidatures = PosteCandidature
                        .findPostesCandidaturesByPostesAndCandidatAndRecevableAndAuditionnableAndModification(
                                searchCriteria.getPostes(), searchCriteria.getCandidats(),
                                searchCriteria.getReviewStatus(), searchCriteria.getRecevable(),
                                searchCriteria.getAuditionnable(), searchCriteria.getModification(),
                                sortFieldName, sortOrder)
                        .getResultList();
                uiModel.addAttribute("postecandidatures", postecandidatures);
                uiModel.addAttribute("nbResultsTotal", postecandidatures.size());
            }

            uiModel.addAttribute("texteMembreAideCandidatures",
                    AppliConfig.getCacheTexteMembreAideCandidatures());
            uiModel.addAttribute("texteCandidatAideCandidatures",
                    AppliConfig.getCacheTexteCandidatAideCandidatures());

            uiModel.addAttribute("legendColors", ManagerReviewLegendColor.getLegendColors());

            uiModel.addAttribute("posteapourvoirs", PosteAPourvoir.findAllPosteAPourvoirNumEplois());
            uiModel.addAttribute("candidats", User.findAllCandidatsIds());
            uiModel.addAttribute("reviewStatusList", Arrays.asList(ReviewStatusTypes.values()));

            uiModel.addAttribute("command", searchCriteria);
            uiModel.addAttribute("finderview", true);

            String mailAuditionnableEntete = AppliConfig.getCacheTexteEnteteMailCandidatAuditionnable();
            String mailAuditionnablePiedPage = AppliConfig.getCacheTextePiedpageMailCandidatAuditionnable();
            uiModel.addAttribute("mailAuditionnableEntete", mailAuditionnableEntete);
            uiModel.addAttribute("mailAuditionnablePiedPage", mailAuditionnablePiedPage);

            addDateTimeFormatPatterns(uiModel);
            return "postecandidatures/list";
        }
    }
}