Example usage for java.util Hashtable containsKey

List of usage examples for java.util Hashtable containsKey

Introduction

In this page you can find the example usage for java.util Hashtable containsKey.

Prototype

public synchronized boolean containsKey(Object key) 

Source Link

Document

Tests if the specified object is a key in this hashtable.

Usage

From source file:org.accada.reader.rprm.core.Source.java

/**
 * Adds information about the source to the report.
 * @param report/*  w  w  w. j  av a  2s . c o  m*/
 *           The report to modify
 * @param dataSelector
 *           The dataSelector to use
 */
protected void addSourceInfo(final SourceReport report, final DataSelector dataSelector) {

    Hashtable fieldNames = dataSelector.getFieldNames();

    if (!report.containsSourceInfo()) {
        SourceInfoType newSourceInfo = new SourceInfoType();
        report.setSourceInfo(newSourceInfo);
    }

    // SOURCE_NAME
    report.getSourceInfo().setSourceName(this.getName());
    log.debug("Source name in source report set to: " + report.getSourceInfo().getSourceName());

    // SOURCE_FREQUENCY
    if (fieldNames.containsKey(FieldName.SOURCE_FREQUENCY) || fieldNames.containsKey(FieldName.ALL_SOURCE)
            || fieldNames.containsKey(FieldName.ALL)) {
        report.getSourceInfo().setSourceFrequency(0);
    } else {
        report.getSourceInfo().setSourceFrequency(-1);
    }

    // SOURCE_PROTOCOL
    if (fieldNames.containsKey(FieldName.SOURCE_PROTOCOL) || fieldNames.containsKey(FieldName.ALL_SOURCE)
            || fieldNames.containsKey(FieldName.ALL)) {
        // Not supported in HardwareAbstraction
        report.getSourceInfo().setSourceProtocol("not supported");
    } else {
        report.getSourceInfo().setSourceProtocol(null);
    }

}

From source file:com.hrs.controller.front.UpdateResumeController.java

@RequestMapping(value = "/resumeUpdate")
public String resumeDownQuery(HttpServletRequest req, HttpSession session, ModelMap modelMap, Integer guid)
        throws Exception {
    String hinderLevel = "", hinderType = "", stillWorking = "";

    // logger.info("id:" + guid);
    List<String> salaryRangeList = salaryRangeList();
    List<String> hinderTypeList = hinderTypeList();
    List<String> hinderLevelList = hinderLevelList();
    List<String> enableDateList = enableDateList();
    List<String> eduBgList = eduBgList();

    // skills/*from   w  w  w. j a v a 2s  .c  o m*/
    List<String> computerSkillList = computerSkillList();
    List<String> oaList = oaList();
    List<String> osList = osList();
    List<String> programList = programList();
    List<String> dbList = dbList();
    List<String> imageList = imageList();
    List<String> uiList = uiList();
    List<String> multimediaList = multimediaList();
    List<String> hardwareList = hardwareList();
    List<String> erpList = erpList();
    List<String> infoList = infoList();
    List<String> hardwareDevList = hardwareDevList();

    List<String> sexList = sexList();
    List<String> maritalStatusList = maritalStatusList();
    List<String> vateranStatusList = vateranStatusList();
    List<String> identityCategoryList = identityCategoryList();
    List<String> stillWorkingList = stillWorkingList();
    List<String> schoolStatusList = schoolStatusList();

    // language
    List<String> languageList = languageList();
    List<String> otherLanguageList = otherLanguageList();
    List<String> LanguageProficiencyList = LanguageProficiencyList();

    List<String> companySizeList = companySizeList();
    List<YearsListDTO> yearsList = newResumeService.getYearsList();
    List<LanguageProficiencyDTO> languageDtoList = new ArrayList<LanguageProficiencyDTO>();
    List<String> languageTypeList = new ArrayList<String>();

    // postType
    List<String> postTypeLevelList = postTypeLevelList();
    List<String> postTypeByManageList = postTypeByManageList();
    List<String> postTypeBySalesList = postTypeBySalesList();
    List<String> postTypeByComputerList = postTypeByComputerList();
    List<String> postTypeByMachineList = postTypeByMachineList();
    List<String> postTypeByPurchaseList = postTypeByPurchaseList();
    List<String> postTypeByMedicalList = postTypeByMedicalList();
    List<String> postTypeByTvList = postTypeByTvList();
    List<String> postTypeByLegalList = postTypeByLegalList();
    List<String> postTypeByPreschoolList = postTypeByPreschoolList();
    List<String> postTypeByLifeList = postTypeByLifeList();
    List<String> postTypeByfinanceList = postTypeByfinanceList();
    List<String> postTypeBySellList = postTypeBySellList();
    List<String> postTypeByIcList = postTypeByIcList();
    List<String> postTypeByMaintainList = postTypeByMaintainList();
    List<String> postTypeByBuildList = postTypeByBuildList();
    List<String> postTypeByBiologicalList = postTypeByBiologicalList();
    List<String> postTypeByArtList = postTypeByArtList();
    List<String> postTypeByEduList = postTypeByEduList();
    List<String> postTypeByCosmetologyList = postTypeByCosmetologyList();
    List<String> postTypeByPoliceList = postTypeByPoliceList();

    Hashtable<Integer, String> languageMap = MapTableArray.languageByUpdateMap();

    Hashtable<Integer, String> otherLanguageMap = MapTableArray.otherLanguageByUpdateMap();

    List<String> certificateByEnglishList = certificateByEnglishList();

    List<String> certificateByJapaneseList = certificateByJapaneseList();

    UpdateResumeDTO updateResumeDTO = updateResumeService.getResumeDetails(guid);
    // logger.info("show basic info id= "
    // + updateResumeDTO.getBasicInformation().getId());
    // logger.info("show basic info guid= "
    // + updateResumeDTO.getBasicInformation().getGuid());
    // logger.info("show basic info id= "
    // + updateResumeDTO.getContactInformation().getId());

    stillWorking = updateResumeDTO.getBasicInformation().isStillWorking() ? "(??)"
            : "()";
    HashMap<String, String> hinderMap = new HashMap<String, String>();
    hinderMap = setHinderData(updateResumeDTO.getBasicInformation().getHinder());
    hinderLevel = hinderMap.get("hinderLevel");
    hinderType = hinderMap.get("hinderType");
    logger.info("hinderLevel = " + hinderLevel);
    logger.info("hinderType = " + hinderType);

    // logger.info("experiences size = "
    // + updateResumeDTO.getExperiences().size());
    // String postType = "";
    setPostYearsData(updateResumeDTO.getExperiences());
    HashMap<String, Boolean> certificateByEnglishMap = new HashMap<String, Boolean>();
    HashMap<String, String> fractionByEnglishMap = new HashMap<String, String>();
    HashMap<String, Integer> idByEnglishMap = new HashMap<String, Integer>();
    HashMap<String, Boolean> certificateByJapaneseMap = new HashMap<String, Boolean>();
    HashMap<String, String> fractionByJapaneseMap = new HashMap<String, String>();
    HashMap<String, Integer> idByJapaneseMap = new HashMap<String, Integer>();

    logger.info("LanguageProficiencies size = " + updateResumeDTO.getLanguageProficiencies().size());

    for (LanguageProficiency temp : updateResumeDTO.getLanguageProficiencies()) {
        LanguageProficiencyDTO languageDto = new LanguageProficiencyDTO();
        languageDto.setId(temp.getId());
        // logger.info("LanguageProficiency id = " + languageDto.getId());
        languageDto.setLocal(languageMap.containsKey(temp.getLanguages()) ? false : true);

        if (languageDto.isLocal() == true) {
            languageDto.setLanguageType(otherLanguageMap.get(temp.getLanguages()));
        } else {
            languageDto.setLanguageType(languageMap.get(temp.getLanguages()));
        }
        String certificate = "", fraction = "";
        for (LanguageCertificates listens : updateResumeDTO.getLanguageCertificateses()) {
            if (determineLanguageTypeByEnglishAndName(languageDto.getLanguageType(), listens.getName())) {
                if (certificateByEnglishList.contains(listens.getName())) {
                    certificateByEnglishMap.put(listens.getName(), true);
                    fractionByEnglishMap.put(listens.getName(), listens.getFraction());
                    idByEnglishMap.put(listens.getName(), listens.getId());
                }

                certificate += listens.getName() + " ";
                fraction += listens.getFraction() + " ";

                languageDto.setCertificate(certificate);
                languageDto.setFraction(fraction);
            }

            if (determineLanguageTypeByJapaneseAndName(languageDto.getLanguageType(), listens.getName())) {
                if (certificateByJapaneseList.contains(listens.getName())) {
                    certificateByJapaneseMap.put(listens.getName(), true);
                    fractionByJapaneseMap.put(listens.getName(), listens.getFraction());
                    idByJapaneseMap.put(listens.getName(), listens.getId());
                }

                certificate += listens.getName() + " ";
                fraction += listens.getFraction() + " ";

                languageDto.setCertificate(certificate);
                languageDto.setFraction(fraction);
            }

        }

        languageDto.setListen(temp.getListen());
        languageDto.setSay(temp.getSay());
        languageDto.setReading(temp.getReading());
        languageDto.setWrite(temp.getWrite());
        languageDtoList.add(languageDto);
        languageTypeList.add(languageDto.getLanguageType());
    }

    modelMap.addAttribute("resumeDTO", updateResumeDTO);
    modelMap.addAttribute("hinderTypeList", hinderTypeList);
    modelMap.addAttribute("hinderLevelList", hinderLevelList);
    modelMap.addAttribute("enableDateList", enableDateList);
    modelMap.addAttribute("eduBgList", eduBgList);
    modelMap.addAttribute("salaryRangeList", salaryRangeList);
    // skills
    modelMap.addAttribute("computerSkillList", computerSkillList);
    modelMap.addAttribute("oaList", oaList);
    modelMap.addAttribute("osList", osList);
    modelMap.addAttribute("programList", programList);
    modelMap.addAttribute("dbList", dbList);
    modelMap.addAttribute("imageList", imageList);
    modelMap.addAttribute("uiList", uiList);
    modelMap.addAttribute("multimediaList", multimediaList);
    modelMap.addAttribute("hardwareList", hardwareList);
    modelMap.addAttribute("erpList", erpList);
    modelMap.addAttribute("infoList", infoList);
    modelMap.addAttribute("hardwareDevList", hardwareDevList);
    // language
    modelMap.addAttribute("languageList", languageList);
    modelMap.addAttribute("otherLanguageList", otherLanguageList);
    modelMap.addAttribute("LanguageProficiencyList", LanguageProficiencyList);
    modelMap.addAttribute("languageDtoList", languageDtoList);
    modelMap.addAttribute("languageTypeList", languageTypeList);

    modelMap.addAttribute("companySizeList", companySizeList);
    modelMap.addAttribute("yearsList", yearsList);

    modelMap.addAttribute("sexList", sexList);
    modelMap.addAttribute("maritalStatusList", maritalStatusList);
    modelMap.addAttribute("vateranStatusList", vateranStatusList);
    modelMap.addAttribute("identityCategoryList", identityCategoryList);

    // postType
    modelMap.addAttribute("postTypeLevelList", postTypeLevelList);
    modelMap.addAttribute("postTypeByManageList", postTypeByManageList);
    modelMap.addAttribute("postTypeBySalesList", postTypeBySalesList);
    modelMap.addAttribute("postTypeByComputerList", postTypeByComputerList);
    modelMap.addAttribute("postTypeByMachineList", postTypeByMachineList);
    modelMap.addAttribute("postTypeByPurchaseList", postTypeByPurchaseList);
    modelMap.addAttribute("postTypeByMedicalList", postTypeByMedicalList);
    modelMap.addAttribute("postTypeByTvList", postTypeByTvList);
    modelMap.addAttribute("postTypeByLegalList", postTypeByLegalList);
    modelMap.addAttribute("postTypeByPreschoolList", postTypeByPreschoolList);
    modelMap.addAttribute("postTypeByLifeList", postTypeByLifeList);
    modelMap.addAttribute("postTypeByfinanceList", postTypeByfinanceList);
    modelMap.addAttribute("postTypeBySellList", postTypeBySellList);
    modelMap.addAttribute("postTypeByIcList", postTypeByIcList);
    modelMap.addAttribute("postTypeByMaintainList", postTypeByMaintainList);
    modelMap.addAttribute("postTypeByBuildList", postTypeByBuildList);
    modelMap.addAttribute("postTypeByBiologicalList", postTypeByBiologicalList);
    modelMap.addAttribute("postTypeByArtList", postTypeByArtList);
    modelMap.addAttribute("postTypeByEduList", postTypeByEduList);
    modelMap.addAttribute("postTypeByCosmetologyList", postTypeByCosmetologyList);
    modelMap.addAttribute("postTypeByPoliceList", postTypeByPoliceList);

    modelMap.addAttribute("hinderLevel", hinderLevel);
    modelMap.addAttribute("hinderType", hinderType);
    modelMap.addAttribute("stillWorking", stillWorking);
    modelMap.addAttribute("stillWorkingList", stillWorkingList);
    modelMap.addAttribute("schoolStatusList", schoolStatusList);
    modelMap.addAttribute("postList", postList);
    modelMap.addAttribute("yearsList", yearsList);
    modelMap.addAttribute("certificateByEnglishMap", certificateByEnglishMap);
    modelMap.addAttribute("fractionByEnglishMap", fractionByEnglishMap);
    modelMap.addAttribute("idByEnglishMap", idByEnglishMap);
    modelMap.addAttribute("certificateByJapaneseMap", certificateByJapaneseMap);
    modelMap.addAttribute("fractionByJapaneseMap", fractionByJapaneseMap);
    modelMap.addAttribute("idByJapaneseMap", idByJapaneseMap);
    modelMap.addAttribute("certificateByEnglishList", certificateByEnglishList);
    modelMap.addAttribute("certificateByJapaneseList", certificateByJapaneseList);

    return "/front/updateResume";
}

From source file:com.mobilefirst.fiberlink.WebServiceRequest.java

/**
  * Description: Create the Request Object
  * @param authToken: required token passed through from initial Authenticator() request
 * @param baseURL: Initial base URL of host and port
 * @param webServiceName: Context root for particular request
 * @param methodType: Integer to say get or post request
 * @param billingId: billing ID to populate into the request
 * @param parametersObjectList: Map containing option parameters, headers and multi-part object
 * @throws Exception//from w  w  w.  j  av  a  2s. c  o  m
 */
public void createRequest(String authToken, String baseURL, String webServiceName, int methodType,
        String billingId, Hashtable<String, Object> parametersObjectList, String... strings) {
    try {
        String apiVersion;
        if (strings.length > 0) {
            if (strings[0].contentEquals("not-found")) {
                apiVersion = "1.0";
            } else {
                apiVersion = strings[0];
            }
        } else {
            apiVersion = "1.0";
        }
        String uri = baseURL + webServiceName.replace("api-version", apiVersion) + billingId;

        System.out.println(">>>Generating Request URL");
        System.out.println("Base URL :: " + uri);

        initializeRequestHeadersAndParameters(parametersObjectList);
        switch (methodType) {
        case 0:
            // Setting PARAMETERS if any
            // this must be before setting the getMethod with URI
            // otherwise request will be created with base URI and no parameters
            if (0 != parameters.size()) {
                uri = formulateGetURI(uri, parameters);
            }
            getMethod = new GetMethod(uri);

            //Setting Required Authorization Header
            System.out.println(">>>Generating GET Request");
            getMethod.addRequestHeader("Authorization", "MaaS token=\"" + authToken + "\"");

            // Setting HEADERS if any
            if (0 != headers.size()) {
                Enumeration<String> keys = headers.keys();
                while (keys.hasMoreElements()) {
                    String key = keys.nextElement();
                    getMethod.addRequestHeader(key, headers.get(key));
                }
            }

            System.out.println(">>>Sending GET Request");
            sendRequest(getMethod, "");
            break;
        case 1:
            postMethod = new PostMethod(uri);
            //Setting Required Authorization Header
            System.out.println(">>>Generating POST Request");
            postMethod.addRequestHeader("Authorization", "MaaS token=\"" + authToken + "\"");

            // Setting HEADERS if any
            if (0 != headers.size()) {
                Enumeration<String> keys = headers.keys();
                while (keys.hasMoreElements()) {
                    String key = keys.nextElement();
                    postMethod.addRequestHeader(key, headers.get(key));
                }
            }

            // Setting PARAMETERS if any
            if (0 != parameters.size()) {
                postMethod.setParams(setMethodParams(postMethod, parameters));

            }

            //START special case
            //If you need to send request body without any encoding or name pair values : like ws which involves bulk like GetCoreAttributesBulk.
            if (parametersObjectList.containsKey("body")) {
                org.apache.commons.httpclient.methods.StringRequestEntity sre;
                @SuppressWarnings("unchecked")
                Hashtable<String, String> a = (Hashtable<String, String>) parametersObjectList.get("body");
                sre = new StringRequestEntity(a.get("payload"), "application/xml", "UTF-8");
                postMethod.setRequestEntity(sre);
            }
            //END of the special case

            //Setting multipart body post if required.
            if (null != parts) {
                postMethod.setRequestEntity(new MultipartRequestEntity(parts, postMethod.getParams()));
            }

            System.out.println(">>>Sending POST Request");
            sendRequest(postMethod, "");
            break;
        default:
            break;
        }
    } catch (Exception e) {

    }
}

From source file:org.unitime.timetable.solver.exam.ExamSolver.java

public ExamProposedChange update(ExamProposedChange change) {
    Lock lock = currentSolution().getLock().writeLock();
    lock.lock();/* w  w  w .j  av a2 s  . c o m*/
    try {
        Hashtable<Exam, ExamPlacement> undoAssign = new Hashtable();
        HashSet<Exam> undoUnassing = new HashSet();
        Vector<Exam> unassign = new Vector();
        Vector<ExamPlacement> assign = new Vector();
        HashSet<ExamPlacement> conflicts = new HashSet();
        /*
        for (ExamAssignment assignment: change.getConflicts()) {
        ExamPlacement placement = getPlacement(assignment);
        if (placement==null || !placement.equals(placement.variable().getAssignment())) return null;
        undoAssign.put((Exam)placement.variable(),placement);
        unassign.add((Exam)placement.variable());
        }
        */
        for (ExamAssignment assignment : change.getAssignments()) {
            ExamPlacement placement = getPlacement(assignment);
            if (placement == null)
                return null;
            if (currentSolution().getAssignment().getValue(placement.variable()) != null)
                undoAssign.put((Exam) placement.variable(),
                        currentSolution().getAssignment().getValue(placement.variable()));
            else
                undoUnassing.add((Exam) placement.variable());
            assign.add(placement);
            unassign.add((Exam) placement.variable());
        }
        for (Exam exam : unassign)
            currentSolution().getAssignment().unassign(0, exam);
        for (ExamPlacement placement : assign) {
            for (Iterator i = placement.variable().getModel()
                    .conflictValues(currentSolution().getAssignment(), placement).iterator(); i.hasNext();) {
                ExamPlacement conflict = (ExamPlacement) i.next();
                Exam conflictingExam = (Exam) conflict.variable();
                if (!undoAssign.containsKey(conflictingExam) && !undoUnassing.contains(conflictingExam))
                    undoAssign.put(conflictingExam, conflict);
                conflicts.add(conflict);
                currentSolution().getAssignment().unassign(0, conflict.variable());
            }
            currentSolution().getAssignment().assign(0, placement);
        }
        change.getAssignments().clear();
        change.getConflicts().clear();
        for (ExamPlacement assignment : assign)
            if (!conflicts.contains(assignment))
                change.getAssignments()
                        .add(new ExamAssignmentInfo(assignment, currentSolution().getAssignment()));
        for (Exam exam : undoUnassing)
            if (currentSolution().getAssignment().getValue(exam) != null)
                currentSolution().getAssignment().unassign(0, exam);
        for (Map.Entry<Exam, ExamPlacement> entry : undoAssign.entrySet())
            currentSolution().getAssignment().unassign(0, entry.getKey());
        for (Map.Entry<Exam, ExamPlacement> entry : undoAssign.entrySet())
            currentSolution().getAssignment().assign(0, entry.getValue());
        for (ExamPlacement conflict : conflicts) {
            ExamPlacement original = undoAssign.get((Exam) conflict.variable());
            change.getConflicts().add(new ExamAssignment(original == null ? conflict : original,
                    currentSolution().getAssignment()));
        }
        return change;
    } finally {
        lock.unlock();
    }
}

From source file:com.rhfung.P2PDictionary.DataConnection.java

private boolean HandleRead(InputStreamReader reader) {
    String command;// ww w .j a  v a  2  s. co  m
    try {
        command = ReadLineFromBinary(reader);
        if (command == null)
            return false;
    } catch (IOException ex) {
        state = ConnectionState.Closing;
        return false;
    }

    //String[] parts = command.split(" ", 3);
    String[] parts = splitFrontEnd3(command);

    // pull using a GET or HEAD command

    if (debugBuffer != null)
        debugBuffer.Log(0, command, true);

    if (parts[0].equals(GET) || parts[0].equals(HEAD)) {
        Hashtable<String, String> headers = ReadHeaders(reader);
        String contentLocation = URLDecode(parts[1]);
        HandleReadGetOrHead(reader, headers, parts[0], contentLocation);
    } else if (parts[0].equals(PUT) || parts[0].equals(DELETE) || parts[0].equals(POST)
            || parts[0].equals(PUSH)) {
        Hashtable<String, String> headers = ReadHeaders(reader);
        String contentLocation = URLDecode(parts[1]);
        HandleReadOne(parts[0], contentLocation, reader, headers);
    }
    // handle server 
    else if (parts[0].equals("HTTP/1.0") || parts[0].equals("HTTP/1.1")) {
        String responseCode = parts[1];// 200, 305, 307, 404

        Hashtable<String, String> headers = ReadHeaders(reader);

        String verb;
        if (responseCode.equals(RESPONSECODE_PROXY)) {
            verb = RESPONSECODE_PROXY;
        } else if (responseCode.equals(RESPONSECODE_PROXY2)) {
            verb = RESPONSECODE_PROXY2;
        } else// assume RESPONSECODE_GOOD
        {
            // detect a response to a GET or HEAD request
            if (headers.containsKey("Response-To")) {
                verb = headers.get("Response-To");

                if (verb.equals(GET)) {
                    if (responseCode.equals(RESPONSECODE_DELETED))
                        verb = DELETE;
                    else
                        verb = PUT;
                } else if (verb.equals(HEAD)) {
                    verb = PUSH; // HEAD carries no payload
                } else {
                    // TODO: changed C# from NotSupported to NotImplemented
                    throw new NotImplementedException("Unsupported verb in Response-To");
                }
            } else {
                throw new NotImplementedException("GET or HEAD required in Response-To");
            }
        }

        String contentLocation = headers.get(HEADER_LOCATION);

        HandleReadOne(verb, contentLocation, reader, headers);

    }

    else // not a GET command or a HTTP response that server can understand
    {
        WriteDebug("Unknown request - emptying buffer");

        // finish reading the command, read until a blank line is reached
        try {
            do {
                command = ReadLineFromBinary(reader);
            } while (command.length() > 0);
        } catch (IOException ex) {
        }

        MemoryStream bufferedOutput = new MemoryStream();
        WriteErrorNotFound(bufferedOutput.createStreamWriter(), "GET", parts[1], 500);
        synchronized (sendBuffer) {
            sendBuffer.add(bufferedOutput);
        }
    }

    return true;
}

From source file:com.alfaariss.oa.profile.saml2.profile.sso.WebBrowserSSO.java

private Hashtable<String, String> readAuthnContextTypes(IConfigurationManager configurationManager,
        Element config) throws OAException {
    Hashtable<String, String> htAuthnContexts = new Hashtable<String, String>();
    _requestedAuthnContextMode = REQ_AUTHNCONTEXT_PASSTHROUGH;

    try {/*from w ww.j a  v  a 2s. c  om*/
        Element eProfile = null;

        Element eAuthentication = configurationManager.getSection(config, "authentication");
        if (eAuthentication == null) {
            StringBuffer sbInfo = new StringBuffer(
                    "No optional 'authentication' section found in 'profile' section in configuration with profile id '");
            sbInfo.append(_sID);
            sbInfo.append("', using default AuthnContext: ");
            sbInfo.append(AuthnContext.UNSPECIFIED_AUTHN_CTX);
            _logger.info(sbInfo.toString());
        } else {
            String requestMode = configurationManager.getParam(eAuthentication, "request_mode");
            if (requestMode != null) {
                if (!(REQ_AUTHNCONTEXT_FILTER.equalsIgnoreCase(requestMode)
                        || REQ_AUTHNCONTEXT_PASSTHROUGH.equalsIgnoreCase(requestMode))) {
                    _logger.error("Invalid value configured for optional authentication@request_mode: "
                            + requestMode + "; allowed: '" + REQ_AUTHNCONTEXT_FILTER + "' or '"
                            + REQ_AUTHNCONTEXT_PASSTHROUGH + "'");

                    throw new OAException(SystemErrors.ERROR_CONFIG_READ);
                }
                _requestedAuthnContextMode = requestMode;
            }

            eProfile = configurationManager.getSection(eAuthentication, "profile");
            if (eProfile == null) {
                _logger.info(
                        "Not one 'profile' section found in 'authentication' section in configuration, using default AuthnContext: "
                                + AuthnContext.UNSPECIFIED_AUTHN_CTX);
            }
        }

        while (eProfile != null) {
            String id = configurationManager.getParam(eProfile, "id");
            if (id == null) {
                _logger.error("No 'id' item found in 'profile' section in configuration");
                throw new OAException(SystemErrors.ERROR_CONFIG_READ);
            }

            String authnContext = configurationManager.getParam(eProfile, "authncontext");
            if (authnContext == null) {
                _logger.error("No 'authncontext' item found in 'profile' section in configuration");
                throw new OAException(SystemErrors.ERROR_CONFIG_READ);
            }

            if (htAuthnContexts.containsKey(id)) {
                _logger.error("Configured 'id' item in 'profile' section is not unique: " + id);
                throw new OAException(SystemErrors.ERROR_CONFIG_READ);
            }

            htAuthnContexts.put(id, authnContext);

            eProfile = configurationManager.getNextSection(eProfile);
        }
    } catch (OAException e) {
        throw e;
    } catch (Exception e) {
        _logger.fatal("Could not read AuthnContext types", e);
        throw new OAException(SystemErrors.ERROR_INTERNAL);
    }

    return htAuthnContexts;
}

From source file:org.agnitas.beans.impl.MailingImpl.java

@Override
public String getPreview(String input_org, int inputType, int customerID, boolean overwriteMailtype,
        ApplicationContext con) throws Exception {
    DynamicTag aktTag = null;/*w  ww.  j  ava 2s  .  com*/
    DynamicTag tmpTag = null;
    DynamicTag contentTag = null;
    String contentString = null;
    DynamicTagContent aContent = null;
    DynamicTagContent aTmpContent = null;
    Target aTarget = null;
    int aTargetID = 0;
    Hashtable<String, DynamicTag> allTags = new Hashtable<String, DynamicTag>();
    Hashtable<String, Target> allTargets = new Hashtable<String, Target>();
    Interpreter aBsh = null;
    String input = input_org;
    TargetDao tDao = (TargetDao) con.getBean("TargetDao");
    StringBuffer output = new StringBuffer(this.personalizeText(input, customerID, con));

    searchPos = 0;
    aBsh = AgnUtils.getBshInterpreter(companyID, customerID, con);
    if (overwriteMailtype) {
        aBsh.set("mailtype", new Integer(inputType));
    }

    if (aBsh == null) {
        throw new Exception("error.template.dyntags");
    }

    Iterator<DynamicTag> it = this.dynTags.values().iterator();
    while (it.hasNext()) {
        aktTag = it.next();
        tmpTag = (DynamicTag) con.getBean("DynamicTag");
        tmpTag.setDynName(aktTag.getDynName());
        Map<String, DynamicTagContent> contentMap = aktTag.getDynContent();
        if (contentMap != null) {
            Iterator<DynamicTagContent> it2 = contentMap.values().iterator();
            while (it2.hasNext()) {
                aContent = it2.next();
                aTmpContent = (DynamicTagContent) con.getBean("DynamicTagContent");
                aTmpContent.setDynName(aContent.getDynName());
                aTmpContent.setDynOrder(aContent.getDynOrder());
                aTmpContent.setDynContent(this.personalizeText(aContent.getDynContent(), customerID, con));
                aTmpContent.setTargetID(aContent.getTargetID());
                aTmpContent.setId(aContent.getId());
                tmpTag.addContent(aTmpContent);
            }
        }
        allTags.put(aktTag.getDynName(), tmpTag);
    }

    aContent = null;

    this.searchPos = 0;

    while ((aktTag = findNextDynTag(output.toString(), con)) != null) {
        searchPos = aktTag.getStartTagStart(); // always search from
        // beginning of last found
        // tag
        if (allTags.containsKey(aktTag.getDynName())) {
            contentTag = (DynamicTag) allTags.get(aktTag.getDynName());
            Map<String, DynamicTagContent> contentMap = contentTag.getDynContent();
            contentString = null; // reset always
            if (contentMap != null) {
                Iterator<DynamicTagContent> it3 = contentMap.values().iterator();
                while (it3.hasNext()) {
                    aContent = it3.next();
                    aTargetID = aContent.getTargetID();
                    if (allTargets.containsKey(Integer.toString(aTargetID))) {
                        aTarget = (Target) allTargets.get(Integer.toString(aTargetID));
                    } else {
                        aTarget = tDao.getTarget(aTargetID, this.companyID);
                        if (aTarget == null) {
                            aTarget = (Target) con.getBean("Target");
                            aTarget.setCompanyID(this.companyID);
                            aTarget.setId(aTargetID);
                        }
                        allTargets.put(Integer.toString(aTarget.getId()), aTarget);
                    }
                    aTargetID = aTarget.getId();
                    if (aTargetID == 0) { // Target fits
                        contentString = aContent.getDynContent();
                        break; // stop processing list of content
                    } else {
                        if (aTarget.isCustomerInGroup(aBsh)) {
                            contentString = aContent.getDynContent();
                            break; // stop processing list of content
                        }
                    }
                }
            }
            // insert content if found content
            if (contentString != null) {
                if (aktTag.isComplex()) {
                    output.delete(aktTag.getEndTagStart(), aktTag.getEndTagEnd());
                    output.replace(aktTag.getValueTagStart(), aktTag.getValueTagEnd(), contentString);
                    output.delete(aktTag.getStartTagStart(), aktTag.getStartTagEnd());
                } else {
                    output.replace(aktTag.getStartTagStart(), aktTag.getStartTagEnd(), contentString);
                }
            } else {
                if (aktTag.isComplex()) {
                    output.delete(aktTag.getStartTagStart(), aktTag.getEndTagEnd());
                } else {
                    output.delete(aktTag.getStartTagStart(), aktTag.getStartTagEnd());
                }
            }
        } else { // dyntag not found in list, throw exception!
            throw new Exception("error.template.dyntags");
        }
    }
    if (inputType == MailingImpl.INPUT_TYPE_TEXT) {
        if (this.getEmailParam().getLinefeed() > 0) {
            output = new StringBuffer(SafeString.cutLineLength(SafeString.removeHTMLTags(output.toString()),
                    this.getEmailParam().getLinefeed()));
        } else {
            output = new StringBuffer(SafeString.removeHTMLTags(output.toString()));
        }
    }

    output = new StringBuffer(this.insertTrackableLinks(output.toString(), customerID, con));

    return output.toString();
}

From source file:org.eclipse.smila.search.index.IndexConnection.java

/**
 * This method extends a given search query with all possible configurable attributes. Additionally checks this method
 * wether there are any conflicts with the index structure or the query constraints.
 * //w ww  .jav a 2 s  . c o  m
 * @param dQuery
 *          -
 * @throws IndexException
 *           -
 */
public void validateQuery(final DQuery dQuery) throws IndexException {
    final Log log = LogFactory.getLog(getClass());
    final Hashtable<Integer, DField> queryFields = new Hashtable<Integer, DField>();
    final DConfiguration dConfig = _index.getConfiguration();

    // 1. check fields of query against index.
    // 2. apply configuration settings
    Enumeration fields = dQuery.getFields();
    while (fields.hasMoreElements()) {
        final DField field = (DField) fields.nextElement();
        if (!_index.getIndexStructure().hasField(field.getFieldNo())) {
            throw new IndexException(
                    "field in search query does not exist in index [" + field.getFieldNo() + "]");
        }
        // checks whether types of search field and index field are compatible.
        // for checking, the type taken from the index field's default configuration will be used,
        // because there we already have simple search types, whereas in the index structure,
        // different types may be used (e. g. Date may be represented by Number)
        if (!dConfig.getDefaultConfig().getField(field.getFieldNo()).getFieldConfig().getType()
                .equals(field.getType())) {
            throw new IndexException("field type in search query does not match field type in index ["
                    + field.getFieldNo() + "]");
        }

        // get default whole parameterization
        DFieldConfig fc = null;

        // check for named config
        if (field.getParameterDescriptor() != null) {
            DNamedConfig nc = null;
            if (!dConfig.hasNamedConfig(field.getParameterDescriptor())) {
                log.error("unable to locate named config for index [" + dQuery.getIndexName() + ";"
                        + field.getParameterDescriptor() + "]");
            } else {
                nc = dConfig.getNamedConfig(field.getParameterDescriptor());

                if (nc != null) {
                    // check for field type specifig named config
                    fc = nc.getFieldConfig(field);

                    if (fc == null) {
                        log.error("unable to locate named config for index [" + dQuery.getIndexName() + ";"
                                + field.getParameterDescriptor() + ";" + field.getType() + "]");
                    }

                }
            }
        }

        final DFieldConfig defaultfc = dConfig.getDefaultConfig().getField(field.getFieldNo()).getFieldConfig();
        // set default config
        applyFieldConfig(field, fc, defaultfc);

        queryFields.put(new Integer(field.getFieldNo()), field);
    }

    // 3. check query constraints for simple search.
    final DQueryConstraints queryConstraints = dConfig.getQueryConstraints();
    if (queryConstraints != null) {
        for (int i = 0; i < queryConstraints.getFieldConstraintsLength(); i++) {
            final DFieldConstraints dFieldConstraints = queryConstraints.getFieldConstraints(i);

            final String occurrence = dFieldConstraints.getOccurrence();
            if (occurrence.equals("required")) {
                if (!queryFields.containsKey(new Integer(dFieldConstraints.getFieldNo()))) {
                    throw new IndexException(
                            "query constraint requires field [" + dFieldConstraints.getFieldNo() + "]");
                }
            } else if (occurrence.equals("prohibited")) {
                if (queryFields.containsKey(new Integer(dFieldConstraints.getFieldNo()))) {
                    throw new IndexException(
                            "query constraint prohibits field [" + dFieldConstraints.getFieldNo() + "]");
                }
            }

            // check further query constraints
            final DField field = queryFields.get(new Integer(dFieldConstraints.getFieldNo()));
            if (field == null) {
                continue;
            }
            if (dFieldConstraints.getFieldTemplateCount() > 0) {
                boolean matchConstraint = false;
                final String[] fieldTemplates = dFieldConstraints.getFieldTemplates();
                final String fieldTemplate = field.getFieldTemplate() != null ? field.getFieldTemplate().trim()
                        : "";
                for (final String fieldTemplate2 : fieldTemplates) {
                    if (fieldTemplate2.equals(fieldTemplate)) {
                        matchConstraint = true;
                        break;
                    }
                }

                if (!matchConstraint) {
                    throw new IndexException("query field does not match field template constraint ["
                            + field.getFieldNo() + "]");
                }
            }

            if (dFieldConstraints.getNodeTransformerCount() > 0) {
                boolean matchConstraint = false;
                final String[] nodeTransformers = dFieldConstraints.getNodeTransformers();
                final String nodeTransformerName = field.getNodeTransformer() != null
                        ? field.getNodeTransformer().getName()
                        : "";
                for (final String nodeTransformer : nodeTransformers) {
                    if (nodeTransformer.equals(nodeTransformerName)) {
                        matchConstraint = true;
                        break;
                    }
                }

                if (!matchConstraint) {
                    throw new IndexException("query field does not match node transformer constraint ["
                            + field.getFieldNo() + "]");
                }
            }

            if (dFieldConstraints.getConstraintCount() > 0) {
                boolean matchConstraint = false;
                final String[] constraints = dFieldConstraints.getConstraints();
                final String constraint = field.getConstraint() != null ? field.getConstraint() : "";
                for (final String constraint2 : constraints) {
                    if (constraint2.equals(constraint)) {
                        matchConstraint = true;
                        break;
                    }
                }

                if (!matchConstraint) {
                    throw new IndexException(
                            "query field does not match constraint constraint [" + field.getFieldNo() + "]");
                }
            }
        }
    }

    // apply field valiadtion and transformation
    fields = dQuery.getFields();
    while (fields.hasMoreElements()) {
        final DField field = (DField) fields.nextElement();

        if (field instanceof DTextField) {
            encodeTextField((DTextField) field);
        }
    }
}

From source file:unalcol.termites.boxplots.HybridGlobalInfoReport.java

private static void createSuperGraph() {
    XYSeriesCollection juegoDatos = null;
    Hashtable<String, XYSeriesCollection> dataCollected = new Hashtable();
    DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();
    String sDirectorio = experimentsDir;
    File f = new File(sDirectorio);
    String extension;/*  w w  w.ja va  2s  .  com*/
    File[] files = f.listFiles();
    Hashtable<String, String> Pop = new Hashtable<>();
    PrintWriter escribir;
    Scanner sc = null;
    double sucessfulExp = 0.0;
    for (File file : files) {
        extension = "";
        int i = file.getName().lastIndexOf('.');
        int p = Math.max(file.getName().lastIndexOf('/'), file.getName().lastIndexOf('\\'));
        if (i > p) {
            extension = file.getName().substring(i + 1);
        }
        // System.out.println(file.getName() + "extension" + extension);
        if (file.isFile() && extension.equals("csv") && file.getName().startsWith("dataCollected")
                && file.getName().contains(mazeMode)) {
            System.out.println(file.getName());
            System.out.println("get: " + file.getName());
            String[] filenamep = file.getName().split(Pattern.quote("+"));
            XYSeries globalInfo;

            System.out.println("file" + filenamep[9]);

            int popsize = Integer.valueOf(filenamep[3]);
            double pf = Double.valueOf(filenamep[5]);
            String mode = filenamep[7];

            int maxIter = -1;
            //if (!filenamep[8].isEmpty()) {
            maxIter = Integer.valueOf(filenamep[9]);
            //}
            int n = 0;
            int rho = 0;
            double evapRate = 0.0;
            //14, 16, 16
            if (mode.equals("hybrid")) {
                n = Integer.valueOf(filenamep[15]);
                rho = Integer.valueOf(filenamep[17]);
                String[] tmp = filenamep[19].split(Pattern.quote("."));

                System.out.println("history size:" + n);
                System.out.println("rho:" + rho);
                String sEvap = tmp[0] + "." + tmp[1];
                evapRate = Double.valueOf(sEvap);
            }

            System.out.println("psize:" + popsize);
            System.out.println("pf:" + pf);
            System.out.println("mode:" + mode);
            System.out.println("maxIter:" + maxIter);

            //String[] aMode = {"random", "levywalk", "sandc", "sandclw"};
            //String[] aMode = {"lwphclwevap", "lwsandc2", "lwsandc", "lwphevap2", "lwphevap"};
            //String[] aMode = {"hybrid", "lwphevap", "levywalk"};
            //String[] aMode = {"levywalk", "lwphevap", "hybrid", "hybrid3", "hybrid4", "sequential"};
            String key;
            if (mode.equals("hybrid")) {
                key = getTechniqueName(mode) + "+" + pf + "+" + rho + "+" + n + "+" + popsize + "+" + evapRate;
            } else {
                key = getTechniqueName(mode) + "+" + pf + "+" + popsize + "+" + evapRate;
            }

            System.out.println("key" + key);
            if (isInMode(aMode, mode)) {
                final List list = new ArrayList();
                try {
                    sc = new Scanner(file);

                } catch (FileNotFoundException ex) {
                    Logger.getLogger(DataCollectedLatexConsolidatorSASOMessagesSend1.class.getName())
                            .log(Level.SEVERE, null, ex);
                }
                int roundNumber = 0;
                double globalInfoCollected = 0.0;

                //ArrayList<Double> acSt = new ArrayList<>();
                //ArrayList<Double> avgExp = new ArrayList<>();
                String[] data = null;
                globalInfo = new XYSeries("");
                while (sc.hasNext()) {
                    String line = sc.nextLine();
                    //System.out.println("line:" + line);
                    data = line.split(",");
                    roundNumber = Integer.valueOf(data[0]);
                    globalInfoCollected = Double.valueOf(data[4]);

                    if (globalInfoCollected > 100) {
                        System.out.println("more than 100:" + file.getName());
                    } else {
                        globalInfo.add(roundNumber, globalInfoCollected);
                    }
                    //System.out.println("r" + roundNumber + "dc:" + globalInfoCollected);
                    //Add Data and generate statistics 
                    //acSt.add((double) agentsCorrect);
                    //avgExp.add(averageExplored);
                }

                if (!dataCollected.containsKey(key)) {
                    juegoDatos = new XYSeriesCollection();
                    juegoDatos.addSeries(globalInfo);
                    dataCollected.put(key, juegoDatos);
                } else {
                    ((XYSeriesCollection) dataCollected.get(key)).addSeries(globalInfo);
                }
                //if (Pf.contains(pf)) {
                /*if (mode.equals("hybrid")) {
                String nameSeries = n + "-" + rho + "-" + evapRate;
                defaultcategorydataset.addValue(((double) sucessfulExp) / acSt.size() * 100.0, "" + popsize, nameSeries);
                } else {
                defaultcategorydataset.addValue(((double) sucessfulExp) / acSt.size() * 100.0, "" + popsize, getTechniqueName(mode) + "\nPf:" + pf);
                }*/
                /*pf == 1.0E-4 || pf == 3.0E-4*/
                //}
            }
        }
    }
    createChart(dataCollected);
}

From source file:com.rhfung.P2PDictionary.DataConnection.java

private void HandleReadGetOrHead(InputStreamReader reader, Hashtable<String, String> headers, String verb,
        String resource) {/*from   w  w  w . j a v  a  2 s  .co  m*/

    MemoryStream memBuffer = new MemoryStream();

    // this part is very simple
    // just look up the data that the other side requested and give the data

    // detect for web browser
    //bytesRead += command.Length + NetworkDelay.CountHeaders(headers);

    //#if SIMULATION
    //                            // 8 - 81ms delay in N.America      http://ipnetwork.bgtmo.ip.att.net/pws/network_delay.html
    //                            // 100 Mb/s link
    //                            Thread.Sleep(NetworkDelay.GetLatency(8, 81, 13107200, bytesRead));
    //#endif

    boolean browserRequest = DetectBrowser(headers);

    //                {
    //                String[] res = resource.split("\\?", 2);
    //                resource = res[0];
    //                String query = res.length > 1 ? res[1] : null;
    //                
    //                
    //                if (query != null)
    //                {
    //                   String[] q = query.split("#", 2);
    //                   
    //                    Map<String,String> queries= getQueryMap(q[0]);
    //                    if (queries.containsKey("format") )
    //                    {
    //                       retJson = queries.get("format").equals("json");
    //                    }
    //                }
    //                
    //
    //                }

    // see which resource is being accessed
    // latter half of condition is only for web browsers
    if (resource.equals(DATA_NAMESPACE) || resource.equals(DATA_NAMESPACE + "/")) {
        boolean retJson = false;
        if (headers.containsKey("Accept"))
            retJson = headers.get("Accept").contains("application/json");

        // whole dictionary
        if (retJson)
            ResponseDictionaryJson(verb, memBuffer.createStreamWriter(), GetListOfThisLocalID(), null,
                    browserRequest);
        else
            ResponseDictionaryText(verb, memBuffer.createStreamWriter(), GetListOfThisLocalID(), null,
                    browserRequest);
    } else if (resource.equals(ROOT_NAMESPACE)) {
        ResponseIndex(verb, memBuffer.createStreamWriter(), browserRequest);
    } else if (resource.equals(CLOSE_MESSAGE) || resource.equals(CLOSE_MESSAGE + "/")) {
        // don't know what to do here
        WriteErrorNotFound(memBuffer.createStreamWriter(), verb, CLOSE_MESSAGE, 200);
    } else if (resource.equals(SUBSCRIPTIONS_NS) || resource.equals(SUBSCRIPTIONS_NS + "/")) {

        ResponseSubscriptions(verb, memBuffer.createStreamWriter(), browserRequest);
    } else if (resource.equals(CONNECTIONS_NS) || resource.equals(CONNECTIONS_NS + "/")) {

        ResponseConnections(verb, memBuffer.createStreamWriter(), browserRequest);
    } else if (resource.equals(BONJOUR_NS) || resource.equals(BONJOUR_NS + "/")) {
        ResponseBonjour(verb, memBuffer.createStreamWriter(), browserRequest);
    } else if (this.data.containsKey(resource)) {
        // handles current and expired data
        DataEntry entry = P2PDictionary.GetEntry(this.data, this.dataLock, resource); //this.data[parts[1]];
        synchronized (entry) {
            if (entry.subscribed && !DataMissing.isSingleton(entry.value)) {
                // give the caller the data
                Response(verb, resource, GetListOfThisLocalID(), null, entry, memBuffer.createStreamWriter(),
                        browserRequest);
            } else {
                // tell the caller to look somewhere else
                //if (IsWebClientConnected)
                //{
                // tell the caller that a proxy must be used
                ResponseCode(memBuffer.createStreamWriter(), resource, GetListOfThisLocalID(),
                        entry.lastOwnerID, entry.lastOwnerRevision, 305);
                //}
                //else
                //{

                //    // tell the caller that a proxy must be used
                //    ResponseCode(bufferedOutput, parts[1], GetListOfThisLocalID(), headers["P2P-Path"], entry.lastOwnerID, entry.lastOwnerRevision, 305);
                //}
            }
        }
    } else if (resource.startsWith(PROXY_PREFIX + "/")) {
        throw new NotImplementedException();
    } else {
        // anything else
        WriteErrorNotFound(memBuffer.createStreamWriter(), verb, resource, 404, GetListOfThisLocalID());
    }

    // spit everything out of the writer

    synchronized (sendBuffer) {
        sendBuffer.add(memBuffer);
    }
}