Example usage for org.apache.commons.lang ArrayUtils contains

List of usage examples for org.apache.commons.lang ArrayUtils contains

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils contains.

Prototype

public static boolean contains(boolean[] array, boolean valueToFind) 

Source Link

Document

Checks if the value is in the given array.

Usage

From source file:com.ecyrd.jspwiki.auth.SecurityVerifier.java

/**
 * Verifies that the roles given in the security policy are reflected by the
 * container <code>web.xml</code> file.
 * @throws WikiException if the web authorizer cannot verify the roles
 *//*w  w w.j a va 2  s  . c  o m*/
protected final void verifyPolicyAndContainerRoles() throws WikiException {
    Authorizer authorizer = m_engine.getAuthorizationManager().getAuthorizer();
    Principal[] containerRoles = authorizer.getRoles();
    boolean missing = false;
    for (Principal principal : m_policyPrincipals) {
        if (principal instanceof Role) {
            Role role = (Role) principal;
            boolean isContainerRole = ArrayUtils.contains(containerRoles, role);
            if (!Role.isBuiltInRole(role) && !isContainerRole) {
                m_session.addMessage(ERROR_ROLES,
                        "Role '" + role.getName() + "' is defined in security policy but not in web.xml.");
                missing = true;
            }
        }
    }
    if (!missing) {
        m_session.addMessage(INFO_ROLES,
                "Every non-standard role defined in the security policy was also found in web.xml.");
    }
}

From source file:com.icantrap.collections.dawg.Dawg.java

/**
 * Finds the candidates for next node./*from   w  ww.j  av  a2  s . com*/
 *
 * Note. The long parameter list is because we're trying to minimize allocations.  We could put the candidates in a 
 * collection and return that to be iterated and put on the stack.  That would shrink the parameter list.  Given how
 * often this function is called, that would generate lots of allocations.  In fact, this method originally did return
 * a collection of Nodes, and the Android Logcat showed exorbitant GC.  So now, we have a long parameter list (uglier
 * code), but significantly fewer allocations.
 */
private void addCandidates(Stack<StackEntry> stack, List<PatternToken> patternTokens, int patternIndex,
        int node, char[] letters, String subword, List<Integer> wildcardPositions) {
    if (patternIndex < patternTokens.size()) {
        PatternToken patternToken = patternTokens.get(patternIndex);
        if (patternToken.required) {
            switch (patternToken.letter) {
            case '?':
                for (char letter : getUniqueLetters(letters)) {
                    if (ArrayUtils.contains(letters, '?'))
                        for (Iterator<Integer> iter = childIterator(node); iter.hasNext();)
                            stack.push(new StackEntry(iter.next(), letters, subword, wildcardPositions,
                                    patternIndex));
                    else {
                        int candidate = findChild(node, letter);
                        if (-1 != candidate)
                            stack.push(new StackEntry(candidate, letters, subword, wildcardPositions,
                                    patternIndex));
                    }
                }
                break;
            case (char) -1:
                stack.push(new StackEntry(node, letters, subword, wildcardPositions, patternIndex));
                break;
            default:
                int candidate = findChild(node, patternToken.letter);
                if (-1 != candidate)
                    stack.push(new StackEntry(candidate, letters, subword, wildcardPositions, patternIndex));
                break;
            }
        } else // since this token isn't required, all the children that are in the letters and the letter from the pattern
        {
            if (patternToken.letter != '?') {
                int candidate = findChild(node, patternToken.letter);
                if (candidate != -1)
                    stack.push(new StackEntry(candidate, letters, subword, wildcardPositions, patternIndex));
            }

            addCandidatesFromLetters(stack, node, letters, subword, wildcardPositions, patternIndex);
        }
    } else
        addCandidatesFromLetters(stack, node, letters, subword, wildcardPositions, patternIndex);
}

From source file:adalid.util.meta.sql.MetaPlatformSql.java

private void readFile(WriterContext templateWriterContext, TemplateBean templateBean) {
    File templatePropertiesFile = templateBean.getPropertiesFile();
    VelocityContext fileContext = templateWriterContext.getVelocityContextClone();
    Properties properties = mergeProperties(fileContext, templatePropertiesFile);
    putStrings(fileContext, properties);
    String userPath = pathString(USER_DIR);
    String temptype = StringUtils.defaultIfBlank(properties.getProperty(TP_TYPE), TP_TYPE_VELOCITY);
    String template = StringUtils.trimToNull(properties.getProperty(TP_TEMPLATE));
    String filePath = StringUtils.trimToNull(properties.getProperty(TP_PATH));
    String filePack = StringUtils.trimToNull(properties.getProperty(TP_PACKAGE));
    String fileName = StringUtils.trimToNull(properties.getProperty(TP_FILE));
    String preserve = StringUtils.trimToNull(properties.getProperty(TP_PRESERVE));
    String charset1 = StringUtils.trimToNull(properties.getProperty(TP_ENCODING));
    String charset2 = StringUtils.trimToNull(properties.getProperty(TP_CHARSET));
    String disabled = properties.getProperty(TP_DISABLED, Boolean.FALSE.toString());
    String disabledMissing = properties.getProperty(TP_DISABLED_MISSING);
    String executeCommand = StringUtils.trimToNull(properties.getProperty(TP_EXECUTE_COMMAND));
    String executeDirectory = StringUtils.trimToNull(properties.getProperty(TP_EXECUTE_DIRECTORY));
    String forEach = StringUtils.trimToNull(properties.getProperty(TP_FOR_EACH));
    String hint = ", check property \"{0}\" at file \"{1}\"";
    if (ArrayUtils.contains(TP_TYPE_ARRAY, temptype)) {
    } else {//w ww. j  a  v a 2s .co m
        String pattern = "failed to obtain a valid template type" + hint;
        String message = MessageFormat.format(pattern, TP_TYPE, templatePropertiesFile);
        logger.error(message);
        errors++;
        return;
    }
    if (template == null) {
        String pattern = "failed to obtain a valid template name" + hint;
        String message = MessageFormat.format(pattern, TP_TEMPLATE, templatePropertiesFile);
        logger.error(message);
        errors++;
        return;
    }
    if (fileName == null) {
        String pattern = "failed to obtain a valid file name" + hint;
        String message = MessageFormat.format(pattern, TP_FILE, templatePropertiesFile);
        logger.error(message);
        errors++;
        return;
    }
    String templatePathString = pathString(template);
    String templatePath = StringUtils.substringBeforeLast(templatePathString, FILE_SEPARATOR);
    fileContext.put(VC_TEMPLATE, StringEscapeUtils.escapeJava(templatePathString));
    fileContext.put(VC_TEMPLATE_PATH, StringUtils.replace(templatePath, FILE_SEPARATOR, "/"));
    fileContext.put(VC_FILE, fileName);
    if (filePath == null) {
        filePath = userPath;
    } else {
        filePath = pathString(filePath);
        if (isRelativePath(filePath)) {
            if (filePath.startsWith(FILE_SEPARATOR)) {
                filePath = userPath + filePath;
            } else {
                filePath = userPath + FILE_SEPARATOR + filePath;
            }
        }
    }
    fileContext.put(VC_PATH, StringEscapeUtils.escapeJava(filePath));
    if (filePack != null) {
        filePath += FILE_SEPARATOR + pathString(StringUtils.replace(filePack, ".", "/"));
        fileContext.put(VC_PACKAGE, dottedString(filePack));
    }
    File path = new File(filePath);
    String fullname = path.getPath() + FILE_SEPARATOR + fileName;
    fileContext.put(VC_FILE_PATH, StringEscapeUtils.escapeJava(filePath));
    fileContext.put(VC_FILE_NAME, StringEscapeUtils.escapeJava(fileName));
    fileContext.put(VC_FILE_PATH_NAME, StringEscapeUtils.escapeJava(fullname));
    fileContext.put(VC_FILE_PATH_FILE, path);
    /**/
    templateBean.setPath(templatePathString);
    templateBean.setType(temptype);
    templateBean.setEncoding(charset1);
    templateBean.setForEach(forEach);
    templateBean.setTargetPath(filePath);
    templateBean.setTargetPackage(filePack);
    templateBean.setTargetFile(fileName);
    templateBean.setTargetFileEncoding(charset2);
    templateBean.setExecuteCommand(executeCommand);
    templateBean.setExecuteDirectory(executeDirectory);
    templateBean.setDisabled(BitUtils.valueOf(disabled));
    templateBean.setDisabledWhenMissing(BitUtils.valueOf(disabledMissing));
    templateBean.setPreserveExistingFile(BitUtils.valueOf(preserve));
    templateBean.setBytes(0);
    templateBean.setLines(0);
}

From source file:com.prowidesoftware.swift.model.AbstractSwiftMessage.java

/**
 * Get the last saved status data of this message or empty string if not found
 * @param statuses an array of statuses to check data into, if <code>null</code> all message statuses are checked for data
 * @return the most recent (last) status data found
 *///  w w  w. j  a v  a 2 s .c o m
public String getLastData(String... statuses) {
    List<SwiftMessageStatusInfo> l = getStatusTrail();
    if (l != null && !l.isEmpty()) {
        for (int i = l.size() - 1; i >= 0; i--) {
            String d = l.get(i).getData();
            if (d != null && (statuses == null || ArrayUtils.contains(statuses, l.get(i).getName()))) {
                return d;
            }
        }
    }
    return "";
}

From source file:com.l2jserver.gameserver.features.data.Q00255_Tutorial.java

@Override
public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    if (Config.DISABLE_TUTORIAL) {
        return "";
    }//from  w  w  w  . j  av  a2s .  co m

    QuestState st = player.getQuestState(getName());
    String htmltext = "";
    final int classId = player.getClassId().getId();
    final int playerLevel = player.getLevel();
    final int Ex = st.getInt("Ex");

    if (event.startsWith("UC")) {
        if ((playerLevel < 6) && (st.getInt("onlyone") == 0)) {
            final int uc = st.getInt("ucMemo");

            switch (uc) {
            case 0:
                st.set("ucMemo", "0");
                st.startQuestTimer("QT", 10000);
                st.set("ucMemo", "0");
                st.set("Ex", "-2");
                break;
            case 1:
                st.showQuestionMark(1);
                st.playTutorialVoice("tutorial_voice_006");
                st.playSound("ItemSound.quest_tutorial");
                break;
            case 2:
                if (Ex == 2) {
                    st.showQuestionMark(3);
                    st.playSound("ItemSound.quest_tutorial");
                }

                if (st.getQuestItemsCount(6353) == 1) {
                    st.showQuestionMark(5);
                    st.playSound("ItemSound.quest_tutorial");
                }
                break;
            case 3:
                st.showQuestionMark(12);
                st.playSound("ItemSound.quest_tutorial");
                st.onTutorialClientEvent(0);
                break;
            default:
                break;
            }
        } else {
            switch (playerLevel) {
            case 18:
                if (player.getQuestState("Q10276_MutatedKaneusGludio") == null) {
                    st.showQuestionMark(33);
                    st.playSound("ItemSound.quest_tutorial");
                }
                break;
            case 28:
                if (((player.getQuestState("Q10277_MutatedKaneusDion") == null)
                        || (player.getQuestState("Q10278_MutatedKaneusHeine") == null))
                        || (player.getQuestState("Q10279_MutatedKaneusOren") == null)
                        || (player.getQuestState("Q10280_MutatedKaneusSchuttgart") == null)
                        || (player.getQuestState("Q10281_MutatedKaneusRune") == null)) {
                    st.showQuestionMark(33);
                    st.playSound("ItemSound.quest_tutorial");
                }
                break;
            case 79:
                if (player.getQuestState("Q00192_SevenSignSeriesOfDoubt") == null) {
                    st.showQuestionMark(33);
                    st.playSound("ItemSound.quest_tutorial");
                }
                break;
            }
        }
    } else if (event.startsWith("QT")) {
        switch (Ex) {
        case -2:
            String voice = "";
            for (String[] element : QTEXMTWO) {
                if (classId == Integer.valueOf(element[0])) {
                    voice = element[1];
                    htmltext = element[2];
                }
                st.playTutorialVoice(voice);
            }
            if (st.getQuestItemsCount(5588) == 0) {
                st.giveItems(5588, 1);
            }
            st.set("Ex", "-3");
            st.startQuestTimer("QT", 30000);
            break;
        case -3:
            st.playTutorialVoice("tutorial_voice_002");
            st.set("Ex", "0");
            break;
        case -4:
            st.playTutorialVoice("tutorial_voice_008");
            st.set("Ex", "-5");
            break;
        }
    } else if (event.startsWith("TE")) {
        final int eventId = Integer.valueOf(event.substring(2));

        switch (eventId) {
        case 0:
            st.closeTutorialHtml();
            break;
        case 1:
            st.closeTutorialHtml();
            st.playTutorialVoice("tutorial_voice_006");
            st.showQuestionMark(1);
            st.playSound("ItemSound.quest_tutorial");
            st.startQuestTimer("QT", 30000);
            st.set("Ex", "-4");
            break;
        case 2:
            st.playTutorialVoice("tutorial_voice_003");
            htmltext = "tutorial_02.htm";
            st.onTutorialClientEvent(1);
            st.set("Ex", "-5");
            break;
        case 3:
            htmltext = "tutorial_03.htm";
            st.onTutorialClientEvent(2);
            break;
        case 5:
            htmltext = "tutorial_05.htm";
            st.onTutorialClientEvent(8);
            break;
        case 7:
            htmltext = "tutorial_100.htm";
            st.onTutorialClientEvent(0);
            break;
        case 8:
            htmltext = "tutorial_101.htm";
            st.onTutorialClientEvent(0);
            break;
        case 10:
            htmltext = "tutorial_103.htm";
            st.onTutorialClientEvent(0);
            break;
        case 12:
            st.closeTutorialHtml();
            break;
        case 23:
            for (String[] element : TCL_B) {
                if (classId == Integer.valueOf(element[0])) {
                    htmltext = element[1];
                }
            }
            break;
        case 24:
            for (String[] element : TCL_C) {
                if (classId == Integer.valueOf(element[0])) {
                    htmltext = element[1];
                }
            }
            break;
        case 25:
            htmltext = "tutorial_22cc.htm";
            break;
        case 26:
            for (String[] element : TCL_A) {
                if (classId == Integer.valueOf(element[0])) {
                    htmltext = element[1];
                }
            }
            break;
        case 27:
            htmltext = "tutorial_29.htm";
            break;
        case 28:
            htmltext = "tutorial_28.htm";
            break;
        }
    } else if (event.startsWith("CE")) {
        final int eventId = Integer.valueOf(event.substring(2));

        switch (eventId) {
        case 1:
            if (playerLevel < 6) {
                st.playTutorialVoice("tutorial_voice_004");
                htmltext = "tutorial_03.htm";
                st.playSound("ItemSound.quest_tutorial");
                st.onTutorialClientEvent(2);
            }
            break;
        case 2:
            if (playerLevel < 6) {
                st.playTutorialVoice("tutorial_voice_005");
                htmltext = "tutorial_05.htm";
                st.playSound("ItemSound.quest_tutorial");
                st.onTutorialClientEvent(8);
            }
            break;
        case 8:
            if (playerLevel < 6) {
                int x = 0;
                int y = 0;
                int z = 0;
                for (String[] element : CEE_A) {
                    if (classId == Integer.valueOf(element[0])) {
                        htmltext = element[1];
                        x = Integer.valueOf(element[2]);
                        y = Integer.valueOf(element[3]);
                        z = Integer.valueOf(element[4]);
                    }
                }
                st.addRadar(x, y, z);
                st.playTutorialVoice("tutorial_voice_007");
                st.set("ucMemo", "1");
                st.set("Ex", "-5");
            }
            break;
        case 30:
            if ((playerLevel < 10) && (st.getInt("Die") == 0)) {
                st.playTutorialVoice("tutorial_voice_016");
                st.playSound("ItemSound.quest_tutorial");
                st.set("Die", "1");
                st.showQuestionMark(8);
                st.onTutorialClientEvent(0);
            }
            break;
        case 800000:
            if ((playerLevel < 6) && (st.getInt("sit") == 0)) {
                st.playTutorialVoice("tutorial_voice_018");
                st.playSound("ItemSound.quest_tutorial");
                st.set("sit", "1");
                st.onTutorialClientEvent(0);
                htmltext = "tutorial_21z.htm";
            }
            break;
        case 40:
            if ((playerLevel == 5) && (player.getClassId().level() == 0)) {
                if (st.getInt("lvl") < 5) {
                    if (!player.getClassId().isMage() || (classId == 49)) {
                        st.playTutorialVoice("tutorial_voice_014");
                        st.showQuestionMark(9);
                        st.playSound("ItemSound.quest_tutorial");
                        st.set("lvl", "5");
                    }
                }
            } else if ((playerLevel == 6) && (st.getInt("lvl") < 6) && (player.getClassId().level() == 0)) {
                st.playTutorialVoice("tutorial_voice_020");
                st.playSound("ItemSound.quest_tutorial");
                st.showQuestionMark(24);
                st.set("lvl", "6");
            } else if ((playerLevel == 7) && player.getClassId().isMage() && (classId != 49)) {
                if ((st.getInt("lvl") < 7) && (player.getClassId().level() == 0)) {
                    st.playTutorialVoice("tutorial_voice_019");
                    st.playSound("ItemSound.quest_tutorial");
                    st.set("lvl", "7");
                    st.showQuestionMark(11);
                }
            } else {
                switch (playerLevel) {
                case 10:
                    if (st.getInt("lvl") < 10) {
                        st.playTutorialVoice("tutorial_voice_030");
                        st.playSound("ItemSound.quest_tutorial");
                        st.set("lvl", "10");
                        st.showQuestionMark(27);
                    }
                    break;
                case 15:
                    if (st.getInt("lvl") < 15) {
                        st.playSound("ItemSound.quest_tutorial");
                        st.set("lvl", "15");
                        st.showQuestionMark(17);
                    }
                    break;
                case 18:
                    if (st.getInt("lvl") < 18) {
                        st.playSound("ItemSound.quest_tutorial");
                        st.set("lvl", "18");
                        st.showQuestionMark(33);
                    }
                    break;
                case 19:
                    if (st.getInt("lvl") < 19) {
                        final int race = player.getRace().ordinal();
                        if ((race != 5) && (player.getClassId().level() == 0)) {
                            final int[] classIds = { 0, 10, 18, 25, 31, 38, 44, 49, 52 };
                            if (ArrayUtils.contains(classIds, classId)) {
                                st.playSound("ItemSound.quest_tutorial");
                                st.set("lvl", "19");
                                st.showQuestionMark(35);
                            }
                        }
                    }
                    break;
                case 28:
                    if (st.getInt("lvl") < 28) {
                        st.playSound("ItemSound.quest_tutorial");
                        st.set("lvl", "28");
                        st.showQuestionMark(33);
                    }
                    break;
                case 35:
                    if (st.getInt("lvl") < 35) {
                        final int race = player.getRace().ordinal();
                        if ((race != 5) && (player.getClassId().level() == 1)) {
                            final int[] classIds = { 1, 4, 7, 11, 15, 19, 22, 26, 29, 32, 35, 39, 42, 45, 47,
                                    50, 54, 56 };
                            if (ArrayUtils.contains(classIds, classId)) {
                                st.playSound("ItemSound.quest_tutorial");
                                st.set("lvl", "35");
                                st.showQuestionMark(34);
                            }
                        }
                    }
                    break;
                case 38:
                    if (st.getInt("lvl") < 38) {
                        st.playSound("ItemSound.quest_tutorial");
                        st.set("lvl", "38");
                        st.showQuestionMark(33);
                    }
                    break;
                case 48:
                    if (st.getInt("lvl") < 48) {
                        st.playSound("ItemSound.quest_tutorial");
                        st.set("lvl", "48");
                        st.showQuestionMark(33);
                    }
                    break;
                case 58:
                    if (st.getInt("lvl") < 58) {
                        st.playSound("ItemSound.quest_tutorial");
                        st.set("lvl", "58");
                        st.showQuestionMark(33);
                    }
                    break;
                case 68:
                    if (st.getInt("lvl") < 68) {
                        st.playSound("ItemSound.quest_tutorial");
                        st.set("lvl", "68");
                        st.showQuestionMark(33);
                    }
                    break;
                case 79:
                    if (st.getInt("lvl") < 79) {
                        st.playSound("ItemSound.quest_tutorial");
                        st.set("lvl", "79");
                        st.showQuestionMark(33);
                    }
                    break;
                }
            }
            break;
        case 45:
            if (playerLevel < 10) {
                if (st.getInt("HP") == 0) {
                    st.playTutorialVoice("tutorial_voice_017");
                    st.playSound("ItemSound.quest_tutorial");
                    st.set("HP", "1");
                    st.showQuestionMark(10);
                    st.onTutorialClientEvent(800000);
                }
            }
            break;
        case 57:
            if ((playerLevel < 6) && (st.getInt("Adena") == 0)) {
                st.playTutorialVoice("tutorial_voice_012");
                st.playSound("ItemSound.quest_tutorial");
                st.set("Adena", "1");
                st.showQuestionMark(23);
            }
            break;
        case 6353:
            if ((playerLevel < 6) && (st.getInt("Gemstone") == 0)) {
                st.playTutorialVoice("tutorial_voice_013");
                st.playSound("ItemSound.quest_tutorial");
                st.set("Gemstone", "1");
                st.showQuestionMark(5);
            }
            break;
        }
    } else if (event.startsWith("QM")) {
        final int eventId = Integer.valueOf(event.substring(2));

        int x = 0;
        int y = 0;
        int z = 0;

        switch (eventId) {

        case 1:
            st.playTutorialVoice("tutorial_voice_007");
            st.set("Ex", "-5");
            for (String[] element : CEE_A) {
                if (classId == Integer.valueOf(element[0])) {
                    htmltext = element[1];
                    x = Integer.valueOf(element[2]);
                    y = Integer.valueOf(element[3]);
                    z = Integer.valueOf(element[4]);
                }
            }
            st.addRadar(x, y, z);
            break;
        case 3:
            htmltext = "tutorial_09.htm";
            break;
        case 5:
            for (String[] element : CEE_A) {
                if (classId == Integer.valueOf(element[0])) {
                    htmltext = element[1];
                    x = Integer.valueOf(element[2]);
                    y = Integer.valueOf(element[3]);
                    z = Integer.valueOf(element[4]);
                }
            }
            st.addRadar(x, y, z);
            htmltext = "tutorial_11.htm";
            break;
        case 7:
            htmltext = "tutorial_15.htm";
            st.set("ucMemo", "3");
            break;
        case 8:
            htmltext = "tutorial_18.htm";
            break;
        case 9:
            for (String[] element : QMC_A) {
                if (classId == Integer.valueOf(element[0])) {
                    htmltext = element[1];
                    x = Integer.valueOf(element[2]);
                    y = Integer.valueOf(element[3]);
                    z = Integer.valueOf(element[4]);
                }
            }
            st.addRadar(x, y, z);
            break;
        case 10:
            htmltext = "tutorial_19.htm";
            break;
        case 11:
            for (String[] element : QMC_A) {
                if (classId == Integer.valueOf(element[0])) {
                    htmltext = element[1];
                    x = Integer.valueOf(element[2]);
                    y = Integer.valueOf(element[3]);
                    z = Integer.valueOf(element[4]);
                }
            }
            st.addRadar(x, y, z);
            break;
        case 12:
            htmltext = "tutorial_15.htm";
            st.set("ucMemo", "4");
            break;
        case 13:
            htmltext = "tutorial_30.htm";
            break;
        case 17:
            htmltext = "tutorial_27.htm";
            break;
        case 23:
            htmltext = "tutorial_24.htm";
            break;
        case 24:
            for (String[] element : QMC_B) {
                if (classId == Integer.valueOf(element[0])) {
                    htmltext = element[1];
                }
            }
            break;
        case 26:
            if (player.getClassId().isMage() && (classId != 49)) {
                htmltext = "tutorial_newbie004b.htm";
            } else {
                htmltext = "tutorial_newbie004a.htm";
            }
            break;
        case 27:
            htmltext = "tutorial_20.htm";
            break;
        case 33:
            switch (playerLevel) {
            case 18:
                htmltext = "tutorial_kama_18.htm";
                break;
            case 28:
                htmltext = "tutorial_kama_28.htm";
                break;
            case 38:
                htmltext = "tutorial_kama_38.htm";
                break;
            case 48:
                htmltext = "tutorial_kama_48.htm";
                break;
            case 58:
                htmltext = "tutorial_kama_58.htm";
                break;
            case 68:
                htmltext = "tutorial_kama_68.htm";
                break;
            case 79:
                htmltext = "tutorial_epic_quest.htm";
                break;
            }
            break;
        case 34:
            htmltext = "tutorial_28.htm";
            break;
        case 35:
            for (String[] element : QMC_C) {
                if (classId == Integer.valueOf(element[0])) {
                    htmltext = element[1];
                }
            }
            break;
        }
    }

    if (htmltext.isEmpty()) {
        return "";
    }

    st.showTutorialHTML(htmltext);

    return "";
}

From source file:net.di2e.ecdr.commons.query.rest.parsers.BasicQueryParser.java

protected boolean isUniqueQuery(MultivaluedMap<String, String> queryParameters, String sourceId) {
    boolean isUniqueQuery = true;
    isUniqueQuery = queryRequestCache.isQueryIdUnique(queryParameters.getFirst(SearchConstants.OID_PARAMETER));

    String path = queryParameters.getFirst(BrokerConstants.PATH_PARAMETER);
    if (StringUtils.isNotBlank(path)) {
        String[] pathValues = path.split(",");
        if (ArrayUtils.contains(pathValues, sourceId)) {
            isUniqueQuery = false;//from ww  w . j  a v  a  2  s .c o m
        }
    }
    return isUniqueQuery;
}

From source file:de.ingrid.interfaces.csw.admin.EditIBusHarvesterController.java

@RequestMapping(value = TEMPLATE_EDIT_HARVESTER_3, method = RequestMethod.POST)
public String step3Post(final HttpServletRequest request, final HttpSession session, final ModelMap modelMap,
        @ModelAttribute("harvester") final IBusHarvesterCommandObject harvester, final Errors errors,
        @RequestParam(value = "enable", required = false) final String enable,
        @RequestParam(value = "disable", required = false) final String disable,
        @RequestParam(value = "edit", required = false) final String edit) throws Exception {

    if (enable != null && enable.length() > 0) {
        RequestDefinition rd = new RequestDefinition();
        rd.setPlugId(enable);/*from   w  w w  . j a  va2 s  .  c o m*/

        String query = "iplugs:\"" + enable + "\" ranking:score";
        // if datatype metadata is supported, then also filter by that datatype
        // since an iPlug can have multiple indices now, we do not want to fetch addresses for example
        if (ArrayUtils.contains(iplugDatatypesMap.get(enable), "metadata")) {
            query += " datatype:metadata";
        }
        rd.setQueryString(query);

        if (harvester.getRequestDefinitions() == null) {
            harvester.setRequestDefinitions(new ArrayList<RequestDefinition>());
        }
        harvester.getRequestDefinitions().add(rd);

        updateAndSaveConfiguration((HarvesterConfiguration) harvester);

    } else if (disable != null && disable.length() > 0) {
        int idx = -1;
        for (RequestDefinition rd : harvester.getRequestDefinitions()) {
            if (rd.getPlugId().equals(disable)) {
                idx = harvester.getRequestDefinitions().indexOf(rd);
                break;
            }
        }
        if (idx > -1) {
            harvester.getRequestDefinitions().remove(idx);
        }
        updateAndSaveConfiguration((HarvesterConfiguration) harvester);
        indexManager.removeDocumentsByQuery("iplug:\"" + disable + "\"");

    } else if (edit != null && edit.length() > 0) {
        return "redirect:" + EditIBusHarvesterController.TEMPLATE_EDIT_HARVESTER_4 + "?plugid=" + edit;
    } else if (WebUtils.hasSubmitParameter(request, "back")) {
        return "redirect:" + TEMPLATE_EDIT_HARVESTER_2;
    }

    return "redirect:" + TEMPLATE_EDIT_HARVESTER_3;
}

From source file:com.flexive.ejb.beans.UserGroupEngineBean.java

/**
 * {@inheritDoc}//from  w w  w  .j ava  2  s  . c  om
 */
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void setRoles(long groupId, long[] roles) throws FxApplicationException {

    final UserTicket ticket = FxContext.getUserTicket();

    UserGroup aGroup = CacheAdmin.getEnvironment().getUserGroup(groupId);

    // Permission check
    if (!ticket.isGlobalSupervisor())
        try {
            if (aGroup.getMandatorId() != ticket.getMandatorId()) {
                // foreign mandator
                throw new FxNoAccessException("ex.usergroup.noPermSetRoles", aGroup.getName());
            }
            if (!(ticket.isInRole(Role.AccountManagement) || ticket.isInRole(Role.MandatorSupervisor))) {
                throw new FxNoAccessException("ex.usergroup.noPermSetRoles", aGroup.getName());
            }
        } catch (FxNoAccessException nae) {
            if (LOG.isInfoEnabled())
                LOG.info(nae);
            throw nae;
        }

    // Bye bye duplicates
    roles = FxArrayUtils.removeDuplicates(roles);
    //only allow to assign roles which the calling user is a member of (unless it is a global supervisor)
    if (!ticket.isGlobalSupervisor()) {
        List<Role> orgRoles = getRoles(groupId);
        List<Long> orgRoleIds = FxSharedUtils.getSelectableObjectIdList(orgRoles);
        //check removed roles
        for (long check : orgRoleIds) {
            if (!ArrayUtils.contains(roles, check)) {
                if (!ticket.isInRole(Role.getById(check))) {
                    EJBUtils.rollback(ctx);
                    throw new FxNoAccessException("ex.account.roles.assign.noMember.remove",
                            Role.getById(check).getName());
                }
            }
        }
        //check added roles
        for (long check : roles) {
            if (!orgRoleIds.contains(check)) {
                if (!ticket.isInRole(Role.getById(check))) {
                    EJBUtils.rollback(ctx);
                    throw new FxNoAccessException("ex.account.roles.assign.noMember.add",
                            Role.getById(check).getName());
                }
            }
        }
    }

    // Write roles to database
    Connection con = null;
    Statement stmt = null;
    String sCurSql;

    try {
        // Obtain a database connection
        con = Database.getDbConnection();

        // Delete the old assignments of the user
        sCurSql = "DELETE FROM " + TBL_ROLE_MAPPING + " WHERE USERGROUP=" + groupId;
        stmt = con.createStatement();
        stmt.executeUpdate(sCurSql);
        stmt.close();

        // Store the new assignments of the user
        for (long role : roles) {

            if (Role.isUndefined(role))
                continue;

            stmt = con.createStatement();
            sCurSql = "INSERT INTO " + TBL_ROLE_MAPPING + " (ACCOUNT,USERGROUP,ROLE) VALUES ("
                    + Account.NULL_ACCOUNT + "," + groupId + "," + role + ")";
            stmt.executeUpdate(sCurSql);
            stmt.close();
        }

        // Update all active user tickets that are affected
        UserTicketStore.flagDirtyHavingGroupId(groupId);

    } catch (SQLException exc) {
        EJBUtils.rollback(ctx);
        FxUpdateException dbe = new FxUpdateException(exc, "ex.usergroup.updateRolesSqlException",
                aGroup.getName());
        LOG.error(dbe);
        throw dbe;
    } finally {
        Database.closeObjects(UserGroupEngineBean.class, con, stmt);
    }

}

From source file:it.openutils.mgnlaws.magnolia.init.ClasspathProviderImpl.java

/**
 * @see info.magnolia.repository.Provider#registerWorkspace(java.lang.String)
 *//* w w w.  j  ava  2  s . c  om*/
public boolean registerWorkspace(String workspaceName) throws RepositoryException {
    // check if workspace already exists
    SimpleCredentials credentials = new SimpleCredentials(ContentRepository.REPOSITORY_USER,
            ContentRepository.REPOSITORY_PSWD.toCharArray());
    Session jcrSession = this.repository.login(credentials);

    try {
        WorkspaceImpl defaultWorkspace = (WorkspaceImpl) jcrSession.getWorkspace();
        String[] workspaceNames = defaultWorkspace.getAccessibleWorkspaceNames();

        boolean alreadyExists = ArrayUtils.contains(workspaceNames, workspaceName);
        if (!alreadyExists) {
            defaultWorkspace.createWorkspace(workspaceName);
        }
        jcrSession.logout();

        return !alreadyExists;
    } catch (ClassCastException e) {
        // this could happen if the repository provider does not have proper Shared API for the
        // application server like at the moment in Jackrabbit
        log.debug("Unable to register workspace, will continue", e);
    } catch (Throwable t) {
        log.error("Unable to register workspace, will continue", t);
    }
    return false;
}

From source file:marytts.unitselection.analysis.Phone.java

/**
 * Get the F0 values from a SelectedUnit's Datagrams.
 * <p>//w ww.j  a  v  a  2s .  c o m
 * Since these are not stored explicitly, we are forced to rely on the inverse of the Datagram durations, which means that
 * during unvoiced regions, we recover a value of 100 Hz...
 * 
 * @param unit
 *            from whose Datagrams to recover the F0 values
 * @return the F0 value of each Datagram in the unit in an array, or null if the unit is null or any of the Datagrams have
 *         zero duration
 */
private double[] getUnitF0Values(SelectedUnit unit) {
    double[] f0Values = null;
    try {
        double[] durations = getUnitFrameDurations(unit);
        if (!ArrayUtils.contains(durations, 0)) {
            f0Values = MathUtils.invert(durations);
        } else {
            // leave at null
        }
    } catch (IllegalArgumentException e) {
        // leave at null
    }
    return f0Values;
}